Class XACMLPrivilegeUtils
- java.lang.Object
-
- com.sun.identity.entitlement.xacml3.XACMLPrivilegeUtils
-
public class XACMLPrivilegeUtils extends Object
Class with utility methods to map fromcom.sun.identity.entity.Privilegeto com.sun.identity.entitlement.xacml3.core.Policy
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static List<AnyOf>actionNamesToAnyOfList(Set<String> actionNames, String applicationName)static MatchactionNameToMatch(String actionName, String applicationName)static PolicySetaddPolicyToPolicySet(Policy policy, PolicySet policySet)static AnyOfapplicationNameToAnyOf(String applicationName)static MatchapplicationNameToMatch(String applicationName)static booleancontainsUndesiredCharacters(String s)OPENAM-5031: We would have used DN.escapeAttributeValue to encode the incoming string and compare with the original string - if there are differences then the incoming string contains characters which LDAP requires quoted.static AnyOfentitlementSubjectToAnyOf(EntitlementSubject es)static List<AnyOf>entitlementSubjectToAnyOfList(EntitlementSubject es)static ConditioneSubjectConditionToXCondition(EntitlementSubject es, EntitlementCondition ec)static Map<String,Boolean>getActionValuesFromPolicy(Policy policy)Gets the action values from the policy.static StringgetApplicationNameFromPolicy(Policy policy)Gets the name of the application to which this policy belongs.static EntitlementConditiongetEntitlementConditionFromPolicy(Policy policy)Constructs EntitlementCondition from the policy.static EntitlementSubjectgetEntitlementSubjectFromPolicy(Policy policy)Constructs EntitlementSubject from policy.static Set<Policy>getPoliciesFromPolicySet(PolicySet policySet)static Set<String>getResourceNamesFromPolicy(Policy policy)Gets the resource names from the policy.static StringgetRuleCombiningAlgId(String applicationName)static StringgetVariableById(Policy policy, String id)static booleanisReferralPolicy(Policy policy)static PolicySetnewPolicySet(String realm)static StringpolicyIdToPrivilegeName(String policyId)static Set<Privilege>policySetToPrivileges(PolicySet policySet)static PrivilegepolicyToPrivilege(Policy policy)static ReferralPrivilegepolicyToReferral(Policy policy)static StringprivilegeNameToPolicyId(String privilegeName, String applicationName)static PolicySetprivilegesToPolicySet(String realm, Collection<Privilege> privileges)static PolicyprivilegeToPolicy(Privilege privilege)static AnyOfrealmsAppsResourcesToAnyOf(Set<String> realms, Map<String,Set<String>> appsResources)static PolicyreferralToPolicy(ReferralPrivilege privilege)static PolicyreferralToPolicyInternal(ReferralPrivilege privilege)static List<AnyOf>resourceNamesToAnyOfList(Set<String> resourceNames, String applicationName)static MatchresourceNameToMatch(String resourceName, String applicationName)static MatchresourceNameToNotMatch(String resourceName, String applicationName)static PolicySetstreamToPolicySet(InputStream stream)static StringtoXACML(Privilege privilege)static StringtoXML(Policy policy)static StringtoXML(PolicySet policySet)static voidvalidate(Privilege privilege, PrivilegeValidator privilegeValidator)Validates the privilege instance.static voidwriteXMLToStream(PolicySet policySet, OutputStream outputStream)
-
-
-
Method Detail
-
toXML
public static String toXML(PolicySet policySet) throws EntitlementException
- Throws:
EntitlementException
-
writeXMLToStream
public static void writeXMLToStream(PolicySet policySet, OutputStream outputStream) throws EntitlementException
- Throws:
EntitlementException
-
privilegeNameToPolicyId
public static String privilegeNameToPolicyId(String privilegeName, String applicationName)
-
entitlementSubjectToAnyOfList
public static List<AnyOf> entitlementSubjectToAnyOfList(EntitlementSubject es)
-
entitlementSubjectToAnyOf
public static AnyOf entitlementSubjectToAnyOf(EntitlementSubject es) throws JAXBException
- Throws:
JAXBException
-
resourceNamesToAnyOfList
public static List<AnyOf> resourceNamesToAnyOfList(Set<String> resourceNames, String applicationName)
-
actionNamesToAnyOfList
public static List<AnyOf> actionNamesToAnyOfList(Set<String> actionNames, String applicationName)
-
resourceNameToMatch
public static Match resourceNameToMatch(String resourceName, String applicationName)
-
resourceNameToNotMatch
public static Match resourceNameToNotMatch(String resourceName, String applicationName)
-
eSubjectConditionToXCondition
public static Condition eSubjectConditionToXCondition(EntitlementSubject es, EntitlementCondition ec) throws JAXBException
- Throws:
JAXBException
-
policySetToPrivileges
public static Set<Privilege> policySetToPrivileges(PolicySet policySet) throws EntitlementException
- Throws:
EntitlementException
-
policyToPrivilege
public static Privilege policyToPrivilege(Policy policy) throws EntitlementException
- Throws:
EntitlementException
-
getApplicationNameFromPolicy
public static String getApplicationNameFromPolicy(Policy policy)
Gets the name of the application to which this policy belongs.- Parameters:
policy- read from XACML import stream.- Returns:
- application name.
-
getResourceNamesFromPolicy
public static Set<String> getResourceNamesFromPolicy(Policy policy)
Gets the resource names from the policy.- Parameters:
policy- read from XACML import stream.- Returns:
- resource names.
-
privilegesToPolicySet
public static PolicySet privilegesToPolicySet(String realm, Collection<Privilege> privileges)
-
newPolicySet
public static PolicySet newPolicySet(String realm) throws JAXBException
- Throws:
JAXBException
-
addPolicyToPolicySet
public static PolicySet addPolicyToPolicySet(Policy policy, PolicySet policySet) throws JAXBException
- Throws:
JAXBException
-
getActionValuesFromPolicy
public static Map<String,Boolean> getActionValuesFromPolicy(Policy policy)
Gets the action values from the policy.- Parameters:
policy- instance read from the XACML input stream.- Returns:
- action values.
-
getEntitlementSubjectFromPolicy
public static EntitlementSubject getEntitlementSubjectFromPolicy(Policy policy)
Constructs EntitlementSubject from policy.- Parameters:
policy- from which the EntitlementSubject is created.- Returns:
- EntitlementSubject created from the policy instance.
-
getEntitlementConditionFromPolicy
public static EntitlementCondition getEntitlementConditionFromPolicy(Policy policy) throws EntitlementException
Constructs EntitlementCondition from the policy.- Parameters:
policy- from which EntitlementCondition is constructed.- Returns:
- EntitlementCondition instance created from the policy instance.
- Throws:
EntitlementException- when any error occurs during construction.
-
streamToPolicySet
public static PolicySet streamToPolicySet(InputStream stream) throws JAXBException
- Throws:
JAXBException
-
referralToPolicy
public static Policy referralToPolicy(ReferralPrivilege privilege) throws org.json.JSONException
- Throws:
org.json.JSONException
-
referralToPolicyInternal
public static Policy referralToPolicyInternal(ReferralPrivilege privilege) throws JAXBException, org.json.JSONException
- Throws:
JAXBExceptionorg.json.JSONException
-
isReferralPolicy
public static boolean isReferralPolicy(Policy policy)
-
policyToReferral
public static ReferralPrivilege policyToReferral(Policy policy) throws EntitlementException, org.json.JSONException
- Throws:
EntitlementExceptionorg.json.JSONException
-
realmsAppsResourcesToAnyOf
public static AnyOf realmsAppsResourcesToAnyOf(Set<String> realms, Map<String,Set<String>> appsResources) throws org.json.JSONException
- Throws:
org.json.JSONException
-
validate
public static void validate(Privilege privilege, PrivilegeValidator privilegeValidator) throws EntitlementException
Validates the privilege instance.- Parameters:
privilege- instance to be validated.privilegeValidator- the validator for privilege.- Throws:
EntitlementException- if the privilege is invalid.
-
containsUndesiredCharacters
public static boolean containsUndesiredCharacters(String s)
OPENAM-5031: We would have used DN.escapeAttributeValue to encode the incoming string and compare with the original string - if there are differences then the incoming string contains characters which LDAP requires quoted. However ssoadm doesn't include the jar that the DN class ends up in. In order to avoid the overhead of adding a whole jar just for one function in one class, this is provided here. Thus, this function returns true if the incoming string contains any character which LDAP requires to be quoted.- Parameters:
s- The specified string.- Returns:
- true if the string contains characters which require quotation for LDAP to work, false otherwise
-
-