use of org.nhindirect.policy.x509.TBSFieldName in project nhin-d by DirectProject.
the class SimpleTextV1LexiconPolicyParser method buildTBSField.
/**
* Builds a certificate reference expression that is an {@link TBSField}.
* @param token The token used to build the field.
* @return An {@link TBSField} object that represents the token. Returns null if the token does not represent an {@link TBSField}.
* @throws PolicyParseException
*/
protected PolicyExpression buildTBSField(String token) throws PolicyParseException {
TBSField<?> retVal = null;
final TBSFieldName fieldName = TBSFieldName.fromToken(token);
if (fieldName != null) {
try {
final Class<? extends TBSField<?>> fieldRefClass = fieldName.getReferenceClass(token);
if (fieldRefClass == null)
throw new PolicyParseException("TBSField with token name " + token + " has not been implemented yet.");
if (fieldRefClass.equals(IssuerAttributeField.class) || fieldRefClass.equals(SubjectAttributeField.class)) {
boolean required = token.endsWith("+");
final String rdnLookupToken = (required) ? token.substring(0, token.length() - 1) : token;
final RDNAttributeIdentifier identifier = RDNAttributeIdentifier.fromName(rdnLookupToken);
retVal = fieldRefClass.equals(IssuerAttributeField.class) ? new IssuerAttributeField(required, identifier) : new SubjectAttributeField(required, identifier);
} else {
retVal = fieldRefClass.newInstance();
}
} catch (PolicyParseException ex) {
throw ex;
}///CLOVER:OFF
catch (Exception e) {
throw new PolicyParseException("Error building TBSField", e);
}
///CLOVER:ON
}
return retVal;
}
Aggregations