9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.security.jgss;
27
28 import org.ietf.jgss.*;
29 import sun.security.jgss.GSSContextImpl;
30 import sun.security.krb5.internal.AuthorizationData;
31
32 /**
33 * The extended GSSContext interface for supporting additional
34 * functionalities not defined by {@code org.ietf.jgss.GSSContext},
35 * such as querying context-specific attributes.
36 */
37 public interface ExtendedGSSContext extends GSSContext {
38
39 // The impl is almost identical to GSSContextImpl with only 2 differences:
40 // 1. It implements the extended interface
41 // 2. It translates result to data types here in inquireSecContext
42 static class ExtendedGSSContextImpl extends GSSContextImpl
43 implements ExtendedGSSContext {
44
45 public ExtendedGSSContextImpl(GSSContextImpl old) {
46 super(old);
47 }
48
49 @Override
50 public Object inquireSecContext(InquireType type) throws GSSException {
51 SecurityManager security = System.getSecurityManager();
52 if (security != null) {
53 security.checkPermission(
54 new InquireSecContextPermission(type.toString()));
55 }
56 Object output = super.inquireSecContext(type.name());
57 if (output != null) {
58 if (type == InquireType.KRB5_GET_AUTHZ_DATA) {
59 AuthorizationData ad = (AuthorizationData) output;
60 AuthorizationDataEntry[] authzData =
61 new AuthorizationDataEntry[ad.count()];
62 for (int i = 0; i < ad.count(); i++) {
63 authzData[i] = new AuthorizationDataEntry(
64 ad.item(i).adType, ad.item(i).adData);
65 }
66 output = authzData;
67 }
68 }
69 return output;
70 }
71 }
72
73 /**
74 * Return the mechanism-specific attribute associated with {@code type}.
75 * <p>
76 * If there is a security manager, an {@link InquireSecContextPermission}
77 * with the name {@code type.mech} must be granted. Otherwise, this could
78 * result in a {@link SecurityException}.
79 * <p>
80 * Example:
81 * <pre>
82 * GSSContext ctxt = m.createContext(...)
83 * // Establishing the context
84 * if (ctxt instanceof ExtendedGSSContext) {
85 * ExtendedGSSContext ex = (ExtendedGSSContext)ctxt;
86 * try {
87 * Key key = (key)ex.inquireSecContext(
88 * InquireType.KRB5_GET_SESSION_KEY);
89 * // read key info
90 * } catch (GSSException gsse) {
91 * // deal with exception
|
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.security.jgss;
27
28 import org.ietf.jgss.*;
29
30 /**
31 * The extended GSSContext interface for supporting additional
32 * functionalities not defined by {@code org.ietf.jgss.GSSContext},
33 * such as querying context-specific attributes.
34 */
35 public interface ExtendedGSSContext extends GSSContext {
36
37 /**
38 * Return the mechanism-specific attribute associated with {@code type}.
39 * <p>
40 * If there is a security manager, an {@link InquireSecContextPermission}
41 * with the name {@code type.mech} must be granted. Otherwise, this could
42 * result in a {@link SecurityException}.
43 * <p>
44 * Example:
45 * <pre>
46 * GSSContext ctxt = m.createContext(...)
47 * // Establishing the context
48 * if (ctxt instanceof ExtendedGSSContext) {
49 * ExtendedGSSContext ex = (ExtendedGSSContext)ctxt;
50 * try {
51 * Key key = (key)ex.inquireSecContext(
52 * InquireType.KRB5_GET_SESSION_KEY);
53 * // read key info
54 * } catch (GSSException gsse) {
55 * // deal with exception
|