@Override public String toString() { StringBuilder res = new StringBuilder(); res.append("-- CertificationRequestInfo:"); res.append("\n version: "); res.append(version); res.append("\n subject: "); res.append(subject.getName(X500Principal.CANONICAL)); res.append("\n subjectPublicKeyInfo: "); res.append("\n\t algorithm: "); res.append(subjectPublicKeyInfo.getAlgorithmIdentifier().getAlgorithm()); res.append("\n\t public key: ").append(subjectPublicKeyInfo.getPublicKey()); res.append("\n attributes: "); if (attributes != null) { res.append(attributes.toString()); } else { res.append("none"); } res.append("\n-- CertificationRequestInfo End\n"); return res.toString(); }
/** * Creates object from DSAPublicKeySpec. * * @param keySpec - a DSAPublicKeySpec object */ public DSAPublicKeyImpl(DSAPublicKeySpec keySpec) { super("DSA"); SubjectPublicKeyInfo spki; p = keySpec.getP(); q = keySpec.getQ(); g = keySpec.getG(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper .map2OID("DSA"), threeInts.getEncoded()); y = keySpec.getY(); spki = new SubjectPublicKeyInfo(ai, ASN1Integer.getInstance().encode( y.toByteArray())); setEncoding(spki.getEncoded()); params = (DSAParams) (new DSAParameterSpec(p, q, g)); }
/** * Returns the PublicKey corresponding to this SubjectPublicKeyInfo * instance. */ public PublicKey getPublicKey() { if (publicKey == null) { final byte[] encoded = getEncoded(); final KeySpec keySpec = new X509EncodedKeySpec(encoded); /* Try using the algorithm name first. */ final String algName = algorithmID.getAlgorithmName(); publicKey = generateKeyForAlgorithm(keySpec, algName); /* * Fall back to using the algorithm OID if it's not the same as the * algorithm name. */ final String algOid = algorithmID.getAlgorithm(); if (publicKey == null && !algOid.equals(algName)) { publicKey = generateKeyForAlgorithm(keySpec, algOid); } /* * Encode this as an X.509 public key since we didn't have any * KeyFactory that could handle this algorithm name or OID. Perhaps * the thing that's using this can decode it. */ if (publicKey == null) { publicKey = new X509PublicKey(algOid, encoded, subjectPublicKey); } } return publicKey; }
@Override public PublicKey getPublicKey() { PublicKey result = publicKey; if (result == null) { publicKey = result = tbsCert.getSubjectPublicKeyInfo().getPublicKey(); } return result; }
subjectPublicKeyInfo.getSubjectPublicKey())); } catch (IOException e) { throw new InvalidKeySpecException("Failed to decode parameters: " + e); ai = subjectPublicKeyInfo.getAlgorithmIdentifier();
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new SubjectPublicKeyInfo( (AlgorithmIdentifier) values[0], ((BitString) values[1]).bytes, ((BitString) values[1]).unusedBits, in.getEncoded()); }
AlgorithmIdentifier ai = ((SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1.decode(encoding)) .getAlgorithmIdentifier(); if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) { return false;
/** * Sets the criterion for the subject public key. * * @param key * the subject public key in ASN.1 DER encoded format or {@code null} to * not check the key. * @throws IOException * if decoding the the public key fails. */ public void setSubjectPublicKey(byte[] key) throws IOException { if (key == null) { subjectPublicKey = null; subjectPublicKeyImpl = null; return; } subjectPublicKey = new byte[key.length]; System.arraycopy(key, 0, subjectPublicKey, 0, key.length); subjectPublicKeyImpl = ((SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1.decode(key)) .getPublicKey(); }
subjectPublicKeyInfo.getSubjectPublicKey())); } catch (IOException e) { throw new InvalidKeySpecException("Failed to decode parameters: " + e); ai = subjectPublicKeyInfo.getAlgorithmIdentifier();
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new SubjectPublicKeyInfo( (AlgorithmIdentifier) values[0], ((BitString) values[1]).bytes, ((BitString) values[1]).unusedBits, in.getEncoded()); }
AlgorithmIdentifier ai = ((SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1.decode(encoding)) .getAlgorithmIdentifier(); if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) { return false;
@Override public String toString() { StringBuilder res = new StringBuilder(); res.append("-- CertificationRequestInfo:"); res.append("\n version: "); res.append(version); res.append("\n subject: "); res.append(subject.getName(X500Principal.CANONICAL)); res.append("\n subjectPublicKeyInfo: "); res.append("\n\t algorithm: "); res.append(subjectPublicKeyInfo.getAlgorithmIdentifier().getAlgorithm()); res.append("\n\t public key: ").append(subjectPublicKeyInfo.getPublicKey()); res.append("\n attributes: "); if (attributes != null) { res.append(attributes.toString()); } else { res.append("none"); } res.append("\n-- CertificationRequestInfo End\n"); return res.toString(); }
sb.append("\n Signature Algorithm: "); signature.dumpValue(sb); sb.append("\n Key: ").append(subjectPublicKeyInfo.getPublicKey().toString()); sb.append("\n Validity: [From: ").append(validity.getNotBefore()); sb.append("\n To: ").append(validity.getNotAfter()).append(']');
/** * Creates object from DSAPublicKeySpec. * * @param keySpec - a DSAPublicKeySpec object */ public DSAPublicKeyImpl(DSAPublicKeySpec keySpec) { super("DSA"); SubjectPublicKeyInfo spki; p = keySpec.getP(); q = keySpec.getQ(); g = keySpec.getG(); ThreeIntegerSequence threeInts = new ThreeIntegerSequence(p .toByteArray(), q.toByteArray(), g.toByteArray()); AlgorithmIdentifier ai = new AlgorithmIdentifier(AlgNameMapper .map2OID("DSA"), threeInts.getEncoded()); y = keySpec.getY(); spki = new SubjectPublicKeyInfo(ai, ASN1Integer.getInstance().encode( y.toByteArray())); setEncoding(spki.getEncoded()); params = (DSAParams) (new DSAParameterSpec(p, q, g)); }
/** * Returns the PublicKey corresponding to this SubjectPublicKeyInfo * instance. */ public PublicKey getPublicKey() { if (publicKey == null) { final byte[] encoded = getEncoded(); final KeySpec keySpec = new X509EncodedKeySpec(encoded); /* Try using the algorithm name first. */ final String algName = algorithmID.getAlgorithmName(); publicKey = generateKeyForAlgorithm(keySpec, algName); /* * Fall back to using the algorithm OID if it's not the same as the * algorithm name. */ final String algOid = algorithmID.getAlgorithm(); if (publicKey == null && !algOid.equals(algName)) { publicKey = generateKeyForAlgorithm(keySpec, algOid); } /* * Encode this as an X.509 public key since we didn't have any * KeyFactory that could handle this algorithm name or OID. Perhaps * the thing that's using this can decode it. */ if (publicKey == null) { publicKey = new X509PublicKey(algOid, encoded, subjectPublicKey); } } return publicKey; }
subjectPublicKeyInfo.getSubjectPublicKey())); } catch (IOException e) { throw new InvalidKeySpecException("Failed to decode parameters: " + e); ai = subjectPublicKeyInfo.getAlgorithmIdentifier();
@Override protected Object getDecodedObject(BerInputStream in) { Object[] values = (Object[]) in.content; return new SubjectPublicKeyInfo( (AlgorithmIdentifier) values[0], ((BitString) values[1]).bytes, ((BitString) values[1]).unusedBits, in.getEncoded()); }
AlgorithmIdentifier ai = ((SubjectPublicKeyInfo) SubjectPublicKeyInfo.ASN1.decode(encoding)) .getAlgorithmIdentifier(); if (!subjectPublicKeyAlgID.equals(ai.getAlgorithm())) { return false;
@Override public String toString() { StringBuilder res = new StringBuilder(); res.append("-- CertificationRequestInfo:"); res.append("\n version: "); res.append(version); res.append("\n subject: "); res.append(subject.getName(X500Principal.CANONICAL)); res.append("\n subjectPublicKeyInfo: "); res.append("\n\t algorithm: "); res.append(subjectPublicKeyInfo.getAlgorithmIdentifier().getAlgorithm()); res.append("\n\t public key: ").append(subjectPublicKeyInfo.getPublicKey()); res.append("\n attributes: "); if (attributes != null) { res.append(attributes.toString()); } else { res.append("none"); } res.append("\n-- CertificationRequestInfo End\n"); return res.toString(); }
@Override public PublicKey getPublicKey() { PublicKey result = publicKey; if (result == null) { publicKey = result = tbsCert.getSubjectPublicKeyInfo().getPublicKey(); } return result; }