Search in sources :

Example 1 with IdentityProviderListItem

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

the class ServerIdpManagementService method createIDPListResponse.

private IdentityProviderListResponse createIDPListResponse(IdpSearchResult idpSearchResult, List<String> requestedAttributeList) {
    List<IdentityProvider> idps = idpSearchResult.getIdPs();
    IdentityProviderListResponse listResponse = new IdentityProviderListResponse();
    if (CollectionUtils.isNotEmpty(idps)) {
        List<IdentityProviderListItem> identityProviderList = new ArrayList<>();
        for (IdentityProvider idp : idps) {
            IdentityProviderListItem listItem = populateIDPListResponse(idp, requestedAttributeList);
            identityProviderList.add(listItem);
        }
        listResponse.setIdentityProviders(identityProviderList);
        listResponse.setCount(idps.size());
    } else {
        listResponse.setCount(0);
    }
    listResponse.setTotalResults(idpSearchResult.getTotalIDPCount());
    listResponse.setStartIndex(idpSearchResult.getOffSet() + 1);
    listResponse.setLinks(createLinks(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT, idpSearchResult.getLimit(), idpSearchResult.getOffSet(), idpSearchResult.getTotalIDPCount(), idpSearchResult.getFilter()));
    return listResponse;
}
Also used : IdentityProviderListItem(org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListItem) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdentityProviderListResponse(org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListResponse)

Example 2 with IdentityProviderListItem

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

the class ServerIdpManagementService method populateIDPListResponse.

private IdentityProviderListItem populateIDPListResponse(IdentityProvider idp, List<String> requestedAttributeList) {
    IdentityProviderListItem identityProviderListItem = new IdentityProviderListItem();
    // Create IDP basic information.
    identityProviderListItem.setId(idp.getResourceId());
    identityProviderListItem.setName(idp.getIdentityProviderName());
    identityProviderListItem.setDescription(idp.getIdentityProviderDescription());
    identityProviderListItem.setIsEnabled(idp.isEnable());
    identityProviderListItem.setImage(idp.getImageUrl());
    identityProviderListItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + IDP_PATH_COMPONENT + "/%s", idp.getResourceId())).toString());
    // Populate optional IDP information if exists.
    if (requestedAttributeList != null) {
        for (String requestedAttribute : requestedAttributeList) {
            switch(requestedAttribute) {
                case Constants.IS_PRIMARY:
                    identityProviderListItem.setIsPrimary(idp.isPrimary());
                    break;
                case Constants.IS_FEDERATION_HUB:
                    identityProviderListItem.setIsFederationHub(idp.isFederationHub());
                    break;
                case Constants.HOME_REALM_IDENTIFIER:
                    identityProviderListItem.setHomeRealmIdentifier(idp.getHomeRealmId());
                    break;
                case Constants.CERTIFICATE:
                    identityProviderListItem.setCertificate(createIDPCertificate(idp));
                    break;
                case Constants.ALIAS:
                    identityProviderListItem.setAlias(idp.getAlias());
                    break;
                case Constants.CLAIMS:
                    identityProviderListItem.setClaims(createClaimResponse(idp.getClaimConfig()));
                    break;
                case Constants.ROLES:
                    identityProviderListItem.setRoles(createRoleResponse(idp));
                    break;
                case Constants.FEDERATED_AUTHENTICATORS:
                    identityProviderListItem.setFederatedAuthenticators(createFederatedAuthenticatorResponse(idp));
                    break;
                case Constants.PROVISIONING:
                    identityProviderListItem.setProvisioning(createProvisioningResponse(idp));
                    break;
                default:
                    if (log.isDebugEnabled()) {
                        log.debug("Unknown requested attribute: " + requestedAttribute);
                    }
                    break;
            }
        }
    }
    return identityProviderListItem;
}
Also used : IdentityProviderListItem(org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListItem)

Aggregations

IdentityProviderListItem (org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListItem)2 ArrayList (java.util.ArrayList)1 IdentityProviderListResponse (org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListResponse)1 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)1