Class SubjectPublicKeyInfo

  • All Implemented Interfaces:
    java.io.Serializable, java.security.Key, java.security.PublicKey, java.security.spec.KeySpec, ASN1Value

    public class SubjectPublicKeyInfo
    extends java.security.spec.X509EncodedKeySpec
    implements ASN1Value, java.security.PublicKey
    A SubjectPublicKeyInfo, which stores information about a public key. This class implements java.security.PublicKey.
    See Also:
    Serialized Form
    • Field Detail

      • TAG

        public static final Tag TAG
    • Method Detail

      • getAlgorithm

        public java.lang.String getAlgorithm()
        Specified by:
        getAlgorithm in interface java.security.Key
        Overrides:
        getAlgorithm in class java.security.spec.EncodedKeySpec
      • getEncoded

        public byte[] getEncoded()
        Specified by:
        getEncoded in interface java.security.Key
        Overrides:
        getEncoded in class java.security.spec.X509EncodedKeySpec
      • getSubjectPublicKey

        public BIT_STRING getSubjectPublicKey()
      • getTag

        public Tag getTag()
        Description copied from interface: ASN1Value
        Returns the base tag for this type, not counting any tags that may be imposed on it by its context.
        Specified by:
        getTag in interface ASN1Value
        Returns:
        Base tag.
      • encode

        public void encode​(java.io.OutputStream ostream)
                    throws java.io.IOException
        Description copied from interface: ASN1Value
        Write this value's DER encoding to an output stream using its own base tag.
        Specified by:
        encode in interface ASN1Value
        Parameters:
        ostream - Output stream.
        Throws:
        java.io.IOException - If an error occurred.
      • encode

        public void encode​(Tag implicit,
                           java.io.OutputStream ostream)
                    throws java.io.IOException
        Description copied from interface: ASN1Value
        Write this value's DER encoding to an output stream using an implicit tag.
        Specified by:
        encode in interface ASN1Value
        Parameters:
        implicit - Implicit tag.
        ostream - Output stream.
        Throws:
        java.io.IOException - If an error occurred.
      • toPublicKey

        public java.security.PublicKey toPublicKey()
                                            throws java.security.NoSuchAlgorithmException,
                                                   InvalidKeyFormatException
        Creates a PublicKey from the public key information. Currently only RSA and DSA keys can be converted.
        Throws:
        java.security.NoSuchAlgorithmException - If the cryptographic provider does not recognize the algorithm for this public key.
        InvalidKeyFormatException - If the subjectPublicKey could not be decoded correctly.