FileDocCategorySizeDatePackage
SubjectPublicKeyInfo.javaAPI DocAndroid 1.5 API6232Wed May 06 22:41:06 BST 2009org.apache.harmony.security.x509

SubjectPublicKeyInfo

public class SubjectPublicKeyInfo extends Object
The class encapsulates the ASN.1 DER encoding/decoding work with the following structure which is a part of X.509 certificate (as specified in RFC 3280 - Internet X.509 Public Key Infrastructure. Certificate and Certificate Revocation List (CRL) Profile. http://www.ietf.org/rfc/rfc3280.txt):
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING
}

Fields Summary
private AlgorithmIdentifier
algorithmID
private byte[]
subjectPublicKey
private PublicKey
publicKey
private int
unusedBits
private byte[]
encoding
public static final org.apache.harmony.security.asn1.ASN1Sequence
ASN1
Constructors Summary
public SubjectPublicKeyInfo(AlgorithmIdentifier algID, byte[] subjectPublicKey)
TODO

param
algID: AlgorithmIdentifier
param
subjectPublicKey: byte[]

 
        this(algID, subjectPublicKey, 0);
    
public SubjectPublicKeyInfo(AlgorithmIdentifier algID, byte[] subjectPublicKey, int unused)
TODO

param
algID: AlgorithmIdentifier
param
subjectPublicKey: byte[]
param
unused: int

        this(algID, subjectPublicKey, 0, null);
    
private SubjectPublicKeyInfo(AlgorithmIdentifier algID, byte[] subjectPublicKey, int unused, byte[] encoding)

        this.algorithmID = algID;
        this.subjectPublicKey = subjectPublicKey;
        this.unusedBits = unused;
        this.encoding = encoding;
    
Methods Summary
public AlgorithmIdentifiergetAlgorithmIdentifier()
Returns the value of algorithmIdentifier field of the structure.

return
algorithmIdentifier

        return algorithmID;
    
public byte[]getEncoded()
Returns ASN.1 encoded form of this X.509 SubjectPublicKeyInfo value.

return
a byte array containing ASN.1 encode form.

        if (encoding == null) {
            encoding = ASN1.encode(this);
        }
        return encoding;
    
public java.security.PublicKeygetPublicKey()
Returns The PublicKey corresponding to this SubjectPublicKeyInfo instance.

return
public key corresponding to this SubjectPublicKeyInfo.

        if (publicKey == null) {
            String alg_oid = algorithmID.getAlgorithm();
            try {
                String alg = 
                    AlgNameMapper.map2AlgName(alg_oid);
                
                if (alg == null) {
                    alg = alg_oid;
                }
                publicKey = KeyFactory.getInstance(alg)
                    .generatePublic(new X509EncodedKeySpec(getEncoded()));
            } catch (InvalidKeySpecException e) {
            } catch (NoSuchAlgorithmException e) {
            }
            if (publicKey == null) {
                publicKey = new X509PublicKey(alg_oid, getEncoded(),
                        subjectPublicKey);
            }
        }
        return publicKey;
    
public byte[]getSubjectPublicKey()
Returns the value of subjectPublicKey field of the structure.

return
subjectPublicKey

        return subjectPublicKey;
    
public intgetUnusedBits()
Returns the value of unusedBits field of the structure.

return
unusedBits

        return unusedBits;