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

File AsymmetricKeyFactory.java

 

Code metrics

0
0
0
1
88
17
0
-
-
0
-

Classes

Class Line # Actions
AsymmetricKeyFactory 37 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

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;
21   
22    import java.io.IOException;
23    import java.security.PrivateKey;
24    import java.security.PublicKey;
25   
26    import org.xwiki.component.annotation.Role;
27    import org.xwiki.crypto.params.cipher.asymmetric.PrivateKeyParameters;
28    import org.xwiki.crypto.params.cipher.asymmetric.PublicKeyParameters;
29   
30    /**
31    * Component role for creating key instances and key parameters instances.
32    *
33    * @version $Id: 099286eb41d8cda15976e82240ecdd40de6ece4c $
34    * @since 5.4M1
35    */
36    @Role
 
37    public interface AsymmetricKeyFactory
38    {
39    /**
40    * Create public key parameters from its X.509 encoded form.
41    *
42    * @param encoded an X.509 serialized form of the public key to create.
43    * @return a public key.
44    * @throws IOException on error.
45    */
46    PublicKeyParameters fromX509(byte[] encoded) throws IOException;
47   
48    /**
49    * Create a private key parameters from its PKCS#8 encoded form.
50    *
51    * @param encoded an PKCS#8 serialized form of the private key to create.
52    * @return a private key.
53    * @throws IOException on error.
54    */
55    PrivateKeyParameters fromPKCS8(byte[] encoded) throws IOException;
56   
57    /**
58    * Create a public key parameters from a (compatible) public key.
59    *
60    * @param key any public key.
61    * @return a public key from this factory.
62    */
63    PublicKeyParameters fromKey(PublicKey key);
64   
65    /**
66    * Create a private key parameters from a (compatible) private key.
67    *
68    * @param key any private key.
69    * @return a private key from this factory.
70    */
71    PrivateKeyParameters fromKey(PrivateKey key);
72   
73    /**
74    * Create a public key from public key parameters.
75    *
76    * @param key any public key.
77    * @return a public key from this factory.
78    */
79    PublicKey toKey(PublicKeyParameters key);
80   
81    /**
82    * Create a private key from private key parameters.
83    *
84    * @param key any private key.
85    * @return a private key from this factory.
86    */
87    PrivateKey toKey(PrivateKeyParameters key);
88    }