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;
}
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);
}
}
Aggregations