For demonstration purposes, sso.jsp looks up proxy authentication information for the current user and prints the user name, password, and URL from that proxy authentication information record to the JSP.
Here is the sample sso.jsp:
<%@ page import="javax.servlet.*"%>
<%@ page import="java.security.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.rmi.PortableRemoteObject"%>
<%@ page import="com.sybase.ep.security.management.*"%><%@ page import="com.sybase.ep.security.sessionsvcs.*"%>
<%
String asset = "a1=Application_1,o=sybase,c=us";
// You can change the assetDN to something more readable using
// Enterprise Security. For example, if there is only one asset
// in your system with the name "Application_1", then you can
// change the AssetDN to "Application_1", and correspondingly
// String asset = "Application_1";
//in this code.
Principal p = null;
String user = null;
String pwd = null;
String backendURL = null;
try
{
//Get the user principal
p = request.getUserPricipal ();
//System.out.println(“SSO user principal is: “ + p);
Context ctx = new InitialContext();
//Get the EP PortalSession object to get the
//Proxy authentication information
PortalSessionHome psHome = (PortalSessionHome)
PortableRemoteObject.narrow(
ctx.lookup("com.sybase.ep.security.sessionsvcs/PortalSession"),
PortalSessionHome.class);
PortalSession ps = psHome.findByCurrentSession();
ProxyAuthenticationInfo pai = ps.findProxyAuthenticationInfo(asset);
//Get the username
user = pai.authenticationName;
//Get the password
byte[] password = pai.authenticationCredential;
pwd = new String(password);
backendURL = pai.serviceURL;
//System.out.println(Asset “ + asset + “ provided proxy auth user: “
//+ user + “ with password: “ + pwd
//+ “ and extraURL info: “ + backend URL);
}
catch (Exception e)
{
e.printStackTrace();
}
%>
<h1 align="center"> Single Sign On Example </h1>
SSO user Principal is <%=p.getName()%>
<P> Proxy Authentication info for Asset: <%=asset%>
<P> User name: <%=user%>
<P> Password: <%=pwd%>
<P> URL: <%=backendURL%>
In this example, the asset variable “Application_1” matches the asset created using the Enterprise Security Manager, and the complete DN (distinguished name) for the asset is provided.
Running the JSP
Log in to Portal Interface.
Open a Web browser, and enter:
http://machine_name.domain:8080/onepage/index.jsp
where machine_name is the name of the machine where the onepage Web application is installed and domain is the network domain in which the machine is registered. This displays the Portal Login page.
Enter your member name and password, then click Sign In.
Click the Add Page icon.
In the Add Page window, select the page containing the SSO portlet that you created (ProxyAuthPage), and click Done.
The ProxyAuthPage (which contains the ProxyAuth portlet) displays. When this JSP is executed for an authenticated user who has the PortalUser role and READ access to the Application_1 asset, it prints:
SSO user Principal is
uid=userID, cn=UserName
o=Sybase, c=us
Proxy Authentication info for Asset:
a1=Application_1,o=Sybase,c=us
User name: proxyUser
Password: proxyPasswordURL:
This output differs based on the proxy authentication information Enterprise Security determines is appropriate for the current user.