Search in sources :

Example 31 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class DefaultAuthenticationRequestHandlerTest method addApplicationConfig.

private void addApplicationConfig(AuthenticationContext context) {
    ApplicationConfig applicationConfig = new ApplicationConfig(new ServiceProvider());
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
    applicationConfig.getServiceProvider().setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
    context.getSequenceConfig().setApplicationConfig(applicationConfig);
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider)

Example 32 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class Util method mockSequenceConfig.

public static SequenceConfig mockSequenceConfig(Map<String, String> spRoleMappings) {
    SequenceConfig sequenceConfig = spy(new SequenceConfig());
    ApplicationConfig applicationConfig = mock(ApplicationConfig.class);
    ServiceProvider serviceProvider = mock(ServiceProvider.class);
    LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = mock(LocalAndOutboundAuthenticationConfig.class);
    when(applicationConfig.getApplicationName()).thenReturn("APP");
    when(sequenceConfig.getApplicationConfig()).thenReturn(applicationConfig);
    when(applicationConfig.getRoleMappings()).thenReturn(spRoleMappings);
    when(applicationConfig.getServiceProvider()).thenReturn(serviceProvider);
    when(serviceProvider.getLocalAndOutBoundAuthenticationConfig()).thenReturn(localAndOutboundAuthenticationConfig);
    when(localAndOutboundAuthenticationConfig.isUseUserstoreDomainInRoles()).thenReturn(false);
    return sequenceConfig;
}
Also used : LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ApplicationConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.ApplicationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) SequenceConfig(org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)

Example 33 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class ApplicationDAOImpl method updateAuthenticationScriptConfiguration.

/**
 * Updates the authentication script configuration.
 *
 * @param applicationId
 * @param localAndOutboundAuthConfig
 * @param connection
 * @param tenantID
 * @throws SQLException
 */
private void updateAuthenticationScriptConfiguration(int applicationId, LocalAndOutboundAuthenticationConfig localAndOutboundAuthConfig, Connection connection, int tenantID) throws SQLException {
    if (localAndOutboundAuthConfig.getAuthenticationScriptConfig() != null) {
        AuthenticationScriptConfig authenticationScriptConfig = localAndOutboundAuthConfig.getAuthenticationScriptConfig();
        try (PreparedStatement storeAuthScriptPrepStmt = connection.prepareStatement(STORE_SP_AUTH_SCRIPT)) {
            storeAuthScriptPrepStmt.setInt(1, tenantID);
            storeAuthScriptPrepStmt.setInt(2, applicationId);
            storeAuthScriptPrepStmt.setString(3, authenticationScriptConfig.getLanguage());
            setBlobValue(authenticationScriptConfig.getContent(), storeAuthScriptPrepStmt, 4);
            storeAuthScriptPrepStmt.setString(5, authenticationScriptConfig.isEnabled() ? "1" : "0");
            storeAuthScriptPrepStmt.execute();
        } catch (IOException ex) {
            log.error("Error occurred while updating authentication script configuration.", ex);
        }
    }
}
Also used : AuthenticationScriptConfig(org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig) PreparedStatement(java.sql.PreparedStatement) NamedPreparedStatement(org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement) IOException(java.io.IOException)

Example 34 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class ApplicationDAOImpl method getBasicApplicationData.

/**
 * @param applicationName
 * @param connection
 * @return
 * @throws SQLException
 */
private ServiceProvider getBasicApplicationData(String applicationName, Connection connection, int tenantID) throws SQLException, IdentityApplicationManagementException {
    ServiceProvider serviceProvider = null;
    if (log.isDebugEnabled()) {
        log.debug("Loading Basic Application Data of " + applicationName);
    }
    PreparedStatement loadBasicAppInfoStmt = null;
    ResultSet basicAppDataResultSet = null;
    try {
        loadBasicAppInfoStmt = connection.prepareStatement(LOAD_BASIC_APP_INFO_BY_APP_NAME);
        // SELECT * FROM IDN_APPMGT_APP WHERE APP_NAME = ? AND TENANT_ID = ?
        loadBasicAppInfoStmt.setString(1, applicationName);
        loadBasicAppInfoStmt.setInt(2, tenantID);
        basicAppDataResultSet = loadBasicAppInfoStmt.executeQuery();
        if (basicAppDataResultSet.next()) {
            serviceProvider = new ServiceProvider();
            serviceProvider.setApplicationID(basicAppDataResultSet.getInt(1));
            serviceProvider.setApplicationResourceId(basicAppDataResultSet.getString(ApplicationTableColumns.UUID));
            serviceProvider.setApplicationName(basicAppDataResultSet.getString(3));
            serviceProvider.setDescription(basicAppDataResultSet.getString(6));
            serviceProvider.setImageUrl(basicAppDataResultSet.getString(ApplicationTableColumns.IMAGE_URL));
            serviceProvider.setAccessUrl(basicAppDataResultSet.getString(ApplicationTableColumns.ACCESS_URL));
            serviceProvider.setDiscoverable(getBooleanValue(basicAppDataResultSet.getString(ApplicationTableColumns.IS_DISCOVERABLE)));
            String tenantDomain;
            try {
                tenantDomain = ApplicationManagementServiceComponentHolder.getInstance().getRealmService().getTenantManager().getDomain(basicAppDataResultSet.getInt(2));
            } catch (UserStoreException e) {
                log.error("Error while reading tenantDomain", e);
                throw new IdentityApplicationManagementException("Error while reading tenant " + "domain for application " + applicationName);
            }
            User owner = new User();
            owner.setUserName(basicAppDataResultSet.getString(5));
            owner.setTenantDomain(tenantDomain);
            owner.setUserStoreDomain(basicAppDataResultSet.getString(4));
            serviceProvider.setOwner(owner);
            ClaimConfig claimConfig = new ClaimConfig();
            claimConfig.setRoleClaimURI(basicAppDataResultSet.getString(7));
            claimConfig.setLocalClaimDialect("1".equals(basicAppDataResultSet.getString(10)));
            claimConfig.setAlwaysSendMappedLocalSubjectId("1".equals(basicAppDataResultSet.getString(11)));
            serviceProvider.setClaimConfig(claimConfig);
            LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig();
            localAndOutboundAuthenticationConfig.setAlwaysSendBackAuthenticatedListOfIdPs("1".equals(basicAppDataResultSet.getString(14)));
            localAndOutboundAuthenticationConfig.setEnableAuthorization("1".equals(basicAppDataResultSet.getString(15)));
            localAndOutboundAuthenticationConfig.setSubjectClaimUri(basicAppDataResultSet.getString(16));
            serviceProvider.setLocalAndOutBoundAuthenticationConfig(localAndOutboundAuthenticationConfig);
            serviceProvider.setSaasApp("1".equals(basicAppDataResultSet.getString(17)));
            /*
                ConsentConfig consentConfig = new ConsentConfig();
                consentConfig.setEnabled("1".equals(basicAppDataResultSet.getString(18)));
                serviceProvider.setConsentConfig(consentConfig);
                */
            if (log.isDebugEnabled()) {
                log.debug("ApplicationID: " + serviceProvider.getApplicationID() + " ApplicationName: " + serviceProvider.getApplicationName() + " UserName: " + serviceProvider.getOwner().getUserName() + " TenantDomain: " + serviceProvider.getOwner().getTenantDomain());
            }
        }
        return serviceProvider;
    } finally {
        IdentityApplicationManagementUtil.closeResultSet(basicAppDataResultSet);
        IdentityApplicationManagementUtil.closeStatement(loadBasicAppInfoStmt);
    }
}
Also used : User(org.wso2.carbon.identity.application.common.model.User) LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ClaimConfig(org.wso2.carbon.identity.application.common.model.ClaimConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) ResultSet(java.sql.ResultSet) UserStoreException(org.wso2.carbon.user.api.UserStoreException) PreparedStatement(java.sql.PreparedStatement) NamedPreparedStatement(org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)

Example 35 with LocalAndOutboundAuthenticationConfig

use of org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig in project carbon-identity-framework by wso2.

the class ApplicationIdentityProviderMgtListener method doPreUpdateIdP.

