UmaLabelResource.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 collection provider for UMA Labels.
* @Since 13.0.0
*/
public class UmaLabelResource implements CollectionResourceProvider {
private final UmaLabelsStore labelStore;
private final ContextHelper contextHelper;
private final ClientRegistrationStore clientRegistrationStore;
this.labelStore = labelStore;
this.contextHelper = contextHelper;
}
}
}
try {
} catch (BadRequestException e) {
return e.asPromise();
}
final ResourceSetLabel label;
try {
label = labelStore.create(realm, userName, new ResourceSetLabel(null, labelName, LabelType.valueOf(labelType), Collections.EMPTY_SET));
return newResultPromise(newResourceResponse(label.getId(), String.valueOf(label.hashCode()), label.asJson()));
} catch (ResourceException e) {
return e.asPromise();
}
}
try {
} catch (JsonValueException e) {
}
}
public Promise<ResourceResponse, ResourceException> deleteInstance(Context serverContext, String labelId,
try {
ResourceSetLabel resourceSetLabel = labelStore.read(getRealm(serverContext), getUserName(serverContext), labelId);
throw new BadRequestException("Revision number doesn't match latest revision.");
}
} catch (ResourceException e) {
}
}
return true;
}
}
}
}
try {
} catch (ResourceException e) {
}
try {
} catch (InternalServerErrorException e) {
}
}
return newResultPromise(newQueryResponse());
}
private ResourceSetLabel resolveLabelName(String realm, ResourceSetLabel label, LocaleContext localeContext)
throws InternalServerErrorException {
if (resourceServerName != null) {
}
}
return label;
}
private String resolveResourceServerName(String resourceServerId, final String realm, LocaleContext localeContext)
throws InternalServerErrorException {
try {
ClientRegistration clientRegistration = clientRegistrationStore.get(resourceServerId, new OAuth2Request() {
public <T> T getRequest() {
throw new UnsupportedOperationException("Realm parameter only OAuth2Request");
}
return (T) realm;
}
throw new UnsupportedOperationException("Realm parameter only OAuth2Request");
}
return null;
}
return null;
}
});
} catch (InvalidClientException | NotFoundException e) {
throw new InternalServerErrorException("Could not resolve Resource Server label name", e);
}
}
}
}
}
}
}