public void performTest() throws Exception { X500NameStyle style = RFC4519Style.INSTANCE; for (int i = 0; i != attributeTypes.length; i++) { if (!attributeTypeOIDs[i].equals(style.attrNameToOID(attributeTypes[i]))) { fail("mismatch for " + attributeTypes[i]); } } byte[] enc = Hex.decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65"); X500Name n = X500Name.getInstance(style, X500Name.getInstance(enc)); if (!n.toString().equals("l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU")) { fail("Failed composite to string test got: " + n.toString()); } n = new X500Name(style, "l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU"); if (!Arrays.areEqual(n.getEncoded(), enc)) { fail("re-encoding test after parse failed"); } }
@Override public boolean authorize(String dn, String operation, String resource) { boolean authorized = config.getAccessControlList().isAuthorized(dn, operation, resource); if (log.isInfoEnabled()) { StringBuilder sb = new StringBuilder(); if (authorized) { sb.append("Authorized: "); } else { sb.append("Rejected: "); } if (Strings.isNullOrEmpty(dn)) { sb.append("<null DN>"); } else { X500NameStyle x500NameStyle = ExtendedRFC4519Style.INSTANCE; X500Name principal = new X500Name(dn); sb.append(x500NameStyle.toString(principal)); } sb.append(", "); sb.append(operation); sb.append(" "); sb.append(resource); log.info(sb.toString()); } return authorized; }
@Test public void performTest() throws Exception { X500NameStyle style = ExtendedRFC4519Style.INSTANCE; for (int i = 0; i != attributeTypes.length; i++) { if (!attributeTypeOIDs[i].equals(style.attrNameToOID(attributeTypes[i]))) { fail("mismatch for " + attributeTypes[i]); } } byte[] enc = Hex.decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65"); X500Name n = new X500Name(style, X500Name.getInstance(enc)); if (!n.toString().equals("l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU")) { fail("Failed composite to string test got: " + n.toString()); } n = new X500Name(style, "l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU"); if (!Arrays.areEqual(n.getEncoded(), enc)) { fail("re-encoding test after parse failed"); } }
public static X500Name getIssuer(X500NameStyle style, X509Certificate certificate) { try { return X500Name.getInstance(style, PrincipalUtil.getIssuerX509Principal(certificate).getEncoded()); } catch (Exception e) { throw new IllegalStateException(e.toString()); } }
public static X500Name getSubject(X500NameStyle style, X509Certificate certificate) { try { return X500Name.getInstance(style, PrincipalUtil.getSubjectX509Principal(certificate).getEncoded()); } catch (Exception e) { throw new IllegalStateException(e.toString()); } }
public void performTest() throws Exception { X500NameStyle style = RFC4519Style.INSTANCE; for (int i = 0; i != attributeTypes.length; i++) { if (!attributeTypeOIDs[i].equals(style.attrNameToOID(attributeTypes[i]))) { fail("mismatch for " + attributeTypes[i]); } } byte[] enc = Hex.decode("305e310b300906035504061302415531283026060355040a0c1f546865204c6567696f6e206f662074686520426f756e637920436173746c653125301006035504070c094d656c626f75726e653011060355040b0c0a4173636f742056616c65"); X500Name n = new X500Name(style, X500Name.getInstance(enc)); if (!n.toString().equals("l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU")) { fail("Failed composite to string test got: " + n.toString()); } n = new X500Name(style, "l=Melbourne+ou=Ascot Vale,o=The Legion of the Bouncy Castle,c=AU"); if (!Arrays.areEqual(n.getEncoded(), enc)) { fail("re-encoding test after parse failed"); } }
public static X500Name getIssuer(X500NameStyle style, X509Certificate certificate) { return X500Name.getInstance(style, certificate.getIssuerX500Principal().getEncoded()); }
public static X500Name getSubject(X500NameStyle style, X509Certificate certificate) { return X500Name.getInstance(style, certificate.getSubjectX500Principal().getEncoded()); }