Java Code Examples for org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil#getProperty()

The following examples show how to use org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil#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: FileBasedIdPMgtDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain,
                                                           String authenticatorName) {

    Map<String, IdentityProvider> identityProviders = IdPManagementServiceComponent.getFileBasedIdPs();
    for (Entry<String, IdentityProvider> entry : identityProviders.entrySet()) {
        FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = entry.getValue().
                getFederatedAuthenticatorConfigs();
        // Get SAML2 Web SSO authenticator
        FederatedAuthenticatorConfig samlAuthenticatorConfig = IdentityApplicationManagementUtil.
                getFederatedAuthenticator(federatedAuthenticatorConfigs, authenticatorName);
        if (samlAuthenticatorConfig != null) {
            Property samlProperty = IdentityApplicationManagementUtil.getProperty(samlAuthenticatorConfig.
                    getProperties(), property);
            if (samlProperty != null) {
                if (value.equalsIgnoreCase(samlProperty.getValue())) {
                    return entry.getValue();
                }
            }
        }
    }
    return null;
}
 
Example 2
Source File: IdPManagementUtil.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static int getIdleSessionTimeOut(String tenantDomain) {

        IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
        int timeout = Integer.parseInt(IdentityApplicationConstants.SESSION_IDLE_TIME_OUT_DEFAULT);

        try {
            IdentityProvider identityProvider = identityProviderManager.getResidentIdP(tenantDomain);
            IdentityProviderProperty idpProperty = IdentityApplicationManagementUtil.getProperty(
                    identityProvider.getIdpProperties(), IdentityApplicationConstants.SESSION_IDLE_TIME_OUT);
            if (idpProperty != null) {
                timeout = Integer.parseInt(idpProperty.getValue());
            }
        } catch (IdentityProviderManagementException e) {
            log.error("Error when accessing the IdentityProviderManager for tenant : " + tenantDomain, e);
        }
        return timeout * 60;
    }
 
Example 3
Source File: IdPManagementUtil.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
public static int getRememberMeTimeout(String tenantDomain) {

        IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
        int rememberMeTimeout = Integer.parseInt(IdentityApplicationConstants.REMEMBER_ME_TIME_OUT_DEFAULT);

        try {
            IdentityProvider identityProvider = identityProviderManager.getResidentIdP(tenantDomain);
            IdentityProviderProperty idpProperty = IdentityApplicationManagementUtil.getProperty(
                    identityProvider.getIdpProperties(), IdentityApplicationConstants.REMEMBER_ME_TIME_OUT);
            if (idpProperty != null) {
                rememberMeTimeout = Integer.parseInt(idpProperty.getValue());
            }
        } catch (IdentityProviderManagementException e) {
            log.error("Error when accessing the IdentityProviderManager for tenant : " + tenantDomain, e);
        }
        return rememberMeTimeout * 60;
    }
 
Example 4
Source File: OpenIDConnectFederatedAuthenticatorConfig.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isValid() {
    if (IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.OIDC.CLIENT_ID) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.CLIENT_ID)) &&
            IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.CLIENT_SECRET) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.CLIENT_SECRET)) &&
            IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_AUTHZ_URL) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_AUTHZ_URL)) &&
            IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_TOKEN_URL) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OIDC.OAUTH2_TOKEN_URL))) {
        return true;
    }
    return false;
}
 
Example 5
Source File: SAML2SSOFederatedAuthenticatorConfig.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
@Override
public boolean isValid() {

    if (IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID) != null
            && !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.IDP_ENTITY_ID))
            && IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID) != null
            && !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.SP_ENTITY_ID))
            && IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL) != null
            && !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.SAML2SSO.SSO_URL))) {
        return true;
    }
    return false;
}
 
Example 6
Source File: IdPManagementUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static int getIdleSessionTimeOut(String tenantDomain) {

        IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
        int timeout = Integer.parseInt(IdentityApplicationConstants.SESSION_IDLE_TIME_OUT_DEFAULT);

        try {
            IdentityProvider identityProvider = identityProviderManager.getResidentIdP(tenantDomain);
            IdentityProviderProperty idpProperty = IdentityApplicationManagementUtil.getProperty(
                    identityProvider.getIdpProperties(), IdentityApplicationConstants.SESSION_IDLE_TIME_OUT);
            if (idpProperty != null) {
                timeout = Integer.parseInt(idpProperty.getValue());
            }
        } catch (IdentityProviderManagementException e) {
            log.error("Error when accessing the IdentityProviderManager for tenant : " + tenantDomain, e);
        }
        return timeout * 60;
    }
 
