< prev index next >
src/jdk.security.jgss/share/classes/com/sun/security/jgss/Extender.java
Print this page
rev 14722 : imported patch 8153362
@@ -25,32 +25,77 @@
package com.sun.security.jgss;
import org.ietf.jgss.GSSContext;
import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
import sun.security.jgss.GSSContextImpl;
import sun.security.jgss.GSSCredentialImpl;
import sun.security.jgss.JgssExtender;
+import sun.security.krb5.internal.AuthorizationData;
// The com.sun.security.jgss extension to JGSS-API
class Extender extends JgssExtender {
static {
JgssExtender.setExtender(new Extender());
}
public GSSCredential wrap(GSSCredential cred) {
- if (cred instanceof ExtendedGSSCredential.ExtendedGSSCredentialImpl) {
+ if (cred instanceof ExtendedGSSCredentialImpl) {
return cred;
} else {
- return new ExtendedGSSCredential.ExtendedGSSCredentialImpl((GSSCredentialImpl)cred);
+ return new ExtendedGSSCredentialImpl((GSSCredentialImpl)cred);
}
}
public GSSContext wrap(GSSContext ctxt) {
- if (ctxt instanceof ExtendedGSSContext.ExtendedGSSContextImpl) {
+ if (ctxt instanceof ExtendedGSSContextImpl) {
return ctxt;
} else {
- return new ExtendedGSSContext.ExtendedGSSContextImpl((GSSContextImpl)ctxt);
+ return new ExtendedGSSContextImpl((GSSContextImpl)ctxt);
}
}
+
+ // The impl is almost identical to GSSContextImpl with only 2 differences:
+ // 1. It implements the extended interface
+ // 2. It translates result to data types here in inquireSecContext
+ class ExtendedGSSContextImpl extends GSSContextImpl
+ implements ExtendedGSSContext {
+
+ public ExtendedGSSContextImpl(GSSContextImpl old) {
+ super(old);
+ }
+
+ @Override
+ public Object inquireSecContext(InquireType type) throws GSSException {
+ SecurityManager security = System.getSecurityManager();
+ if (security != null) {
+ security.checkPermission(
+ new InquireSecContextPermission(type.toString()));
+ }
+ Object output = super.inquireSecContext(type.name());
+ if (output != null) {
+ if (type == InquireType.KRB5_GET_AUTHZ_DATA) {
+ AuthorizationData ad = (AuthorizationData) output;
+ AuthorizationDataEntry[] authzData =
+ new AuthorizationDataEntry[ad.count()];
+ for (int i = 0; i < ad.count(); i++) {
+ authzData[i] = new AuthorizationDataEntry(
+ ad.item(i).adType, ad.item(i).adData);
+ }
+ output = authzData;
+ }
+ }
+ return output;
+ }
+ }
+
+ class ExtendedGSSCredentialImpl extends GSSCredentialImpl
+ implements ExtendedGSSCredential {
+
+ public ExtendedGSSCredentialImpl(GSSCredentialImpl old) {
+ super(old);
+ }
+ }
+
}
< prev index next >