/** * Builds a certificate reference expression that is an {@link X509Field}. * @param token The token used to build the field. * @return An {@link X509Field} object that represents the token. Returns null if the token does not represent an {@link X509Field}. * @throws PolicyParseException */ public X509Field <string> BuildX509Field(String token) //throws PolicyParseException { X509Field <string> retVal = null; X509FieldType fieldType = X509FieldType.FromToken(token); if (fieldType != null) { try { retVal = fieldType.GetReferenceClass(); if (retVal == null) { throw new PolicyParseException("X509Field with token name " + token + " has not been implemented yet."); } } catch (PolicyParseException) { throw; } catch (Exception e) { throw new PolicyParseException("Error building X509Field", e); } } return(retVal); }
protected IPolicyValue <T> EvaluateX509Field <T>(X509Certificate2 cert, X509Field <T> expression) { try { expression.InjectReferenceValue(cert); return(expression.GetPolicyValue()); } catch (PolicyRequiredException e) { // add this to the report and re-evaluate without the required flag if (ReportModeEnabled) { AddErrorToReport(e); expression.SetRequired(false); expression.InjectReferenceValue(cert); return(expression.GetPolicyValue()); } // re-throw throw; } }