| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
package javax.security.auth.message.callback; |
| 18 | |
|
| 19 | |
import javax.security.auth.callback.Callback; |
| 20 | |
import javax.security.auth.x500.X500Principal; |
| 21 | |
|
| 22 | |
import java.math.BigInteger; |
| 23 | |
import java.security.PrivateKey; |
| 24 | |
import java.security.cert.Certificate; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public class PrivateKeyCallback implements Callback { |
| 34 | |
|
| 35 | |
private final Request request; |
| 36 | |
private Certificate[] chain; |
| 37 | |
private PrivateKey key; |
| 38 | |
|
| 39 | 0 | public PrivateKeyCallback(Request request) { |
| 40 | 0 | this.request = request; |
| 41 | 0 | } |
| 42 | |
|
| 43 | |
public Request getRequest() { |
| 44 | 0 | return request; |
| 45 | |
} |
| 46 | |
|
| 47 | |
public Certificate[] getChain() { |
| 48 | 0 | return chain; |
| 49 | |
} |
| 50 | |
|
| 51 | |
public PrivateKey getKey() { |
| 52 | 0 | return key; |
| 53 | |
} |
| 54 | |
|
| 55 | |
public void setKey(PrivateKey key, Certificate[] chain) { |
| 56 | 0 | this.key = key; |
| 57 | 0 | this.chain = chain; |
| 58 | 0 | } |
| 59 | |
|
| 60 | |
public static interface Request { |
| 61 | |
} |
| 62 | |
|
| 63 | |
public static class AliasRequest implements Request { |
| 64 | |
|
| 65 | |
private final String alias; |
| 66 | |
|
| 67 | 0 | public AliasRequest(String alias) { |
| 68 | 0 | this.alias = alias; |
| 69 | 0 | } |
| 70 | |
|
| 71 | |
public String getAlias() { |
| 72 | 0 | return alias; |
| 73 | |
} |
| 74 | |
} |
| 75 | |
|
| 76 | |
public static class DigestRequest implements Request { |
| 77 | |
private final byte[] digest; |
| 78 | |
private final String algorithm; |
| 79 | |
|
| 80 | |
|
| 81 | 0 | public DigestRequest(byte[] digest, String algorithm) { |
| 82 | 0 | this.digest = digest; |
| 83 | 0 | this.algorithm = algorithm; |
| 84 | 0 | } |
| 85 | |
|
| 86 | |
public byte[] getDigest() { |
| 87 | 0 | return digest; |
| 88 | |
} |
| 89 | |
|
| 90 | |
public String getAlgorithm() { |
| 91 | 0 | return algorithm; |
| 92 | |
} |
| 93 | |
} |
| 94 | |
|
| 95 | |
public static class SubjectKeyIDRequest implements Request { |
| 96 | |
|
| 97 | |
private final byte[] subjectKeyID; |
| 98 | |
|
| 99 | 0 | public SubjectKeyIDRequest(byte[] subjectKeyID) { |
| 100 | 0 | this.subjectKeyID = subjectKeyID; |
| 101 | 0 | } |
| 102 | |
|
| 103 | |
public byte[] getSubjectKeyID() { |
| 104 | 0 | return subjectKeyID; |
| 105 | |
} |
| 106 | |
} |
| 107 | |
|
| 108 | |
public static class IssuerSerialNumRequest implements Request { |
| 109 | |
private final X500Principal issuer; |
| 110 | |
private final BigInteger serialNum; |
| 111 | |
|
| 112 | 0 | public IssuerSerialNumRequest(X500Principal issuer, BigInteger serialNum) { |
| 113 | 0 | this.issuer = issuer; |
| 114 | 0 | this.serialNum = serialNum; |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
public X500Principal getIssuer() { |
| 118 | 0 | return issuer; |
| 119 | |
} |
| 120 | |
|
| 121 | |
public BigInteger getSerialNum() { |
| 122 | 0 | return serialNum; |
| 123 | |
} |
| 124 | |
} |
| 125 | |
} |