Home

Results 1 to 4 of 4

Thread: AGLogout, Redirecting to Custom URL not working

Threaded View

  1. #1
    Join Date
    Mar 2017
    Posts
    43

    AGLogout, Redirecting to Custom URL not working

    I want to redirect user to the Custom URL from AGLogout.
    For this I follow the below URL
    https://www.netiq.com/communities/co...-logout-pages/
    https://www.netiq.com/documentation/...a/b6but9k.html
    But not works for me.

    I modified "logoutSuccess_legacy.jsp" file of Access Gateway. This file code is given below
    Code:
    <%@ page language="java" %>
    <%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
    <%@ page import="java.util.*" %>
    <%@ page import="com.novell.nidp.*" %>
    <%@ page import="com.novell.nidp.authentication.local.X509Class" %>
    <%@ page import="com.novell.nidp.resource.*" %>
    <%@ page import="com.novell.nidp.resource.jsp.*" %>
    <%@ page import="com.novell.nidp.ui.*" %>
    <%@ page import="com.novell.nidp.sessionassurance.NIDPSessionAssurance" %>
    <%
    		// Added for the Redirection
            String site = (String) request.getHeader("referer");
            System.out.println("site11>>>>>>>>>>"+site);
            if(site.startsWith("https://demo.testlab.local")) {
                response.setStatus(302);
                response.setHeader("Location", "http://demolab.org/logoutPages/wwwLogout.jsp");
                response.setHeader("Connection", "close");
            }
            Properties properties = new Properties();
            properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("demoLogoutSuccess.properties"));
            final String env                = (String) properties.get("demo.environment");
            final String test1LogoutURL       = (String) properties.get("demo."+ env +".test1LogoutURL");
            final String test2LogoutURL       = (String) properties.get("demo."+ env +".test2LogoutURL");
            final String test3LogoutURL        = (String) properties.get("demo."+ env +".test3LogoutURL");
            final String expireTokenURL     = (String) properties.get("demo."+ env +".expireTokenURL");
            final String demoDomain          = (String) properties.get("demo."+ env +".domain");
            final String ssoLogoutURL       = "https://sso" + demoDomain + "/nidp/app/plogout";
            String AuthTokenID = null;
            Cookie[] cookies = null;
            cookies = request.getCookies();        
            if (cookies != null){
                    for (int i=0;i < cookies.length; i++)
                    {
                            if (cookies[i].getName().equals("OAUTH2ACCESSTOKEN"))
                            {
                                    AuthTokenID = cookies[i].getValue();
                                    break;
                            }
                    }
            }
            if (AuthTokenID == null)
            {
                    AuthTokenID="";
            }
    		response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
    		response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
    		response.setDateHeader("Expires", 0); // Proxies.
    		Cookie cookie = new Cookie("JSESSIONID", null);
    		cookie.setPath(request.getContextPath()+"/");
    		cookie.setMaxAge(0);
    		response.addCookie(cookie);
    		com.novell.nidp.authentication.local.PersistenceAuthClass.clearCookie(request,response);
    		NIDPSessionAssurance nidpSessAssurance = NIDPSessionAssurance.getInstance();
    		nidpSessAssurance.clearIDCCookie(request,response);
    		response.setHeader("Connection", "close");
    		UIHandler uh = new UIHandler(request,response);
    		ArrayList logoutStrings = null;
    		ArrayList logos = null;
    		if (uh.isJSPMsg())
    		{
    			NIDPLogoutMessage msg = 
    				(NIDPLogoutMessage)uh.getMessage(true);
    			if (msg.isConfirmLogouts())
    			{
    				logoutStrings = ((NIDPLogoutMessage)msg).getStrings();
    				logos = ((NIDPLogoutMessage)msg).getLogos();
    			}
    		}
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//Dtd HTML 4.0 transitional//<%=uh.getLanguageCode()%>">
    <html lang="<%=uh.getLanguageCode()%>">
        <head>
            <link href="<%= uh.getImage("hf_style.css",false)%>" rel="stylesheet">
    	    <style type="text/css" media="screen">
    		</style>
                    <script type="text/javascript" src="/nesp/images/jquery-1.7.js"></script>
                    <%@ include file="cookies.js" %>
                    <script>
                    function getParameterByName(name) {
                            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
                            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)");
                            results = regex.exec(location.search);
                            return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
                    }
                    var redirectTarget = getParameterByName("redirect_uri");
                    var landingTarget = getParameterByName("landing");
                    switch(landingTarget) {
                            case "test4":
                            redirectTarget = "https://test4<%=demoDomain%>/AGLogout?target=test4";
                            break;
                            case "test5":
                            redirectTarget = "https://test4<%=demoDomain%>/AGLogout?target=test5";
                            break;
                    }
                    var access_token;
                    function doRedirect() {
                            docCookies.removeItem("OAUTH2ACCESSTOKEN","/");
                            docCookies.setItem("OAUTH2ACCESSTOKEN","", -1, "/","<%=demoDomain%>");
                            var idpLoginType = docCookies.getItem("idpLoginType");
                            if (idpLoginType === "oneid-remote") {
                                    window.top.location = "<%=ssoLogoutURL%>";
                            } else if (redirectTarget != "") {
                                    window.top.location=redirectTarget;
                            } else {
                                    window.top.location=window.top.location.href.replace("nesp\/app\/plogout","").replace("AGLogout","") + "#/logout";
                            }
                    }
            </script>
        </head>
        <body marginwidth="0" marginheight="0" leftmargin="10" topmargin="0">
    <div style="visibility:hidden">
    <% if (AuthTokenID != "") { %>
    <iframe src="<%=expireTokenURL+AuthTokenID%>/expire" height="1" width="1">Unable to remove Token</iframe>
    <%}%>
    <% if (test2LogoutURL != "") { %>
    <iframe src="<%=test2LogoutURL%>" height="1" width="1">Unable to clear sessions</iframe>
    <%}%>
    <% if (test3LogoutURL != "") { %>
    <iframe src="<%=test3LogoutURL%>" height="1" width="1">Unable to clear sessions</iframe>
    <%}%>
    <% if (test1LogoutURL != "") { %>
    <iframe src="<%=test1LogoutURL%>" height="1" width="1">Unable to clear sessions</iframe>
    <%}%>
    <script type="text/javascript">
            var counter=0;
            $('iframe').load(function() {if (document.location.href != document.referrer)
            {counter++;}
            if (counter == $('iframe').length){
                    doRedirect();
            }
            });
    </script>
    </div>
            <div class="head3b"><%=uh.getResource(JSPResDesc.LOGOUT)%></div>		
    	    <table border=0>
    	        <tr>
    	            <td><%=uh.getResource(JSPResDesc.LOGOUT_SUCCESS_MSG)%></td>
     	        </tr>
    <%
    	if (logos != null && logos.size() > 0)
        {
    %>
    	    	<tr>
    		  	    <td>
                        <table cellSpacing=7 cellPadding=0 align=left border=0>
                            <tr>
                                <td width=15><img height=1 src="<%=uh.getImage("spacer.gif",false)%>" width=15 border=0 alt=""></td>
                                <td colspan="2"><b><%=uh.getResource(JSPResDesc.LOGOUT_SITES)%></b></td>
                            </tr>
    		<%
                    for (int i = 0; i < logos.size(); i++)
                    {
            %>
                            <tr>
                                <td width="15"><img height=1 src="<%=uh.getImage("spacer.gif",false)%>" width=15 border=0 alt=""></td>
                                            <td class=leadCopy><%= (String)logos.get(i) %></td>
                                            <%
                                                    String s = (String)logoutStrings.get(i);
                                                    if((s != null) && (s.indexOf("?") != -1))
                                                    {
                                            %>
                                                    <td><iframe id="remoteContent" src="<%= s %>"  WIDTH=0 HEIGHT=0 frameborder=0></iframe> </td>
                                            <%
                                                    }
                                                    else
                                                    {
                                            %>
                                                    <td><img alt="<%=uh.getResource(JSPResDesc.LOGOUT)%>" src="<%= s %>"/></td>
                                            <%
                                                    }
                                            %>
                                    </tr>
            <%
                    }
            %>
                        </table>
    		  		</td>
    	    	</tr>
    <%    } %>
    		</table>
        </body>
    </html>
    <%request.getSession().invalidate();%>
    When I try to hit https://demo.testlab.local/AGLogout. I think they will not come to this code because I did sysout and I did not found any thing in the log but when I hit the URL with AGLogout that was already protected and working fine, In that case they will come to this code and print sysout message.
    Last edited by fartyalvikram; 21-Sep-2017 at 03:58 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •