当前位置: 首页>>代码示例>>Java>>正文


Java InquireType类代码示例

本文整理汇总了Java中com.sun.security.jgss.InquireType的典型用法代码示例。如果您正苦于以下问题:Java InquireType类的具体用法?Java InquireType怎么用?Java InquireType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InquireType类属于com.sun.security.jgss包,在下文中一共展示了InquireType类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inquireSecContext

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
/**
 * Return the mechanism-specific attribute associated with {@code type}.
 */
public Object inquireSecContext(InquireType type)
        throws GSSException {
    if (!isEstablished()) {
         throw new GSSException(GSSException.NO_CONTEXT, -1,
                 "Security context not established.");
    }
    switch (type) {
        case KRB5_GET_SESSION_KEY:
            return new KerberosSessionKey(key);
        case KRB5_GET_TKT_FLAGS:
            return tktFlags.clone();
        case KRB5_GET_AUTHZ_DATA:
            if (isInitiator()) {
                throw new GSSException(GSSException.UNAVAILABLE, -1,
                        "AuthzData not available on initiator side.");
            } else {
                return (authzData==null)?null:authzData.clone();
            }
        case KRB5_GET_AUTHTIME:
            return authTime;
    }
    throw new GSSException(GSSException.UNAVAILABLE, -1,
            "Inquire type not supported.");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Krb5Context.java

示例2: main

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

        new OneKDC(null).writeJAASConf();

        Context c, s;
        c = Context.fromJAAS("client");
        s = Context.fromJAAS("server");

        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);

        Context.handshake(c, s);

        ExtendedGSSContext ctxt = (ExtendedGSSContext)c.x();
        EncryptionKey key = (EncryptionKey)
                ctxt.inquireSecContext(InquireType.KRB5_GET_SESSION_KEY_EX);
        KerberosCredMessage cred = (KerberosCredMessage)
                ctxt.inquireSecContext(InquireType.KRB5_GET_KRB_CRED);
        c.status();

        // Confirm the KRB_CRED message is encrypted with the session key.
        new KRBCred(cred.getEncoded()).encPart.decrypt(
                new sun.security.krb5.EncryptionKey(key.getKeyType(), key.getEncoded()),
                KeyUsage.KU_ENC_KRB_CRED_PART);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:NewInquireTypes.java

示例3: checkAuthzData

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
public static KerbToken checkAuthzData(GSSContext context) throws GSSException, IOException {
    System.out.println("Looking for token from authorization data in GSSContext");

    Object authzData = null;
    if (context instanceof ExtendedGSSContext) {
        ExtendedGSSContext ex = (ExtendedGSSContext)context;
        authzData = ex.inquireSecContext(
                InquireType.KRB5_GET_AUTHZ_DATA);
    }

    if (authzData != null) {
        AuthorizationDataEntry[] authzEntries = (AuthorizationDataEntry[]) authzData;
        KerbToken resultToken = null;
        for (int i = 0; i < authzEntries.length; ++i) {
            resultToken = getAuthzToken(authzEntries[i]);
            if (resultToken != null) {
                return resultToken;
            }
        }
    }
    return null;
}
 
开发者ID:drankye,项目名称:haox,代码行数:23,代码来源:TokenExtractor.java

示例4: inquireSecContext

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
/**
 * Retrieve attribute of the context for {@code type}.
 */
