001: // CMP implementation copyright (c) 2003 NOVOSEC AG (http://www.novosec.com)
002: //
003: // Author: Maik Stohn
004: //
005: // Permission is hereby granted, free of charge, to any person obtaining a copy of this
006: // software and associated documentation files (the "Software"), to deal in the Software
007: // without restriction, including without limitation the rights to use, copy, modify, merge,
008: // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
009: // to whom the Software is furnished to do so, subject to the following conditions:
010: //
011: // The above copyright notice and this permission notice shall be included in all copies or
012: // substantial portions of the Software.
013: //
014: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
015: // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
016: // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
017: // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
018: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
019:
020: package com.novosec.pkix.asn1.cmp;
021:
022: import java.util.Enumeration;
023: import java.util.Vector;
024:
025: import org.bouncycastle.asn1.ASN1EncodableVector;
026: import org.bouncycastle.asn1.ASN1Sequence;
027: import org.bouncycastle.asn1.ASN1TaggedObject;
028: import org.bouncycastle.asn1.DEREncodable;
029: import org.bouncycastle.asn1.DERObject;
030: import org.bouncycastle.asn1.DERSequence;
031:
032: /**
033: * ASN.1 structure DER En/DeCoder.
034: *
035: * <pre>
036: * RevReqContent ::= SEQUENCE OF RevDetails
037: *
038: * </pre>
039: */
040: public class RevReqContent implements DEREncodable {
041: Vector revDetails = new Vector();
042:
043: public static RevReqContent getInstance(ASN1TaggedObject obj,
044: boolean explicit) {
045: return getInstance(ASN1Sequence.getInstance(obj, explicit));
046: }
047:
048: public static RevReqContent getInstance(Object obj) {
049: if (obj instanceof RevReqContent) {
050: return (RevReqContent) obj;
051: } else if (obj instanceof ASN1Sequence) {
052: return new RevReqContent((ASN1Sequence) obj);
053: }
054:
055: throw new IllegalArgumentException("unknown object in factory");
056: }
057:
058: public RevReqContent(ASN1Sequence seq) {
059: Enumeration e = seq.getObjects();
060:
061: while (e.hasMoreElements())
062: revDetails.addElement(RevDetails.getInstance(e
063: .nextElement()));
064: }
065:
066: public RevReqContent(RevDetails p) {
067: revDetails.addElement(p);
068: }
069:
070: public void addRevDetails(RevDetails p) {
071: revDetails.addElement(p);
072: }
073:
074: public RevDetails getRevDetails(int nr) {
075: if (revDetails.size() > nr)
076: return (RevDetails) revDetails.elementAt(nr);
077:
078: return null;
079: }
080:
081: public DERObject getDERObject() {
082: ASN1EncodableVector v = new ASN1EncodableVector();
083:
084: for (int i = 0; i < revDetails.size(); i++)
085: v.add((RevDetails) revDetails.elementAt(i));
086:
087: return new DERSequence(v);
088: }
089:
090: public String toString() {
091: String s = "RevReqContent: (";
092:
093: for (int i = 0; i < revDetails.size(); i++)
094: s += revDetails.elementAt(i) + ", ";
095:
096: s += ")";
097:
098: return s;
099: }
100: }
|