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