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

KeyUsage

public class KeyUsage extends ExtensionValue
Key Usage Extension (OID = 2.5.29.15). The ASN.1 definition for Key Usage Extension is:
id-ce-keyUsage OBJECT IDENTIFIER ::= { id-ce 15 }

KeyUsage ::= BIT STRING {
digitalSignature (0),
nonRepudiation (1),
keyEncipherment (2),
dataEncipherment (3),
keyAgreement (4),
keyCertSign (5),
cRLSign (6),
encipherOnly (7),
decipherOnly (8)
}
(as specified in RFC 3280 http://www.ietf.org/rfc/rfc3280.txt)

Fields Summary
private static final String[]
USAGES
The names of the usages.
private final boolean[]
keyUsage
private static final org.apache.harmony.security.asn1.ASN1Type
ASN1
X.509 Extension value encoder/decoder.
Constructors Summary
public KeyUsage(boolean[] keyUsage)
Creates the extension object corresponding to the given key usage.


                   
       
        this.keyUsage = keyUsage;
    
public KeyUsage(byte[] encoding)
Creates the extension object on the base of its encoded form.

        super(encoding);
        this.keyUsage = (boolean[]) ASN1.decode(encoding);
    
Methods Summary
public voiddumpValue(java.lang.StringBuffer buffer, java.lang.String prefix)
Places the string representation of extension value into the StringBuffer object.

        buffer.append(prefix).append("KeyUsage [\n"); //$NON-NLS-1$
        for (int i=0; i<keyUsage.length; i++) {
            if (keyUsage[i]) {
                buffer.append(prefix).append("  ") //$NON-NLS-1$
                    .append(USAGES[i]).append('\n");
            }
        }
        buffer.append(prefix).append("]\n"); //$NON-NLS-1$
    
public byte[]getEncoded()
Returns the encoded of the object.

return
a byte array containing ASN.1 encoded form.

        if (encoding == null) {
            encoding = ASN1.encode(keyUsage);
        }
        return encoding;
    
public boolean[]getKeyUsage()

        return keyUsage;