public Object inquireSecContext(InquireType type)
        throws GSSException {
    if (mechContext == null) {
        throw new GSSException(GSSException.NO_CONTEXT, -1,
                "Underlying mech not established.");
    }
    if (mechContext instanceof ExtendedGSSContext) {
        return ((ExtendedGSSContext)mechContext).inquireSecContext(type);
    } else {
        throw new GSSException(GSSException.BAD_MECH, -1,
                "inquireSecContext not supported by underlying mech.");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:SpNegoContext.java

示例5: getNegotiatedProperty

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
@Override
public Object getNegotiatedProperty(String propName) {
    if (!completed) {
        throw new IllegalStateException("Authentication incomplete");
    }
    String xprefix = "com.sun.security.jgss.inquiretype.";
    if (propName.startsWith(xprefix)) {
        String type = propName.substring(xprefix.length());
        if (logger.isLoggable(Level.FINEST)) {
            logger.logp(Level.FINE, "GssKrb5Base",
                    "getNegotiatedProperty", propName);
        }
        for (InquireType t: InquireType.values()) {
            if (t.name().toLowerCase(Locale.US).equals(type)) {
                try {
                    return ((ExtendedGSSContext)secCtx).inquireSecContext(t);
                } catch (GSSException e) {
                    if (logger.isLoggable(Level.FINEST)) {
                        logger.log(Level.WARNING, "inquireSecContext error", e);
                    }
                    return null;
                }
            }
        }
        // No such InquireType. Although not likely to be defined
        // as a property in a parent class, still try it.
    }
    return super.getNegotiatedProperty(propName);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:GssKrb5Base.java

示例6: getServiceTicketData

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
/**
 * 
 * @param servicePrincipalName
 * @return
 * @throws GSSException
 */
private byte[] getServiceTicketData(final String servicePrincipalName) throws GSSException {
	byte serviceTicket[] = null;
	serviceTicket = (byte[]) (byte[]) Subject.doAs(subject, new PrivilegedAction<byte[]>() {
		public byte[] run() {
			try {
				GSSManager manager = GSSManager.getInstance();
				Oid krb5Oid = new Oid("1.2.840.113554.1.2.2");
				Oid krb5PrincipalNameType = new Oid("1.2.840.113554.1.2.2.1");
				GSSName serverName = manager.createName(servicePrincipalName,
						krb5PrincipalNameType);
				final GSSContext context = manager.createContext(serverName, krb5Oid, null, 0);
				byte[] token = new byte[0];
				context.requestMutualAuth(false);
				context.requestCredDeleg(false);
				byte[] srvTckt = context.initSecContext(token, 0, token.length);
				
				if (context instanceof ExtendedGSSContext) {
					ExtendedGSSContext exgssContext = (ExtendedGSSContext) context;
					// return the mechanism-specific attribute associated with type
					Key encKey = (Key) exgssContext.inquireSecContext(InquireType.KRB5_GET_SESSION_KEY);
					// algorithm name here does not really matter.
					SecretKeySpec keySpec = new SecretKeySpec(encKey.getEncoded(), "DES");
					sessionKey = (SecretKey) keySpec;
				}
				
				return srvTckt;
				
			} catch (GSSException e) {
				log.error("Error occurred while accepting securing context", e);
				return null;
			}
		}
	});

	return serviceTicket;
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:43,代码来源:WSSecKerberosToken.java

示例7: acceptSecurityContext

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
/**
 * 
 * @param ks
 * @return
 * @throws GSSException
 */
private GSSContext acceptSecurityContext(final KerberosSecurity ks)
		throws GSSException {

	Subject.doAs(subject, new PrivilegedAction<GSSContext>() {
		public GSSContext run() {
			try {
				GSSManager gssManager = null;
				gssManager = GSSManager.getInstance();
				gssContext = gssManager.createContext((GSSCredential) null);
				byte[] token = ks.getToken();
				gssContext.acceptSecContext(token, 0, token.length);
				
				if (gssContext instanceof ExtendedGSSContext) {
					ExtendedGSSContext exgssContext = (ExtendedGSSContext) gssContext;
					// return the mechanism-specific attribute associated with type
					Key encKey = (Key) exgssContext.inquireSecContext(InquireType.KRB5_GET_SESSION_KEY);
					// the algorithm name does not matter here
					SecretKeySpec keySpec = new SecretKeySpec(encKey.getEncoded(), "DES");
					key = (SecretKey) keySpec;
				}
				
				return gssContext;
			} catch (GSSException e) {
				log.error("Error occurred while accepting securing context", e);
				return null;
			}
		}
	});
	return gssContext;
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:37,代码来源:KerberosTokenProcessor.java

示例8: inquireSecContext

import com.sun.security.jgss.InquireType; //导入依赖的package包/类
public Object inquireSecContext(InquireType type)
        throws GSSException {
    throw new GSSException(GSSException.UNAVAILABLE, -1,
            "Inquire type not supported.");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:NativeGSSContext.java


注:本文中的com.sun.security.jgss.InquireType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。