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

The following examples show how to use org.wso2.carbon.identity.application.common.util.IdentityApplicationManagementUtil#getFederatedAuthenticator() . 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: CellerySignedJWTValidator.java    From cellery-security with Apache License 2.0 6 votes vote down vote up
private IdentityProvider getLocalIdpForIssuer(String jwtIssuer,
                                              String tenantDomain) throws IdentityOAuth2Exception {

    String residentIdpIssuer = null;
    IdentityProvider residentIdentityProvider;
    try {
        residentIdentityProvider = IdentityProviderManager.getInstance().getResidentIdP(tenantDomain);
    } catch (IdentityProviderManagementException e) {
        throw new IdentityOAuth2Exception("Error retrieving resident IDP information for issuer: " + jwtIssuer +
                " of tenantDomain: " + tenantDomain, e);
    }

    FederatedAuthenticatorConfig[] fedAuthnConfigs = residentIdentityProvider.getFederatedAuthenticatorConfigs();
    FederatedAuthenticatorConfig oauthAuthenticatorConfig =
            IdentityApplicationManagementUtil.getFederatedAuthenticator(fedAuthnConfigs,
                    IdentityApplicationConstants.Authenticator.OIDC.NAME);
    if (oauthAuthenticatorConfig != null) {
        residentIdpIssuer = IdentityApplicationManagementUtil.getProperty(oauthAuthenticatorConfig.getProperties(),
                Utils.OPENID_IDP_ENTITY_ID).getValue();
    }
    return StringUtils.equalsIgnoreCase(residentIdpIssuer, jwtIssuer) ? residentIdentityProvider : null;
}
 
Example 2
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 3
Source File: ExtendedJWTBearerGrantHandler.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private IdentityProvider getResidentIDPForIssuer(String tenantDomain, String jwtIssuer) throws IdentityOAuth2Exception {
    String issuer = "";

    IdentityProvider residentIdentityProvider;
    try {
        residentIdentityProvider = IdentityProviderManager.getInstance().getResidentIdP(tenantDomain);
    } catch (IdentityProviderManagementException var7) {
        String errorMsg = String.format("Error while getting Resident Identity Provider of '%s' tenant.", tenantDomain);
        throw new IdentityOAuth2Exception(errorMsg, var7);
    }

    FederatedAuthenticatorConfig[] fedAuthnConfigs = residentIdentityProvider.getFederatedAuthenticatorConfigs();
    FederatedAuthenticatorConfig oauthAuthenticatorConfig = IdentityApplicationManagementUtil.
            getFederatedAuthenticator(fedAuthnConfigs, "openidconnect");
    if (oauthAuthenticatorConfig != null) {
        issuer = IdentityApplicationManagementUtil.getProperty(oauthAuthenticatorConfig.
                getProperties(), "IdPEntityId").getValue();
    }

    return jwtIssuer.equals(issuer) ? residentIdentityProvider : null;
}
 
Example 4
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;
}