Clover Coverage Report
Coverage timestamp: Sun Mar 23 2008 08:24:39 GMT
25   190   6   2.5
8   53   0.6   10
10     1.5  
1    
 
 
  AuthorityAttributeIdentifier       Line # 75 25 6 60.5% 0.60465115
 
  (1)
 
1    /*
2    * Copyright (c) 2006, University of Kent
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * Redistributions of source code must retain the above copyright notice, this
9    * list of conditions and the following disclaimer.
10    *
11    * Redistributions in binary form must reproduce the above copyright notice,
12    * this list of conditions and the following disclaimer in the documentation
13    * and/or other materials provided with the distribution.
14    *
15    * 1. Neither the name of the University of Kent nor the names of its
16    * contributors may be used to endorse or promote products derived from this
17    * software without specific prior written permission.
18    *
19    * 2. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20    * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22    * PURPOSE ARE DISCLAIMED.
23    *
24    * 3. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31    * POSSIBILITY OF SUCH DAMAGE.
32    *
33    * 4. YOU AGREE THAT THE EXCLUSIONS IN PARAGRAPHS 2 AND 3 ABOVE ARE REASONABLE
34    * IN THE CIRCUMSTANCES. IN PARTICULAR, YOU ACKNOWLEDGE (1) THAT THIS
35    * SOFTWARE HAS BEEN MADE AVAILABLE TO YOU FREE OF CHARGE, (2) THAT THIS
36    * SOFTWARE IS NOT "PRODUCT" QUALITY, BUT HAS BEEN PRODUCED BY A RESEARCH
37    * GROUP WHO DESIRE TO MAKE THIS SOFTWARE FREELY AVAILABLE TO PEOPLE WHO WISH
38    * TO USE IT, AND (3) THAT BECAUSE THIS SOFTWARE IS NOT OF "PRODUCT" QUALITY
39    * IT IS INEVITABLE THAT THERE WILL BE BUGS AND ERRORS, AND POSSIBLY MORE
40    * SERIOUS FAULTS, IN THIS SOFTWARE.
41    *
42    * 5. This license is governed, except to the extent that local laws
43    * necessarily apply, by the laws of England and Wales.
44    */
45   
46    package issrg.ac.attributes;
47    import iaik.asn1.*;
48    import issrg.ac.IssuerSerial;
49    import java.util.Vector;
50   
51    /**
52    *
53    * @author anhnt
54    */
55   
56   
57    /*15.5.2.4 Authority attribute identifier extension
58   
59    authorityAttributeIdentifier EXTENSION ::=
60    {
61    SYNTAX AuthorityAttributeIdentifierSyntax
62    IDENTIFIED BY { id-ce-authorityAttributeIdentifier }
63    }
64    AuthorityAttributeIdentifierSyntax ::= SEQUENCE SIZE (1..MAX) OF AuthAttId
65    AuthAttId ::= IssuerSerial
66   
67    IssuerSerial ::= SEQUENCE {
68    issuer GeneralNames,
69    serial CertificateSerialNumber, //INTEGER
70    issuerUID UniqueIdentifier OPTIONAL }
71   
72    */
73   
74   
 
75    public class AuthorityAttributeIdentifier extends issrg.ac.Extension {
76   
77    /**
78    *The string stores the standard OID for the Authority Attribute Identifier: 2.5.29.38
79    */
80    public static final String AUTHORITY_ATTRIBUTE_IDENTIFIER_OID = "2.5.29.38";
81   
82    private IssuerSerial[] issuers;
83   
84    /**
85    * This method registers this extension as an extension with a specific
86    * OID. After it has been registered, Extensions can recognise
87    * the extension with this OID.
88    */
89   
 
90  19 toggle public static void registerMe() {
91  19 issrg.ac.Extensions.registerExtension(AUTHORITY_ATTRIBUTE_IDENTIFIER_OID, AuthorityAttributeIdentifier.class);
92    }
93   
94   
95    /** Creates a new instance of AAI extension based on an
96    *existing AAI extension
97    *
98    *@param e is an AAI extension
99    */
100   
 
101  0 toggle public AuthorityAttributeIdentifier(AuthorityAttributeIdentifier e) throws CodingException {
102  0 super(AUTHORITY_ATTRIBUTE_IDENTIFIER_OID, false, e.getExtensionValue());
103    }
104   
105    /**
106    *This method constructs an AAI extension based on a list of issuerSerials
107    *@param issuerSerials is an array of IssuerSerial objects.
108    */
109   
 
110  1 toggle public AuthorityAttributeIdentifier (IssuerSerial[] issuerSerials) {
111  1 super(AUTHORITY_ATTRIBUTE_IDENTIFIER_OID, false);
112  1 setIssuerSerials(issuerSerials);
113    }
114   
 
115  0 toggle public Object clone(){
116  0 try {
117  0 return new AuthorityAttributeIdentifier(this);
118  0 } catch (CodingException ce) {return null;}
119    }
120   
121    /**
122    *This method decodes an ASN1Object to get the array of IssuerSerials
123    *object.
124    *
125    *@param ao is the ASN1Object is going to be decoded.
126    */
 
127  538 toggle public void decodeValue(ASN1Object ao) throws CodingException {
128  538 if (ao.getAsnType()!=ASN.SEQUENCE){
129  0 throw new CodingException("SEQUENCE was expected in AttributeAuthorityIdentifier extension");
130    }
131  538 Vector s = new Vector();
132  538 int num = ao.countComponents();
133  1076 for (int i = 0; i < num; i++) s.add(new IssuerSerial(ao.getComponentAt(i)));
134  538 issuers = (IssuerSerial[]) s.toArray(new IssuerSerial[0]);
135    }
136   
137    /**
138    *This method encodes an array of IssuerSerials objects to an ASN1Object
139    *object. This method is the reversion of the previous method.
140    *
141    *@return an ASN1Object that contains the array of IssuerSerials objects.
142    */
143   
 
144  40 toggle public ASN1Object encodeValue() throws CodingException {
145  40 SEQUENCE s=new SEQUENCE();
146   
147  80 for(int i=0; i<issuers.length; i++){
148  40 s.addComponent(issuers[i].toASN1Object());
149    }
150  40 return s;
151    }
152   
153    /**
154    *This method constructs an AAI extension from an ASN1Object.
155    *
156    *@param ao is an ASN1Object.
157    */
 
158  538 toggle public AuthorityAttributeIdentifier(ASN1Object ao) throws CodingException{
159  538 super(ao);
160    }
161   
162    /**
163    *This method returns all the issuerSerials
164    *@return an array of IssuerSerial
165    */
166   
 
167  0 toggle public IssuerSerial [] getIssuerSerials(){
168  0 return issuers;
169    }
170   
171    /**
172    *This method is used to set the issuerSerials for the object
173    *@param is is an array of IssuerSerial
174    */
175   
 
176  1 toggle public void setIssuerSerials(IssuerSerial [] is){
177  1 issuers=is;
178    }
179   
180    /**
181    *This method creates a string that represents all issuer serials
182    *@param ident is a string used to separate the issuer serials
183    *@return a string that represents all the issuer serials
184    */
 
185  0 toggle public String extensionValueToString(String indent){
186  0 String ret = "";
187  0 for (int i = 0; i < issuers.length; i++) ret=ret+issuers[i].toString(indent);
188  0 return ret;
189    }
190    }