use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class BaseURLProviderFactory method create.
private synchronized BaseURLProvider create(String realmDN) {
if (!providers.containsKey(realmDN)) {
debug.message("Creating base URL provider for realm: {}", realmDN);
OpenAMSettingsImpl settings = new OpenAMSettingsImpl(SERVICE_NAME, SERVICE_VERSION);
try {
BaseURLProvider provider;
if (settings.hasConfig(realmDN)) {
ProviderType providerType = ProviderType.valueOf(settings.getStringSetting(realmDN, PROVIDER_TYPE));
provider = providerType.getProvider();
provider.init(settings, realmDN);
provider.setContextPath(settings.getStringSetting(realmDN, CONTEXT_PATH));
} else {
provider = new RequestValuesBaseURLProvider();
provider.setContextPath(servletContext.getContextPath());
}
provider.setCoreWrapper(coreWrapper);
providers.put(realmDN, provider);
} catch (SMSException | SSOException e) {
debug.error("Unable to access BaseURL config for realm {}", realmDN, e);
throw new IllegalStateException(e);
}
}
return providers.get(realmDN);
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class SMPostAuthPlugin method onLoginSuccess.
/**
* Post processing on successful authentication.
*
* @param requestParamsMap map containing <code>HttpServletRequest</code>
* parameters
* @param request <code>HttpServletRequest</code> object.
* @param response <code>HttpServletResponse</code> object.
* @param ssoToken authenticated user's single sign token.
* @exception AuthenticationException if there is an error.
*/
public void onLoginSuccess(Map requestParamsMap, HttpServletRequest request, HttpServletResponse response, SSOToken ssoToken) throws AuthenticationException {
Set configuredHTTPHeaders = (Set) request.getAttribute("SM-HTTPHeaders");
if (configuredHTTPHeaders == null || configuredHTTPHeaders.isEmpty()) {
System.out.println("HTTP headers in auth module are not configured");
return;
}
for (Iterator iter = configuredHTTPHeaders.iterator(); iter.hasNext(); ) {
String configHeader = (String) iter.next();
String headerValue = request.getHeader(configHeader);
if (headerValue == null) {
System.out.println("Config Header " + configHeader + " is not present");
continue;
}
try {
ssoToken.setProperty(configHeader, headerValue);
} catch (SSOException se) {
throw new AuthenticationException(se.getMessage());
}
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class CDCServlet method redirectWithAuthNResponse.
/**
* Constructs the Liberty AuthNResponse with Restricted SSOToken
* and redirects the user to the requested resouce
*/
private void redirectWithAuthNResponse(HttpServletRequest request, HttpServletResponse response, SSOToken token) throws ServletException, IOException {
String gotoURL = getRedirectURL(request, response);
if (debug.messageEnabled()) {
debug.message("CDCServlet.redirectWithAuthNResponse: gotoURL = " + gotoURL);
}
if (debug.messageEnabled()) {
debug.message("CDCServlet.redirectWithAuthNResponse: After encoding: gotoURL = " + gotoURL);
}
if (gotoURL != null) {
try {
String inResponseTo = request.getParameter(REQUEST_ID);
String spDescriptor = request.getParameter(PROVIDER_ID);
String resTokenID = null;
/**
* validateAndGetRestriction throws an exception if an agent
* profile with provider id and goto url is not present
*/
TokenRestriction tokenRes = spValidator.validateAndGetRestriction(FSAuthnRequest.parseURLEncodedRequest(request), gotoURL);
if (uniqueCookieEnabled) {
resTokenID = sessionService.getRestrictedTokenId(token.getTokenID().toString(), tokenRes);
} else {
resTokenID = token.getTokenID().toString();
}
FSAssertion assertion = createAssertion(spDescriptor, SELF_PROVIDER_ID, resTokenID, token.getAuthType(), token.getProperty("authInstant"), token.getPrincipal().getName(), inResponseTo);
String relayState = request.getParameter(RELAY_STATE);
Status status = new Status(new StatusCode(IFSConstants.STATUS_CODE_SUCCESS));
FSAuthnResponse authnResponse = createAuthnResponse(SELF_PROVIDER_ID, responseID, inResponseTo, status, assertion, relayState);
sendAuthnResponse(request, response, authnResponse, gotoURL);
} catch (SAMLException se) {
debug.error("CDCServlet.doGetPost", se);
showError(response);
} catch (FSMsgException fe) {
debug.error("CDCServlet.doGetPost", fe);
showError(response);
} catch (FSException fse) {
debug.error("CDCServlet.doGetPost", fse);
showError(response);
} catch (SessionException e) {
debug.error("CDCServlet.doGetPost", e);
} catch (SSOException ssoe) {
debug.error("CDCServlet.doGetPost", ssoe);
} catch (Exception e) {
debug.error("CDCServlet.doGetPost", e);
spValidator = new LdapSPValidator();
showError(response, FORBIDDEN_STR_MATCH);
}
}
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class CDCServlet method checkForPolicyAdvice.
/**
* Returns policy advices
*/
private String checkForPolicyAdvice(SSOToken token, HttpServletRequest request, HttpServletResponse response) {
StringBuilder adviceList = null;
for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) {
String paramName = (String) e.nextElement();
// upgrade
if (adviceParams.contains(paramName)) {
if (token != null) {
if (paramName.equals("realm") && request.getParameter("sunamcompositeadvice") == null) {
try {
String orgDN = token.getProperty("Organization");
if (orgDN != null) {
String tokenRealm = LDAPUtils.rdnTypeFromDn(orgDN);
if (tokenRealm.equalsIgnoreCase(SMSEntry.getRootSuffix())) {
tokenRealm = "/";
} else {
int orgIndex = tokenRealm.indexOf(SMSEntry.ORGANIZATION_RDN + SMSEntry.EQUALS);
tokenRealm = tokenRealm.substring(orgIndex + 2, tokenRealm.length());
}
String requestRealm = request.getParameter(paramName);
if (tokenRealm.equalsIgnoreCase(requestRealm)) {
//then it's not session upgrade and therefore no re-auth necessary
return null;
}
}
} catch (SSOException ssoe) {
debug.error("CDCServlet.checkForPolicyAdvice: Failed to get realm info. ", ssoe);
}
}
}
if (adviceList == null) {
adviceList = new StringBuilder();
} else {
adviceList.append(AMP);
}
String[] values = request.getParameterValues(paramName);
if (values != null) {
for (int i = 0; i < values.length; i++) {
adviceList.append(paramName).append(EQUALS).append(values[i]);
}
}
}
}
if (debug.messageEnabled()) {
debug.message("CDCServlet.checkForPolicyAdvice: Advice List is : " + adviceList);
}
return (adviceList == null) ? null : adviceList.toString();
}
use of com.iplanet.sso.SSOException in project OpenAM by OpenRock.
the class CDCServlet method init.
/**
* Initiates the servlet.
*
* @param config Servlet Configuration object that contains configutation
* information for this servlet.
* @throws ServletException if servlet failed to initialize.
*/
public void init(ServletConfig config) throws ServletException {
super.init(config);
debug.message("CDCServlet Initializing...");
try {
tokenManager = SSOTokenManager.getInstance();
sessionService = InjectorHolder.getInstance(SessionService.class);
spValidator = new LdapSPValidator();
DNSAddress = SystemConfigurationUtil.getProperty(Constants.AM_SERVER_HOST);
IPAddress = InetAddress.getByName(DNSAddress).getHostAddress();
authURLCookieName = SystemConfigurationUtil.getProperty(Constants.AUTH_UNIQUE_COOKIE_NAME, UNIQUE_COOKIE_NAME);
authURLCookieDomain = SystemConfigurationUtil.getProperty(Constants.AUTH_UNIQUE_COOKIE_DOMAIN, "");
deployDescriptor = SystemConfigurationUtil.getProperty(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR, DEFAULT_DEPLOY_URI);
// Check if CDC needs to generate restricted SSO Tokens
uniqueCookieEnabled = Boolean.valueOf(SystemConfigurationUtil.getProperty(Constants.IS_ENABLE_UNIQUE_COOKIE, "false")).booleanValue();
if (debug.messageEnabled()) {
debug.message("CDCServlet init params:" + " Restricted Token Enabled = " + uniqueCookieEnabled + " Auth URL Cookie Name = " + authURLCookieName + " Auth URL Cookie Domain = " + authURLCookieDomain + " Deployment Descriptor: " + deployDescriptor);
}
} catch (SSOException e) {
debug.error("CDCServlet.init: Unable to get SSOTokenManager", e);
throw new ServletException(e.getMessage());
} catch (UnknownHostException e) {
debug.error("CDCServlet.init", e);
throw new ServletException(e.getMessage());
}
}
Aggregations