Java Code Examples for org.wso2.carbon.identity.core.util.IdentityUtil#getProperty()

The following examples show how to use org.wso2.carbon.identity.core.util.IdentityUtil#getProperty() . 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: FrameworkUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the authentication flow should continue upon facing a claim handling error.
 *
 * @return true/false Continue or break flow when facing claim handling errors.
 */
public static boolean isContinueOnClaimHandlingErrorAllowed() {

    String continueOnClaimHandlingErrorValue = IdentityUtil.getProperty(CONTINUE_ON_CLAIM_HANDLING_ERROR);

    // If config is empty or not a boolean value, the property must be set to the default value which is true.
    return !Boolean.FALSE.toString().equalsIgnoreCase(continueOnClaimHandlingErrorValue);
}
 
Example 2
Source File: SAMLSSOService.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static boolean isSAMLSSOLoginAccepted() {
    if (IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_SAMLSSO_LOGIN) != null &&
            !"".equals(IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_SAMLSSO_LOGIN).trim())) {
        return Boolean.parseBoolean(IdentityUtil.getProperty(IdentityConstants.ServerConfig.ACCEPT_SAMLSSO_LOGIN).trim());
    } else {
        return false;
    }
}
 
Example 3
Source File: EntitlementServiceComponent.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Read the port from identity.xml which is overridden by carbon.xml to facilitating
 * multiple servers at a time.
 */
private int readThriftReceivePort() {
    int port = -1;
    String portValue = IdentityUtil.getProperty(ThriftConfigConstants.PARAM_RECEIVE_PORT);
    //if the port contains a template string that refers to carbon.xml
    if ((portValue.contains("${")) && (portValue.contains("}"))) {
        port = (CarbonUtils.getPortFromServerConfig(portValue));
    } else { //if port directly mentioned in identity.xml
        port = Integer.parseInt(portValue);
    }
    return port;
}
 
Example 4
Source File: SAMLSSOUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static String getDefaultLogoutEndpoint(){
    String defaultLogoutLocation = IdentityUtil.getProperty(IdentityConstants.ServerConfig
            .DEFAULT_LOGOUT_ENDPOINT);
    if (StringUtils.isBlank(defaultLogoutLocation)){
        defaultLogoutLocation = IdentityUtil.getServerURL(SAMLSSOConstants
                .DEFAULT_LOGOUT_ENDPOINT, false, false);
    }
    return defaultLogoutLocation;
}
 
Example 5
Source File: PrivateAssociationCryptoStore.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public PrivateAssociationCryptoStore() {
    storeId = new Random().nextInt(9999);
    counter = 0;
    String serverKey = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_PRIVATE_ASSOCIATION_SERVER_KEY);
    if(StringUtils.isNotBlank(serverKey)){
        this.serverKey = serverKey;
    }
}
 
Example 6
Source File: ApplicationMgtUtil.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Return the Service Provider validation regex.
 *
 * @return regex.
 */
public static String getSPValidatorRegex() {

    String spValidatorRegex = IdentityUtil.getProperty(SERVICE_PROVIDERS_NAME_REGEX);
    if (StringUtils.isBlank(spValidatorRegex)) {
        spValidatorRegex = APP_NAME_VALIDATING_REGEX;
    }
    return spValidatorRegex;
}
 
Example 7
Source File: OpenIDUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static String getOpenIDServerURL() {
    // Read from OpenID configuration in identity.xml
    String openIDServerURL = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_SERVER_URL);
    // If configuration are not defined,  build URL from server configurations.
    if (StringUtils.isBlank(openIDServerURL)) {
        openIDServerURL = IdentityUtil.getServerURL(OpenIDServerConstants.OPENID_SERVER, true, true);
    }
    return openIDServerURL;
}
 
Example 8
Source File: AuthenticationContextCache.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor which will not allow to create objects of this class from outside
 */
