AjaxProxy.jsp revision e8721886dbfd32e88cc7077cbee4b6bb1b44b443
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%--
1e83c8de3aa48b316b28057d53995272baf1260cwrowe DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe The contents of this file are subject to the terms
1e83c8de3aa48b316b28057d53995272baf1260cwrowe of the Common Development and Distribution License
1e83c8de3aa48b316b28057d53995272baf1260cwrowe (the License). You may not use this file except in
1e83c8de3aa48b316b28057d53995272baf1260cwrowe compliance with the License.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe You can obtain a copy of the License at
1e83c8de3aa48b316b28057d53995272baf1260cwrowe https://opensso.dev.java.net/public/CDDLv1.0.html or
1e83c8de3aa48b316b28057d53995272baf1260cwrowe opensso/legal/CDDLv1.0.txt
1e83c8de3aa48b316b28057d53995272baf1260cwrowe See the License for the specific language governing
1e83c8de3aa48b316b28057d53995272baf1260cwrowe permission and limitations under the License.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe When distributing Covered Code, include this CDDL
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Header Notice in each file and include the License file
1e83c8de3aa48b316b28057d53995272baf1260cwrowe at opensso/legal/CDDLv1.0.txt.
1e83c8de3aa48b316b28057d53995272baf1260cwrowe If applicable, add the following below the CDDL Header,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe with the fields enclosed by brackets [] replaced by
1e83c8de3aa48b316b28057d53995272baf1260cwrowe your own identifying information:
1e83c8de3aa48b316b28057d53995272baf1260cwrowe "Portions Copyrighted [year] [name of copyright owner]"
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe $Id: AjaxProxy.jsp,v 1.7 2009/08/04 20:50:49 asyhuang Exp $
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe--%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%--
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Portions Copyrighted 2012 ForgeRock Inc
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Portions Copyrighted 2012 Open Source Solution Technology Corporation
1e83c8de3aa48b316b28057d53995272baf1260cwrowe--%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.iplanet.am.util.SystemProperties"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.iplanet.sso.SSOException"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.iplanet.sso.SSOToken"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.iplanet.sso.SSOTokenManager"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.idm.AMIdentity"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.idm.IdRepoException"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.idm.IdType"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.security.AdminTokenAction"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.console.base.AMViewBeanBase" %>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.workflow.ITask" %>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="com.sun.identity.workflow.WorkflowException" %>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="java.security.AccessController"%>
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%@page import="java.util.*" %>
56e85d89d42a6980f31b800266649efbed338da3wrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe<%
1e83c8de3aa48b316b28057d53995272baf1260cwrowe response.setContentType("text/html; charset=UTF-8");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe request.setCharacterEncoding("UTF-8");
37ad54b8fd2611b7a4f2b269eec3d27ed784a25dwrowe String locale = request.getParameter("locale");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe Locale resLocale = null;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if ((locale != null) && (locale.length() > 0)) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe StringTokenizer st = new StringTokenizer(locale, "|");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe int cnt = st.countTokens();
94b262d3639149df0b02642a9daa6db8bff58577wrowe if (cnt == 1) {
94b262d3639149df0b02642a9daa6db8bff58577wrowe resLocale = new Locale(st.nextToken());
94b262d3639149df0b02642a9daa6db8bff58577wrowe } else if (cnt == 2) {
94b262d3639149df0b02642a9daa6db8bff58577wrowe resLocale = new Locale(st.nextToken(), st.nextToken());
94b262d3639149df0b02642a9daa6db8bff58577wrowe } else {
94b262d3639149df0b02642a9daa6db8bff58577wrowe resLocale = new Locale(st.nextToken(), st.nextToken(),
94b262d3639149df0b02642a9daa6db8bff58577wrowe st.nextToken());
94b262d3639149df0b02642a9daa6db8bff58577wrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe } else {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe resLocale = Locale.US;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String amadminUUID = null;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String adminUser = SystemProperties.get(
1e83c8de3aa48b316b28057d53995272baf1260cwrowe "com.sun.identity.authentication.super.user");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if (adminUser != null) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe SSOToken adminToken = (SSOToken) AccessController.doPrivileged(
1e83c8de3aa48b316b28057d53995272baf1260cwrowe AdminTokenAction.getInstance());
1e83c8de3aa48b316b28057d53995272baf1260cwrowe AMIdentity adminUserId = new AMIdentity(adminToken, adminUser,
1e83c8de3aa48b316b28057d53995272baf1260cwrowe IdType.USER, "/", null);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe amadminUUID = adminUserId.getUniversalId();
5ac28f3fe2417368757f29cf381338357605fd52wrowe }
e1ad80c048e29e968221817698529d73098f07a4wrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe try {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe SSOTokenManager manager = SSOTokenManager.getInstance();
1e83c8de3aa48b316b28057d53995272baf1260cwrowe SSOToken ssoToken = manager.createSSOToken(request);
37ad54b8fd2611b7a4f2b269eec3d27ed784a25dwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe if (!manager.isValidToken(ssoToken)) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String redirectUrl = request.getScheme() + "://" +
1e83c8de3aa48b316b28057d53995272baf1260cwrowe request.getServerName() + ":" +
1e83c8de3aa48b316b28057d53995272baf1260cwrowe request.getServerPort() +
94b262d3639149df0b02642a9daa6db8bff58577wrowe request.getContextPath();
94b262d3639149df0b02642a9daa6db8bff58577wrowe response.sendRedirect(redirectUrl);
94b262d3639149df0b02642a9daa6db8bff58577wrowe return;
94b262d3639149df0b02642a9daa6db8bff58577wrowe }
94b262d3639149df0b02642a9daa6db8bff58577wrowe
94b262d3639149df0b02642a9daa6db8bff58577wrowe AMIdentity user = new AMIdentity(ssoToken);
94b262d3639149df0b02642a9daa6db8bff58577wrowe if (!user.getUniversalId().equalsIgnoreCase(amadminUUID)) {
94b262d3639149df0b02642a9daa6db8bff58577wrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe ResourceBundle rb = null;
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String RB_NAME = "workflowMessages";
1e83c8de3aa48b316b28057d53995272baf1260cwrowe com.sun.identity.shared.debug.Debug debug =
1e83c8de3aa48b316b28057d53995272baf1260cwrowe com.sun.identity.shared.debug.Debug.getInstance("workflowMessages");
1e83c8de3aa48b316b28057d53995272baf1260cwrowe rb = ResourceBundle.getBundle(RB_NAME, resLocale);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String msg = com.sun.identity.shared.locale.Locale.getString(
1e83c8de3aa48b316b28057d53995272baf1260cwrowe rb, "ajax.user.privilege.invalid", debug);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe throw new RuntimeException(msg);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe }
1e83c8de3aa48b316b28057d53995272baf1260cwrowe
1e83c8de3aa48b316b28057d53995272baf1260cwrowe } catch (SSOException ssoe) {
1e83c8de3aa48b316b28057d53995272baf1260cwrowe String redirectUrl = request.getScheme() + "://" +
1e83c8de3aa48b316b28057d53995272baf1260cwrowe request.getServerName() + ":" +
8c8173f49dd7122e10636b3d20ae841551bd0b43wrowe request.getServerPort() +
1e83c8de3aa48b316b28057d53995272baf1260cwrowe request.getContextPath();
1e83c8de3aa48b316b28057d53995272baf1260cwrowe response.sendRedirect(redirectUrl);
1e83c8de3aa48b316b28057d53995272baf1260cwrowe return;
} catch (IdRepoException ex) {
String redirectUrl = request.getScheme() + "://" +
request.getServerName() + ":" +
request.getServerPort() +
request.getContextPath() +
"/base/AMUncaughtException";
response.sendRedirect(redirectUrl);
return;
}
String clazzName = request.getParameter("class");
if (clazzName == null) {
String redirectUrl = request.getScheme() + "://" +
request.getServerName() + ":" +
request.getServerPort() +
request.getContextPath() +
"/base/AMUncaughtException";
response.sendRedirect(redirectUrl);
return;
}
try {
Class clazz = Class.forName(clazzName);
ITask task = (ITask) clazz.newInstance();
Map map = new HashMap();
for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) {
String n = (String) e.nextElement();
if (!n.equals("class") && !n.equals("locale")) {
map.put(n, request.getParameter(n));
}
}
map.put("_servlet_context_", getServletConfig().getServletContext());
map.put("_request_", request);
out.println("0|" + task.execute(resLocale, map));
} catch (WorkflowException e) {
out.write("1|" + AMViewBeanBase.stringToHex(
e.getL10NMessage(resLocale)));
} catch (IllegalAccessException e) {
out.write("1|" + e.getMessage());
} catch (InstantiationException e) {
out.write("1|" + e.getMessage());
} catch (ClassNotFoundException e) {
out.write("1|" + e.getMessage());
}
%>