@Override public boolean isValid(String id) { try { new X500Principal(id); return true; } catch (IllegalArgumentException e) { return false; } }
DistinguishedNameParser(X500Principal principal) { // RFC2253 is used to ensure we get attributes in the reverse // order of the underlying ASN.1 encoding, so that the most // significant values of repeated attributes occur first. this.dn = principal.getName(X500Principal.RFC2253); this.length = this.dn.length(); }
/** * Returns the subject that a certificate must match. * * @return the subject distinguished name in ASN.1 DER format, or {@code * null} if the subject is not to be checked. * @throws IOException * if encoding the subject fails. */ public byte[] getSubjectAsBytes() throws IOException { if (subject == null) { return null; } return subject.getEncoded(); }
public boolean equals(final DirectoryName other) { return (new X500Principal(name)).equals(new X500Principal(other.getName())); }
@Override public int hashCode() { return getCanonicalName().hashCode(); }
/** * <b>Do not use</b>, use {@link #getSubject()} or * {@link #getSubjectAsBytes()} instead. Returns the subject that a * certificate must match. * * @return the subject distinguished name in RFC 2253 format, or {@code * null} if the subject is not to be checked. */ public String getSubjectAsString() { if (subject == null) { return null; } return subject.getName(); }
private X500Principal buildSubject() { StringBuilder nameBuilder = new StringBuilder(); if (cn != null) { nameBuilder.append("CN=").append(cn); } else { nameBuilder.append("CN=").append(UUID.randomUUID()); } if (ou != null) { nameBuilder.append(", OU=").append(ou); } return new X500Principal(nameBuilder.toString()); }
public CertificationRequestInfo(X500Principal subject, PublicKey publicKey) { this.subject = requireNonNull(subject, "subject is null"); this.publicKey = requireNonNull(publicKey, "publicKey is null"); this.encoded = encodeSequence(VERSION_0_ENCODED, subject.getEncoded(), publicKey.getEncoded(), EMPTY_ATTRIBUTES_ENCODED); }
/** * <b>Do not use</b>, use {@link #getIssuer()} or * {@link #getIssuerAsBytes()} instead. Returns the issuer that a * certificate must match in a RFC 2253 format string. * * @return the issuer in a RFC 2253 format string, or {@code null} if the * issuer is not to be checked. */ public String getIssuerAsString() { if (issuer == null) { return null; } if (issuerName == null) { issuerName = issuer.getName(); } return issuerName; }
public CertificationRequest(String x500Name, String signatureAlgorithm, KeyPair keyPair) throws GeneralSecurityException { this(new CertificationRequestInfo(new X500Principal(x500Name), keyPair.getPublic()), findSignatureAlgorithmIdentifier(signatureAlgorithm), keyPair.getPrivate()); }
DistinguishedNameParser(X500Principal principal) { // RFC2253 is used to ensure we get attributes in the reverse // order of the underlying ASN.1 encoding, so that the most // significant values of repeated attributes occur first. this.dn = principal.getName(X500Principal.RFC2253); this.length = this.dn.length(); }
/** * Returns <code>X500Principal</code> instance corresponding to this * <code>Name</code> instance * * @return equivalent X500Principal object */ public X500Principal getX500Principal(){ return new X500Principal(getEncoded()); }
/** * Determine the string to be used as the remote host session Id for * authorization purposes. Associate this client identifier with a * ServerCnxn that has been authenticated over SSL, and any ACLs that refer * to the authenticated client. * * @param clientCert Authenticated X509Certificate associated with the * remote host. * @return Identifier string to be associated with the client. */ protected String getClientId(X509Certificate clientCert) { return clientCert.getSubjectX500Principal().getName(); }
public TestCertificate(String name) { encoded = name.getBytes(); principal = new X500Principal("CN=" + name); publicKey = new TestPublicKey(); } @Override
DistinguishedNameParser(X500Principal principal) { // RFC2253 is used to ensure we get attributes in the reverse // order of the underlying ASN.1 encoding, so that the most // significant values of repeated attributes occur first. this.dn = principal.getName(X500Principal.RFC2253); this.length = this.dn.length(); }
public DistinguishedNameParser(X500Principal principal) { // RFC2253 is used to ensure we get attributes in the reverse // order of the underlying ASN.1 encoding, so that the most // significant values of repeated attributes occur first. this.dn = principal.getName(X500Principal.RFC2253); this.length = this.dn.length(); }
public DistinguishedNameParser(X500Principal principal) { // RFC2253 is used to ensure we get attributes in the reverse // order of the underlying ASN.1 encoding, so that the most // significant values of repeated attributes occur first. this.dn = principal.getName(X500Principal.RFC2253); this.length = this.dn.length(); }
public static KeyStore loadTrustStore(File certificateChainFile) throws IOException, GeneralSecurityException { KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(null, null); List<X509Certificate> certificateChain = readCertificateChain(certificateChainFile); for (X509Certificate certificate : certificateChain) { X500Principal principal = certificate.getSubjectX500Principal(); keyStore.setCertificateEntry(principal.getName("RFC2253"), certificate); } return keyStore; }
public static KeyStore loadTrustStore(File certificateChainFile) throws IOException, GeneralSecurityException { KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(null, null); List<X509Certificate> certificateChain = readCertificateChain(certificateChainFile); for (X509Certificate certificate : certificateChain) { X500Principal principal = certificate.getSubjectX500Principal(); keyStore.setCertificateEntry(principal.getName("RFC2253"), certificate); } return keyStore; }
KeyStore agentTruststore() throws IOException, CertificateException, KeyStoreException, NoSuchAlgorithmException { KeyStore trustStore = null; List<X509Certificate> certificates = new CertificateFileParser().certificates(rootCertFile); for (X509Certificate certificate : certificates) { if (trustStore == null) { trustStore = KeyStore.getInstance(KeyStore.getDefaultType()); trustStore.load(null, null); } trustStore.setCertificateEntry(certificate.getSubjectX500Principal().getName(), certificate); } return trustStore; }