Search in sources :

Example 26 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project carbon-identity-framework by wso2.

the class ConsentMgtPostAuthnHandler method getStandardDialect.

private String getStandardDialect(AuthenticationContext context) {
    String clientType = context.getRequestType();
    ApplicationConfig appConfig = context.getSequenceConfig().getApplicationConfig();
    Map<String, String> claimMappings = appConfig.getClaimMappings();
    if (FrameworkConstants.RequestType.CLAIM_TYPE_OIDC.equals(clientType)) {
        return HTTP_WSO2_ORG_OIDC_CLAIM;
    } else if (FrameworkConstants.RequestType.CLAIM_TYPE_STS.equals(clientType)) {
        return HTTP_SCHEMAS_XMLSOAP_ORG_WS_2005_05_IDENTITY;
    } else if (FrameworkConstants.RequestType.CLAIM_TYPE_OPENID.equals(clientType)) {
        return HTTP_AXSCHEMA_ORG;
    } else if (FrameworkConstants.RequestType.CLAIM_TYPE_WSO2.equals(clientType)) {
        return ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT;
    } else if (FrameworkConstants.RequestType.CLAIM_TYPE_SCIM.equals(clientType)) {
        return URN_SCIM_SCHEMAS_CORE_1_0;
    } else if (claimMappings == null || claimMappings.isEmpty()) {
        return ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT;
    } else {
        boolean isAtLeastOneNotEqual = false;
        for (Map.Entry<String, String> entry : claimMappings.entrySet()) {
            if (!entry.getKey().equalsIgnoreCase(entry.getValue())) {
                isAtLeastOneNotEqual = true;
                break;
            }
        }
        if (!isAtLeastOneNotEqual) {
            return ApplicationConstants.LOCAL_IDP_DEFAULT_CLAIM_DIALECT;
        }
    }
    return null;
}
Also used : ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) StringUtils.defaultString(org.apache.commons.lang.StringUtils.defaultString)

Example 27 with ApplicationConfig

use of org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig in project identity-inbound-auth-oauth by wso2-extensions.

the class PasswordGrantHandler method initializeAuthContext.

/**
 * This method will create an AuthenticationContext object which needs to be passed to the publish methods.
 *
 * @param authenticatedUser User which tries to be authenticated.
 * @param serviceProvider Service provider which contains the details of the application.
 * @return An AuthenticationContest object with relevant details.
 */
private AuthenticationContext initializeAuthContext(AuthenticatedUser authenticatedUser, ServiceProvider serviceProvider) {
    AuthenticationContext authenticationContext = new AuthenticationContext();
    String contextId = UUIDGenerator.generateUUID();
    authenticationContext.setContextIdentifier(contextId);
    authenticationContext.setTenantDomain(authenticatedUser.getTenantDomain());
    authenticationContext.setRequestType(OAUTH2);
    authenticationContext.setRememberMe(false);
    authenticationContext.setForceAuthenticate(true);
    authenticationContext.setPassiveAuthenticate(false);
    authenticationContext.setProperty(IS_INITIAL_LOGIN, true);
    // Setting sequenceConfig with authenticatedUser, serviceProvider.
    SequenceConfig sequenceConfig = new SequenceConfig();
    sequenceConfig.setAuthenticatedUser(authenticatedUser);
    // Setting applicationConfig with serviceProvider.
    ApplicationConfig applicationConfig = new ApplicationConfig(serviceProvider);
    sequenceConfig.setApplicationConfig(applicationConfig);
    sequenceConfig.setAuthenticatedIdPs(FrameworkConstants.LOCAL_IDP_NAME);
    authenticationContext.setSequenceConfig(sequenceConfig);
    /* Setting the authenticated IDP for currentAuthenticatedIDPs to get
         the tenant domain and other parameters when the login is a success. */
    AuthenticatedIdPData authenticatedIdPData = new AuthenticatedIdPData();
    authenticatedIdPData.setUser(authenticatedUser);
    authenticatedIdPData.setIdpName(FrameworkConstants.LOCAL_IDP_NAME);
    AuthenticatorConfig authenticatorConfig = new AuthenticatorConfig();
    authenticatorConfig.setName(PASSWORD_GRANT_AUTHENTICATOR_NAME);
    authenticatedIdPData.addAuthenticator(authenticatorConfig);
    authenticationContext.getCurrentAuthenticatedIdPs().put(FrameworkConstants.LOCAL_IDP_NAME, authenticatedIdPData);
    // Setting serviceProviderName from applicationConfig.
    authenticationContext.setServiceProviderName(sequenceConfig.getApplicationConfig().getApplicationName());
    return authenticationContext;
}
Also used : AuthenticatorConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig) AuthenticationContext(org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig) AuthenticatedIdPData(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedIdPData)

Aggregations

ApplicationConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig)25 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)11 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Test (org.testng.annotations.Test)7 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)6 ArrayList (java.util.ArrayList)5 FrameworkException (org.wso2.carbon.identity.application.authentication.framework.exception.FrameworkException)5 HashMap (java.util.HashMap)4 StringUtils.defaultString (org.apache.commons.lang.StringUtils.defaultString)4 AuthenticatorConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.AuthenticatorConfig)4 StepConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.StepConfig)4 AuthenticationContext (org.wso2.carbon.identity.application.authentication.framework.context.AuthenticationContext)4 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)4 PostAuthenticationFailedException (org.wso2.carbon.identity.application.authentication.framework.exception.PostAuthenticationFailedException)3 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)3 List (java.util.List)2 Map (java.util.Map)2 ApplicationAuthenticator (org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator)2 ExternalIdPConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.ExternalIdPConfig)2