Java Code Examples for org.wso2.balana.PolicyReference#POLICY_REFERENCE
The following examples show how to use
org.wso2.balana.PolicyReference#POLICY_REFERENCE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimplePolicyCollection.java From carbon-identity-framework with Apache License 2.0 | 6 votes |
@Override public AbstractPolicy getPolicy(URI identifier, int type, VersionConstraints constraints) { AbstractPolicy policy = policyCollection.get(identifier); if (policy != null) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) { return policy; } } else { if (policy instanceof PolicySet) { return policy; } } } return null; }
Example 2
Source File: SimplePolicyCollection.java From carbon-identity with Apache License 2.0 | 6 votes |
@Override public AbstractPolicy getPolicy(URI identifier, int type, VersionConstraints constraints) { AbstractPolicy policy = policyCollection.get(identifier); if (policy != null) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) return policy; } else { if (policy instanceof PolicySet) return policy; } } return null; }
Example 3
Source File: FileBasedPolicyFinderModule.java From balana with Apache License 2.0 | 6 votes |
@Override public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData) { AbstractPolicy policy = policies.get(idReference); if (policy != null) { if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) { return new PolicyFinderResult(policy); } } else { if (policy instanceof PolicySet) { return new PolicyFinderResult(policy); } } } // if there was an error loading the policy, return the error ArrayList<String> code = new ArrayList<String>(); code.add(Status.STATUS_PROCESSING_ERROR); Status status = new Status(code, "couldn't load referenced policy"); return new PolicyFinderResult(status); }
Example 4
Source File: PolicyCombinerElement.java From balana with Apache License 2.0 | 6 votes |
/** * Encodes this <code>PolicyCombinerElement</code> into its XML form and writes this out to the provided * <code>StringBuilder<code> * * @param builder string stream into which the XML-encoded data is written */ public void encode(StringBuilder builder) { if (!getParameters().isEmpty()) { AbstractPolicy policy = getPolicy(); // FIXME: This is ugly and happens in several places...maybe this // should get folded into the AbstractPolicy API? if (policy instanceof Policy) { encodeParamaters(builder, "Policy", policy.getId().toString()); } else if (policy instanceof PolicySet) { encodeParamaters(builder, "PolicySet", policy.getId().toString()); } else { PolicyReference ref = (PolicyReference) policy; if (ref.getReferenceType() == PolicyReference.POLICY_REFERENCE) encodeParamaters(builder, "Policy", ref.getReference().toString()); else encodeParamaters(builder, "PolicySet", ref.getReference().toString()); } } getPolicy().encode(builder); }
Example 5
Source File: PAPPolicyFinder.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData) { // clear all current policies policies.getPolicies().clear(); AbstractPolicy policy = null; try { AbstractPolicy policyFromStore = policyReader.readPolicy(idReference.toString(), this.policyFinder); if (policyFromStore != null) { if (type == PolicyReference.POLICY_REFERENCE) { if (policyFromStore instanceof Policy) { policy = policyFromStore; policies.addPolicy(policy); } } else { if (policyFromStore instanceof PolicySet) { policy = policyFromStore; policies.addPolicy(policy); } } } } catch (EntitlementException e) { // ignore and just log the error. log.error(e); } if (policy == null) { return new PolicyFinderResult(); } else { return new PolicyFinderResult(policy); } }
Example 6
Source File: DefaultPolicyCollection.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
/** * Attempts to retrieve a policy based on the given identifier and other constraints. If there * are multiple versions of the identified policy that meet the version constraints, then the * most recent version is returned. * * @param identifier * @param type * @param constraints * @return */ public AbstractPolicy getPolicy(URI identifier, int type, VersionConstraints constraints) { TreeSet<AbstractPolicy> set = policies.get(identifier.toString()); // if we don't know about this identifier then there's nothing to do if (set == null) return null; // walk through the set starting with the most recent version, looking // for a match until we exhaust all known versions Iterator<AbstractPolicy> it = set.iterator(); while (it.hasNext()) { AbstractPolicy policy = (AbstractPolicy) (it.next()); if (constraints.meetsConstraint(policy.getVersion())) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) return policy; } else { if (policy instanceof PolicySet) return policy; } } } // we didn't find a match return null; }
Example 7
Source File: CarbonPolicyFinder.java From carbon-identity-framework with Apache License 2.0 | 5 votes |
@Override public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData) { AbstractPolicy policy = policyReferenceCache.get(idReference); if (policy == null) { if (this.finderModules != null) { for (PolicyFinderModule finderModule : this.finderModules) { String policyString = finderModule.getReferencedPolicy(idReference.toString()); if (policyString != null) { policy = policyReader.getPolicy(policyString); if (policy != null) { policyReferenceCache.put(idReference, policy); break; } } } } } if (policy != null) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) { return new PolicyFinderResult(policy); } } else { if (policy instanceof PolicySet) { return new PolicyFinderResult(policy); } } } return new PolicyFinderResult(); }
Example 8
Source File: PAPPolicyFinder.java From carbon-identity with Apache License 2.0 | 5 votes |
public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData) { // clear all current policies policies.getPolicies().clear(); AbstractPolicy policy = null; try { AbstractPolicy policyFromStore = policyReader.readPolicy(idReference.toString(), this.policyFinder); if (policyFromStore != null) { if (type == PolicyReference.POLICY_REFERENCE) { if (policyFromStore instanceof Policy) { policy = policyFromStore; policies.addPolicy(policy); } } else { if (policyFromStore instanceof PolicySet) { policy = policyFromStore; policies.addPolicy(policy); } } } } catch (EntitlementException e) { // ignore and just log the error. log.error(e); } if (policy == null) { return new PolicyFinderResult(); } else { return new PolicyFinderResult(policy); } }
Example 9
Source File: DefaultPolicyCollection.java From carbon-identity with Apache License 2.0 | 5 votes |
/** * Attempts to retrieve a policy based on the given identifier and other constraints. If there * are multiple versions of the identified policy that meet the version constraints, then the * most recent version is returned. * * @param identifier * @param type * @param constraints * @return */ public AbstractPolicy getPolicy(URI identifier, int type, VersionConstraints constraints) { TreeSet<AbstractPolicy> set = policies.get(identifier.toString()); // if we don't know about this identifier then there's nothing to do if (set == null) return null; // walk through the set starting with the most recent version, looking // for a match until we exhaust all known versions Iterator<AbstractPolicy> it = set.iterator(); while (it.hasNext()) { AbstractPolicy policy = (AbstractPolicy) (it.next()); if (constraints.meetsConstraint(policy.getVersion())) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) return policy; } else { if (policy instanceof PolicySet) return policy; } } } // we didn't find a match return null; }
Example 10
Source File: CarbonPolicyFinder.java From carbon-identity with Apache License 2.0 | 5 votes |
@Override public PolicyFinderResult findPolicy(URI idReference, int type, VersionConstraints constraints, PolicyMetaData parentMetaData) { AbstractPolicy policy = policyReferenceCache.get(idReference); if (policy == null) { if (this.finderModules != null) { for (PolicyFinderModule finderModule : this.finderModules) { String policyString = finderModule.getReferencedPolicy(idReference.toString()); if (policyString != null) { policy = policyReader.getPolicy(policyString); if (policy != null) { policyReferenceCache.put(idReference, policy); break; } } } } } if (policy != null) { // we found a valid version, so see if it's the right kind, // and if it is then we return it if (type == PolicyReference.POLICY_REFERENCE) { if (policy instanceof Policy) { return new PolicyFinderResult(policy); } } else { if (policy instanceof PolicySet) { return new PolicyFinderResult(policy); } } } return new PolicyFinderResult(); }