Coverage Report - javax.security.auth.message.callback.PrivateKeyCallback
 
Classes in this File Line Coverage Branch Coverage Complexity
PrivateKeyCallback
0%
0/9
N/A
1
PrivateKeyCallback$AliasRequest
0%
0/4
N/A
1
PrivateKeyCallback$DigestRequest
0%
0/6
N/A
1
PrivateKeyCallback$IssuerSerialNumRequest
0%
0/6
N/A
1
PrivateKeyCallback$Request
N/A
N/A
1
PrivateKeyCallback$SubjectKeyIDRequest
0%
0/4
N/A
1
 
 1  
 /**
 2  
  *  Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  *  contributor license agreements.  See the NOTICE file distributed with
 4  
  *  this work for additional information regarding copyright ownership.
 5  
  *  The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  *  (the "License"); you may not use this file except in compliance with
 7  
  *  the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  *  Unless required by applicable law or agreed to in writing, software
 12  
  *  distributed under the License is distributed on an "AS IS" BASIS,
 13  
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  *  See the License for the specific language governing permissions and
 15  
  *  limitations under the License.
 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  
  * Callback that enables an authentication module to request a certificate chain and private key from the runtime.
 28  
  * The information specifying the chain and key may be an alias, a digest, a subject key, or an issuer ID.
 29  
  * Other request types may be supported.
 30  
  *
 31  
  * @version $Rev: 768352 $ $Date: 2009-04-24 09:26:01 -0700 (Fri, 24 Apr 2009) $
 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  
 }