web.identity-mgt.account-recovery.jsp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.wso2.carbon.identity.mgt.ui Show documentation
Show all versions of org.wso2.carbon.identity.mgt.ui Show documentation
A custom wso2 products or solution
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)) {
%>
<%
} else {
%>
<%
}
%>