Search in sources :

Example 1 with ExtensionIdentifier

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;
}
Also used : ExtensionIdentifier(org.nhindirect.policy.x509.ExtensionIdentifier) PolicyParseException(org.nhindirect.policy.PolicyParseException) PolicyGrammarException(org.nhindirect.policy.PolicyGrammarException) IOException(java.io.IOException) PolicyParseException(org.nhindirect.policy.PolicyParseException)

Aggregations

IOException (java.io.IOException)1 PolicyGrammarException (org.nhindirect.policy.PolicyGrammarException)1 PolicyParseException (org.nhindirect.policy.PolicyParseException)1 ExtensionIdentifier (org.nhindirect.policy.x509.ExtensionIdentifier)1