Class MetadataPolicyEntry
- java.lang.Object
-
- com.nimbusds.openid.connect.sdk.federation.policy.MetadataPolicyEntry
-
- All Implemented Interfaces:
Map.Entry<String,List<PolicyOperation>>
public class MetadataPolicyEntry extends Object implements Map.Entry<String,List<PolicyOperation>>
Policy entry for a metadata parameter.
-
-
Field Summary
Fields Modifier and Type Field Description static PolicyOperationCombinationValidator
DEFAULT_POLICY_COMBINATION_VALIDATOR
The default policy operation combination validator.static PolicyOperationFactory
DEFAULT_POLICY_OPERATION_FACTORY
The default policy operation factory.
-
Constructor Summary
Constructors Constructor Description MetadataPolicyEntry(String parameterName, List<PolicyOperation> policyOperations)
Creates a new policy entry for a metadata parameter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
apply(Object value)
Applies this policy entry for a metadata parameter to the specified value.MetadataPolicyEntry
combine(MetadataPolicyEntry other)
Combines this policy entry with another one for the same parameter name.MetadataPolicyEntry
combine(MetadataPolicyEntry other, PolicyOperationCombinationValidator combinationValidator)
Combines this policy entry with another one for the same parameter name.String
getKey()
Map<OperationName,PolicyOperation>
getOperationsMap()
Returns a map of the operations for this policy entry.String
getParameterName()
Returns the parameter name.List<PolicyOperation>
getPolicyOperations()
Returns the policy operations.List<PolicyOperation>
getValue()
static MetadataPolicyEntry
parse(String parameterName, net.minidev.json.JSONObject entrySpec)
Parses a policy entry for a metadata parameter.static MetadataPolicyEntry
parse(String parameterName, net.minidev.json.JSONObject entrySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator)
Parses a policy entry for a metadata parameter.List<PolicyOperation>
setValue(List<PolicyOperation> policyOperations)
net.minidev.json.JSONObject
toJSONObject()
Returns a JSON object representation of the policy operations for this entry.
-
-
-
Field Detail
-
DEFAULT_POLICY_OPERATION_FACTORY
public static final PolicyOperationFactory DEFAULT_POLICY_OPERATION_FACTORY
The default policy operation factory.
-
DEFAULT_POLICY_COMBINATION_VALIDATOR
public static final PolicyOperationCombinationValidator DEFAULT_POLICY_COMBINATION_VALIDATOR
The default policy operation combination validator.
-
-
Constructor Detail
-
MetadataPolicyEntry
public MetadataPolicyEntry(String parameterName, List<PolicyOperation> policyOperations)
Creates a new policy entry for a metadata parameter.- Parameters:
parameterName
- The parameter name. Must not benull
.policyOperations
- The policy operations, empty list ornull
if none.
-
-
Method Detail
-
getParameterName
public String getParameterName()
Returns the parameter name.- Returns:
- The parameter name.
- See Also:
getKey()
-
getKey
public String getKey()
- Specified by:
getKey
in interfaceMap.Entry<String,List<PolicyOperation>>
- See Also:
getParameterName()
-
getPolicyOperations
public List<PolicyOperation> getPolicyOperations()
Returns the policy operations.- Returns:
- The policy operations, empty list if none.
- See Also:
getValue()
-
getValue
public List<PolicyOperation> getValue()
- Specified by:
getValue
in interfaceMap.Entry<String,List<PolicyOperation>>
- See Also:
getPolicyOperations()
-
setValue
public List<PolicyOperation> setValue(List<PolicyOperation> policyOperations)
- Specified by:
setValue
in interfaceMap.Entry<String,List<PolicyOperation>>
-
getOperationsMap
public Map<OperationName,PolicyOperation> getOperationsMap()
Returns a map of the operations for this policy entry.- Returns:
- The map, empty if no operations.
-
combine
public MetadataPolicyEntry combine(MetadataPolicyEntry other) throws PolicyViolationException
Combines this policy entry with another one for the same parameter name. Uses thedefault policy combination validator
.- Parameters:
other
- The other policy entry. Must not benull
.- Returns:
- The new combined policy entry.
- Throws:
PolicyViolationException
- If the parameter names don't match or another violation was encountered.
-
combine
public MetadataPolicyEntry combine(MetadataPolicyEntry other, PolicyOperationCombinationValidator combinationValidator) throws PolicyViolationException
Combines this policy entry with another one for the same parameter name.- Parameters:
other
- The other policy entry. Must not benull
.combinationValidator
- The policy operation combination validator. Must not benull
.- Returns:
- The new combined policy entry.
- Throws:
PolicyViolationException
- If the parameter names don't match or another violation was encountered.
-
apply
public Object apply(Object value) throws PolicyViolationException
Applies this policy entry for a metadata parameter to the specified value.- Parameters:
value
- The parameter value,null
if not specified.- Returns:
- The resulting value, can be
null
. - Throws:
PolicyViolationException
- On a policy violation.
-
toJSONObject
public net.minidev.json.JSONObject toJSONObject()
Returns a JSON object representation of the policy operations for this entry.- Returns:
- The JSON object keeping the ordering of the members.
-
parse
public static MetadataPolicyEntry parse(String parameterName, net.minidev.json.JSONObject entrySpec) throws ParseException, PolicyViolationException
Parses a policy entry for a metadata parameter. This method is intended for policies with standardPolicyOperation
s only. Uses the defaultpolicy operation
andpolicy combination validator
factories.- Parameters:
parameterName
- The parameter name. Must not benull
.entrySpec
- The JSON object entry specification, must not benull
.- Returns:
- The policy entry for the metadata parameter.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
parse
public static MetadataPolicyEntry parse(String parameterName, net.minidev.json.JSONObject entrySpec, PolicyOperationFactory factory, PolicyOperationCombinationValidator combinationValidator) throws ParseException, PolicyViolationException
Parses a policy entry for a metadata parameter. This method is intended for policies including non-standardPolicyOperation
s.- Parameters:
parameterName
- The parameter name. Must not benull
.entrySpec
- The JSON object entry specification, must not benull
.factory
- The policy operation factory. Must not benull
.combinationValidator
- The policy operation combination validator. Must not benull
.- Returns:
- The policy entry for the metadata parameter.
- Throws:
ParseException
- On JSON parsing exception.PolicyViolationException
- On a policy violation.
-
-