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

web.identity-mgt.challenges-mgt-finish-ajaxprocessor.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.Iterator" %>
<%@ page import="java.util.List" %>



<%
    String httpMethod = request.getMethod();
    if (!"post".equalsIgnoreCase(httpMethod)) {
        response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        return;
    }

    List challenges =  new ArrayList();
    String  removeSetId = request.getParameter("removeSetId");

    if(removeSetId != null && removeSetId.trim().length() > 0){
        List retrievedChallenges = (List) session.
                getAttribute(IdentityManagementAdminClient.CHALLENGE_QUESTION);

        if(retrievedChallenges != null){
            Iterator iterator = retrievedChallenges.iterator();
            while(iterator.hasNext()){
                ChallengeQuestionDTO dto = iterator.next();
                if(removeSetId.trim().equals(dto.getQuestionSetId())){
                    iterator.remove();
                }
            }
            challenges = retrievedChallenges;
        }
    }

    int i = 1;
    while(true){
        String question = request.getParameter("question" + i);
        String setId = request.getParameter("setId" + i);
        if(question == null || question.trim().length() == 0 || question.trim().equals("null")){
            if(setId == null || setId.trim().length() < 1 || setId.trim().equals("null")){
                break;
            }
        } else {
            ChallengeQuestionDTO dto = new ChallengeQuestionDTO();
            dto.setQuestion(question.trim());
            dto.setPromoteQuestion(true);
            dto.setQuestionSetId(setId.trim());
            challenges.add(dto);
        }
        i++;
    }

    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 proxy =
                            new IdentityManagementAdminClient(cookie, backendServerURL, configContext);
        if(challenges.size() >= 0){
            proxy.setChallengeQuestions(challenges.toArray(new ChallengeQuestionDTO[challenges.size()]));
        }

%>
    
<%
    } catch (Exception e) {
        CarbonUIMessage.sendCarbonUIMessage(e.getMessage(), CarbonUIMessage.ERROR,
                request);
%>
    
<%
    return;
    }
%>
        





© 2015 - 2024 Weber Informatics LLC | Privacy Policy