Search in sources :

Example 6 with IdpSearchResult

use of org.wso2.carbon.idp.mgt.model.IdpSearchResult in project identity-api-server by wso2.

the class ServerAuthenticatorManagementService method buildAuthenticatorsListResponse.

private List<Authenticator> buildAuthenticatorsListResponse(String filter, List<String> requestedAttributeList, String localAuthNames, String authenticatorNameFilterOperator, ArrayList<String> filterTagsList, LocalAuthenticatorConfig[] localAuthenticatorConfigs, RequestPathAuthenticatorConfig[] requestPathAuthenticatorConfigs, List<IdentityProvider> identityProviders) {
    int maximumItemsPerPage = IdentityUtil.getMaximumItemPerPage();
    List<Authenticator> authenticators = new ArrayList<>();
    if (localAuthenticatorConfigs != null) {
        for (LocalAuthenticatorConfig config : localAuthenticatorConfigs) {
            addLocalAuthenticator(config, authenticators, localAuthNames, authenticatorNameFilterOperator, filterTagsList, maximumItemsPerPage);
        }
    }
    if ((authenticators.size() < maximumItemsPerPage) && requestPathAuthenticatorConfigs != null) {
        for (RequestPathAuthenticatorConfig config : requestPathAuthenticatorConfigs) {
            addLocalAuthenticator(config, authenticators, localAuthNames, authenticatorNameFilterOperator, filterTagsList, maximumItemsPerPage);
        }
    }
    if (StringUtils.isBlank(filter)) {
        if ((authenticators.size() < maximumItemsPerPage) && identityProviders != null) {
            for (IdentityProvider identityProvider : identityProviders) {
                if (authenticators.size() < maximumItemsPerPage) {
                    List<String> configTagsListDistinct = getDistinctTags(identityProvider);
                    addIdp(identityProvider, authenticators, configTagsListDistinct);
                }
            }
        }
    } else {
        List<ExpressionNode> expressionNodesForIdp = getExpressionNodesForIdp(filter);
        int idPCountToBeRetrieved = maximumItemsPerPage - authenticators.size();
        IdpSearchResult idpSearchResult;
        try {
            idpSearchResult = AuthenticatorsServiceHolder.getInstance().getIdentityProviderManager().getIdPs(idPCountToBeRetrieved, null, null, null, ContextLoader.getTenantDomainFromContext(), requestedAttributeList, expressionNodesForIdp);
            identityProviders = idpSearchResult.getIdPs();
            if (identityProviders != null) {
                addIdPsToAuthenticatorList(maximumItemsPerPage, identityProviders, authenticators, filterTagsList);
                int limit = idpSearchResult.getLimit();
                int offSet = idpSearchResult.getOffSet();
                int totalIdpCount = idpSearchResult.getTotalIDPCount();
                while (authenticators.size() < maximumItemsPerPage && limit > 0 && offSet >= 0 && totalIdpCount > (limit + offSet)) {
                    identityProviders = new ArrayList<>();
                    getFilteredIdPs(limit, offSet, requestedAttributeList, identityProviders, expressionNodesForIdp);
                    addIdPsToAuthenticatorList(maximumItemsPerPage, identityProviders, authenticators, filterTagsList);
                    offSet = offSet + limit;
                }
            }
        } catch (IdentityProviderManagementException e) {
            throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null);
        }
    }
    return authenticators;
}
Also used : ArrayList(java.util.ArrayList) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) RequestPathAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException) Authenticator(org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator)

Example 7 with IdpSearchResult

use of org.wso2.carbon.idp.mgt.model.IdpSearchResult in project identity-api-server by wso2.

the class ServerAuthenticatorManagementService method getFilteredIdPs.

private void getFilteredIdPs(int limit, int offSet, List<String> requestedAttributeList, List<IdentityProvider> identityProviders, List<ExpressionNode> expressionNodes) {
    try {
        IdpSearchResult idpSearchResult = AuthenticatorsServiceHolder.getInstance().getIdentityProviderManager().getIdPs(limit, (offSet + limit), null, null, ContextLoader.getTenantDomainFromContext(), requestedAttributeList, expressionNodes);
        identityProviders.addAll(idpSearchResult.getIdPs());
    } catch (IdentityProviderManagementException e) {
        throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null);
    }
}
Also used : IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Aggregations

IdpSearchResult (org.wso2.carbon.idp.mgt.model.IdpSearchResult)6 ArrayList (java.util.ArrayList)3 IdentityProvider (org.wso2.carbon.identity.application.common.model.IdentityProvider)3 ExpressionNode (org.wso2.carbon.identity.core.model.ExpressionNode)3 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)3 LocalAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig)2 RequestPathAuthenticatorConfig (org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig)2 Authenticator (org.wso2.carbon.identity.api.server.authenticators.v1.model.Authenticator)1 NameFilter (org.wso2.carbon.identity.api.server.authenticators.v1.model.NameFilter)1 IdentityProviderListItem (org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListItem)1 IdentityProviderListResponse (org.wso2.carbon.identity.api.server.idp.v1.model.IdentityProviderListResponse)1 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)1