1 /*
2  * @(#) $Id: CSRInfo.java,v 1.3 2003/07/08 08:13:53 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10package org.jstk.pki;
11
12import java.io.IOException;
13import org.jstk.asn1.*;
14
15/*
16 * CSRInfo ::= SEQUENCE {
17 *   version                INTEGER,
18 *   subject                Name,
19 *   publicKeyInfo          SubjectPublicKeyInfo,
20 *   attributes             SET OF ... }
21 */
22public class CSRInfo extends ASN1Seq{
23    // A sequence of following elements.
24    private ASN1Integer version = new ASN1Integer();
25    private Name subject = new Name();
26    private SubjectPublicKeyInfo publicKeyInfo = new SubjectPublicKeyInfo();
27    private ASN1Any attributes = new ASN1Any();
28
29    public CSRInfo(){
30        super();
31        attributes.setTagNumber(0);
32        attributes.setConsMask(CONSTRUCTED);
33
34        add(version);
35        add(subject);
36        add(publicKeyInfo);
37        add(attributes);
38    }
39
40    public ASN1Integer getVersion(){
41        return version;
42    }
43
44    public Name getSubject(){
45        return subject;
46    }
47
48    public void setSubject(Name subject){
49        this.subject = subject;
50    }
51
52    public SubjectPublicKeyInfo getPublicKeyInfo(){
53        return publicKeyInfo;
54    }
55
56    public ASN1Any getAttributes(){
57        return attributes;
58    }
59
60    public String toString(){
61        StringBuffer sb = new StringBuffer();
62        sb.append("CSRInfo-SEQ(" + version.toString() + ", " + subject.toString() + ", ");
63        sb.append(publicKeyInfo.toString() + ", " + attributes.toString() + ")");
64        return sb.toString();
65    }
66}
67
68