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

web.identity-mgt.account-recovery.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.mgt.stub.dto.ChallengeQuestionDTO"%>
<%@page import="org.wso2.carbon.identity.mgt.stub.dto.UserChallengesDTO"%>
<%@page import="org.wso2.carbon.identity.mgt.ui.IdentityManagementAdminClient"%>
<%@page import="org.wso2.carbon.identity.mgt.ui.UserInformationRecoveryClient"%>





<%@ page import="org.wso2.carbon.ui.CarbonUIMessage"%>
<%@ page import="org.wso2.carbon.ui.CarbonUIUtil" %>
<%@ page import="org.wso2.carbon.utils.ServerConstants" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.ResourceBundle" %>
<%@ page import="org.owasp.encoder.Encode" %>


<%
    String username = request.getParameter("username");
    String forwardTo = null;
    IdentityManagementAdminClient client = null;
    UserInformationRecoveryClient infoClient = null;
    ChallengeQuestionDTO[] challenges;
    UserChallengesDTO[] userChallenges = null;
    UserChallengesDTO currentUserChallenge;
    Map> challengesMap = new HashMap>();
    Map userChallengesMap = new HashMap();

    if (username == null) {
        username = (String) request.getSession().getAttribute("logged-user");
    }

    String BUNDLE = "org.wso2.carbon.identity.mgt.ui.i18n.Resources";
    ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale());

    try {
        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);
        client = new IdentityManagementAdminClient(cookie,
                backendServerURL, configContext);
        infoClient = new UserInformationRecoveryClient(cookie, backendServerURL, configContext);
        
     	challenges = infoClient.getChallengeQuestions();
		try {
			userChallenges = client.getChallengeQuestionsOfUser(username);
		} catch (Exception e) {

		}
		if (challenges != null) {
			for (ChallengeQuestionDTO challenge : challenges) {
				HashSet questionDTOs = challengesMap.get(challenge
						.getQuestionSetId());
				if (questionDTOs == null) {
					questionDTOs = new HashSet();
					questionDTOs.add(challenge);
					challengesMap.put(challenge.getQuestionSetId(), questionDTOs);
				}
				questionDTOs.add(challenge);
			}
		}

		if (userChallenges != null) {
			for (UserChallengesDTO userChallengesDTO : userChallenges) {
				userChallengesMap.put(userChallengesDTO.getId(), userChallengesDTO);
			}
		}
	} catch (Exception e) {
		String message = resourceBundle
				.getString("error.while.loading.account.recovery.data");
		CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request);
		forwardTo = "../admin/error.jsp";
	}
%>

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



<%
    return;
	}
%>








    

    

<% if(!client.isReadOnlyUserStore(username, null)) { %>
<% if(challengesMap.size() > 0){ int challengeNumber = 1; for(Map.Entry> entry : challengesMap.entrySet()){ currentUserChallenge = userChallengesMap.get(entry.getKey()); %>
<%=challengeNumber%>
<% if (currentUserChallenge != null && currentUserChallenge.getAnswer() != null && currentUserChallenge.getAnswer().trim().length() > 0) { %> <% } else { %> <% } %>
*
<% challengeNumber ++; } } %>
<% } else { %> <% } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy