Search in sources :

Example 1 with IdpSearchResult

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

the class IdentityProviderManagementService method getPaginatedIdpInfo.

/**
 * Retrieves Identity providers list of array for the logged-in tenant.
 *
 * @param filter     searching value.
 * @param pageNumber page number.
 * @return Identity providers list of array.
 * @throws IdentityProviderManagementException Error when getting list of Identity Providers.
 */
public IdentityProvider[] getPaginatedIdpInfo(String filter, int pageNumber) throws IdentityProviderManagementException {
    validateRequestedPageNumber(pageNumber);
    Integer limit = IdentityUtil.getDefaultItemsPerPage();
    Integer offset = getIdpPageOffset(pageNumber, limit);
    String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
    IdpSearchResult idpSearchResult = IdentityProviderManager.getInstance().getIdPs(limit, offset, filter, IdPManagementConstants.DEFAULT_SORT_ORDER, IdPManagementConstants.DEFAULT_SORT_BY, tenantDomain, new ArrayList<>());
    return idpSearchResult.getIdPs().toArray(new IdentityProvider[0]);
}
Also used : IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult)

Example 2 with IdpSearchResult

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

the class IdentityProviderManager method getIdPs.

/**
 * Get all identity provider's Basic information along with additionally requested information depending on the
 * requiredAttributes.
 *
 * @param limit              Limit per page.
 * @param offset             Offset value.
 * @param filter             Filter value for IdP search.
 * @param sortOrder          Order of IdP ASC/DESC.
 * @param sortBy             The column value need to sort.
 * @param tenantDomain       TenantDomain of the user.
 * @param requiredAttributes Required attributes which needs to be return.
 * @return Identity Provider's Basic Information array along with requested attribute
 * information{@link IdpSearchResult}.
 * @throws IdentityProviderManagementException Server/client related error when getting list of Identity Providers.
 */
@Override
public IdpSearchResult getIdPs(Integer limit, Integer offset, String filter, String sortOrder, String sortBy, String tenantDomain, List<String> requiredAttributes) throws IdentityProviderManagementException {
    IdpSearchResult result = new IdpSearchResult();
    List<ExpressionNode> expressionNodes = getExpressionNodes(filter);
    setParameters(limit, offset, sortOrder, sortBy, filter, result);
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    result.setTotalIDPCount(dao.getTotalIdPCount(tenantId, expressionNodes));
    result.setIdpList(dao.getPaginatedIdPsSearch(tenantId, expressionNodes, result.getLimit(), result.getOffSet(), result.getSortOrder(), result.getSortBy(), requiredAttributes));
    return result;
}
Also used : ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult)

Example 3 with IdpSearchResult

use of org.wso2.carbon.idp.mgt.model.IdpSearchResult 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 4 with IdpSearchResult

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

the class ServerAuthenticatorManagementService method getAuthenticators.

/**
 * Retrieves the list of available authenticators.
 *
 * @param filter The filter string.
 * @param limit  The items per page. **Not supported at the moment.**
 * @param offset The offset to be used with the limit parameter. **Not supported at the moment.**
 * @return The list of authenticators
 */
public List<Authenticator> getAuthenticators(String filter, Integer limit, Integer offset) {
    handleNotImplementedCapabilities(limit, offset);
    try {
        String filterAuthenticatorName = null;
        String filterOperationForName = null;
        ArrayList<String> filterTagsList = null;
        int maximumItemPerPage = IdentityUtil.getMaximumItemPerPage();
        if (StringUtils.isNotBlank(filter)) {
            List<ExpressionNode> expressionNodes = getExpressionNodesForAuthenticator(filter);
            if (CollectionUtils.isNotEmpty(expressionNodes)) {
                NameFilter nameFilter = getFilterAuthenticatorNameAndOperation(expressionNodes);
                if (nameFilter != null) {
                    filterAuthenticatorName = nameFilter.getName();
                    filterOperationForName = nameFilter.getOperation();
                }
                filterTagsList = getFilterTagsList(expressionNodes);
            }
        }
        LocalAuthenticatorConfig[] localAuthenticatorConfigs = AuthenticatorsServiceHolder.getInstance().getApplicationManagementService().getAllLocalAuthenticators(ContextLoader.getTenantDomainFromContext());
        int localAuthenticatorsCount = localAuthenticatorConfigs.length;
        RequestPathAuthenticatorConfig[] requestPathAuthenticatorConfigs = new RequestPathAuthenticatorConfig[0];
        /* If there is no filter string available in the request, the request path authenticators are required to
            be fetched only if the  no. of local authenticators retrieved are less than the maximum items per page
            count as the no. of items returned in the response will be capped at the maximum items per page count. */
        if (StringUtils.isNotBlank(filter) || (StringUtils.isBlank(filter) && localAuthenticatorsCount < maximumItemPerPage)) {
            requestPathAuthenticatorConfigs = AuthenticatorsServiceHolder.getInstance().getApplicationManagementService().getAllRequestPathAuthenticators(ContextLoader.getTenantDomainFromContext());
        }
        List<String> requestedAttributeList = new ArrayList<>();
        requestedAttributeList.add(Constants.FEDERATED_AUTHENTICATORS);
        int idPCountToBeRetrieved = maximumItemPerPage - (localAuthenticatorsCount + requestPathAuthenticatorConfigs.length);
        List<IdentityProvider> identityProviders = null;
        /* If there is no filter string available in the request, the identity providers are required to
            be fetched only if the total of local authenticators and request path authenticators retrieved above is
            less than the maximum items per page count as the no. of items returned in the response will be capped
            at the maximum items per page count. */
        if (idPCountToBeRetrieved > 0 && StringUtils.isBlank(filter)) {
            IdpSearchResult idpSearchResult = AuthenticatorsServiceHolder.getInstance().getIdentityProviderManager().getIdPs(idPCountToBeRetrieved, null, null, null, null, ContextLoader.getTenantDomainFromContext(), requestedAttributeList);
            identityProviders = idpSearchResult.getIdPs();
        }
        return buildAuthenticatorsListResponse(filter, requestedAttributeList, filterAuthenticatorName, filterOperationForName, filterTagsList, localAuthenticatorConfigs, requestPathAuthenticatorConfigs, identityProviders);
    } catch (IdentityApplicationManagementException e) {
        throw handleApplicationMgtException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_AUTHENTICATORS, null);
    } catch (IdentityProviderManagementException e) {
        throw handleIdPException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_LISTING_IDPS, null);
    }
}
Also used : IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) LocalAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.LocalAuthenticatorConfig) ArrayList(java.util.ArrayList) IdentityProvider(org.wso2.carbon.identity.application.common.model.IdentityProvider) IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult) NameFilter(org.wso2.carbon.identity.api.server.authenticators.v1.model.NameFilter) ExpressionNode(org.wso2.carbon.identity.core.model.ExpressionNode) RequestPathAuthenticatorConfig(org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig) IdentityProviderManagementException(org.wso2.carbon.idp.mgt.IdentityProviderManagementException)

Example 5 with IdpSearchResult

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

the class IdentityProviderManager method getIdPs.

/**
 * Get basic information of identity providers along with additionally requested information.
 *
 * @param limit              The limit per page.
 * @param offset             The offset value.
 * @param sortOrder          The order of IdP ASC/DESC.
 * @param sortBy             The column value need to sort.
 * @param tenantDomain       The tenant domain of the user.
 * @param requiredAttributes The required attributes which needs to be returned.
 * @param expressionNodes    The list of filters.
 * @return The basic information of identity providers along with requested attributes.
 * @throws IdentityProviderManagementException Server/client related errors when getting list of identity providers.
 */
@Override
public IdpSearchResult getIdPs(Integer limit, Integer offset, String sortOrder, String sortBy, String tenantDomain, List<String> requiredAttributes, List<ExpressionNode> expressionNodes) throws IdentityProviderManagementException {
    IdpSearchResult result = new IdpSearchResult();
    setParameters(limit, offset, null, sortBy, sortBy, result);
    int tenantId = IdentityTenantUtil.getTenantId(tenantDomain);
    result.setTotalIDPCount(dao.getTotalIdPCount(tenantId, expressionNodes));
    result.setIdpList(dao.getPaginatedIdPsSearch(tenantId, expressionNodes, result.getLimit(), result.getOffSet(), result.getSortOrder(), result.getSortBy(), requiredAttributes));
    return result;
}
Also used : IdpSearchResult(org.wso2.carbon.idp.mgt.model.IdpSearchResult)

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