use of org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig in project identity-api-server by wso2.
the class ServerConfigManagementService method getAuthenticator.
/**
* Get an authenticator identified by its resource ID.
*
* @param authenticatorId Authenticator resource ID.
* @return Authenticator.
*/
public Authenticator getAuthenticator(String authenticatorId) {
try {
LocalAuthenticatorConfig authenticatorConfig = getAuthenticatorById(ConfigsServiceHolder.getInstance().getApplicationManagementService().getAllLocalAuthenticators(ContextLoader.getTenantDomainFromContext()), authenticatorId);
if (authenticatorConfig != null) {
return buildAuthenticatorResponse(authenticatorConfig);
}
RequestPathAuthenticatorConfig requestPathConfig = getAuthenticatorById(ConfigsServiceHolder.getInstance().getApplicationManagementService().getAllRequestPathAuthenticators(ContextLoader.getTenantDomainFromContext()), authenticatorId);
if (requestPathConfig != null) {
return buildAuthenticatorResponse(requestPathConfig);
}
throw handleException(Response.Status.NOT_FOUND, Constants.ErrorMessage.ERROR_CODE_AUTHENTICATOR_NOT_FOUND, authenticatorId);
} catch (IdentityApplicationManagementException e) {
throw handleApplicationMgtException(e, Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_AUTHENTICATOR, authenticatorId);
}
}
use of org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig in project identity-api-server by wso2.
the class ServerConfigManagementService method buildAuthenticatorListResponse.
private List<AuthenticatorListItem> buildAuthenticatorListResponse(LocalAuthenticatorConfig[] localConfigs, RequestPathAuthenticatorConfig[] requestPathConfigs) {
List<AuthenticatorListItem> authenticatorListItems = new ArrayList<>();
if (localConfigs != null) {
for (LocalAuthenticatorConfig config : localConfigs) {
AuthenticatorListItem authenticatorListItem = new AuthenticatorListItem();
String authenticatorId = base64URLEncode(config.getName());
authenticatorListItem.setId(authenticatorId);
authenticatorListItem.setName(config.getName());
authenticatorListItem.setDisplayName(config.getDisplayName());
authenticatorListItem.setIsEnabled(config.isEnabled());
authenticatorListItem.setType(AuthenticatorListItem.TypeEnum.LOCAL);
String[] tags = config.getTags();
if (ArrayUtils.isNotEmpty(tags)) {
authenticatorListItem.setTags(Arrays.asList(tags));
}
authenticatorListItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + CONFIGS_AUTHENTICATOR_PATH_COMPONENT + PATH_SEPERATOR + "%s", authenticatorId)).toString());
authenticatorListItems.add(authenticatorListItem);
}
}
if (requestPathConfigs != null) {
for (RequestPathAuthenticatorConfig config : requestPathConfigs) {
AuthenticatorListItem authenticatorListItem = new AuthenticatorListItem();
String authenticatorId = base64URLEncode(config.getName());
authenticatorListItem.setId(authenticatorId);
authenticatorListItem.setName(config.getName());
authenticatorListItem.setDisplayName(config.getDisplayName());
authenticatorListItem.setIsEnabled(config.isEnabled());
authenticatorListItem.setType(AuthenticatorListItem.TypeEnum.REQUEST_PATH);
String[] tags = config.getTags();
if (ArrayUtils.isNotEmpty(tags)) {
authenticatorListItem.setTags(Arrays.asList(tags));
}
authenticatorListItem.setSelf(ContextLoader.buildURIForBody(String.format(V1_API_PATH_COMPONENT + CONFIGS_AUTHENTICATOR_PATH_COMPONENT + PATH_SEPERATOR + "%s", authenticatorId)).toString());
authenticatorListItems.add(authenticatorListItem);
}
}
return authenticatorListItems;
}
use of org.wso2.carbon.identity.application.common.model.RequestPathAuthenticatorConfig in project identity-api-server by wso2.
the class ServerConfigManagementService method buildAuthenticatorResponse.
private Authenticator buildAuthenticatorResponse(LocalAuthenticatorConfig config) {
Authenticator authenticator = new Authenticator();
authenticator.setId(base64URLEncode(config.getName()));
authenticator.setName(config.getName());
authenticator.setDisplayName(config.getDisplayName());
authenticator.setIsEnabled(config.isEnabled());
if (config instanceof RequestPathAuthenticatorConfig) {
authenticator.setType(Authenticator.TypeEnum.REQUEST_PATH);
} else {
authenticator.setType(Authenticator.TypeEnum.LOCAL);
}
String[] tags = config.getTags();
if (ArrayUtils.isNotEmpty(tags)) {
authenticator.setTags(Arrays.asList(tags));
}
List<AuthenticatorProperty> authenticatorProperties = Arrays.stream(config.getProperties()).map(propertyToExternal).collect(Collectors.toList());
authenticator.setProperties(authenticatorProperties);
return authenticator;
}
Aggregations