ProxyAuth.jsp looks up proxy authentication information for the current user and prints the user name, password, and URL from that information to the JSP.The ProxyAuth.jsp source file looks like this:
<%@ 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";
//If you place that asset in the "root" organization,
//you can use this shortened naming.
// String asset = "Application_1"; Principal p = null;
String user = null;
String pwd = null;
String backendURL = null;
try
{
//Get the user principal
p = request.getUesrPrincipal();
//System.out.println("ProxyAuth 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: " + backendURL);
}
catch (Exception e)
{
e.printStackTrace();
}
%>
<h1 align="center"> Single Sign On Example </h1>
ProxyAuth user Principal is <%=p.getName()%>
<P> Proxy Authentication info for Asset: <%=asset%>
<P> User name: <%=user%>
<P> Password: <%=pwd%>
<P> URL: <%=backendURL%>