PrivilegeUtils.java revision ba3008548cd047b233fcd32bb3c5d69926eed22f
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
*
* 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
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/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 Copyrighted [year] [name of copyright owner]"
*
* $Id: PrivilegeUtils.java,v 1.4 2010/01/07 00:19:11 veiming Exp $
*/
/*
* Portions Copyrighted 2014 ForgeRock AS
*/
/**
* Class with utility methods to map from
* <code>com.sun.identity.entity.Privilege</code>
* to
* </code>com.sun.identity.policy.Policy</code>
*/
public class PrivilegeUtils {
private static ServiceTypeManager svcTypeManager;
static {
try {
} catch (SSOException ex) {
}
}
/**
* Constructs XACMLPrivilegeUtils
*/
private PrivilegeUtils() {
}
/**
* Maps an OpenAM Policy to entitlement Privilege
* @param policyObject OpenAM Policy object
* @return entitlement Privilege object
* @throws com.sun.identity.policy.PolicyException if the mapping fails
*/
if (policyObject == null) {
return Collections.EMPTY_SET;
}
if (policyObject instanceof
privileges.add(p);
} else if (policyObject instanceof Policy) {
} else {
}
return privileges;
}
if (policy.isReferralPolicy()) {
} else {
} else {
for (Entitlement e : entitlements) {
}
}
}
}
private static Privilege createPrivilege(
Entitlement e,
) throws EntitlementException {
return privilege;
}
throws PolicyException {
new HashSet<EntitlementSubject>();
if (subjectNames != null) {
boolean dealtWith = false;
/*
if (subject instanceof AMIdentitySubject) {
AMIdentitySubject sbj = (AMIdentitySubject) subject;
Set<EntitlementSubject> eSubjects = toEntitlementSubject(
sbj, exclusive);
if (!eSubjects.isEmpty()) {
entitlementSubjects.addAll(eSubjects);
dealtWith = true;
}
} else if (subject instanceof AuthenticatedUsers) {
AuthenticatedUsers sbj = (AuthenticatedUsers)subject;
Set<EntitlementSubject> eSubjects = toEntitlementSubject(
sbj, exclusive);
if (!eSubjects.isEmpty()) {
entitlementSubjects.addAll(eSubjects);
dealtWith = true;
}
} */
if (!dealtWith) {
}
}
}
}
if (entitlementSubjects.isEmpty()) {
return null;
}
new OrSubject(entitlementSubjects);
}
throws PolicyException, EntitlementException {
}
return nConditionsToECondition(nConditions);
}
throws PolicyException, EntitlementException {
}
return nrpsToResourceAttributes(nrps);
}
throws NameNotFoundException {
}
return rules;
}
throws NameNotFoundException {
if (ruleResources != null) {
if (resourceNames == null) {
}
}
}
return results;
}
throws NameNotFoundException {
} else {
}
}
}
return results;
}
if (ruleResources != null) {
}
}
return entitlements;
}
private static EntitlementCondition nConditionsToECondition(Set nConditons) throws EntitlementException {
}
return null;
}
}
Map<String, Set<EntitlementCondition>> cnEntcMap = new HashMap<String, Set<EntitlementCondition>>();
}
}
}
} else {
}
}
return new AndCondition(andSet);
}
private static EntitlementSubject mapGenericSubject(
boolean exclusive) {
try {
return es;
} else {
}
} catch (ClassNotFoundException e) {
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
}
return null;
}
if (rp instanceof ResponseProvider) {
}
return results;
}
return null;
}
private static EntitlementCondition mapGenericCondition(
try {
return ec;
} else if (objCondition instanceof Condition) {
}
} catch (ClassNotFoundException e) {
"PrivilegeUtils.mapGenericCondition", e);
} catch (InstantiationException e) {
"PrivilegeUtils.mapGenericCondition", e);
} catch (IllegalAccessException e) {
"PrivilegeUtils.mapGenericCondition", e);
}
return null;
}
public static Object privilegeToPolicyObject(
} else {
}
return policyObject;
}
referralPrivilege.getDescription(), true);
int count = 1;
}
count = 1;
if (application == null) {
}
}
}
return policy;
}
}
}
}
}
}
}
return policy;
}
/**
* Determine a name to use for this subject. If the subject is a legacy policy subject then use the name (if any)
* associated with that. Otherwise, generate a random name.
*
* @param subject the subject to generate a name for.
* @return a suitable name for the subject.
*/
if (subject instanceof PolicySubject) {
}
name = randomName();
}
return name;
}
/**
* Determins a name to use for this condition. If the condition is a legacy policy condition then use the name
* (if any) associated with that. Otherwise, generate a random name.
*
* @param condition the condition to generate a name for.
* @return a suitable name for the condition.
*/
if (condition instanceof PolicyCondition) {
}
name = randomName();
}
return name;
}
if (application == null) {
}
if (resourceNames != null) {
entName = "entitlement";
}
}
return rules;
}
if (es instanceof PolicySubject) {
// It already is one captain!
}
return ps;
}
if (ec instanceof PolicyCondition) {
}
return pc;
}
private static Set<ResourceAttribute> nrpsToResourceAttributes(Set nrps) throws EntitlementException {
if (rp instanceof IDRepoResponseProvider) {
} else if (rp instanceof ResponseProvider) {
}
}
}
return resourceAttributesSet;
}
sa = new StaticAttributes();
}
}
}
}
ua = new UserAttributes();
}
}
}
}
}
return results;
}
if (resourceAttributes != null) {
if (ra instanceof StaticAttributes) {
} else if (ra instanceof UserAttributes) {
}
}
}
}
// Copy any legacy response providers over directly
if (ra instanceof PolicyResponseProvider) {
}
}
}
return results;
}
private static void resourceAttributesToResponseProviders(
}
}
}
private static void resourceAttributesToResponseProviders(
}
}
}
private static void getResponseAttributeValues(
for (String v : propertyValues) {
}
} else {
}
}
private static String randomName() {
}
static Map pravToPav(Map<String, Boolean> actionValues, String serviceName) throws PolicyException, SSOException {
if (actionValues == null) {
return null;
}
try {
} catch (NameNotFoundException e) {
//ignore
}
try {
if (serviceType != null) {
} else {
}
} else {
}
} catch (InvalidNameException e) {
}
}
return av;
}
if (actionValues == null) {
return null;
}
if (serviceName != null) {
try {
} catch (NameNotFoundException e) {
//ignore
}
}
} else {
if (serviceType != null) {
try {
} else {
}
} else {
// Append action value to action name
}
} catch (InvalidNameException e) {
}
} else {
}
}
}
return av;
}
} else {
}
return xmlString;
}
} else {
}
return name;
}
//TODO: implement method, objectToPrivileges(Object object)
} else {
}
return privileges;
}
}