web.identity-mgt.challenges-mgt.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.ui.IdentityManagementAdminClient" %>
<%@ 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.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.List" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%
String selectedChallenge = null;
List challenges = null;
String deleteRowId = request.getParameter("deleteRowId");
String editRowId = request.getParameter("editRowId");
String addRowId = request.getParameter("addRowId");
String setName = request.getParameter("setName");
challenges = (List) session.
getAttribute(IdentityManagementAdminClient.CHALLENGE_QUESTION);
if(challenges == null){
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);
IdentityManagementAdminClient client =
new IdentityManagementAdminClient(cookie, backendServerURL, configContext) ;
ChallengeQuestionDTO[] questionDTOs = client.getChallengeQuestions();
if(questionDTOs != null && questionDTOs.length > 0){
challenges = new ArrayList(Arrays.asList(questionDTOs));
session.setAttribute(IdentityManagementAdminClient.CHALLENGE_QUESTION, challenges);
}
} catch (Exception e) {
CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR,
request);
%>
<%
return;
}
}
if(challenges != null ){
if(deleteRowId != null){
int rowNo = Integer.parseInt(deleteRowId);
challenges.remove(rowNo);
}
if(editRowId != null){
int rowNo = Integer.parseInt(editRowId);
selectedChallenge = challenges.get(rowNo).getQuestion();
challenges.remove(rowNo);
}
} else {
challenges = new ArrayList();
}
if(addRowId != null){
ChallengeQuestionDTO dto = new ChallengeQuestionDTO();
dto.setQuestion(addRowId);
dto.setQuestionSetId(setName);
challenges.add(dto);
}
session.setAttribute(IdentityManagementAdminClient.CHALLENGE_QUESTION, challenges);
%>
Add Challenge Questions