KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > security > jauth > callback > SecretKeyCallback


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.security.jauth.callback;
25
26 import java.math.BigInteger JavaDoc;
27 import java.security.Principal JavaDoc;
28 import javax.crypto.SecretKey;
29 import javax.security.auth.callback.Callback JavaDoc;
30
31 /**
32  * Callback for private key and corresponding certificate chain.
33  *
34  * @version %I%, %G%
35  */

36 public class SecretKeyCallback implements Callback JavaDoc {
37
38     private Request request;
39     private SecretKey key;
40
41     /**
42      * Marker interface for private key request types.
43      */

44     public static interface Request { };
45
46     /**
47      * Request type for secret keys that are identified via an alias.
48      */

49     public static class AliasRequest implements Request {
50     private String JavaDoc alias;
51
52     /**
53      * Construct an AliasRequest with an alias.
54      *
55      * <p> The alias is used to directly identify the secret key
56      * to be returned.
57      *
58      * <p> If the alias is null,
59      * the handler of the callback relies on its own default.
60      *
61      * @param alias name identifier for the secret key, or null.
62      */

63     public AliasRequest(String JavaDoc alias) {
64         this.alias = alias;
65     }
66
67     /**
68      * Get the alias.
69      *
70      * @return the alias, or null.
71      */

72     public String JavaDoc getAlias() {
73         return alias;
74     }
75     }
76
77     /**
78      * Constructs this SecretKeyCallback with a secret key Request object.
79      *
80      * <p> The <i>request</i> object identifies the secret key
81      * to be returned.
82      *
83      * If the alias is null, the handler of the callback
84      * relies on its own default.
85      *
86      * @param request request object identifying the secret key, or null.
87      */

88     public SecretKeyCallback(Request request) {
89     this.request = request;
90     }
91
92     /**
93      * Get the Request object which identifies the secret key to be returned.
94      *
95      * @return the Request object which identifies the private key
96      * to be returned, or null. If null, the handler of the callback
97      * relies on its own deafult.
98      */

99     public Request getRequest() {
100     return request;
101     }
102
103     /**
104      * Set the requested secret key.
105      *
106      * @param key the secret key, or null if no key was found.
107      */

108     public void setKey(SecretKey key) {
109     this.key = key;
110     }
111
112     /**
113      * Get the requested secret key.
114      *
115      * @return the secret key, or null if no key was found.
116      */

117     public SecretKey getKey() {
118     return key;
119     }
120 }
121
Popular Tags