
web.oauth.remove-app-ajaxprocessor.jsp Maven / Gradle / Ivy
<%@page import="org.apache.axis2.context.ConfigurationContext" %>
<%@ page import="org.owasp.encoder.Encode" %>
<%@ page import="org.wso2.carbon.CarbonConstants" %>
<%@ page import="org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO" %>
<%@ page import="org.wso2.carbon.identity.oauth.ui.client.OAuthAdminClient" %>
<%@ 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.ResourceBundle" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
<%
String httpMethod = request.getMethod();
if (!"post".equalsIgnoreCase(httpMethod)) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
return;
}
String consumerkey = request.getParameter("consumerkey");
String appName = request.getParameter("appName");
String spName = request.getParameter("spName");
String forwardTo = "index.jsp";
boolean qpplicationComponentFound = CarbonUIUtil.isContextRegistered(config, "/application/");
if (qpplicationComponentFound) {
forwardTo =
"../application/configure-service-provider.jsp?action=delete&spName=" + Encode.forUriComponent(spName) +
"&oauthapp=" + Encode.forUriComponent(consumerkey);
}
String BUNDLE = "org.wso2.carbon.identity.oauth.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);
OAuthAdminClient client = new OAuthAdminClient(cookie, backendServerURL, configContext);
if (appName != null) {
OAuthConsumerAppDTO app = client.getOAuthApplicationDataByAppName(appName);
consumerkey = app.getOauthConsumerKey();
}
client.removeOAuthApplicationData(consumerkey);
String message = resourceBundle.getString("app.removed.successfully");
CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request);
} catch (Exception e) {
String message = resourceBundle.getString("error.while.removing.app");
CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request, e);
forwardTo = "../admin/error.jsp";
}
%>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy