Search in sources :

Example 21 with ServiceProviderProperty

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

the class ApplicationManagementServiceImpl method addUserIdAsDefaultSubject.

private void addUserIdAsDefaultSubject(ServiceProvider serviceProvider) {
    boolean containsUseUserIdForSubjectProp = false;
    ArrayList<ServiceProviderProperty> serviceProviderProperties = new ArrayList<>(Arrays.asList(serviceProvider.getSpProperties()));
    for (ServiceProviderProperty prop : serviceProviderProperties) {
        if (IdentityApplicationConstants.USE_USER_ID_FOR_DEFAULT_SUBJECT.equals(prop.getName())) {
            containsUseUserIdForSubjectProp = true;
            break;
        }
    }
    if (!containsUseUserIdForSubjectProp) {
        ServiceProviderProperty useUserIdForSubject = new ServiceProviderProperty();
        useUserIdForSubject.setName(IdentityApplicationConstants.USE_USER_ID_FOR_DEFAULT_SUBJECT);
        useUserIdForSubject.setValue("true");
        serviceProviderProperties.add(useUserIdForSubject);
        serviceProvider.setSpProperties(serviceProviderProperties.toArray(new ServiceProviderProperty[0]));
    }
}
Also used : ArrayList(java.util.ArrayList) ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)

Example 22 with ServiceProviderProperty

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

the class ApplicationDAOImpl method addServiceProviderProperties.

/**
 * Add Service provider properties
 *
 * @param dbConnection
 * @param spId
 * @param properties
 * @throws SQLException
 */
private void addServiceProviderProperties(Connection dbConnection, int spId, List<ServiceProviderProperty> properties, int tenantId) throws SQLException {
    PreparedStatement prepStmt = null;
    try {
        prepStmt = isH2DB() ? dbConnection.prepareStatement(ADD_SP_METADATA_H2) : dbConnection.prepareStatement(ADD_SP_METADATA);
        for (ServiceProviderProperty property : properties) {
            if (StringUtils.isNotBlank(property.getValue())) {
                prepStmt.setInt(1, spId);
                prepStmt.setString(2, property.getName());
                prepStmt.setString(3, property.getValue());
                prepStmt.setString(4, property.getDisplayName());
                prepStmt.setInt(5, tenantId);
                prepStmt.addBatch();
            } else {
                if (log.isDebugEnabled()) {
                    String msg = "SP property '%s' of Sp with id: %d of tenantId: %d is empty or null. " + "Not adding the property to 'SP_METADATA' table.";
                    log.debug(String.format(msg, property.getName(), spId, tenantId));
                }
            }
        }
        prepStmt.executeBatch();
    } catch (DataAccessException e) {
        String errorMsg = "Error while adding SP properties for SP ID: " + spId + " and tenant ID: " + tenantId;
        throw new SQLException(errorMsg, e);
    } finally {
        IdentityApplicationManagementUtil.closeStatement(prepStmt);
    }
}
Also used : SQLException(java.sql.SQLException) PreparedStatement(java.sql.PreparedStatement) NamedPreparedStatement(org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement) ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Example 23 with ServiceProviderProperty

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

the class ApplicationDAOImpl method readAndSetConfigurationsFromProperties.

private void readAndSetConfigurationsFromProperties(List<ServiceProviderProperty> propertyList, LocalAndOutboundAuthenticationConfig localAndOutboundConfig) {
    // Override with changed values.
    if (CollectionUtils.isNotEmpty(propertyList)) {
        for (ServiceProviderProperty serviceProviderProperty : propertyList) {
            String name = serviceProviderProperty.getName();
            String value = serviceProviderProperty.getValue();
            if (USE_DOMAIN_IN_ROLES.equals(name)) {
                localAndOutboundConfig.setUseUserstoreDomainInRoles(value == null || Boolean.parseBoolean(value));
            } else if (SKIP_CONSENT.equals(name)) {
                localAndOutboundConfig.setSkipConsent(Boolean.parseBoolean(value));
            } else if (SKIP_LOGOUT_CONSENT.equals(name)) {
                localAndOutboundConfig.setSkipLogoutConsent(Boolean.parseBoolean(value));
            }
        }
    }
}
Also used : ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)

Example 24 with ServiceProviderProperty

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

the class ApplicationDAOImpl method buildUserStoreDomainInRolesProperty.

private ServiceProviderProperty buildUserStoreDomainInRolesProperty(ServiceProvider sp) {
    ServiceProviderProperty property = new ServiceProviderProperty();
    property.setName(USE_DOMAIN_IN_ROLES);
    property.setDisplayName(USE_DOMAIN_IN_ROLE_DISPLAY_NAME);
    property.setValue(String.valueOf(sp.getLocalAndOutBoundAuthenticationConfig().isUseUserstoreDomainInRoles()));
    return property;
}
Also used : ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)

Example 25 with ServiceProviderProperty

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

the class ApplicationDAOImpl method buildTemplateIdProperty.

private ServiceProviderProperty buildTemplateIdProperty(ServiceProvider sp) {
    ServiceProviderProperty templateIdProperty = new ServiceProviderProperty();
    templateIdProperty.setName(TEMPLATE_ID_SP_PROPERTY_NAME);
    templateIdProperty.setDisplayName(TEMPLATE_ID_SP_PROPERTY_DISPLAY_NAME);
    templateIdProperty.setValue(StringUtils.isNotBlank(sp.getTemplateId()) ? sp.getTemplateId() : StringUtils.EMPTY);
    return templateIdProperty;
}
Also used : ServiceProviderProperty(org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)

Aggregations

ServiceProviderProperty (org.wso2.carbon.identity.application.common.model.ServiceProviderProperty)24 ServiceProvider (org.wso2.carbon.identity.application.common.model.ServiceProvider)8 PreparedStatement (java.sql.PreparedStatement)7 NamedPreparedStatement (org.wso2.carbon.database.utils.jdbc.NamedPreparedStatement)7 ArrayList (java.util.ArrayList)6 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 HashMap (java.util.HashMap)3 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)3 ClaimMapping (org.wso2.carbon.identity.application.common.model.ClaimMapping)3 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)3 IOException (java.io.IOException)2 List (java.util.List)2 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)2 AuthenticationStep (org.wso2.carbon.identity.application.common.model.AuthenticationStep)2 ClaimConfig (org.wso2.carbon.identity.application.common.model.ClaimConfig)2 InboundAuthenticationRequestConfig (org.wso2.carbon.identity.application.common.model.InboundAuthenticationRequestConfig)2 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)2 Property (org.wso2.carbon.identity.application.common.model.Property)2 RoleMapping (org.wso2.carbon.identity.application.common.model.RoleMapping)2