I have written following code:
<%@ include file="/WEB-INF/I18n.inc" %>
<%@ page import="..."%>
<HTML>
<%
out.print("Came to correct page");
AardvarkSecurityPlugin asp = new AardvarkSecurityPlugin();
Properties p1 = new Properties();
p1.put("pluginclass","com.firstbase.framework.security2.plugin.AardvarkSecurityPlugin");
p1.put("logname","Securitytest");
p1.put("securitydomain","AARDVARK");
p1.put("applications","AARDVARK");
p1.put("dsname","FirstBase");
p1.put("cachelife","10000");
asp.init(p1);
String email = "d@d.com";
String pwd = "password";
Principal p = asp.authenticate(request, email, "FORM", pwd);
System.out.println("Seems principal is:" + p);
System.out.println("Principal in session 1:" + session.getAttribute("PRINCIPAL_USER").toString());
System.out.println("Principal in session 2:" + session.getAttribute("org.apache.catalina.authenticator.PRINCIPAL").toString());
System.out.println("Principal in session 3:" + request.getUserPrincipal());
%>
<a href="/tester/servlet/FsmServlet?MACH_NAME=STUDENT&ACTION_NAME=Welcome"> click here </a>
</body>
</HTML>
in which AardvarkSecurityPlugin is class derived from DefaultSecurityPlugin..when I am dont with authentication among 4 above sop's first 3 are printing something but request.getUserPrincipal() always giving null. please let me know where am I missing.authenticate method is having followign code peice:
HttpSession session = req.getSession();
SessionLogin login = getSessionLogin(session);
Credentials credentialsObject =createCredentials(req,username,password);
LoginResult result = login.validateCredentials(credentialsObject);
//check for principal associates with the correct clint for asserion app
if (result.isSuccess()){ // Login event has succeeded
principal = new AuthenticatedUser(username);
roleTable.remove(username);
try{
SecurityLogger.log(securityDomain,principal, SecurityLogger.AUTHENTICATED,
"user Logged In", "AUTHENTICATED", dsName);
}
catch(Exception e){
Logger.log("UserManager",Logger.ERROR,"exception in updation last logged exception is "+e);
}
session.setAttribute("com.firstbase.framework.security2.LoginResult", result);
// Destroy user profiles
// If the user has logged on successfully then delete the LoginSession
// object since it is no longer required
if (principal!=null){
session.removeAttribute("com.firstbase.framework.security2.SessionLogin");
session.setAttribute(ServletConstants.PRINCIPAL_USER,principal);
if (preload)
loadUser(username);
}
return principal;
}