use of org.nhindirect.policy.x509.ExtensionIdentifier in project nhin-d by DirectProject.
the class SimpleTextV1LexiconPolicyParser method buildExtensionField.
/**
* Builds a certificate reference expression that is an {@link ExtensionField}.
* @param token The token used to build the field.
* @return An {@link ExtensionField} object that represents the token. Returns null if the token does not represent an {@link ExtensionField}.
* @throws PolicyParseException
*/
protected PolicyExpression buildExtensionField(String token) throws PolicyParseException {
ExtensionField<?> retVal = null;
final ExtensionIdentifier fieldType = ExtensionIdentifier.fromToken(token);
if (fieldType != null) {
try {
boolean required = token.endsWith("+");
final Class<? extends ExtensionField<?>> fieldRefClass = fieldType.getReferenceClass(token);
if (fieldRefClass == null)
throw new PolicyParseException("ExtensionField with token name " + token + " has not been implemented yet.");
final Constructor<?> cons = fieldRefClass.getConstructor(Boolean.TYPE);
retVal = (ExtensionField<?>) cons.newInstance(required);
} catch (PolicyParseException ex) {
throw ex;
}///CLOVER:OFF
catch (Exception e) {
throw new PolicyParseException("Error building ExtensionField", e);
}
///CLOVER:ON
}
return retVal;
}
Aggregations