/*
* 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 2014-2016 ForgeRock AS.
*/
import static org.forgerock.openam.forgerockrest.utils.PrincipalRestUtils.getPrincipalNameFromSubject;
/**
* Endpoint for the ApplicationsResource.
*
* This endpoint supports the CRUDQ operations. It uses the
* Jackson library and annotated wrapper classes to generate the
* pojos that it will store. Similarly, when reading out from the
* data store, we wrap the object to allow Jackson to do the serialization
* leg for us.
*
*/
mvccSupported = false,
),
name = "applicationName",
type = "string",
)
)
private final ExceptionMappingHandler<EntitlementException, ResourceException> exceptionMappingHandler;
/**
* @param debug Debug instance.
* @param applicationServiceFactory Application service factory responsible for creating the application service.
* @param appTypeManagerWrapper instantiable version of the static ApplicationTypeManager class. Cannot be null.
* @param exceptionMappingHandler Error handler to convert EntitlementExceptions to ResourceExceptions.
*/
public ApplicationsResource(@Named("frRest") Debug debug, ApplicationServiceFactory applicationServiceFactory,
}
}
/**
* Not Supported Action Collection Operation.
*
* @param context {@inheritDoc}
* @param request {@inheritDoc}
*/
public Promise<ActionResponse, ResourceException> actionCollection(Context context, ActionRequest request) {
return RestUtils.generateUnsupportedOperation();
}
/**
* Not Supported Action Instance Operation.
*
* @param context {@inheritDoc}
* @param resourceId {@inheritDoc}
* @param request {@inheritDoc}
*/
public Promise<ActionResponse, ResourceException> actionInstance(Context context, String resourceId,
return RestUtils.generateUnsupportedOperation();
}
/**
* Create an {@link Application}.
*
* @param context {@inheritDoc}
* @param request {@inheritDoc}
*/
@Create(
errors = {
@ApiError(
code = BAD_REQUEST,
),
@ApiError(
code = UNAUTHORIZED,
),
@ApiError(
)
}
)
)
public Promise<ResourceResponse, ResourceException> createInstance(Context context, CreateRequest request) {
return new BadRequestException().asPromise();
}
try {
}
Application application = appService(subject, realm).saveApplication(applicationWrapper.getApplication());
} catch (EntitlementException e) {
}
}
/**
* Abstracts out the createApplicationWrapper method so that we can easily test this class.
*
* @param jsonValue The JsonValue to create the wrapper from
* @return An ApplicationWrapper, wrapping the Application represented by the JsonValue provided
* @throws EntitlementException If there were errors writing the application to disk
*/
protected ApplicationWrapper createApplicationWrapper(JsonValue jsonValue) throws EntitlementException {
try {
} catch (IOException e) {
}
}
/**
* Creates an {@link ApplicationWrapper} to hold the {@link Application} object, after having deserialized it
* via Jackson.
*
* @param jsonValue The JSON to deserialize
* @param mySubject The subject authorizing the request
* @return An ApplicationWrapper containing an Application, null
* @throws EntitlementException If there were issues generating the application wrapper
*/
throws EntitlementException {
"Specified Application Type was not available.");
}
return wrapp;
}
/**
* Creates an {@link ApplicationWrapper} to hold the {@link Application} object.
* <p/>
* This method provides an abstraction to aid testing.
*
* @param application
* The application
* @param type
* The application type
*
* @return A new {@link ApplicationWrapper} wrapping the passed application
*/
protected ApplicationWrapper createApplicationWrapper(Application application, ApplicationTypeManagerWrapper type) {
}
/**
* Deletes an {@link Application} as per the {@link DeleteRequest}.
*
* @param context {@inheritDoc}
* @param resourceId {@inheritDoc}
* @param request {@inheritDoc}
*/
@Delete(
errors = {
@ApiError(
code = UNAUTHORIZED,
),
@ApiError(
)
}
)
)
public Promise<ResourceResponse, ResourceException> deleteInstance(Context context, String resourceId,
return new BadRequestException().asPromise();
}
try {
}
} catch (EntitlementException e) {
debug.error("ApplicationsResource :: DELETE by {}: Application failed to delete the resource specified. ",
}
}
/**
* Not Supported Patch Operation.
*
* @param context {@inheritDoc}
* @param resourceId {@inheritDoc}
* @param request {@inheritDoc}
*/
public Promise<ResourceResponse, ResourceException> patchInstance(Context context, String resourceId,
return RestUtils.generateUnsupportedOperation();
}
/**
* Queries for a collection of resources.
*
* @param context {@inheritDoc}
* @param request {@inheritDoc}
* @param handler {@inheritDoc}
*/
@Query(
),
queryableFields = "*"
)
public Promise<QueryResponse, ResourceException> queryCollection(Context context, QueryRequest request,
return new BadRequestException().asPromise();
}
if (queryFilter == null) {
// Return everything
}
QueryFilter<String> stringQueryFilter = queryFilter.accept(new QueryByStringFilterConverter(), null);
try {
}
} catch (EntitlementException e) {
}
}
/**
* Reads an instance of an application.
*
* @param context {@inheritDoc}
* @param resourceId {@inheritDoc}
* @param request {@inheritDoc}
*/
@Read(
errors = {
@ApiError(
code = UNAUTHORIZED,
),
@ApiError(
)
}
)
)
public Promise<ResourceResponse, ResourceException> readInstance(Context context, String resourceId,
return new BadRequestException().asPromise();
}
try {
if (application == null) {
}
ApplicationWrapper applicationWrapper = createApplicationWrapper(application, appTypeManagerWrapper);
} catch (EntitlementException e) {
debug.error("ApplicationsResource :: READ by {}: Application failed to retrieve the resource specified.",
}
}
/**
* Updates an existing {@link Application}.
* The resourceId is the name of the application to update.
* The new Application may alter this name, but doing so will mean the original
* resourceId will no longer reference the new Application.
*
* @param context {@inheritDoc}
* @param resourceId {@inheritDoc}
* @param request {@inheritDoc}
*/
@Update(
errors = {
@ApiError(
code = BAD_REQUEST,
),
@ApiError(
code = UNAUTHORIZED,
),
@ApiError(
),
@ApiError(
)
}
)
)
public Promise<ResourceResponse, ResourceException> updateInstance(Context context, String resourceId,
return new BadRequestException().asPromise();
}
try {
}
Application application = appService(subject, realm).saveApplication(applicationWrapper.getApplication());
} catch (EntitlementException e) {
}
}
private boolean applicationExists(String applicationId, String realm, Subject subject) throws EntitlementException {
return isNotEmpty(appService(subject, realm).search(QueryFilter.equalTo(NAME_ATTRIBUTE, applicationId)));
}
throws EntitlementException {
}
}
if (isBlank(applicationId)) {
}
}
if (applicationId == null) {
}
// OPENAM-5031
// This is a bad solution and should be rewritten when we have time. This code rejects anything in the
// name that when encoded differs from the original. So, for instance "+" becomes "\+".
// What we should do is to encode the name for storage purposes, and decode it before presentation to the
// user.
throw new EntitlementException(EntitlementException.INVALID_VALUE, "policy name \"" + applicationId + "\"");
}
}
}
}