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

web.userprofile.remove-profile-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.user.profile.ui.client.UserProfileCient"%>
<%@page import="org.wso2.carbon.ui.CarbonUIMessage"%>
<%@page import="org.wso2.carbon.ui.CarbonUIUtil"%>
<%@ page import="org.wso2.carbon.user.mgt.ui.Util" %>

<%@page import="org.wso2.carbon.utils.ServerConstants"%>
<%@page import="java.util.ResourceBundle"%>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.identity.user.profile.ui.client.UserProfileUIUtil" %>
<%@ page import="org.wso2.carbon.identity.user.profile.ui.client.UserProfileUIException" %>


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

    String profile = request.getParameter("profile");
    String username = request.getParameter("username");
    String forwardTo = "";
    String BUNDLE = "org.wso2.carbon.identity.user.profile.ui.i18n.Resources";
	ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE, request.getLocale());
	String fromUserMgt = (String) request.getParameter("fromUserMgt");
    String encryptedUsername;

    if (fromUserMgt==null) fromUserMgt = "false";

    try {
        encryptedUsername = UserProfileUIUtil.getEncryptedAndBase64encodedUsername(username);
        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);
        UserProfileCient client = new UserProfileCient(cookie, backendServerURL, configContext);
        client.deleteUserProfile(username, profile);
        String message = resourceBundle.getString("user.profile.deleted.successfully");
        CarbonUIMessage.sendCarbonUIMessage(message,CarbonUIMessage.INFO, request);
        if ("true".equals(fromUserMgt)) {
           forwardTo = "index.jsp?username="+ Encode.forUriComponent(encryptedUsername);
        }else{
        	forwardTo = "index.jsp";
        }
    } catch (Exception e) {
        String message = resourceBundle.getString("error.while.updating.profile.user");
        CarbonUIMessage.sendCarbonUIMessage(message,CarbonUIMessage.ERROR, request,e);
        forwardTo = "../admin/error.jsp";
    }
%>







© 2015 - 2024 Weber Informatics LLC | Privacy Policy