SmsRealmProvider.java revision a28658e7b50a29668499ee011576a857117fea4f
/*
* 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.
*/
public class SmsRealmProvider implements RequestHandler {
/**
* Create an amAdmin SSOToken
*
* @return SSOToken adminSSOtoken
*/
private SSOToken getSSOToken() {
}
/**
* Throws an appropriate HTTP status code
*
* @param exception SMSException to be mapped to HTTP Status code
* @throws ForbiddenException
* @throws NotFoundException
* @throws PermanentException
* @throws ConflictException
* @throws BadRequestException
*/
switch (exception.getErrorCode()) {
case "sms-REALM_NAME_NOT_FOUND":
case "sms-INVALID_SSO_TOKEN":
case "sms-organization_already_exists1":
case "sms-invalid-org-name":
case "sms-cannot_delete_rootsuffix":
case "sms-entries-exists":
case "sms-SMSSchema_service_notfound":
case "sms-no-organization-schema":
case "sms-attribute-values-does-not-match-schema":
default:
}
}
public void handleAction(ServerContext context, ActionRequest request, ResultHandler<JsonValue> handler) {
case SmsResourceProvider.TEMPLATE:
return;
case SmsResourceProvider.SCHEMA:
return;
default:
}
}
// TODO locale
field("required", true)
)),
field("required", true)
)),
field("required", true)
)),
field("required", true)
))
))));
}
public void handleCreate(ServerContext serverContext, CreateRequest createRequest, ResultHandler<Resource> resultHandler) {
try {
throw new BadRequestException("No realm name provided");
}
throw new BadRequestException("Realm names cannot contain '/'");
}
}
}
OrganizationConfigManager realmManager = new OrganizationConfigManager(getUserSsoToken(serverContext), parentRealm);
if (debug.messageEnabled()) {
childRealm + " in realm " + parentRealm + " performed by {}", PrincipalRestUtils.getPrincipalNameFromServerContext(serverContext));
}
resultHandler.handleResult(new Resource(childRealm, String.valueOf(jsonValue.hashCode()), jsonValue));
} catch (SMSException e) {
handleError(resultHandler, e);
} catch (SSOException sso) {
} catch (BadRequestException fe) {
}
}
}
/**
* Creates a Map from JsonValue content
*
* @param realmDetails Payload that is from request
* @return Map of new attributes for realm realm
*/
} else {
}
attributes.put(IdConstants.ORGANIZATION_ALIAS_ATTR, new HashSet<>(realmDetails.get("aliases").asCollection(String.class)));
return attributes;
}
public void handleDelete(ServerContext serverContext, DeleteRequest request, ResultHandler<Resource> resultHandler) {
try {
debug.message("RealmResource.deleteInstance :: DELETE of realm " + realmPath + " performed by " + principalName);
} catch (SMSException smse) {
try {
} catch (NotFoundException nf) {
} catch (Exception e) {
}
} catch (Exception e) {
}
}
public void handlePatch(ServerContext context, PatchRequest request, ResultHandler<Resource> handler) {
}
return;
}
return;
}
try {
final OrganizationConfigManager ocm = new OrganizationConfigManager(getUserSsoToken(context), realmPath);
//Return realm query is being performed on
} else {
}
}
} catch (SSOException ex) {
} catch (SMSException ex) {
switch (ex.getExceptionCode()) {
case STATUS_NO_PERMISSION:
// This exception will be thrown if permission to read realms from SMS has not been delegated
break;
default:
break;
}
}
}
public void handleRead(ServerContext context, ReadRequest request, ResultHandler<Resource> resultHandler) {
try {
if (debug.messageEnabled()) {
}
resultHandler.handleResult(new Resource(realmPath, String.valueOf(System.currentTimeMillis()), jsonResponse));
} catch (SMSException smse) {
try {
} catch (NotFoundException nf) {
}
} catch (Exception e) {
}
}
}
} else {
return realmName;
}
}
Set result = (Set) realmManager.getAttributes(ROOT_SERVICE).get("sunidentityrepositoryservice-sunOrganizationStatus");
}
Set<String> result = (Set) realmManager.getAttributes(ROOT_SERVICE).get("sunidentityrepositoryservice-sunOrganizationAliases");
}
public void handleUpdate(ServerContext context, UpdateRequest request, ResultHandler<Resource> handler) {
try {
} catch (BadRequestException e) {
}
try {
handler.handleResult(new Resource(realmPath, String.valueOf(System.currentTimeMillis()), json(object(field("realmUpdated", realmManager.getOrganizationName())))));
} catch (SMSException e) {
handleError(handler, e);
}
}
}
}
try {
} catch (ForbiddenException | PermanentException | ConflictException | BadRequestException | NotFoundException configuredError) {
}
}
/**
* Assigns Services to a realm
*
* @param realmManager Organization Configuration Manager
* @param newServiceNames List of service names to be assigned/unassigned
* @throws SMSException
*/
throws SMSException {
try {
}
}
} catch (SMSException e) {
throw e;
}
}
}