01: package org.bouncycastle.asn1.crmf;
02:
03: import org.bouncycastle.asn1.ASN1Encodable;
04: import org.bouncycastle.asn1.ASN1EncodableVector;
05: import org.bouncycastle.asn1.ASN1Sequence;
06: import org.bouncycastle.asn1.DERObject;
07: import org.bouncycastle.asn1.DERSequence;
08: import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
09:
10: public class POPOSigningKeyInput extends ASN1Encodable {
11: private ASN1Encodable authInfo;
12: private SubjectPublicKeyInfo publicKey;
13:
14: private POPOSigningKeyInput(ASN1Sequence seq) {
15: authInfo = (ASN1Encodable) seq.getObjectAt(0);
16: publicKey = SubjectPublicKeyInfo
17: .getInstance(seq.getObjectAt(1));
18: }
19:
20: public static POPOSigningKeyInput getInstance(Object o) {
21: if (o instanceof POPOSigningKeyInput) {
22: return (POPOSigningKeyInput) o;
23: }
24:
25: if (o instanceof ASN1Sequence) {
26: return new POPOSigningKeyInput((ASN1Sequence) o);
27: }
28:
29: throw new IllegalArgumentException("Invalid object: "
30: + o.getClass().getName());
31: }
32:
33: public SubjectPublicKeyInfo getPublicKey() {
34: return publicKey;
35: }
36:
37: /**
38: * <pre>
39: * POPOSigningKeyInput ::= SEQUENCE {
40: * authInfo CHOICE {
41: * sender [0] GeneralName,
42: * -- used only if an authenticated identity has been
43: * -- established for the sender (e.g., a DN from a
44: * -- previously-issued and currently-valid certificate
45: * publicKeyMAC PKMACValue },
46: * -- used if no authenticated GeneralName currently exists for
47: * -- the sender; publicKeyMAC contains a password-based MAC
48: * -- on the DER-encoded value of publicKey
49: * publicKey SubjectPublicKeyInfo } -- from CertTemplate
50: * </pre>
51: * @return a basic ASN.1 object representation.
52: */
53: public DERObject toASN1Object() {
54: ASN1EncodableVector v = new ASN1EncodableVector();
55:
56: v.add(authInfo);
57: v.add(publicKey);
58:
59: return new DERSequence(v);
60: }
61: }
|