OAuthLogout.jsp revision e8721886dbfd32e88cc7077cbee4b6bb1b44b443
6fe48fb46e53ffc37542853a1edb74cb481b7d94Automatic Updater DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User Copyright (c) 2011 ForgeRock Inc. All rights reserved.
e9e4257668ff6c4e583b0c0db2508650b0b677b8Tinderbox User The contents of this file are subject to the terms
e9e4257668ff6c4e583b0c0db2508650b0b677b8Tinderbox User of the Common Development and Distribution License
c57668a2fbbe558c1bd21652813616f2f517c469Tinderbox User (the License). You may not use this file except in
5e047890ac9b745db060d95f7d1b4f876511240dTinderbox User compliance with the License.
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User You can obtain a copy of the License at
02b47c5d62e1e827743684c28a08e871da454a2dMark Andrews See the License for the specific language governing
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User permission and limitations under the License.
e20309353e6246485c521278131d3fced73d7957Tinderbox User When distributing Covered Code, include this CDDL
e20309353e6246485c521278131d3fced73d7957Tinderbox User Header Notice in each file and include the License file
9a5217f827ac0e006016745e5305b31dc0c7767fTinderbox User If applicable, add the following below the CDDL Header,
3cc98b8ecedcbc8465f1cf2740b966b315662430Automatic Updater with the fields enclosed by brackets [] replaced by
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews your own identifying information:
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews "Portions Copyrighted [year] [name of copyright owner]"
df4ebd8217d02dafc12145b55c4d93d0255d1ec7Tinderbox User Portions Copyrighted 2012 Open Source Solution Technology Corporation
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson<%@ page language="java" pageEncoding="UTF-8" %>
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater<%@ page import="org.owasp.esapi.*" %>
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User<%@ page import="com.iplanet.am.util.SystemProperties" %>
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User<%@ page import="com.sun.identity.shared.Constants" %>
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt<%@ page import="static org.forgerock.openam.authentication.modules.oauth2.OAuthParam.*" %>
e130ab53e992670e2a2ecf043976ac09f21358d1Automatic Updater<%@ page import="java.io.IOException" %>
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater<%@ page import="java.util.ResourceBundle" %>
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt<%@ page import="java.util.Locale" %>
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater<%@ page import="java.util.MissingResourceException" %>
24934f08b9ff81c2be711e566e8002d145573031Tinderbox User<%@ page import="org.forgerock.openam.authentication.modules.oauth2.OAuthUtil" %>
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt // Internationalization stuff. You can use any internationalization framework
24934f08b9ff81c2be711e566e8002d145573031Tinderbox User String lang = request.getParameter("lang");
e9e4257668ff6c4e583b0c0db2508650b0b677b8Tinderbox User ResourceBundle resources;
aa9c561961e9d877946ebaa8795fa2be054ab7bfEvan Hunt Locale locale = null;
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater if (lang != null && lang.length() != 0) {
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater locale = new Locale(lang);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater resources = ResourceBundle.getBundle("amAuthOAuth", locale);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater OAuthUtil.debugMessage("OAuthLogout: obtained resource bundle with locale " + locale);
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater } catch (MissingResourceException mr) {
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater OAuthUtil.debugError("OAuthLogout: Resource Bundle not found", mr);
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews resources = ResourceBundle.getBundle("amAuthOAuth");
b886b04d8d2b085cbf3e1bf4442dee87f43ba5e4Tinderbox User String logoutForm = ESAPI.encoder().encodeForHTML(LOGOUT_FORM);
e20309353e6246485c521278131d3fced73d7957Tinderbox User String loggedoutParam = ESAPI.encoder().encodeForHTML(PARAM_LOGGEDOUT);
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String gotoParam = ESAPI.encoder().encodeForHTML(PARAM_GOTO);
24934f08b9ff81c2be711e566e8002d145573031Tinderbox User String logoutURLParam = ESAPI.encoder().encodeForHTML(PARAM_LOGOUT_URL);
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String logmeoutValue = ESAPI.encoder().encodeForHTML(resources.getString("logmeout"));
7feccf248d2a20a2ae48b290f58ded5abc853e9aTinderbox User String donotValue = ESAPI.encoder().encodeForHTML(resources.getString("donot"));
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String doYouWantToLogout = resources.getString("doYouWantToLogout");
ad411d8ccf8a27eb903b842ab507ba6729d0246bTinderbox User String youVeBeenLogedOut = resources.getString("youVeBeenLogedOut");
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updater String loggingYouOut = resources.getString("loggingYouOut");
ad411d8ccf8a27eb903b842ab507ba6729d0246bTinderbox User // Getting and validating params
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String gotoURL = request.getParameter(PARAM_GOTO);
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews String gotoURLencAttr = "";
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews String OAuth2IdP = "";
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater String ServiceURI = SystemProperties.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson if (gotoURL == null || gotoURL.isEmpty() ) {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater gotoURL = ServiceURI + "/UI/Logout";
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews boolean isValidURL = ESAPI.validator().
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater isValidInput("URLContext", gotoURL, "URL", 255, false);
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson boolean isValidURI = ESAPI.validator().
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater isValidInput("HTTP URI: " + gotoURL, gotoURL, "HTTPURI", 2000, false);
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater if (!isValidURL && !isValidURI) {
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson OAuthUtil.debugError("OAuthLogout: wrong goto URL attempted to be used "
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater + "in the Logout page: " + gotoURL);
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews gotoURL = "wronggotoURL";
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User String logoutURL = request.getParameter(PARAM_LOGOUT_URL);
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews if (logoutURL == null) {
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews logoutURL = "";
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews boolean isValidURL = ESAPI.validator().
28a5dd720187fddb16055a0f64b63a7b66f29f64Mark Andrews isValidInput("URLContext", logoutURL, "URL", 255, false);
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont if (!isValidURL) {
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User OAuthUtil.debugError("OAuthLogout: wrong logoutURL URL attempted to be used "
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User + "in the Logout page: " + logoutURL);
2a31bd531072824ef252c18303859d6af7451b00Francis Dupont logoutURL = "wronglogoutURL";
2ba8f584b97cbab864570e38fd26b8cb90961428Tinderbox User int loc1 = logoutURL.indexOf("//") + 2;
3349f0044fda807e1fd6681c833d3593a22dad86Tinderbox User OAuth2IdP = logoutURL.substring(loc1, logoutURL.indexOf("/", loc1));
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews doYouWantToLogout = doYouWantToLogout.replace("#IDP#", OAuth2IdP);
24bf1e02f03577db0feb50b80238c4150c96d05dAutomatic Updater String copyrightNotice = null;
78f3ed4bc2fcd3d270bfd599804f3b27a1db4d91Mark Andrews copyrightNotice = ResourceBundle.getBundle("amAuthUI", locale).getString("copyright.notice");
2ba8f584b97cbab864570e38fd26b8cb90961428Tinderbox User } catch (MissingResourceException mr) {
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews String loggedout = request.getParameter(PARAM_LOGGEDOUT);
551271d8198ae06e37edf5da519d8ee153eeac0fTinderbox User System.out.println("loggedout=" + loggedout);
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
01a5c5503482fb3ba52088bf0178a7213273bf96Mark Andrews <link href="<%= ServiceURI%>/css/new_style.css" rel="stylesheet" type="text/css" />
551271d8198ae06e37edf5da519d8ee153eeac0fTinderbox User <!--[if IE 9]> <link href="<%= ServiceURI %>/css/ie9.css" rel="stylesheet" type="text/css"> <![endif]-->
b871c7156eb037d41f53828c6fcb9cc876128962Mark Andrews <!--[if lte IE 7]> <link href="<%= ServiceURI %>/css/ie7.css" rel="stylesheet" type="text/css"> <![endif]-->
df4ebd8217d02dafc12145b55c4d93d0255d1ec7Tinderbox User <script language="JavaScript" type="text/javascript">
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater function adios() {
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater window.location = "<%= gotoURL %>";
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User function logoutAll() {
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User // Creates an iFrame to log out from the OAuth 2.0 IdP
fa0326cc2cf428f67575b6ba3b97b528a31b0010Tinderbox User var frame = document.getElementById('frame');
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater if (!frame){return};
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater var logMsg = document.getElementById('logoutMsg');
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater var logMsgVs = document.getElementById('logoutMsgVisible');
f2770f6b39a9b2a98afb7a11ed105f73f1570c1eAutomatic Updater var main = document.getElementById('main');
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson var iframe = document.createElement('iframe');
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater iframe.setAttribute('src', '<%= logoutURL %>');
133e6d43fa82e80d3798be4de00f4540f485ec6cAutomatic Updater iframe.setAttribute('frameborder', 0);
5f7586ddbd3edd11272cdd30ed613d936129328bTinderbox User <% if (loggedout != null && loggedout.equalsIgnoreCase("logmeout")){
5f7586ddbd3edd11272cdd30ed613d936129328bTinderbox User out.println("logoutAll(); }");
c7ef13f6c9ef4436bc804b150e0a93307b11fa27Tinderbox User <title>Logout</title>
f132a836c4e386b1af045dd8fe7106ae61b90bffAutomatic Updater <div class="container_12">
d642d3857129678797a01adee14fbd70335b05a9Mark Andrews <div class="grid_4 suffix_8">
609b8d08176469485edce25f3c2f50365bbd3819Mark Andrews <a class="logo" href="<%= ServiceURI%>"></a>
5f33078b538b3d317917deb962bd057b2a888db1Tinderbox User <div class="box box-spaced clear-float">
710bce1a85c96e85ca1a90471382055acd29d51fTinderbox User <div class="grid_3">
8e5fce1f9ceba17dd7e3ff0eb287e1e999c14249Mark Andrews <div class="product-logo"></div>
8711e5c73ca872d59810760af0332194cbdd619bAutomatic Updater <div class="grid_9">
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater <div class="box-content clear-float">
91d187ce035f39073f0732ff2a401a45c3c955fbMark Andrews <div class="message">
91d187ce035f39073f0732ff2a401a45c3c955fbMark Andrews <span class="icon info"></span>
8f2c45a35dd8c40bcc9caba8f7d40ce64fc27bcdAutomatic Updater <div id="logoutMsg" style="display:none">
8e5fce1f9ceba17dd7e3ff0eb287e1e999c14249Mark Andrews <h3><%= loggingYouOut %></h3>
91d187ce035f39073f0732ff2a401a45c3c955fbMark Andrews <div id="logoutMsgVisible">
91d187ce035f39073f0732ff2a401a45c3c955fbMark Andrews <h3><%= doYouWantToLogout %></h3>
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater <div id="frame">
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater Your browser does not support scripts.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater This page needs javascript to be enabled in your browser.
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater <div id="main">
609b8d08176469485edce25f3c2f50365bbd3819Mark Andrews <form name="<%= logoutForm %>" method="POST" action="">
609b8d08176469485edce25f3c2f50365bbd3819Mark Andrews <input name="<%= loggedoutParam %>" type="button" class="button" onClick="adios()" onmousedown="adios()" value="<%= donotValue %>" />
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater <input name="<%= loggedoutParam %>" type="button" class="button right" onClick="logoutAll()" onmousedown="adios()" value="<%= logmeoutValue %>" />
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater <div class="footer alt-color">
5ecad47f69b3fd945472ab2900a9ff826a7ce2f6Automatic Updater <div class="grid_6 suffix_3">
91d187ce035f39073f0732ff2a401a45c3c955fbMark Andrews <% if (copyrightNotice != null){
6a9d2121152c94cb9e35832126c3f2e4d18d81edTinderbox User out.println(copyrightNotice);