Show AuthnAdapterImpl.java syntax highlighted
/**
* Copyright (c) 2005
* Helsinki Institute of Physics
* see LICENSE file for details
*
* AuthAdapterImpl.java
* Created on Nov 1, 2005
*/
package fi.hip.gb.gridlib.gridsp.adapters;
import fi.hip.gb.gridlib.gridsp.userbase.PortalUser;
import fi.hip.gb.gridlib.gridsp.SPConstants;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.sourceid.idff12.adapter.AuthnAdapter;
/**
* This class includes the implementation for the
* org.sourceid.idff12.adapter.AuthnAdapter interface.
* @author Henri Mikkonen
* @version $Id: $
*/
public class AuthnAdapterImpl implements AuthnAdapter {
/**
* Gets the authentication info from the HTTP Session.
* @param request The HTTP Servlet request.
* @param response The HTTP Servlet response.
* @return Authentication info (the principal ID and the session index)
*/
public Info getAuthnInfo(HttpServletRequest request,
HttpServletResponse response) {
Info authnInfo = null;
HttpSession session = request.getSession(false);
if (session != null) {
PortalUser user =
(PortalUser)session.getAttribute(SPConstants.ATTR_USER_KEY);
if (user != null) {
authnInfo = new AuthnAdapter.Info();
authnInfo.principalId = user.getUsername();
authnInfo.sessionIndex = "0";
}
}
return authnInfo;
}
/**
* Gets the sessin ID from the HTTP Session.
* @param request The HTTP Servlet request.
* @param response The HTTP Servlet response.
* @return Session ID as <code>String</code>, null if it does not exist.
*/
public String getSessionId(HttpServletRequest request,
HttpServletResponse response) {
String sessionId = null;
HttpSession session = request.getSession(false);
if (session != null) {
sessionId =
(String)session.getAttribute(SPConstants.ATTR_SESSION_KEY);
}
return sessionId;
}
}
See more files for this project here