All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web.userprofile.edit.jsp Maven / Gradle / Ivy

The newest version!

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar"
           prefix="carbon" %>
<%@page import="org.apache.axis2.context.ConfigurationContext" %>
<%@page import="org.wso2.carbon.CarbonConstants" %>
<%@page import="org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO" %>
<%@page import="org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO" %>
<%@page import="org.wso2.carbon.identity.user.profile.ui.client.UserProfileCient" %>
<%@page import="org.wso2.carbon.ui.CarbonUIMessage" %>
<%@page import="org.wso2.carbon.ui.CarbonUIUtil" %>
<%@page import="org.wso2.carbon.user.mgt.ui.Util" %>
<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
<%@page import="java.net.URLEncoder" %>


<%!
    private static final String ACCOUNT_LOCKED_CLAIM_URI = "http://wso2.org/claims/identity/accountLocked";
    private static final String ACCOUNT_DISABLED_CLAIM_URI = "http://wso2.org/claims/identity/accountDisabled";
%>

<%@ page import="java.util.ResourceBundle" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.identity.user.profile.ui.client.UserProfileUIUtil" %>
<%@ page import="org.wso2.carbon.identity.user.profile.ui.client.UserProfileUIException" %>

<%
    boolean readOnlyUserStore = false;
    String profile = request.getParameter("profile");
    String fromUserMgt = request.getParameter("fromUserMgt");
    String noOfProfiles = request.getParameter("noOfProfiles");
    String ACCOUNT_DISABLED = "http://wso2.org/claims/identity/accountDisabled";
    String currentUser = (String) session.getAttribute("logged-user");
    String encryptedUsername = request.getParameter("username");
    String decryptedUsername = null;
    boolean isLockable = true;

    if (noOfProfiles == null) {
        noOfProfiles = "0";
    }

    if (fromUserMgt == null) fromUserMgt = "false";

    UserProfileDTO userProfile = null;
    UserFieldDTO[] userFields = null;
    String forwardTo = null;
    String[] profileConfigs = null;
    String BUNDLE = "org.wso2.carbon.identity.user.profile.ui.i18n.Resources";
    ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale());

    try {
        if (encryptedUsername != null) {
            decryptedUsername = UserProfileUIUtil.getDecryptedUsername(encryptedUsername);
        }
        String cookie = (String) session.getAttribute(ServerConstants.ADMIN_SERVICE_COOKIE);
        String backendServerURL = CarbonUIUtil.getServerURL(config.getServletContext(),
                session);
        ConfigurationContext configContext = (ConfigurationContext) config
                .getServletContext().getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);
        UserProfileCient client = new UserProfileCient(cookie, backendServerURL,
                configContext);
        userProfile = client.getUserProfile(decryptedUsername, profile);
        
        if ("readonly".equals(userProfile.getProfileConifuration())){
        	readOnlyUserStore = true;
        }
        
        if (userProfile != null) {
            userFields = client.getOrderedUserFields(userProfile.getFieldValues());
            profileConfigs = userProfile.getProfileConfigurations();
        }
        isLockable = UserProfileUIUtil.isAccountLockable(decryptedUsername);
    } catch (Exception e) {
        String message = resourceBundle.getString("error.while.loading.user.profile.data");
        CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request);
        forwardTo = "../admin/error.jsp";
    }
%>

<%
    if (forwardTo != null) {
%>



<%
    return;
    }
%>







    

    
    
    

    
<% if ("true".equals(fromUserMgt)) { %> <% if (!readOnlyUserStore) { %>

<%=Encode.forHtml(decryptedUsername)%>

<% } else { %>

<%=Encode.forHtml(decryptedUsername)%>

<% } } else { %> <% if (!readOnlyUserStore) { %>

<% } else { %>

<% } } %>
<% if (!readOnlyUserStore && profileConfigs != null && profileConfigs.length > 0 && profileConfigs[0] != null) { %> <% } %> <% if (userFields != null) { for (int i = 0; i < userFields.length; i++) { if (ACCOUNT_DISABLED.equals(userFields[i].getClaimUri()) && decryptedUsername.equals(currentUser)) { continue; } %> <% if (userFields[i].getDisplayName() != null) { %> <% String value = userFields[i].getFieldValue(); if (value != null) { if (!readOnlyUserStore && !userFields[i].getReadOnly()) { if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false")) { // assume as boolean value. But actually this must be sent from backend. // will fix for next release. %> <% } else { %> <% } } else { %> <% } } else { %> <% if (!readOnlyUserStore && !userFields[i].getReadOnly()) { %> <% } else { %> <% } } %> <% } } } %>
 * <%=Encode.forHtmlContent(userProfile.getProfileName())%>
<%=Encode.forHtmlContent(userFields[i].getDisplayName())%> <% if (userFields[i].getRequired()) { %>  * <% } %> checked="checked" <%}%> value="<%=Encode.forHtmlAttribute(userFields[i].getClaimUri())%>"/> <%=Encode.forHtmlContent(userFields[i].getFieldValue())%>
<% if (!readOnlyUserStore) { %> <% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy