Class MetadataPolicy
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.federation.policy.MetadataPolicy
-
- All Implemented Interfaces:
net.minidev.json.JSONAware
public class MetadataPolicy extends Object implements net.minidev.json.JSONAware
Policy for a federation entity metadata.Example:
{ "scopes" : { "subset_of" : [ "openid", "eduperson", "phone" ], "superset_of" : [ "openid" ], "default" : [ "openid", "eduperson" ] }, "id_token_signed_response_alg" : { "one_of" : [ "ES256", "ES384", "ES512" ] }, "contacts" : { "add" : "[email protected]" }, "application_type" : { "value": "web" } }
Related specifications:
- OpenID Connect Federation 1.0, section 4.1.
-
-
Constructor Summary
Constructors Constructor Description MetadataPolicy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description net.minidev.json.JSONObject
apply(net.minidev.json.JSONObject metadata)
Applies this policy to the specified metadata.static MetadataPolicy
combine(List<MetadataPolicy> policies)
Combines the specified list of metadata policies.static MetadataPolicy
combine(List<MetadataPolicy> policies, PolicyOperationCombinationValidator combinationValidator)
Combines the specified list of metadata policies.Set<MetadataPolicyEntry>
entrySet()
Gets the policy entries set.List<PolicyOperation>
get(String parameterName)
Gets the policy operations for the specified metadata parameter name.MetadataPolicyEntry
getEntry(String parameterName)
Gets the policy entry for the specified metadata parameter name.static MetadataPolicy
parse(String policySpec)
Parses a policy for a federation entity metadata.static MetadataPolicy
parse(String policySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator)
Parses a policy for a federation entity metadata.static MetadataPolicy
parse(net.minidev.json.JSONObject policySpec)
Parses a policy for a federation entity metadata.static MetadataPolicy
parse(net.minidev.json.JSONObject policySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator)
Parses a policy for a federation entity metadata.void
put(MetadataPolicyEntry entry)
Puts a policy entry for a metadata parameter.void
put(String parameterName, PolicyOperation policyOperation)
Puts a policy entry for a metadata parameter.void
put(String parameterName, List<PolicyOperation> policyOperations)
Puts a policy entry for a metadata parameter.List<PolicyOperation>
remove(String parameterName)
Removes a policy entry.net.minidev.json.JSONObject
toJSONObject()
Returns a JSON object representation of this metadata policy.String
toJSONString()
String
toString()
-
-
-
Constructor Detail
-
MetadataPolicy
public MetadataPolicy()
-
-
Method Detail
-
apply
public net.minidev.json.JSONObject apply(net.minidev.json.JSONObject metadata) throws PolicyViolationException
Applies this policy to the specified metadata.- Parameters:
metadata
- The metadata as JSON object. May benull
.- Returns:
- The resulting metadata,
null
if not specified. - Throws:
PolicyViolationException
- On a policy violation.
-
put
public void put(String parameterName, PolicyOperation policyOperation)
Puts a policy entry for a metadata parameter.- Parameters:
parameterName
- The parameter name. Must not benull
.policyOperation
- The policy operation for the parameter,null
if none.
-
put
public void put(String parameterName, List<PolicyOperation> policyOperations)
Puts a policy entry for a metadata parameter.- Parameters:
parameterName
- The parameter name. Must not benull
.policyOperations
- The ordered policy operations for the parameter,null
if none.
-
put
public void put(MetadataPolicyEntry entry)
Puts a policy entry for a metadata parameter.- Parameters:
entry
- The policy entry. Must not benull
.
-
get
public List<PolicyOperation> get(String parameterName)
Gets the policy operations for the specified metadata parameter name.- Parameters:
parameterName
- The parameter name. Must not benull
.- Returns:
- The ordered policy operations for the parameter,
null
if none.
-
getEntry
public MetadataPolicyEntry getEntry(String parameterName)
Gets the policy entry for the specified metadata parameter name.- Parameters:
parameterName
- The parameter name. Must not benull
.- Returns:
- The policy entry for the parameter,
null
if none.
-
entrySet
public Set<MetadataPolicyEntry> entrySet()
Gets the policy entries set.- Returns:
- The policy entries set.
-
remove
public List<PolicyOperation> remove(String parameterName)
Removes a policy entry.- Parameters:
parameterName
- The parameter name. Must not benull
.- Returns:
- The ordered policy operations for the removed parameter,
null
if not found.
-
toJSONObject
public net.minidev.json.JSONObject toJSONObject()
Returns a JSON object representation of this metadata policy.- Returns:
- The JSON object.
-
toJSONString
public String toJSONString()
- Specified by:
toJSONString
in interfacenet.minidev.json.JSONAware
-
combine
public static MetadataPolicy combine(List<MetadataPolicy> policies) throws PolicyViolationException
Combines the specified list of metadata policies. Uses thedefault policy combination validator
.- Parameters:
policies
- The metadata policies. Must not be empty ornull
.- Returns:
- The new combined metadata policy.
- Throws:
PolicyViolationException
- On a policy violation.
-
combine
public static MetadataPolicy combine(List<MetadataPolicy> policies, PolicyOperationCombinationValidator combinationValidator) throws PolicyViolationException
Combines the specified list of metadata policies.- Parameters:
policies
- The metadata policies. Must not be empty ornull
.combinationValidator
- The policy operation combination validator. Must not benull
.- Returns:
- The new combined metadata policy.
- Throws:
PolicyViolationException
- On a policy violation.
-
parse
public static MetadataPolicy parse(net.minidev.json.JSONObject policySpec) throws ParseException, PolicyViolationException
Parses a policy for a federation entity metadata. This method is intended for policies with standardPolicyOperation
s only. Uses the defaultpolicy operation
andpolicy combination validator
factories.- Parameters:
policySpec
- The JSON object string for the policy specification. Must not benull
.- Returns:
- The metadata policy.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
parse
public static MetadataPolicy parse(net.minidev.json.JSONObject policySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator) throws ParseException, PolicyViolationException
Parses a policy for a federation entity metadata. This method is intended for policies including non-standardPolicyOperation
s.- Parameters:
policySpec
- The JSON object for the policy specification. Must not benull
.factory
- The policy operation factory. Must not benull
.combinationValidator
- The policy operation combination validator. Must not benull
.- Returns:
- The metadata policy.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
parse
public static MetadataPolicy parse(String policySpec) throws ParseException, PolicyViolationException
Parses a policy for a federation entity metadata. This method is intended for policies with standardPolicyOperation
s only. Uses the defaultpolicy operation
andpolicy combination validator
factories.- Parameters:
policySpec
- The JSON object string for the policy specification. Must not benull
.- Returns:
- The metadata policy.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
parse
public static MetadataPolicy parse(String policySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator) throws ParseException, PolicyViolationException
Parses a policy for a federation entity metadata. This method is intended for policies including non-standardPolicyOperation
s.- Parameters:
policySpec
- The JSON object for the policy specification. Must not benull
.factory
- The policy operation factory. Must not benull
.combinationValidator
- The policy operation combination validator. Must not benull
.- Returns:
- The metadata policy.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
-