KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > keys > storage > implementations > SingleCertificateResolver


1
2 /*
3  * Copyright 1999-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package com.sun.org.apache.xml.internal.security.keys.storage.implementations;
19
20
21
22 import java.security.cert.X509Certificate JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolverSpi;
26
27
28 /**
29  * This {@link StorageResolverSpi} makes a single {@link X509Certificate}
30  * available to the {@link com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver}.
31  *
32  * @author $Author: raul $
33  */

34 public class SingleCertificateResolver extends StorageResolverSpi {
35
36    /** Field _certificate */
37    X509Certificate JavaDoc _certificate = null;
38
39    /** Field _iterator */
40    Iterator JavaDoc _iterator = null;
41
42    /**
43     *
44     *
45     * @param x509cert the single {@link X509Certificate}
46     */

47    public SingleCertificateResolver(X509Certificate JavaDoc x509cert) {
48       this._certificate = x509cert;
49       this._iterator = new InternalIterator(this._certificate);
50    }
51
52    /** @inheritDoc */
53    public Iterator JavaDoc getIterator() {
54       return this._iterator;
55    }
56
57    /**
58     * Class InternalIterator
59     *
60     * @author $Author: raul $
61     * @version $Revision: 1.6 $
62     */

63    class InternalIterator implements Iterator JavaDoc {
64
65       /** Field _alreadyReturned */
66       boolean _alreadyReturned = false;
67
68       /** Field _certificate */
69       X509Certificate JavaDoc _certificate = null;
70
71       /**
72        * Constructor InternalIterator
73        *
74        * @param x509cert
75        */

76       public InternalIterator(X509Certificate JavaDoc x509cert) {
77          this._certificate = x509cert;
78       }
79
80       /** @inheritDoc */
81       public boolean hasNext() {
82          return (!this._alreadyReturned);
83       }
84
85       /** @inheritDoc */
86       public Object JavaDoc next() {
87
88          this._alreadyReturned = true;
89
90          return this._certificate;
91       }
92
93       /**
94        * Method remove
95        *
96        */

97       public void remove() {
98          throw new UnsupportedOperationException JavaDoc(
99             "Can't remove keys from KeyStore");
100       }
101    }
102 }
103
Popular Tags