Example 7
Source File: IdPManagementUtil.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public static int getRememberMeTimeout(String tenantDomain) {

        IdentityProviderManager identityProviderManager = IdentityProviderManager.getInstance();
        int rememberMeTimeout = Integer.parseInt(IdentityApplicationConstants.REMEMBER_ME_TIME_OUT_DEFAULT);

        try {
            IdentityProvider identityProvider = identityProviderManager.getResidentIdP(tenantDomain);
            IdentityProviderProperty idpProperty = IdentityApplicationManagementUtil.getProperty(
                    identityProvider.getIdpProperties(), IdentityApplicationConstants.REMEMBER_ME_TIME_OUT);
            if (idpProperty != null) {
                rememberMeTimeout = Integer.parseInt(idpProperty.getValue());
            }
        } catch (IdentityProviderManagementException e) {
            log.error("Error when accessing the IdentityProviderManager for tenant : " + tenantDomain, e);
        }
        return rememberMeTimeout * 60;
    }
 
Example 8
Source File: ServerConfigManagementService.java    From identity-api-server with Apache License 2.0 5 votes vote down vote up
/**
 * Get Server Configs.
 *
 * @return ServerConfig.
 */
public ServerConfig getConfigs() {

    IdentityProvider residentIdP = getResidentIdP();

    String idleSessionTimeout = null;
    IdentityProviderProperty idleSessionProp = IdentityApplicationManagementUtil.getProperty(
            residentIdP.getIdpProperties(), IdentityApplicationConstants.SESSION_IDLE_TIME_OUT);
    if (idleSessionProp != null) {
        idleSessionTimeout = idleSessionProp.getValue();
    }

    String rememberMePeriod = null;
    IdentityProviderProperty rememberMeProp = IdentityApplicationManagementUtil.getProperty(
            residentIdP.getIdpProperties(), IdentityApplicationConstants.REMEMBER_ME_TIME_OUT);
    if (rememberMeProp != null) {
        rememberMePeriod = rememberMeProp.getValue();
    }

    String homeRealmIdStr = residentIdP.getHomeRealmId();
    List<String> homeRealmIdentifiers = null;
    if (StringUtils.isNotBlank(homeRealmIdStr)) {
        homeRealmIdentifiers = Arrays.stream(homeRealmIdStr.split(",")).collect(Collectors.toList());
    }
    ServerConfig serverConfig = new ServerConfig();
    serverConfig.setIdleSessionTimeoutPeriod(idleSessionTimeout);
    serverConfig.setRememberMePeriod(rememberMePeriod);
    serverConfig.setHomeRealmIdentifiers(homeRealmIdentifiers);
    serverConfig.setProvisioning(buildProvisioningConfig());
    serverConfig.setAuthenticators(getAuthenticators(null));
    return serverConfig;
}
 
Example 9
Source File: PassiveSTSFederatedAuthenticatorConfig.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isValid() {

    if (IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_URL) != null
            && !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.PassiveSTS.IDENTITY_PROVIDER_URL))) {
        return true;
    }
    return false;
}
 
Example 10
Source File: FacebookFederatedAuthenticatorConfig.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @return
 */
public boolean isValid() {
    if (IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.Facebook.CLIENT_ID) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.Facebook.CLIENT_ID)) &&
            IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.Facebook.CLIENT_SECRET) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.Facebook.CLIENT_SECRET))) {
        return true;
    }
    return false;
}
 
Example 11
Source File: OpenIDFederatedAuthenticatorConfig.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
@Override
public boolean isValid() {
    if (IdentityApplicationManagementUtil.getProperty(properties,
            IdentityApplicationConstants.Authenticator.OpenID.OPEN_ID_URL) != null &&
            !"".equals(IdentityApplicationManagementUtil.getProperty(properties,
                    IdentityApplicationConstants.Authenticator.OpenID.OPEN_ID_URL))) {

        return true;
    }
    return false;
}
 
Example 12
Source File: FileBasedIdPMgtDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * @param property
 * @param value
 * @param tenantDomain
 * @return
 */
public IdentityProvider getIdPByAuthenticatorPropertyValue(String property, String value, String tenantDomain) {

    Map<String, IdentityProvider> identityProviders = IdPManagementServiceComponent.getFileBasedIdPs();
    for (Iterator<Entry<String, IdentityProvider>> iterator = identityProviders.entrySet().iterator(); iterator
            .hasNext(); ) {
        Entry<String, IdentityProvider> entry = iterator.next();
        FederatedAuthenticatorConfig[] federatedAuthenticatorConfigs = entry.getValue().
                getFederatedAuthenticatorConfigs();
        // Get SAML2 Web SSO authenticator
        FederatedAuthenticatorConfig samlAuthenticatorConfig = IdentityApplicationManagementUtil.
                getFederatedAuthenticator(
                        federatedAuthenticatorConfigs, IdentityApplicationConstants.Authenticator.SAML2SSO.NAME);

        if (samlAuthenticatorConfig != null) {
            Property samlProperty = IdentityApplicationManagementUtil.getProperty(samlAuthenticatorConfig.
                            getProperties(),
                    property);
            if (samlProperty != null) {
                if (value.equalsIgnoreCase(samlProperty.getValue())) {
                    return entry.getValue();
                }
            }
        }
    }
    return null;
}