Java Code Examples for org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext#getAuthenticatorProperties()
The following examples show how to use
org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext#getAuthenticatorProperties() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAMLSSOAuthenticator.java From carbon-identity with Apache License 2.0 | 6 votes |
private Map<String, String> getAdditionalRequestParams(HttpServletRequest request, AuthenticationContext context) { Map<String, String> reqParamMap = new HashMap<String, String>(); Map<String, String> authenticatorProperties = context.getAuthenticatorProperties(); if (authenticatorProperties != null) { String queryString = authenticatorProperties.get(FrameworkConstants.QUERY_PARAMS); if (queryString != null) { reqParamMap = SSOUtils.getQueryMap(queryString); } } String fidp = request.getParameter("domain"); if (fidp != null) { reqParamMap.put("fidp", Encode.forHtmlAttribute(fidp)); } return reqParamMap; }
Example 2
Source File: SAMLSSOAuthenticator.java From carbon-identity with Apache License 2.0 | 4 votes |
@Override protected void initiateAuthenticationRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws AuthenticationFailedException { Map<String, String> authenticatorProperties = context.getAuthenticatorProperties(); String idpURL = authenticatorProperties .get(IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL); String ssoUrl = ""; boolean isPost = false; try { String requestMethod = authenticatorProperties .get(IdentityApplicationConstants.Authenticator.SAML2SSO.REQUEST_METHOD); if (requestMethod != null && requestMethod.trim().length() != 0) { if (SSOConstants.POST.equalsIgnoreCase(requestMethod)) { isPost = true; } else if (SSOConstants.REDIRECT.equalsIgnoreCase(requestMethod)) { isPost = false; } else if (AS_REQUEST.equalsIgnoreCase(requestMethod)) { isPost = context.getAuthenticationRequest().isPost(); } } else { isPost = false; } if (isPost) { sendPostRequest(request, response, false, false, idpURL, context); return; } else { SAML2SSOManager saml2SSOManager = getSAML2SSOManagerInstance(); saml2SSOManager.init(context.getTenantDomain(), context.getAuthenticatorProperties(), context.getExternalIdP().getIdentityProvider()); ssoUrl = saml2SSOManager.buildRequest(request, false, false, idpURL, context); generateAuthenticationRequest(request, response, ssoUrl, authenticatorProperties); } } catch (SAMLSSOException e) { throw new AuthenticationFailedException(e.getMessage(), e); } return; }
Example 3
Source File: FacebookAuthenticator.java From carbon-identity with Apache License 2.0 | 4 votes |
@Override protected void processAuthenticationResponse(HttpServletRequest request, HttpServletResponse response, AuthenticationContext context) throws AuthenticationFailedException { log.trace("Inside FacebookAuthenticator.authenticate()"); try { Map<String, String> authenticatorProperties = context.getAuthenticatorProperties(); String clientId = authenticatorProperties.get(FacebookAuthenticatorConstants.CLIENT_ID); String clientSecret = authenticatorProperties.get(FacebookAuthenticatorConstants.CLIENT_SECRET); String userInfoFields = authenticatorProperties.get(FacebookAuthenticatorConstants.USER_INFO_FIELDS); String tokenEndPoint = getTokenEndpoint(); String fbAuthUserInfoUrl = getUserInfoEndpoint(); String callbackUrl = IdentityUtil.getServerURL(FrameworkConstants.COMMONAUTH, true, true); String code = getAuthorizationCode(request); String token = getToken(tokenEndPoint, clientId, clientSecret, callbackUrl, code); if (!StringUtils.isBlank(userInfoFields)) { if (context.getExternalIdP().getIdentityProvider().getClaimConfig() != null && !StringUtils.isBlank (context.getExternalIdP().getIdentityProvider().getClaimConfig().getUserClaimURI())) { String userClaimUri = context.getExternalIdP().getIdentityProvider().getClaimConfig() .getUserClaimURI(); if (!Arrays.asList(userInfoFields.split(",")).contains(userClaimUri)) { userInfoFields += ("," + userClaimUri); } } else { if (!Arrays.asList(userInfoFields.split(",")).contains(FacebookAuthenticatorConstants .DEFAULT_USER_IDENTIFIER)) { userInfoFields += ("," + FacebookAuthenticatorConstants.DEFAULT_USER_IDENTIFIER); } } } Map<String, Object> userInfoJson = getUserInfoJson(fbAuthUserInfoUrl, userInfoFields, token); buildClaims(context, userInfoJson); } catch (ApplicationAuthenticatorException e) { log.error("Failed to process Facebook Connect response.", e); throw new AuthenticationFailedException(e.getMessage(), e); } }