blob: 6c4f260b9d1b51c5ee44b53e7f9421b0539b6cb6 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5
6/*
7 * Copyright 1999-2004 The Apache Software Foundation.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 */
22package com.sun.org.apache.xml.internal.security.keys.storage.implementations;
23
24
25
26import java.security.cert.X509Certificate;
27import java.util.Iterator;
28
29import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolverSpi;
30
31
32/**
33 * This {@link StorageResolverSpi} makes a single {@link X509Certificate}
34 * available to the {@link com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver}.
35 *
36 * @author $Author: raul $
37 */
38public class SingleCertificateResolver extends StorageResolverSpi {
39
40 /** Field _certificate */
41 X509Certificate _certificate = null;
42
43 /** Field _iterator */
44 Iterator _iterator = null;
45
46 /**
47 *
48 *
49 * @param x509cert the single {@link X509Certificate}
50 */
51 public SingleCertificateResolver(X509Certificate x509cert) {
52 this._certificate = x509cert;
53 this._iterator = new InternalIterator(this._certificate);
54 }
55
56 /** @inheritDoc */
57 public Iterator getIterator() {
58 return this._iterator;
59 }
60
61 /**
62 * Class InternalIterator
63 *
64 * @author $Author: raul $
65 */
66 class InternalIterator implements Iterator {
67
68 /** Field _alreadyReturned */
69 boolean _alreadyReturned = false;
70
71 /** Field _certificate */
72 X509Certificate _certificate = null;
73
74 /**
75 * Constructor InternalIterator
76 *
77 * @param x509cert
78 */
79 public InternalIterator(X509Certificate x509cert) {
80 this._certificate = x509cert;
81 }
82
83 /** @inheritDoc */
84 public boolean hasNext() {
85 return (!this._alreadyReturned);
86 }
87
88 /** @inheritDoc */
89 public Object next() {
90
91 this._alreadyReturned = true;
92
93 return this._certificate;
94 }
95
96 /**
97 * Method remove
98 *
99 */
100 public void remove() {
101 throw new UnsupportedOperationException(
102 "Can't remove keys from KeyStore");
103 }
104 }
105}