1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.crypto.pkix.internal

File BcX509CertificateFactory.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

2
4
2
1
68
30
3
0.75
2
2
1.5

Classes

Class Line # Actions
BcX509CertificateFactory 43 4 0% 3 2
0.7575%
 

Contributing tests

This file is covered by 15 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.crypto.pkix.internal;
21   
22    import java.io.IOException;
23   
24    import javax.inject.Inject;
25    import javax.inject.Named;
26    import javax.inject.Singleton;
27   
28    import org.bouncycastle.cert.X509CertificateHolder;
29    import org.xwiki.component.annotation.Component;
30    import org.xwiki.crypto.pkix.CertificateFactory;
31    import org.xwiki.crypto.pkix.params.CertifiedPublicKey;
32    import org.xwiki.crypto.signer.SignerFactory;
33   
34    /**
35    * X.509 Certificate factory.
36    *
37    * @version $Id: 0bab958acc206555d9a96c4f9eacf54bf56f0ec0 $
38    * @since 5.4
39    */
40    @Component
41    @Singleton
42    @Named("X509")
 
43    public class BcX509CertificateFactory implements CertificateFactory
44    {
45    @Inject
46    private SignerFactory factory;
47   
 
48  36 toggle @Override
49    public CertifiedPublicKey decode(byte[] encoded) throws IOException
50    {
51  36 return convert(new X509CertificateHolder(encoded));
52    }
53   
54    /**
55    * Convert Bouncy Castle certificate holder.
56    *
57    * @param cert a certificate holder.
58    * @return a certified public key.
59    * @since 6.0M1
60    */
 
61  78 toggle public CertifiedPublicKey convert(X509CertificateHolder cert)
62    {
63  78 if (cert == null) {
64  0 return null;
65    }
66  78 return new BcX509CertifiedPublicKey(cert, this.factory);
67    }
68    }