anon.crypto
Class X509KeyUsage

java.lang.Object
  extended by anon.crypto.AbstractX509Extension
      extended by anon.crypto.X509KeyUsage

public class X509KeyUsage
extends AbstractX509Extension

This class implements the KeyUsage extension for X.509-certificates as specified in RFC 5280.

Author:
Robert Hirschberger
See Also:
http://tools.ietf.org/html/rfc5280

Field Summary
static int CRL_SIGN
           
static int DATA_ENCIPHERMENT
           
static int DECIPHER_ONLY
           
static int DIGITAL_SIGNATURE
           
static int ENCIPHER_ONLY
           
static java.lang.String IDENTIFIER
           
static int KEY_AGREEMENT
           
static int KEY_CERT_SIGN
           
static int KEY_ENCIPHERMENT
           
private  int m_usage
          a vector containing
static int NON_REPUDIATION
           
private static java.lang.String TXT_CRL_SIGN
           
private static java.lang.String TXT_DATA_ENCIPHERMENT
           
private static java.lang.String TXT_DECIPHER_ONLY
           
private static java.lang.String TXT_DIGITAL_SIGNATURE
          the Strings for the different KeyUsages as specified by RFC 5280
private static java.lang.String TXT_ENCIPHER_ONLY
           
private static java.lang.String TXT_KEY_AGREEMENT
           
private static java.lang.String TXT_KEY_CERT_SIGN
           
private static java.lang.String TXT_KEY_ENCIPHERMENT
           
private static java.lang.String TXT_NON_REPUDIATION
           
private static int[] USAGES
          the different KeyUsage values packed into an array for easier Parsing
 
Constructor Summary
X509KeyUsage(org.bouncycastle.asn1.DERSequence a_extension)
          Creates an new X509KeyUsage object from a BouncyCastle DERSequence
X509KeyUsage(int a_usage)
          Creates a new X509KeyUsage object from the specified usage integer.
 
Method Summary
 boolean allowsCRLSign()
           
 boolean allowsDataEncipherment()
           
 boolean allowsDecipherOnly()
           
 boolean allowsDigitalSignature()
           
 boolean allowsEncipherOnly()
           
 boolean allowsKeyAgreement()
           
 boolean allowsKeyCertSign()
           
 boolean allowsKeyEncipherment()
           
 boolean allowsNonRepudiation()
           
private static byte[] createDEROctet(int usage)
          Generates the DEROctets of this extension to hand over to the super class.
private  void createValue()
          reads the usage-integer from the DEROctets of this extension.
 java.lang.String getName()
          Returns the human-readable name of this extension.
 java.lang.String getUsageString(int a_usage)
          Translate a single usage-bitstring (no combination) into a human-readable String.
 java.util.Vector getValues()
          This method returns all values of this extension in separated String objects.
 boolean isAllowedUsage(int a_usage)
           
 
Methods inherited from class anon.crypto.AbstractX509Extension
equals, getBCExtension, getDEROctets, getIdentifier, getInstance, hashCode, isCritical, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTIFIER

public static final java.lang.String IDENTIFIER

DIGITAL_SIGNATURE

public static final int DIGITAL_SIGNATURE
See Also:
Constant Field Values

NON_REPUDIATION

public static final int NON_REPUDIATION
See Also:
Constant Field Values

KEY_ENCIPHERMENT

public static final int KEY_ENCIPHERMENT
See Also:
Constant Field Values

DATA_ENCIPHERMENT

public static final int DATA_ENCIPHERMENT
See Also:
Constant Field Values

KEY_AGREEMENT

public static final int KEY_AGREEMENT
See Also:
Constant Field Values

KEY_CERT_SIGN

public static final int KEY_CERT_SIGN
See Also:
Constant Field Values

CRL_SIGN

public static final int CRL_SIGN
See Also:
Constant Field Values

ENCIPHER_ONLY

public static final int ENCIPHER_ONLY
See Also:
Constant Field Values

DECIPHER_ONLY

