/** * 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 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); }
/** * Returns the issuer that a certificate must match. * * @return the distinguished issuer name in ASN.1 DER encoded format, or * {@code null} if the issuer is not to be checked. * @throws IOException * if encoding the issuer fails. */ public byte[] getIssuerAsBytes() throws IOException { if (issuer == null) { return null; } if (issuerBytes == null) { issuerBytes = issuer.getEncoded(); } byte[] result = new byte[issuerBytes.length]; System.arraycopy(issuerBytes, 0, result, 0, issuerBytes.length); return result; }
public void encodeTo(final ASN1Encoder encoder) { encoder.startExplicit(getType()); encoder.writeEncoded(new X500Principal(name).getEncoded()); encoder.endExplicit(); } }
public void encodeTo(final ASN1Encoder encoder) { encoder.startExplicit(getType()); encoder.writeEncoded(new X500Principal(getName()).getEncoded()); encoder.endExplicit(); }
/** * Encode a {@code CertificationRequestInfo} using the given DER encoder. The ASN.1 definition of {@code CertificationRequestInfo} is: * * <pre> * CertificationRequestInfo ::= SEQUENCE { * version INTEGER { v1(0) } (v1,...), * subject Name, * subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }}, * attributes [0] Attributes{{ CRIAttributes }} * } * </pre> * * @param encoder the DER encoder */ private void encodeCertificationRequestInfo(final DEREncoder encoder) { encoder.startSequence(); encoder.encodeInteger(VERSION); encoder.writeEncoded(subjectDn.getEncoded()); encoder.writeEncoded(publicKey.getEncoded()); // subjectPKInfo encoder.encodeImplicit(0); encodeAttributes(encoder); encoder.endSequence(); }
Assert.checkNotNullParam("oids", oids); final Set<String> requiredAttributes = new HashSet<>(Arrays.asList(oids)); final ASN1Decoder decoder = new DERDecoder(principal.getEncoded()); decoder.startSequence(); while (decoder.hasNextElement() && ! requiredAttributes.isEmpty()) {
final ASN1Decoder decoder = new DERDecoder(principal.getEncoded()); String[] strings = NO_STRINGS; int len = 0;
derEncoder.writeEncoded(issuerDn.getEncoded()); // already a SEQUENCE of SET of SEQUENCE of { OBJECT IDENTIFIER, ANY } if (subjectDn != null) derEncoder.writeEncoded(subjectDn.getEncoded()); // already a SEQUENCE of SET of SEQUENCE of { OBJECT IDENTIFIER, ANY }
buf.append(",C=").append(c); String dname = buf.toString(); byte[] issuer = (new X500Principal(dname, OIDS)).getEncoded(); byte[] validity = getValidity(validDays); byte[] subject = issuer;
byte[] issuer = cert.getIssuerX500Principal().getEncoded();
private static int X509_NAME_hash(X500Principal principal, String algorithm) { try { byte[] digest = MessageDigest.getInstance(algorithm).digest(principal.getEncoded()); int offset = 0; return (((digest[offset++] & 0xff) << 0) | ((digest[offset++] & 0xff) << 8) | ((digest[offset++] & 0xff) << 16) | ((digest[offset ] & 0xff) << 24)); } catch (NoSuchAlgorithmException e) { throw new AssertionError(e); } }
/** * Convert an X.500 Principal to an X.500 Name. * * @param principal * X.500 Principal * @return X.500 Name */ public static X500Name x500PrincipalToX500Name(X500Principal principal) { return X500Name.getInstance(KseX500NameStyle.INSTANCE, principal.getEncoded()); }
static X509Principal convertPrincipal( X500Principal principal) { try { return new X509Principal(principal.getEncoded()); } catch (IOException e) { throw new IllegalArgumentException("cannot convert principal"); } }
public static X500Name getSubject(X500NameStyle style, X509Certificate certificate) { return X500Name.getInstance(style, certificate.getSubjectX500Principal().getEncoded()); } }
/** * Base constructor. * * @param issuerDN X.500 DN for the issuer of the attribute certificate. */ public JcaAttributeCertificateIssuer(X500Principal issuerDN) { super(X500Name.getInstance(issuerDN.getEncoded())); } }
/** * Create a PKCS#10 builder for the passed in subject and JCA public key. * * @param subject an X500Principal containing the subject associated with the request we are building. * @param publicKey a JCA public key that is to be associated with the request we are building. */ public JcaPKCS10CertificationRequestBuilder(X500Principal subject, PublicKey publicKey) { super(X500Name.getInstance(subject.getEncoded()), SubjectPublicKeyInfo.getInstance(publicKey.getEncoded())); } }
public JcaCertificateRequestMessageBuilder setIssuer(X500Principal issuer) { if (issuer != null) { setIssuer(X500Name.getInstance(issuer.getEncoded())); } return this; }
public void encodeTo(final ASN1Encoder encoder) { encoder.startExplicit(getType()); encoder.writeEncoded(new X500Principal(getName()).getEncoded()); encoder.endExplicit(); }
/** * This method returns a X509Name object corresponding to a given principal */ public static X509Name getX509Name(X500Principal principal) throws CertificateEncodingException, IOException { ASN1InputStream ais = new ASN1InputStream(principal.getEncoded()); X509Name name = new X509Name((ASN1Sequence)ais.readObject()); ais.close(); return name; }