24 */ |
24 */ |
25 |
25 |
26 |
26 |
27 package com.sun.security.sasl.gsskerb; |
27 package com.sun.security.sasl.gsskerb; |
28 |
28 |
|
29 import java.util.Locale; |
29 import java.util.Map; |
30 import java.util.Map; |
30 import java.util.logging.Level; |
31 import java.util.logging.Level; |
31 import javax.security.sasl.*; |
32 import javax.security.sasl.*; |
32 import com.sun.security.sasl.util.AbstractSaslImpl; |
33 import com.sun.security.sasl.util.AbstractSaslImpl; |
33 import org.ietf.jgss.*; |
34 import org.ietf.jgss.*; |
|
35 import com.sun.security.jgss.ExtendedGSSContext; |
|
36 import com.sun.security.jgss.InquireType; |
34 |
37 |
35 abstract class GssKrb5Base extends AbstractSaslImpl { |
38 abstract class GssKrb5Base extends AbstractSaslImpl { |
36 |
39 |
37 private static final String KRB5_OID_STR = "1.2.840.113554.1.2.2"; |
40 private static final String KRB5_OID_STR = "1.2.840.113554.1.2.2"; |
38 protected static Oid KRB5_OID; |
41 protected static Oid KRB5_OID; |
57 * |
60 * |
58 * @return The string "GSSAPI". |
61 * @return The string "GSSAPI". |
59 */ |
62 */ |
60 public String getMechanismName() { |
63 public String getMechanismName() { |
61 return "GSSAPI"; |
64 return "GSSAPI"; |
|
65 } |
|
66 |
|
67 @Override |
|
68 public Object getNegotiatedProperty(String propName) { |
|
69 if (!completed) { |
|
70 throw new IllegalStateException("Authentication incomplete"); |
|
71 } |
|
72 String xprefix = "com.sun.security.jgss.inquiretype."; |
|
73 if (propName.startsWith(xprefix)) { |
|
74 String type = propName.substring(xprefix.length()); |
|
75 if (logger.isLoggable(Level.FINEST)) { |
|
76 logger.logp(Level.FINE, "GssKrb5Base", |
|
77 "getNegotiatedProperty", propName); |
|
78 } |
|
79 for (InquireType t: InquireType.values()) { |
|
80 if (t.name().toLowerCase(Locale.US).equals(type)) { |
|
81 try { |
|
82 return ((ExtendedGSSContext)secCtx).inquireSecContext(t); |
|
83 } catch (GSSException e) { |
|
84 if (logger.isLoggable(Level.FINEST)) { |
|
85 logger.log(Level.WARNING, "inquireSecContext error", e); |
|
86 } |
|
87 return null; |
|
88 } |
|
89 } |
|
90 } |
|
91 // No such InquireType. Although not likely to be defined |
|
92 // as a property in a parent class, still try it. |
|
93 } |
|
94 return super.getNegotiatedProperty(propName); |
62 } |
95 } |
63 |
96 |
64 public byte[] unwrap(byte[] incoming, int start, int len) |
97 public byte[] unwrap(byte[] incoming, int start, int len) |
65 throws SaslException { |
98 throws SaslException { |
66 if (!completed) { |
99 if (!completed) { |