@Override public byte[] getEncoded() throws IOException { return this.dn.getEncoded(); }
/** * Convert an X.500 Name to an X.500 Principal. * * @param name * X.500 Name * @return X.500 Principal * @throws IOException if an encoding error occurs (incorrect form for DN) */ public static X500Principal x500NameToX500Principal(X500Name name) throws IOException { return new X500Principal(name.getEncoded()); }
public X500Principal getCertificateIssuer() { if (certificateIssuer == null) { return null; } try { return new X500Principal(certificateIssuer.getEncoded()); } catch (IOException e) { return null; } }
public X500Principal getCertificateIssuer() { if (certificateIssuer == null) { return null; } try { return new X500Principal(certificateIssuer.getEncoded()); } catch (IOException e) { return null; } }
public X500Principal getIssuerX500Principal() { try { return new X500Principal(c.getIssuer().getEncoded()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
public X500Principal getIssuerX500Principal() { try { return new X500Principal(c.getIssuer().getEncoded()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
public Principal getIssuerDN() { try { return new X509Principal(X500Name.getInstance(c.getIssuer().getEncoded())); } catch (IOException e) { return null; } }
public Principal getIssuerDN() { try { return new X509Principal(X500Name.getInstance(c.getIssuer().getEncoded())); } catch (IOException e) { return null; } }
public PublicCaInfo(X500Name subject, BigInteger serialNumber, GeneralNames subjectAltName, byte[] subjectKeyIdentifier, CaUris caUris, ConfPairs extraControl) throws OperationException { this.x500Subject = Args.notNull(subject, "subject"); this.serialNumber = Args.notNull(serialNumber, "serialNumber"); this.caUris = (caUris == null) ? CaUris.EMPTY_INSTANCE : caUris; this.caCert = null; this.c14nSubject = X509Util.canonicalizName(subject); try { this.subject = new X500Principal(subject.getEncoded()); } catch (IOException ex) { throw new OperationException(ErrorCode.SYSTEM_FAILURE, "invalid SubjectAltName extension in CA certificate"); } this.subjectKeyIdentifier = (subjectKeyIdentifier == null) ? null : Arrays.copyOf(subjectKeyIdentifier, subjectKeyIdentifier.length); this.subjectAltName = subjectAltName; this.extraControl = extraControl; } // constructor
byte[] derEncoding = certificateAuthority.getEncoded(ASN1Encoding.DER); derEncodings.addElement(derEncoding); totalLength += derEncoding.length + 2;
byte[] derEncoding = certificateAuthority.getEncoded(ASN1Encoding.DER); derEncodings.addElement(derEncoding); totalLength += derEncoding.length + 2;
/** * Constructs a {@link X500Principal} object from a RFC 2253 string. This * method can handle DNs with attributes not supported by the {@link X500Principal} * constructor. * @param rfcDn RFC 2253 DN * @return the created object * @throws IOException IO exception */ public static X500Principal getX500Principal(String rfcDn) throws IOException { JavaAndBCStyle style = new JavaAndBCStyle(); X500Name x500Name = new X500Name(style, rfcDn); RDN[] rdns = x500Name.getRDNs(); for (int i=0; i<rdns.length/2; i++) { RDN bak = rdns[i]; rdns[i] = rdns[rdns.length-1-i]; rdns[rdns.length-1-i] = bak; } X500Name x500Name2 = new X500Name(rdns); byte []encoded = x500Name2.getEncoded(ASN1Encoding.DER); return new X500Principal(encoded); } }
public static X509CertificateBuilder fromCsr(Pkcs10Csr csr, X500Principal caIssuer, Instant notBefore, Instant notAfter, PrivateKey caPrivateKey, SignatureAlgorithm signingAlgorithm, BigInteger serialNumber) { try { PKCS10CertificationRequest bcCsr = csr.getBcCsr(); PublicKey publicKey = new JcaPKCS10CertificationRequest(bcCsr) .setProvider(BouncyCastleProviderHolder.getInstance()) .getPublicKey(); return new X509CertificateBuilder(caIssuer, new X500Principal(bcCsr.getSubject().getEncoded()), notBefore, notAfter, publicKey, caPrivateKey, signingAlgorithm, serialNumber); } catch (GeneralSecurityException e) { throw new RuntimeException(e); } catch (IOException e) { throw new UncheckedIOException(e); } }
private String getLastCN() throws IllegalArgumentException, IOException { byte[] subject = csr.getSubject().getEncoded(ASN1Encoding.DER); X500Name withDefaultStyle = X500Name.getInstance(subject); JavaAndBCStyle style = new JavaAndBCStyle(); return ProxyHelper.getLastCN(X500Name.getInstance(style, withDefaultStyle)); }
public IssuerHash(HashAlgo hashAlgo, Certificate issuerCert) throws IOException { this.hashAlgo = Args.notNull(hashAlgo, "hashAlgo"); Args.notNull(issuerCert, "issuerCert"); byte[] encodedName = issuerCert.getSubject().getEncoded(); byte[] encodedKey = issuerCert.getSubjectPublicKeyInfo().getPublicKeyData().getBytes(); this.issuerNameHash = HashCalculator.hash(hashAlgo, encodedName); this.issuerKeyHash = HashCalculator.hash(hashAlgo, encodedKey); }
public IssuerHash(final HashAlgoType hashAlgo, final Certificate issuerCert) throws IOException { this.hashAlgo = ParamUtil.requireNonNull("hashAlgo", hashAlgo); ParamUtil.requireNonNull("issuerCert", issuerCert); byte[] encodedName = issuerCert.getSubject().getEncoded(); byte[] encodedKey = issuerCert.getSubjectPublicKeyInfo().getPublicKeyData().getBytes(); this.issuerNameHash = HashCalculator.hash(hashAlgo, encodedName); this.issuerKeyHash = HashCalculator.hash(hashAlgo, encodedKey); }
@Override public CertWithRevocationInfo getCert(X500Name issuer, BigInteger serialNumber) throws CaMgmtException { MgmtRequest.GetCert req = new MgmtRequest.GetCert(); try { req.setEncodedIssuerDn(issuer.getEncoded()); } catch (IOException ex) { throw new CaMgmtException("could not encode issuer", ex); } req.setSerialNumber(serialNumber); byte[] respBytes = transmit(MgmtAction.getCert, req); MgmtResponse.GetCert resp = parse(respBytes, MgmtResponse.GetCert.class); try { return resp.getResult().toCertWithRevocationInfo(); } catch (CertificateException ex) { throw new CaMgmtException("could not parse the certificate", ex); } }
@Override public List<CertListInfo> listCertificates(String caName, X500Name subjectPattern, Date validFrom, Date validTo, CertListOrderBy orderBy, int numEntries) throws CaMgmtException { MgmtRequest.ListCertificates req = new MgmtRequest.ListCertificates(); req.setCaName(caName); if (subjectPattern != null) { try { req.setEncodedSubjectDnPattern(subjectPattern.getEncoded()); } catch (IOException ex) { throw new CaMgmtException("could not parse subjectPattern", ex); } } req.setValidFrom(validFrom); req.setValidTo(validTo); req.setOrderBy(orderBy); req.setNumEntries(numEntries); byte[] respBytes = transmit(MgmtAction.listCertificates, req); MgmtResponse.ListCertificates resp = parse(respBytes, MgmtResponse.ListCertificates.class); return resp.getResult(); }
crlselect.addIssuerName(PrincipalUtils.getIssuerPrincipal(crl).getEncoded());
crlselect.addIssuerName(PrincipalUtils.getIssuerPrincipal(crl).getEncoded());