Search in sources :

Example 1 with MetaFederatedAuthenticator

use of org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator in project identity-api-server by wso2.

the class ServerIdpManagementService method createMetaFederatedAuthenticatorListItem.

private MetaFederatedAuthenticatorListItem createMetaFederatedAuthenticatorListItem(FederatedAuthenticatorConfig authenticatorConfig) {
    MetaFederatedAuthenticatorListItem metaFederatedAuthenticator = new MetaFederatedAuthenticatorListItem();
    String authenticatorId = base64URLEncode(authenticatorConfig.getName());
    metaFederatedAuthenticator.setName(authenticatorConfig.getName());
    metaFederatedAuthenticator.setAuthenticatorId(authenticatorId);
    FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName(authenticatorConfig.getName());
    if (federatedAuthenticatorConfig != null) {
        String[] tags = federatedAuthenticatorConfig.getTags();
        if (ArrayUtils.isNotEmpty(tags)) {
            metaFederatedAuthenticator.setTags(Arrays.asList(tags));
        }
    }
    metaFederatedAuthenticator.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT + "/meta/federated-authenticators/%s", authenticatorId)).toString());
    return metaFederatedAuthenticator;
}
Also used : MetaFederatedAuthenticatorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticatorListItem) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)

Example 2 with MetaFederatedAuthenticator

use of org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator in project identity-api-server by wso2.

the class ServerIdpManagementService method createMetaFederatedAuthenticator.

private MetaFederatedAuthenticator createMetaFederatedAuthenticator(FederatedAuthenticatorConfig authenticatorConfig) {
    MetaFederatedAuthenticator metaFederatedAuthenticator = new MetaFederatedAuthenticator();
    metaFederatedAuthenticator.setName(authenticatorConfig.getName());
    metaFederatedAuthenticator.setAuthenticatorId(base64URLEncode(authenticatorConfig.getName()));
    metaFederatedAuthenticator.setDisplayName(authenticatorConfig.getDisplayName());
    FederatedAuthenticatorConfig federatedAuthenticatorConfig = ApplicationAuthenticatorService.getInstance().getFederatedAuthenticatorByName(authenticatorConfig.getName());
    if (federatedAuthenticatorConfig != null) {
        String[] tags = federatedAuthenticatorConfig.getTags();
        if (ArrayUtils.isNotEmpty(tags)) {
            metaFederatedAuthenticator.setTags(Arrays.asList(tags));
        }
    }
    Property[] properties = authenticatorConfig.getProperties();
    List<MetaProperty> metaProperties = Arrays.stream(properties).map(propertyToExternalMeta).collect(Collectors.toList());
    metaFederatedAuthenticator.setProperties(metaProperties);
    return metaFederatedAuthenticator;
}
Also used : MetaFederatedAuthenticator(org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) MetaProperty(org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty) IdentityProviderProperty(org.wso2.carbon.identity.application.common.model.IdentityProviderProperty) Property(org.wso2.carbon.identity.application.common.model.Property) SubProperty(org.wso2.carbon.identity.application.common.model.SubProperty) MetaProperty(org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty)

Example 3 with MetaFederatedAuthenticator

use of org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator in project identity-api-server by wso2.

the class ServerIdpManagementService method getMetaFederatedAuthenticators.

/**
 * Get meta information about Identity Provider's federated authenticators.
 *
 * @return list of meta federated authenticators.
 */
public List<MetaFederatedAuthenticatorListItem> getMetaFederatedAuthenticators() {
    List<MetaFederatedAuthenticatorListItem> metaAuthenticators = new ArrayList<>();
    try {
        FederatedAuthenticatorConfig[] authenticatorConfigs = IdentityProviderServiceHolder.getIdentityProviderManager().getAllFederatedAuthenticators();
        if (ArrayUtils.isNotEmpty(authenticatorConfigs)) {
            for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
                MetaFederatedAuthenticatorListItem metaFederatedAuthenticator = createMetaFederatedAuthenticatorListItem(authenticatorConfig);
                metaAuthenticators.add(metaFederatedAuthenticator);
            }
        }
        return metaAuthenticators;
    } catch (IdentityProviderManagementException e) {
        throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_META_AUTHENTICATORS, null);
    }
}
Also used : MetaFederatedAuthenticatorListItem(org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticatorListItem) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) ArrayList(java.util.ArrayList) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 4 with MetaFederatedAuthenticator

use of org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator in project identity-api-server by wso2.

the class ServerIdpManagementService method getMetaFederatedAuthenticator.

/**
 * Get meta information about a specific federated authenticator supported by the IDPs.
 *
 * @param id Federated authenticator ID.
 * @return MetaFederatedAuthenticator.
 */
public MetaFederatedAuthenticator getMetaFederatedAuthenticator(String id) {
    MetaFederatedAuthenticator authenticator = null;
    try {
        String authenticatorName = decodeAuthenticatorID(id);
        FederatedAuthenticatorConfig[] authenticatorConfigs = IdentityProviderServiceHolder.getIdentityProviderManager().getAllFederatedAuthenticators();
        if (ArrayUtils.isNotEmpty(authenticatorConfigs)) {
            for (FederatedAuthenticatorConfig authenticatorConfig : authenticatorConfigs) {
                if (StringUtils.equals(authenticatorConfig.getName(), authenticatorName)) {
                    authenticator = createMetaFederatedAuthenticator(authenticatorConfig);
                    break;
                }
            }
        }
        return authenticator;
    } catch (IdentityProviderManagementException e) {
        throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_META_AUTHENTICATOR, id);
    }
}
Also used : MetaFederatedAuthenticator(org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator) FederatedAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Aggregations

FederatedAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.FederatedAuthenticatorConfig)4 MetaFederatedAuthenticator (org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticator)2 MetaFederatedAuthenticatorListItem (org.wso2.carbon.identity.api.server.idp.v1.model.MetaFederatedAuthenticatorListItem)2 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)2 ArrayList (java.util.ArrayList)1 MetaProperty (org.wso2.carbon.identity.api.server.idp.v1.model.MetaProperty)1 IdentityProviderProperty (org.wso2.carbon.identity.application.common.model.IdentityProviderProperty)1 Property (org.wso2.carbon.identity.application.common.model.Property)1 SubProperty (org.wso2.carbon.identity.application.common.model.SubProperty)1