View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.ws.security.components.crypto;
21  
22  import java.math.BigInteger;
23  
24  /**
25   * This class represents a way of passing information to the Crypto.getX509Certificates() method.
26   * The TYPE enum describes which method to use to retrieve the Certificate(s). The corresponding
27   * get accessor must be set accordingly. 
28   */
29  public class CryptoType {
30      
31      /**
32       * TYPE.ISSUER_SERIAL - A certificate (chain) is located by the issuer name and serial number
33       * TYPE.THUMBPRINT_SHA1 - A certificate (chain) is located by the SHA1 of the (root) cert
34       * TYPE.SKI_BYTES - A certificate (chain) is located by the SKI bytes of the (root) cert
35       * TYPE.SUBJECT_DN - A certificate (chain) is located by the Subject DN of the (root) cert
36       * TYPE.ALIAS - A certificate (chain) is located by an alias. This alias is implementation
37       * specific, for example - it could be a java KeyStore alias.
38       */
39      public enum TYPE {
40          ISSUER_SERIAL, THUMBPRINT_SHA1, SKI_BYTES, SUBJECT_DN, ALIAS
41      };
42      
43      private TYPE type;
44      private String issuer;
45      private BigInteger serial;
46      private byte[] bytes;
47      private String subjectDN;
48      private String alias;
49      
50      /**
51       * Default constructor
52       */
53      public CryptoType() {
54          //
55      }
56      
57      /**
58       * Constructor with a TYPE argument
59       * @param type describes which method to use to retrieve a certificate (chain) 
60       */
61      public CryptoType(TYPE type) {
62          this.type = type;
63      }
64      
65      /**
66       * Set the type.
67       * @param type describes which method to use to retrieve a certificate (chain) 
68       */
69      public void setType(TYPE type) {
70          this.type = type;
71      }
72      
73      /**
74       * Get the type
75       * @return which method to use to retrieve a certificate (chain) 
76       */
77      public TYPE getType() {
78          return type;
79      }
80      
81      /**
82       * Set the Issuer String, and Serial number of the cert (chain) to retrieve.
83       * @param issuer the issuer String
84       * @param serial the serial number
85       */
86      public void setIssuerSerial(String issuer, BigInteger serial) {
87          this.issuer = issuer;
88          this.serial = serial;
89      }
90      
91      /**
92       * Get the issuer String.
93       * @return the issuer String
94       */
95      public String getIssuer() {
96          return issuer;
97      }
98      
99      /**
100      * Get the serial number
101      * @return the serial number
102      */
103     public BigInteger getSerial() {
104         return serial;
105     }
106     
107     /**
108      * Set the byte[], which could be the SHA1 thumbprint, or SKI bytes of the cert.
109      * @param bytes an array of bytes 
110      */
111     public void setBytes(byte[] bytes) {
112         this.bytes = bytes;
113     }
114     
115     /**
116      * Get the array of bytes, which could be the SHA1 thumbprint, or SKI bytes of the cert.
117      * @return an array of bytes
118      */
119     public byte[] getBytes() {
120         return bytes;
121     }
122     
123     /**
124      * Set the Subject DN of the cert (chain) to locate
125      * @param subjectDN the Subject DN of the cert (chain) to locate
126      */
127     public void setSubjectDN(String subjectDN) {
128         this.subjectDN = subjectDN;
129     }
130     
131     /**
132      * Get the Subject DN of the cert (chain) to locate
133      * @return the Subject DN of the cert (chain) to locate
134      */
135     public String getSubjectDN() {
136         return subjectDN;
137     }
138     
139     /**
140      * Set the alias of the cert (chain) to locate.
141      * @param alias the alias of the cert (chain) to locate.
142      */
143     public void setAlias(String alias) {
144         this.alias = alias;
145     }
146     
147     /**
148      * Get the alias of the cert (chain) to locate.
149      * @return the alias of the cert (chain) to locate.
150      */
151     public String getAlias() {
152         return alias;
153     }
154     
155 }