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

web.identity-mgt.challenges-mgt.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.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

<% if(setName != null && setName.trim().length() > 0){ %> <% } else { %> <% } %> <% if(selectedChallenge != null && selectedChallenge.trim().length() > 0){ %> <% } else { %> <% } %>
Challenge Question Set Id : Enter Challenge Question Set Id :
Edit Challenge Question : Enter New Challenge Question :
<% if(selectedChallenge != null && selectedChallenge.trim().length() > 0){ %> <% } else { %> <% } %>

 

<% if(challenges.size() > 0){ for(int i = 0; i < challenges.size(); i++){ if(setName != null && setName.equals(challenges.get(i).getQuestionSetId())){ %> <% } else { %> <% } %> <% } } %>
Challenge Questions Actions
<%=Encode.forHtmlContent(challenges.get(i).getQuestion())%> Delete Edit




© 2015 - 2024 Weber Informatics LLC | Privacy Policy