]> WPIA git - gigi.git/blob - src/club/wpia/gigi/crypto/key/KeyCheckPublicKeyFormat.java
Merge "add: show more certificates on the "roots" page"
[gigi.git] / src / club / wpia / gigi / crypto / key / KeyCheckPublicKeyFormat.java
1 package club.wpia.gigi.crypto.key;
2
3 import java.security.PublicKey;
4 import java.security.interfaces.DSAPublicKey;
5 import java.security.interfaces.ECPublicKey;
6 import java.security.interfaces.RSAPublicKey;
7
8 import club.wpia.gigi.GigiApiException;
9 import club.wpia.gigi.output.template.SprintfCommand;
10
11 public class KeyCheckPublicKeyFormat extends KeyCheck {
12
13     static {
14         register(new KeyCheckPublicKeyFormat());
15     }
16
17     @Override
18     public void check(PublicKey key) throws GigiApiException {
19
20         if (key instanceof RSAPublicKey) {
21             return;
22         }
23
24         if (key instanceof DSAPublicKey) {
25             return;
26         }
27
28         if (key instanceof ECPublicKey) {
29             return;
30         }
31
32         throw new GigiApiException(SprintfCommand.createSimple("Public Key Format Check: Unknown or unsupported public key algorithm {0}", key.getAlgorithm()));
33
34     }
35
36 }