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