RemoveApplicationPrivilegeResources.java revision a4544a5a0e622ef69e38641f87ab1b5685e05911
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: RemoveApplicationPrivilegeResources.java,v 1.2 2009/11/19 01:02:02 veiming Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted 2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.entitlement.ApplicationPrivilege;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.entitlement.ApplicationPrivilegeManager;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.entitlement.EntitlementException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.entitlement.opensso.SubjectUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.forgerock.openam.entitlement.service.ResourceTypeService;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @author dennis
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class RemoveApplicationPrivilegeResources extends ApplicationPrivilegeBase {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public RemoveApplicationPrivilegeResources(ResourceTypeService resourceTypeService) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Services a Commandline Request.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param rc Request Context.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws CLIException if the request cannot serviced.
e60a1cf74ca44a3bb3e3fe63b106e6ef6dca910fPhill Cunnington String realm = getStringOptionValue(IArgument.REALM_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String name = getStringOptionValue(PARAM_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Subject userSubject = SubjectUtils.createSubject(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ApplicationPrivilegeManager.getInstance(realm, userSubject);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "ATTEMPT_UPDATE_APPLICATION_PRIVILEGE", params);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ApplicationPrivilege appPrivilege = apm.getPrivilege(name);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster removeFromMap(origAppToResources, mapAppToResources);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "remove-application-privilege-resources-emptied-resources"),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster appPrivilege.setApplicationResources(origAppToResources);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getOutputWriter().printlnMessage(MessageFormat.format(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster getResourceString("update-application-privilege-succeeded"),
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "SUCCEEDED_UPDATE_APPLICATION_PRIVILEGE", params);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String[] paramExs = {realm, name, ex.getMessage()};
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "FAILED_UPDATE_APPLICATION_PRIVILEGE", paramExs);