Example usage for org.bouncycastle.asn1.mozilla PublicKeyAndChallenge getInstance

List of usage examples for org.bouncycastle.asn1.mozilla PublicKeyAndChallenge getInstance

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.mozilla PublicKeyAndChallenge getInstance.

Prototype

public static PublicKeyAndChallenge getInstance(Object obj) 

Source Link

Usage

From source file:org.xwiki.crypto.x509.internal.SpkacRequest.java

License:Open Source License

/**
 * Build a new SPKAC request based on the transmitted bytes.
 * @param bytes the bytes received from the browser for the keygen field.
 *///from  w w w.  j  av a2  s . c o  m
public SpkacRequest(byte[] bytes) {
    ASN1Sequence spkac = null;
    try {
        spkac = (ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(bytes)).readObject();
    } catch (IOException e) {
        throw new IllegalArgumentException("invalid SPKAC request format", e);
    }

    if (spkac.size() != 3) {
        throw new IllegalArgumentException("invalid SPKAC request size:" + spkac.size());
    }
    pkac = PublicKeyAndChallenge.getInstance(spkac.getObjectAt(0));
    algorithmIdentifier = AlgorithmIdentifier.getInstance(spkac.getObjectAt(1)).getAlgorithm().getId();
    signature = ((DERBitString) spkac.getObjectAt(2)).getBytes();
}