public static final int DECIPHER_ONLY
See Also:
Constant Field Values

TXT_DIGITAL_SIGNATURE

private static final java.lang.String TXT_DIGITAL_SIGNATURE
the Strings for the different KeyUsages as specified by RFC 5280

See Also:
Constant Field Values

TXT_NON_REPUDIATION

private static final java.lang.String TXT_NON_REPUDIATION
See Also:
Constant Field Values

TXT_KEY_ENCIPHERMENT

private static final java.lang.String TXT_KEY_ENCIPHERMENT
See Also:
Constant Field Values

TXT_DATA_ENCIPHERMENT

private static final java.lang.String TXT_DATA_ENCIPHERMENT
See Also:
Constant Field Values

TXT_KEY_AGREEMENT

private static final java.lang.String TXT_KEY_AGREEMENT
See Also:
Constant Field Values

TXT_KEY_CERT_SIGN

private static final java.lang.String TXT_KEY_CERT_SIGN
See Also:
Constant Field Values

TXT_CRL_SIGN

private static final java.lang.String TXT_CRL_SIGN
See Also:
Constant Field Values

TXT_ENCIPHER_ONLY

private static final java.lang.String TXT_ENCIPHER_ONLY
See Also:
Constant Field Values

TXT_DECIPHER_ONLY

private static final java.lang.String TXT_DECIPHER_ONLY
See Also:
Constant Field Values

USAGES

private static final int[] USAGES
the different KeyUsage values packed into an array for easier Parsing


m_usage

private int m_usage
a vector containing

Constructor Detail

X509KeyUsage

public X509KeyUsage(int a_usage)
Creates a new X509KeyUsage object from the specified usage integer. This has to be constructed through the bitwise or ("|") from the different available usages in the BC-Class KeyUsage.

Parameters:
a_usage -
See Also:
org.bouncycastle.asn1.x509.KeyUsage;

X509KeyUsage

public X509KeyUsage(org.bouncycastle.asn1.DERSequence a_extension)
Creates an new X509KeyUsage object from a BouncyCastle DERSequence

Parameters:
a_extension - the extions as DERSequence
Method Detail

createDEROctet

private static byte[] createDEROctet(int usage)
Generates the DEROctets of this extension to hand over to the super class.

Parameters:
usage - the allowed usages of this certificate
Returns:
the DEROctets of this extension

getName

public java.lang.String getName()
Description copied from class: AbstractX509Extension
Returns the human-readable name of this extension.

Specified by:
getName in class AbstractX509Extension
Returns:
"KeyUsage"

getValues

public java.util.Vector getValues()
Description copied from class: AbstractX509Extension
This method returns all values of this extension in separated String objects. The values should be human readable.

Specified by:
getValues in class AbstractX509Extension
Returns:
a human-readable Vector of the allowed KeyUsages.

getUsageString

public java.lang.String getUsageString(int a_usage)
Translate a single usage-bitstring (no combination) into a human-readable String.

Parameters:
a_usage - a single usage
Returns:
a human-readable String of the usage or null if the usage is unknown. combined usages return also null!

createValue

private void createValue()
reads the usage-integer from the DEROctets of this extension.


isAllowedUsage

public boolean isAllowedUsage(int a_usage)
Parameters:
a_usage - a (combination of) usage(s) to test against the extension's allowed usages.
Returns:
true if all of the usages are allowed or false otherwise.

allowsDigitalSignature

public boolean allowsDigitalSignature()

allowsNonRepudiation

public boolean allowsNonRepudiation()

allowsKeyEncipherment

public boolean allowsKeyEncipherment()

allowsDataEncipherment

public boolean allowsDataEncipherment()

allowsKeyAgreement

public boolean allowsKeyAgreement()

allowsKeyCertSign

public boolean allowsKeyCertSign()

allowsCRLSign

public boolean allowsCRLSign()

allowsEncipherOnly

public boolean allowsEncipherOnly()

allowsDecipherOnly

public boolean allowsDecipherOnly()