use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class FSRegistrationInitiationServlet method doRegistrationInitiation.
/**
* Called when a registration needs to be initiated with a remote provider.
* @param request <code>HTTPServletRequest</code> object received via a
* HTTP Redirect
* @param response <code>HTTPServletResponse</code> object to send the
* response back to user agent
* @param hostedProviderDesc the provider where registration is initiated
* @param hostedConfig the hosted provider's extended meta
* @param hostedEntityId the hosted provider's entity id
* @param hostedRole hosted provider's role
* @param hostedProviderAlias hosted provider's meta alias
*/
private void doRegistrationInitiation(HttpServletRequest request, HttpServletResponse response, ProviderDescriptorType hostedProviderDesc, BaseConfigType hostedConfig, String hostedEntityId, String hostedRole, String hostedProviderAlias) {
FSUtils.debug.message("Entered FSRegistrationInitiationServlet::doRegistrationInitiation");
try {
Object ssoToken = getValidToken(request);
if (ssoToken != null) {
String providerId = request.getParameter(IFSConstants.REGISTRATION_PROVIDER_ID);
if (providerId == null || providerId.length() < 1) {
FSUtils.debug.error("Provider Id not found, display error page");
FSServiceUtils.showErrorPage(response, COMMON_ERROR_PAGE, IFSConstants.REGISTRATION_NO_PROVIDER, IFSConstants.CONTACT_ADMIN);
return;
}
// session is valid, ProviderId available
FSServiceManager instSManager = FSServiceManager.getInstance();
if (instSManager != null) {
FSUtils.debug.message("FSServiceManager Instance not null");
String remoteProviderRole = IFSConstants.SP;
FSAccountFedInfo fedinfo = null;
if (hostedRole.equalsIgnoreCase(IFSConstants.SP)) {
remoteProviderRole = IFSConstants.IDP;
FSSessionManager sessManager = FSSessionManager.getInstance(hostedProviderAlias);
FSSession ssoSession = sessManager.getSession(ssoToken);
if (ssoSession != null) {
if (!ssoSession.getOneTime()) {
fedinfo = ssoSession.getAccountFedInfo();
}
}
}
SessionProvider sessionProvider = SessionManager.getProvider();
FSNameRegistrationHandler handlerObj = instSManager.getNameRegistrationHandler(providerId, remoteProviderRole, sessionProvider.getPrincipalName(ssoToken), hostedEntityId, hostedProviderAlias);
if (handlerObj != null) {
handlerObj.setHostedDescriptor(hostedProviderDesc);
handlerObj.setHostedDescriptorConfig(hostedConfig);
handlerObj.setMetaAlias(hostedProviderAlias);
handlerObj.setHostedProviderRole(hostedRole);
handlerObj.setHostedEntityId(hostedEntityId);
if (fedinfo != null) {
handlerObj.setAccountInfo(fedinfo);
}
boolean bStatus = handlerObj.handleNameRegistration(request, response, ssoToken);
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("handleNameRegistration status is : " + bStatus);
}
return;
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Unable to get registration " + "handler. User account Not valid");
}
}
} else {
FSUtils.debug.message("FSServiceManager Instance null");
}
FSServiceUtils.returnLocallyAfterOperation(response, REGISTRATION_DONE_URL, false, IFSConstants.REGISTRATION_SUCCESS, IFSConstants.REGISTRATION_FAILURE);
return;
} else {
FSServiceUtils.redirectForAuthentication(request, response, hostedProviderAlias);
return;
}
} catch (IOException e) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("IOException in doRegistrationInitiation:", e);
}
} catch (SessionException ex) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("SessionException in doRegistrationInitiation", ex);
}
}
FSServiceUtils.returnLocallyAfterOperation(response, REGISTRATION_DONE_URL, false, IFSConstants.REGISTRATION_SUCCESS, IFSConstants.REGISTRATION_FAILURE);
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class FSProcessLogoutServlet method getValidToken.
/**
* Retrieves valid session from HTTP Request.
* @param request HTTP request object
* @return session if the session is valid; <code>null</code>
* otherwise.
*/
private Object getValidToken(HttpServletRequest request) {
FSUtils.debug.message("Entered FSProcessLogoutServlet::getValidToken");
try {
SessionProvider sessionProvider = SessionManager.getProvider();
Object ssoToken = sessionProvider.getSession(request);
if ((ssoToken == null) || (!sessionProvider.isValid(ssoToken))) {
FSUtils.debug.message("session is not valid, redirecting for authentication");
return null;
}
return ssoToken;
} catch (SessionException e) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("SessionException caught: " + e);
}
return null;
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerImpl method getAssertions.
public Set getAssertions(String ssoToken) throws SAMLException {
checkInitialization();
try {
SessionProvider sessionProvider = SessionManager.getProvider();
Object token = sessionProvider.getSession(ssoToken);
return (assertionManager.getAssertions(token));
} catch (SessionException ssoe) {
if (SAMLUtils.debug.messageEnabled()) {
SAMLUtils.debug.message("AssertionManagerImpl:getAssertions: " + ssoe);
}
throw (new SAMLException(ssoe.getMessage()));
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerImpl method getAssertionArtifacts.
public Set getAssertionArtifacts(String ssoToken) throws SAMLException {
checkInitialization();
try {
SessionProvider sessionProvider = SessionManager.getProvider();
Object token = sessionProvider.getSession(ssoToken);
return (assertionManager.getAssertionArtifacts(token));
} catch (SessionException ssoe) {
if (SAMLUtils.debug.messageEnabled()) {
SAMLUtils.debug.message("AssertionManagerImpl:getAssertionArtifacts: " + ssoe);
}
throw (new SAMLException(ssoe.getMessage()));
}
}
use of com.sun.identity.plugin.session.SessionProvider in project OpenAM by OpenRock.
the class AssertionManagerImpl method createAssertion2.
public String createAssertion2(String ssoToken, List attributes) throws SAMLException {
checkInitialization();
Object token = null;
try {
SessionProvider sessionProvider = SessionManager.getProvider();
token = sessionProvider.getSession(ssoToken);
} catch (SessionException ssoe) {
if (SAMLUtils.debug.messageEnabled()) {
SAMLUtils.debug.message("AssertionManagerImpl:createAssertion(SSO + attrs) " + ssoe);
}
throw (new SAMLException(ssoe.getMessage()));
}
LinkedList ll = new LinkedList();
for (Iterator iter = attributes.iterator(); iter.hasNext(); ) {
ll.add(new Attribute(XMLUtils.toDOMDocument((String) iter.next(), SAMLUtils.debug).getDocumentElement()));
}
Assertion a = assertionManager.createAssertion(token, ll);
return (a.toString(true, true));
}
Aggregations