use of org.forgerock.json.resource.NotSupportedException in project OpenAM by OpenRock.
the class ServerInfoResource method readInstance.
/**
* {@inheritDoc}
*/
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId, ReadRequest request) {
final String realm = getRealm(context);
debug.message("ServerInfoResource :: READ : in realm: " + realm);
if (COOKIE_DOMAINS.equalsIgnoreCase(resourceId)) {
return getCookieDomains();
} else if (ALL_SERVER_INFO.equalsIgnoreCase(resourceId)) {
return getAllServerInfo(context, realm);
} else {
// for now this is the only case coming in, so fail if otherwise
final ResourceException e = new NotSupportedException("ResourceId not supported: " + resourceId);
if (debug.errorEnabled()) {
debug.error("ServerInfoResource :: READ : in realm: " + realm + ": Cannot receive information on requested resource: " + resourceId, e);
}
return e.asPromise();
}
}
use of org.forgerock.json.resource.NotSupportedException in project OpenAM by OpenRock.
the class ResourceSetResource method actionCollection.
/**
* "revokeAll" action supported, which will delete all a user's resource set UMA policies.
*
* @param context {@inheritDoc}
* @param request {@inheritDoc}
*/
@Override
public Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request) {
if ("revokeAll".equalsIgnoreCase(request.getAction())) {
String realm = getRealm(context);
String resourceOwnerId = getUserId(context);
return resourceSetService.revokeAllPolicies(context, realm, resourceOwnerId).thenAsync(new AsyncFunction<Void, ActionResponse, ResourceException>() {
@Override
public Promise<ActionResponse, ResourceException> apply(Void value) throws ResourceException {
return newResultPromise(newActionResponse(json(object())));
}
});
} else {
return new NotSupportedException("Action " + request.getAction() + " not supported").asPromise();
}
}
use of org.forgerock.json.resource.NotSupportedException in project OpenAM by OpenRock.
the class IdentityResourceV1 method actionCollection.
/**
* {@inheritDoc}
*/
@Override
public Promise<ActionResponse, ResourceException> actionCollection(final Context context, final ActionRequest request) {
RealmContext realmContext = context.asContext(RealmContext.class);
final String realm = realmContext.getResolvedRealm();
RestSecurity restSecurity = restSecurityProvider.get(realm);
final String action = request.getAction();
if (action.equalsIgnoreCase("idFromSession")) {
return idFromSession(context, request);
} else if (action.equalsIgnoreCase("register")) {
return createRegistrationEmail(context, request, realm, restSecurity);
} else if (action.equalsIgnoreCase("confirm")) {
return confirmationIdCheck(context, request, realm);
} else if (action.equalsIgnoreCase("anonymousCreate")) {
return anonymousCreate(context, request, realm, restSecurity);
} else if (action.equalsIgnoreCase("forgotPassword")) {
return generateNewPasswordEmail(context, request, realm, restSecurity);
} else if (action.equalsIgnoreCase("forgotPasswordReset")) {
return anonymousUpdate(context, request, realm);
} else {
// for now this is the only case coming in, so fail if otherwise
return new NotSupportedException("Actions are not supported for resource instances").asPromise();
}
}
use of org.forgerock.json.resource.NotSupportedException in project OpenAM by OpenRock.
the class SmsRealmProvider method handleQuery.
@Override
public Promise<QueryResponse, ResourceException> handleQuery(Context context, QueryRequest request, QueryResourceHandler handler) {
if (!"true".equals(request.getQueryFilter().toString())) {
return new NotSupportedException("Query not supported: " + request.getQueryFilter()).asPromise();
}
if (request.getPagedResultsCookie() != null || request.getPagedResultsOffset() > 0 || request.getPageSize() > 0) {
return new NotSupportedException("Query paging not currently supported").asPromise();
}
final String principalName = PrincipalRestUtils.getPrincipalNameFromServerContext(context);
try {
final SessionID sessionID = new SessionID(getUserSsoToken(context).getTokenID().toString());
final String realmPath = coreWrapper.convertOrgNameToRealmName(sessionCache.getSession(sessionID).getClientDomain());
final OrganizationConfigManager ocm = new OrganizationConfigManager(getUserSsoToken(context), realmPath);
//Return realm query is being performed on
handler.handleResource(getResource(getJsonValue(realmPath)));
for (final Object subRealmRelativePath : ocm.getSubOrganizationNames("*", true)) {
String realmName;
if (realmPath.endsWith("/")) {
realmName = realmPath + subRealmRelativePath;
} else {
realmName = realmPath + "/" + subRealmRelativePath;
}
handler.handleResource(getResource(getJsonValue(realmName)));
}
debug.message("RealmResource :: QUERY : performed by {}", principalName);
return newResultPromise(newQueryResponse());
} catch (SSOException ex) {
debug.error("RealmResource :: QUERY by " + principalName + " failed : " + ex);
return new ForbiddenException().asPromise();
} catch (SessionException ex) {
debug.error("RealmResource :: QUERY by " + principalName + " failed : " + ex);
return new InternalServerErrorException().asPromise();
} catch (SMSException ex) {
debug.error("RealmResource :: QUERY by " + principalName + " failed :" + ex);
switch(ex.getExceptionCode()) {
case STATUS_NO_PERMISSION:
// This exception will be thrown if permission to read realms from SMS has not been delegated
return new ForbiddenException().asPromise();
default:
return new InternalServerErrorException().asPromise();
}
}
}
use of org.forgerock.json.resource.NotSupportedException in project OpenAM by OpenRock.
the class SmsServerPropertiesResource method actionInstance.
@Override
public Promise<ActionResponse, ResourceException> actionInstance(Context serverContext, ActionRequest actionRequest) {
if (actionRequest.getAction().equals("schema")) {
Map<String, String> uriVariables = getUriTemplateVariables(serverContext);
final String serverName = uriVariables.get("serverName").toLowerCase();
if (serverName == null) {
return new BadRequestException("Server name not specified.").asPromise();
}
try {
ServiceConfigManager scm = getServiceConfigManager(serverContext);
ServiceConfig serverConfigs = getServerConfigs(scm);
if (!serverConfigs.getSubConfigNames().contains(serverName)) {
return new BadRequestException("Unknown server: " + serverName).asPromise();
}
} catch (SSOException | SMSException e) {
logger.error("Error getting server config", e);
}
final String tabName = getTabName(uriVariables);
if (tabName == null) {
return new BadRequestException("Tab name not specified.").asPromise();
}
JsonValue schema;
final JsonPointer tabPointer = new JsonPointer("_schema/properties/" + tabName);
if (DIRECTORY_CONFIGURATION_TAB_NAME.equalsIgnoreCase(tabName)) {
schema = directoryConfigSchema;
} else if (serverName.equals(SERVER_DEFAULT_NAME)) {
schema = defaultSchema.get(tabPointer);
} else {
schema = nonDefaultSchema.get(tabPointer);
}
if (schema == null) {
return new BadRequestException("Unknown tab: " + tabName).asPromise();
}
return newResultPromise(newActionResponse(schema));
} else {
return new NotSupportedException("Action not supported: " + actionRequest.getAction()).asPromise();
}
}
Aggregations