IdentityResourceV3.java revision 16682c615640da7d54591f86528a5eb562e0ab97
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/**
* A simple {@code Map} based collection resource provider.
*/
public final class IdentityResourceV3 implements CollectionResourceProvider {
private final String objectType;
private final IdentityServicesImpl identityServices;
private final IdentityResourceV2 identityResourceV2;
/**
* Creates a backend
*/
}
// Constructor used for testing...
IdentityResourceV3(String objectType, ServiceConfigManager serviceConfigManager, ServiceConfig serviceConfig,
this.identityResourceV2 = new IdentityResourceV2(objectType, mailServerLoader, identityServices, coreWrapper,
this.objectType = objectType;
this.identityServices = identityServices;
}
/**
* {@inheritDoc}
*/
public Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request) {
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
final CreateRequest request) {
}
/**
* {@inheritDoc}
*/
final String resourceId,
final DeleteRequest request) {
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
final String resourceId,
final UpdateRequest request) {
}
/*******************************************************************************************************************
* {@inheritDoc}
*/
try {
// If the user specified _queryFilter, then (convert and) use that, otherwise look for _queryID
// and if that isn't there either, pretend the user gave a _queryID of "*"
//
if (queryFilter != null) {
admin);
} else {
queryId = "*";
}
admin);
}
+ realm
+ " by "
+ principalName);
"0",
}
} catch (ResourceException resourceException) {
logger.warning("UserIdentityResourceV3.queryCollection caught ResourceException", resourceException);
return resourceException.asPromise();
}
return newResultPromise(newQueryResponse());
}
/**
* Patch the user's password and only the password. No other value may be patched. The old value of the
* password does not have to be known. Admin only. The only patch operation supported is "replace", i.e. not
* "add" or "move", etc.
*
* @param context The context
* @param resourceId The username we're patching
* @param request The patch request
*/
final String resourceId,
final PatchRequest request) {
}
try {
}
ssoToken);
return new ForbiddenException("User "
+ " is not active: Request is forbidden").asPromise();
}
}
boolean updateNeeded = false;
switch (patchOperation.getOperation()) {
case PatchOperation.OPERATION_REPLACE: {
return new BadRequestException("For the object type "
+ ", field \""
+ name
+ "\" cannot be altered by PATCH").asPromise();
}
updateNeeded = true;
break;
}
default:
return new BadRequestException("PATCH of "
+ " does not support operation "
}
}
if (updateNeeded) {
// re-read the altered identity details from the repo.
ssoToken);
}
} catch (final ObjectNotFound notFound) {
} catch (final TokenExpired tokenExpired) {
} catch (final AccessDenied accessDenied) {
} catch (final GeneralFailure generalFailure) {
logger.error("UserIdentityResourceV3.patchInstance, general failure " + generalFailure.getMessage());
} catch (ForbiddenException fex) {
} catch (NotFoundException notFound) {
} catch (ResourceException resourceException) {
return resourceException.asPromise();
}
}
/**
* Convert attributes into a map.
* @param attributes The attributes to convert.
* @return The map.
*/
}
return result;
}
/**
* Convert a map back into an array of attributes.
* @param map The map to convert.
* @return The, possibly empty, array of attributes.
*/
int index = 0;
index++;
}
return result;
}
/**
* Get the field name of a JsonPointer.
* @param field The field.
* @return The field name.
*/
}
return result;
}
/**
* @return the identity services implementation.
*/
private IdentityServicesImpl getIdentityServices() {
return identityServices;
}
}