@Override
public boolean doPreUpdateIdP(String oldIdPName, IdentityProvider identityProvider, String tenantDomain) throws IdentityProviderManagementException {
    try {
        IdentityServiceProviderCache.getInstance().clear(tenantDomain);
        IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
        ConnectedAppsResult connectedApplications;
        String idpId = identityProviderManager.getIdPByName(oldIdPName, tenantDomain).getResourceId();
        if (identityProvider.getResourceId() == null && idpId != null) {
            identityProvider.setResourceId(idpId);
        }
        int offset = 0;
        do {
            connectedApplications = identityProviderManager.getConnectedApplications(idpId, null, offset, tenantDomain);
            List<ServiceProvider> serviceProvidersList = new ArrayList<>();
            for (String appResourceId : connectedApplications.getApps()) {
                ServiceProvider serviceProvider = ApplicationMgtSystemConfig.getInstance().getApplicationDAO().getApplicationByResourceId(appResourceId, tenantDomain);
                serviceProvidersList.add(serviceProvider);
            }
            for (ServiceProvider serviceProvider : serviceProvidersList) {
                LocalAndOutboundAuthenticationConfig localAndOutboundAuthConfig = serviceProvider.getLocalAndOutBoundAuthenticationConfig();
                AuthenticationStep[] authSteps = localAndOutboundAuthConfig.getAuthenticationSteps();
                OutboundProvisioningConfig outboundProvisioningConfig = serviceProvider.getOutboundProvisioningConfig();
                IdentityProvider[] provisioningIdps = outboundProvisioningConfig.getProvisioningIdentityProviders();
                // Check whether the identity provider is referred in a service provider
                validateIdpDisable(identityProvider, authSteps, provisioningIdps);
                // Validating Applications with Federated Authenticators configured.
                updateApplicationWithFederatedAuthenticators(identityProvider, tenantDomain, serviceProvider, localAndOutboundAuthConfig, authSteps);
                // Validating Applications with Outbound Provisioning Connectors configured.
                updateApplicationWithProvisioningConnectors(identityProvider, provisioningIdps);
                // Clear application caches if IDP name is updated.
                if (!StringUtils.equals(oldIdPName, identityProvider.getIdentityProviderName())) {
                    CacheBackedApplicationDAO.clearAllAppCache(serviceProvider, tenantDomain);
                }
            }
            offset = connectedApplications.getOffSet() + connectedApplications.getLimit();
        } while (connectedApplications.getTotalAppCount() > offset);
    } catch (IdentityApplicationManagementException e) {
        throw new IdentityProviderManagementException("Error when updating default authenticator of service providers", e);
    }
    return true;
}
Also used : ConnectedAppsResult(org.wso2.carbon.idp.mgt.model.ConnectedAppsResult) IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) ArrayList(java.util.ArrayList) AuthenticationStep(org.wso2.carbon.identity.application.common.model.AuthenticationStep) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) OutboundProvisioningConfig(org.wso2.carbon.identity.application.common.model.OutboundProvisioningConfig) LocalAndOutboundAuthenticationConfig(org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig) ServiceProvider(org.wso2.carbon.identity.application.common.model.ServiceProvider) IdentityProviderManager(org.wso2.carbon.idp.mgt.IdentityProviderManager) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Aggregations

LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.LocalAndOutboundAuthenticationConfig)27 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)13 LocalAndOutboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAndOutboundAuthenticationConfig)13 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)8 Test (org.testng.annotations.Test)7 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)7 AuthenticationStep (org.wso2.carbon.identity.application.common.model.xsd.AuthenticationStep)7 PreparedStatement (java.sql.PreparedStatement)6 ArrayList (java.util.ArrayList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)6 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.xsd.LocalAuthenticatorConfig)6 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)5 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)5 ResultSet (java.sql.ResultSet)4 SequenceConfig (org.wso2.carbon.identity.application.authentication.framework.config.model.SequenceConfig)4 User (org.wso2.carbon.identity.application.common.model.User)4 AuthenticationScriptConfig (org.wso2.carbon.identity.application.common.model.script.AuthenticationScriptConfig)4 InboundAuthenticationConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationConfig)4 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.xsd.InboundAuthenticationRequestConfig)4