private AuthenticationContextCache() {
    super(AUTHENTICATION_CONTEXT_CACHE_NAME);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        isTemporarySessionDataPersistEnabled = Boolean.parseBoolean(
                IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 9
Source File: UserSessionStore.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private UserSessionStore() {

        String deleteChunkSizeString = IdentityUtil.getProperty(DELETE_CHUNK_SIZE_PROPERTY);
        if (StringUtils.isNotBlank(deleteChunkSizeString)) {
            deleteChunkSize = Integer.parseInt(deleteChunkSizeString);
        }
    }
 
Example 10
Source File: MPAuthenticationProvider.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Login to the XMPP server with the credentials specifid in the Identity.xml
 *
 * @param connection
 * @return
 */
public boolean login(XMPPConnection connection) {
    String userName = IdentityUtil.getProperty(IdentityConstants.ServerConfig.XMPP_SETTINGS_USERNAME);
    String password = IdentityUtil.getProperty(IdentityConstants.ServerConfig.XMPP_SETTINGS_PASSWORD);
    for (int i = 0; i < 3; i++) {
        try {
            connection.login(userName, password, null);
            return true;
        } catch (XMPPException ex) {
            log.error("login failed. Trying again..", ex);
        }
    }
    return false;
}
 
Example 11
Source File: FrameworkUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * To get the username provisioning url from the configuration file.
 *
 * @return relevant username provisioning url.
 */
public static String getUserNameProvisioningUIUrl() {

    String userNamePrvisioningUrl = IdentityUtil.getProperty("JITProvisioning.UserNameProvisioningUI");
    if (StringUtils.isEmpty(userNamePrvisioningUrl)) {
        userNamePrvisioningUrl = FrameworkConstants.REGISTRATION_ENDPOINT;
    }
    return userNamePrvisioningUrl;
}
 
Example 12
Source File: FrameworkUtils.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * To get the password provisioning url from the configuration file.
 *
 * @return relevant password provisioning url.
 */
public static String getPasswordProvisioningUIUrl() {

    String passwordProvisioningUrl = IdentityUtil.getProperty("JITProvisioning.PasswordProvisioningUI");
    if (StringUtils.isEmpty(passwordProvisioningUrl)) {
        passwordProvisioningUrl = FrameworkConstants.SIGN_UP_ENDPOINT;
    }
    return passwordProvisioningUrl;
}
 
Example 13
Source File: AuthenticationContextCache.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor which will not allow to create objects of this class from outside
 */
private AuthenticationContextCache() {
    super(AUTHENTICATION_CONTEXT_CACHE_NAME, true);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        isTemporarySessionDataPersistEnabled = Boolean.parseBoolean(
                IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 14
Source File: OpenIDUtil.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public static String getOpenIDLoginPageURL() {
    // Read from OpenID configuration in identity.xml
    String openIDServerURL = IdentityUtil.getProperty(IdentityConstants.ServerConfig.OPENID_LOGIN_PAGE_URL);
    // If configuration are not defined,  build URL from server configurations.
    if (StringUtils.isBlank(openIDServerURL)) {
        openIDServerURL = IdentityUtil.getServerURL("/authenticationendpoint/openid_login.do", false, false);
    }
    return openIDServerURL;
}
 
Example 15
Source File: AuthenticationResultCache.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor which will not allow to create objects of this class from outside
 */
private AuthenticationResultCache() {
    super(CACHE_NAME, true);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        isTemporarySessionDataPersistEnabled = Boolean.parseBoolean(
                IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 16
Source File: SessionDataCache.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private SessionDataCache() {
    super(SESSION_DATA_CACHE_NAME);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        isTemporarySessionDataPersistEnabled = Boolean.parseBoolean(
                IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 17
Source File: InboundAuthenticationContextCache.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
private InboundAuthenticationContextCache(String cacheName) {
    super(cacheName);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        enableRequestScopeCache = Boolean
                .parseBoolean(IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 18
Source File: IdentityContextCache.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
private IdentityContextCache(String cacheName) {
    super(cacheName);
    if (IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Temporary") != null) {
        enableRequestScopeCache = Boolean.parseBoolean(IdentityUtil.getProperty(
                "JDBCPersistenceManager.SessionDataPersist.Temporary"));
    }
}
 
Example 19
Source File: SessionDataStore.java    From carbon-identity with Apache License 2.0 4 votes vote down vote up
private SessionDataStore() {
    String enablePersistVal = IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.Enable");
    enablePersist = true;
    if (enablePersistVal != null) {
        enablePersist = Boolean.parseBoolean(enablePersistVal);
    }
    String insertSTORESQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.InsertSTORE");
    String insertDELETESQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.InsertDELETE");
    String deleteSTORETaskSQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.DeleteSTORETask");
    String deleteDELETETaskSQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.DeleteDELETETask");
    String selectSQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.Select");
    String deleteExpiredDataTaskSQL = IdentityUtil
            .getProperty("JDBCPersistenceManager.SessionDataPersist.SQL.DeleteExpiredDataTask");
    if (!StringUtils.isBlank(insertSTORESQL)) {
        sqlInsertSTORE = insertSTORESQL;
    } else {
        sqlInsertSTORE = SQL_INSERT_STORE_OPERATION;
    }
    if (!StringUtils.isBlank(insertDELETESQL)) {
        sqlInsertDELETE = insertDELETESQL;
    } else {
        sqlInsertDELETE = SQL_INSERT_DELETE_OPERATION;
    }
    if (!StringUtils.isBlank(deleteSTORETaskSQL)) {
        sqlDeleteSTORETask = deleteSTORETaskSQL;
    }

    if (!StringUtils.isBlank(deleteDELETETaskSQL)) {
        sqlDeleteDELETETask = deleteDELETETaskSQL;
    } else {
        sqlDeleteDELETETask = SQL_DELETE_DELETE_OPERATIONS_TASK;
    }
    if (!StringUtils.isBlank(selectSQL)) {
        sqlSelect = selectSQL;
    }

    if (!StringUtils.isBlank(deleteExpiredDataTaskSQL)) {
        sqlDeleteExpiredDataTask = deleteExpiredDataTaskSQL;
    } else {
        sqlDeleteExpiredDataTask = SQL_DELETE_EXPIRED_DATA_TASK;
    }

    if (!enablePersist) {
        log.info("Session Data Persistence of Authentication framework is not enabled.");
    }
    String isCleanUpEnabledVal = IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.SessionDataCleanUp.Enable");

    String isOperationCleanUpEnabledVal = IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.OperationDataCleanUp.Enable");
    String operationCleanUpPeriodVal = IdentityUtil.getProperty("JDBCPersistenceManager.SessionDataPersist.OperationDataCleanUp.CleanUpPeriod");


    if (StringUtils.isBlank(isCleanUpEnabledVal)) {
        isCleanUpEnabledVal = defaultCleanUpEnabled;
    }
    if (StringUtils.isBlank(isOperationCleanUpEnabledVal)) {
        isOperationCleanUpEnabledVal = defaultOperationCleanUpEnabled;
    }

    if (Boolean.parseBoolean(isCleanUpEnabledVal)) {
        long sessionCleanupPeriod = IdentityUtil.getCleanUpPeriod(
                CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
        SessionCleanUpService sessionCleanUpService = new SessionCleanUpService(sessionCleanupPeriod/4,
                sessionCleanupPeriod);
        sessionCleanUpService.activateCleanUp();
    } else {
        log.info("Session Data CleanUp Task of Authentication framework is not enabled.");
    }
    if (Boolean.parseBoolean(isOperationCleanUpEnabledVal)) {
        if (StringUtils.isNotBlank(operationCleanUpPeriodVal)) {
            operationCleanUpPeriod = Long.parseLong(operationCleanUpPeriodVal);
        }
        OperationCleanUpService operationCleanUpService = new OperationCleanUpService(operationCleanUpPeriod/4,
                operationCleanUpPeriod);
        operationCleanUpService.activateCleanUp();
    } else {
        log.info("Session Data Operations CleanUp Task of Authentication framework is not enabled.");
    }
}
 
Example 20
Source File: FrameworkUtils.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * Map the external IDP roles to local roles.
 * If excludeUnmapped is true exclude unmapped roles.
 * Otherwise include unmapped roles as well.
 *
 * @param externalIdPConfig     Relevant external IDP Config.
 * @param extAttributesValueMap Attributes map.
 * @param idpRoleClaimUri       IDP role claim URI.
 * @param excludeUnmapped       to indicate whether to exclude unmapped.
 * @return ArrayList<string> list of roles.
 */
public static List<String> getIdentityProvideMappedUserRoles(ExternalIdPConfig externalIdPConfig,
        Map<String, String> extAttributesValueMap, String idpRoleClaimUri, Boolean excludeUnmapped) {

    if (idpRoleClaimUri == null) {
        // Since idpRoleCalimUri is not defined cannot do role mapping.
        if (log.isDebugEnabled()) {
            log.debug("Role claim uri is not configured for the external IDP: " + externalIdPConfig.getIdPName()
                    + ", in Domain: " + externalIdPConfig.getDomain() + ".");
        }
        return new ArrayList<>();
    }
    String idpRoleAttrValue = null;
    if (extAttributesValueMap != null) {
        idpRoleAttrValue = extAttributesValueMap.get(idpRoleClaimUri);
    }
    String[] idpRoles;
    String federatedIDPRoleClaimAttributeSeparator;
    if (idpRoleAttrValue != null) {
        if (IdentityUtil.getProperty(FrameworkConstants.FEDERATED_IDP_ROLE_CLAIM_VALUE_SEPARATOR) != null) {
            federatedIDPRoleClaimAttributeSeparator = IdentityUtil.getProperty(FrameworkConstants
                    .FEDERATED_IDP_ROLE_CLAIM_VALUE_SEPARATOR);
            if (log.isDebugEnabled()) {
                log.debug("The IDP side role claim value separator is configured as : " + federatedIDPRoleClaimAttributeSeparator);
            }
        } else {
            federatedIDPRoleClaimAttributeSeparator = FrameworkUtils.getMultiAttributeSeparator();
        }

        idpRoles = idpRoleAttrValue.split(federatedIDPRoleClaimAttributeSeparator);
    } else {
        // No identity provider role values found.
        if (log.isDebugEnabled()) {
            log.debug(
                    "No role attribute value has received from the external IDP: " + externalIdPConfig.getIdPName()
                            + ", in Domain: " + externalIdPConfig.getDomain() + ".");
        }
        return new ArrayList<>();
    }
    Map<String, String> idpToLocalRoleMapping = externalIdPConfig.getRoleMappings();
    Set<String> idpMappedUserRoles = new HashSet<>();
    // If no role mapping is configured in the identity provider.
    if (MapUtils.isEmpty(idpToLocalRoleMapping)) {
        if (log.isDebugEnabled()) {
            log.debug("No role mapping is configured in the external IDP: " + externalIdPConfig.getIdPName()
                    + ", in Domain: " + externalIdPConfig.getDomain() + ".");
        }
        if (excludeUnmapped) {
            return new ArrayList<>();
        }
        idpMappedUserRoles.addAll(Arrays.asList(idpRoles));
        return new ArrayList<>(idpMappedUserRoles);
    }
    for (String idpRole : idpRoles) {
        if (idpToLocalRoleMapping.containsKey(idpRole)) {
            idpMappedUserRoles.add(idpToLocalRoleMapping.get(idpRole));
        } else if (!excludeUnmapped) {
            idpMappedUserRoles.add(idpRole);
        }
    }
    return new ArrayList<>(idpMappedUserRoles);
}