Coverage Report - org.openpermis.cert.CertStoreCertificateRepository
 
Classes in this File Line Coverage Branch Coverage Complexity
CertStoreCertificateRepository
71%
5/7
50%
1/2
1.667
 
 1  
 /*
 2  
  * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport
 3  
  *                     (http://www.vbs.admin.ch)
 4  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 5  
  * All rights reserved.
 6  
  *
 7  
  * Licensed under the Open Permis License which accompanies this distribution,
 8  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 9  
  */
 10  
 package org.openpermis.cert;
 11  
 
 12  
 import java.security.cert.CRL;
 13  
 import java.security.cert.CRLSelector;
 14  
 import java.security.cert.CertSelector;
 15  
 import java.security.cert.CertStore;
 16  
 import java.security.cert.CertStoreException;
 17  
 import java.security.cert.Certificate;
 18  
 import java.util.Collection;
 19  
 
 20  
 /**
 21  
  * This certificate repository is backed the specified {@link CertStore} object.
 22  
  * 
 23  
  * Different crypto providers offer different certificate stores such as memory based
 24  
  * and LDAP directory based certificate stores.
 25  
  * @since 0.3.0
 26  
  */
 27  
 public class CertStoreCertificateRepository implements CertificateRepository {
 28  
 
 29  
         //---- State
 30  
         // internal collection based cert store
 31  
         private CertStore certStore;
 32  
         
 33  
         //---- Constructors
 34  
         
 35  
         /**
 36  
          * Creates an instance of this certificate repository implementation given the specified 
 37  
          * {@link CertStore} object.
 38  
          * @param certStore The certificate store object. Must not be <code>null</code>.
 39  
          * @since 0.3.0
 40  
          */
 41  9
         public CertStoreCertificateRepository (CertStore certStore) {
 42  9
                 if (certStore == null) {
 43  0
                         throw new IllegalArgumentException("cert store is null");
 44  
                 }
 45  9
                 this.certStore = certStore;
 46  9
         }
 47  
         
 48  
         /**
 49  
          * {@inheritDoc}
 50  
          * @since 0.3.0
 51  
          */
 52  
         public Collection<? extends Certificate> getCertificates (CertSelector selector) 
 53  
                 throws CertStoreException 
 54  
         {
 55  6
                 return this.certStore.getCertificates(selector);
 56  
         }
 57  
 
 58  
         /**
 59  
          * {@inheritDoc}
 60  
          * @since 0.3.0
 61  
          */
 62  
         public Collection<? extends CRL> getCrls (CRLSelector selector) throws CertStoreException {
 63  0
                 return this.certStore.getCRLs(selector);
 64  
         }
 65  
 
 66  
 }