ssoadm.jsp revision 984ea967792540448d05fba2ac6fad5dadf91fd6
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%--
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry The contents of this file are subject to the terms
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry of the Common Development and Distribution License
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry (the License). You may not use this file except in
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry compliance with the License.
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry You can obtain a copy of the License at
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry https://opensso.dev.java.net/public/CDDLv1.0.html or
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry opensso/legal/CDDLv1.0.txt
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry See the License for the specific language governing
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry permission and limitations under the License.
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry When distributing Covered Code, include this CDDL
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Header Notice in each file and include the License file
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry at opensso/legal/CDDLv1.0.txt.
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry If applicable, add the following below the CDDL Header,
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry with the fields enclosed by brackets [] replaced by
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry your own identifying information:
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry "Portions Copyrighted [year] [name of copyright owner]"
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry $Id: ssoadm.jsp,v 1.9 2010/01/20 00:46:52 veiming Exp $
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry--%>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%--
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Portions Copyrighted 2010-2012 ForgeRock Inc
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry--%>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.iplanet.am.util.SystemProperties" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.iplanet.sso.*" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.sun.identity.cli.*" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.sun.identity.shared.Constants" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="java.text.MessageFormat" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.sun.identity.common.DNUtils" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.sun.identity.idm.AMIdentity" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="com.sun.identity.idm.IdType" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page import="java.util.ResourceBundle" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%@ page contentType="text/html; charset=UTF-8" %>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<html xmlns="http://www.w3.org/1999/xhtml">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<head>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <title>OpenAM</title>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <link rel="stylesheet" type="text/css" href="com_sun_web_ui/css/css_ns6up.css" />
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <link rel="shortcut icon" href="com_sun_web_ui/images/favicon/favicon.ico" type="image/x-icon" />
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <script language="Javascript" src="js/admincli.js"></script>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry</head>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<body class="DefBdy">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <div class="SkpMedGry1"><a href="#SkipAnchor3860"><img src="com_sun_web_ui/images/other/dot.gif" alt="Jump to End of Masthead" border="0" height="1" width="1" /></a></div><div class="MstDiv">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <table class="MstTblBot" title="" border="0" cellpadding="0" cellspacing="0" width="100%">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <tr>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <td class="MstTdTtl" width="99%">
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <div class="MstDivTtl"><img name="AMConfig.configurator.ProdName" src="console/images/PrimaryProductName.png" alt="OpenSSO" border="0" /></div>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry </td>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <td class="MstTdLogo" width="1%"><img name="AMConfig.configurator.BrandLogo" src="com_sun_web_ui/images/other/javalogo.gif" alt="Java(TM) Logo" border="0" height="55" width="31" /></td>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry </tr>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry </table>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <table class="MstTblEnd" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td><img name="RMRealm.mhCommon.EndorserLogo" src="com_sun_web_ui/images/masthead/masthead-sunname.gif" alt="Sun(TM) Microsystems, Inc." align="right" border="0" height="10" width="108" /></td></tr></table>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry </div>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <table class="SkpMedGry1" border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td><img src="com_sun_web_ui/images/other/dot.gif" alt="Jump to End of Masthead" border="0" height="1" width="1" /></a></td></tr></table>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry <table border="0" cellpadding="10" cellspacing="0" width="100%"><tr><td></td></tr></table>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<table cellpadding=5>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<tr>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<td>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<pre>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry<%
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry String strDisabled = SystemProperties.get("ssoadm.disabled", "true");
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry if (Boolean.parseBoolean(strDisabled)) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry response.sendRedirect(SystemProperties.get(
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry } else {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry try {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry SSOTokenManager manager = SSOTokenManager.getInstance();
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry SSOToken ssoToken = manager.createSSOToken(request);
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry String adminUserDN = "";
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry AMIdentity adminUserId = null;
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry // This will give you the 'amAdmin' user dn
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry String adminUser = SystemProperties.get(
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry "com.sun.identity.authentication.super.user");
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry if (adminUser != null) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry adminUserDN = DNUtils.normalizeDN(adminUser);
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry // This will give you the 'amAdmin' Identity
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry adminUserId = new AMIdentity(ssoToken, adminUser,
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry IdType.USER, "/", null);
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry }
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry // This will be your incoming user/token.
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry AMIdentity user = new AMIdentity(ssoToken);
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry if ((!adminUserDN.equals(DNUtils.normalizeDN(
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry ssoToken.getPrincipal().getName()))) &&
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry (!user.equals(adminUserId))) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry out.println(ResourceBundle.getBundle("encode", request.getLocale()).getString("no.permission"));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry return;
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry }
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry WebCLIHelper helper = new WebCLIHelper(request,
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry "com.sun.identity.cli.AccessManager,com.sun.identity.federation.cli.FederationManager",
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry "ssoadm", request.getContextPath() + "/ssoadm.jsp");
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry out.println(helper.getHTML(request, ssoToken));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Object[] param = {"0"};
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry out.println(MessageFormat.format(
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry CLIConstants.JSP_EXIT_CODE_TAG, param));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry } catch (SSOException e) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry response.sendRedirect("UI/Login?goto=../ssoadm.jsp");
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry } catch (CLIException e) {
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry Object[] param = {Integer.toString(e.getExitCode())};
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry out.println(MessageFormat.format(
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry CLIConstants.JSP_EXIT_CODE_TAG, param));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry out.println(WebCLIHelper.escapeTags(e.getMessage()));
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry }
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry }
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry%>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry</pre>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry</td></tr>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry</table>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry</body></html>
ba7b222e36bac28710a7f43739283302b617e7f5Glenn Barry