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


Java ProtocolVersion类代码示例

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


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

示例1: KerberosPreMasterSecret

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
/**
 * Constructor used by client to generate premaster secret.
 *
 * Client randomly creates a pre-master secret and encrypts it
 * using the Kerberos session key; only the server can decrypt
 * it, using the session key available in the service ticket.
 *
 * @param protocolVersion used to set preMaster[0,1]
 * @param generator random number generator for generating premaster secret
 * @param sessionKey Kerberos session key for encrypting premaster secret
 */
KerberosPreMasterSecret(ProtocolVersion protocolVersion,
    SecureRandom generator, EncryptionKey sessionKey) throws IOException {

    if (sessionKey.getEType() ==
        EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
        throw new IOException(
           "session keys with des3-cbc-hmac-sha1-kd encryption type " +
           "are not supported for TLS Kerberos cipher suites");
    }

    this.protocolVersion = protocolVersion;
    preMaster = generatePreMaster(generator, protocolVersion);

    // Encrypt premaster secret
    try {
        EncryptedData eData = new EncryptedData(sessionKey, preMaster,
            KeyUsage.KU_UNKNOWN);
        encrypted = eData.getBytes();  // not ASN.1 encoded.

    } catch (KrbException e) {
        throw (SSLKeyException)new SSLKeyException
            ("Kerberos premaster secret error").initCause(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:KerberosPreMasterSecret.java

示例2: init

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
/**
 * Creates an instance of KerberosClientKeyExchange consisting of the
 * Kerberos service ticket, authenticator and encrypted premaster secret.
 * Called by client handshaker.
 *
 * @param serverName name of server with which to do handshake;
 *             this is used to get the Kerberos service ticket
 * @param protocolVersion Maximum version supported by client (i.e,
 *          version it requested in client hello)
 * @param rand random number generator to use for generating pre-master
 *          secret
 */
@Override
public void init(String serverName,
    AccessControlContext acc, ProtocolVersion protocolVersion,
    SecureRandom rand) throws IOException {

     // Get service ticket
     KerberosTicket ticket = getServiceTicket(serverName, acc);
     encodedTicket = ticket.getEncoded();

     // Record the Kerberos principals
     peerPrincipal = ticket.getServer();
     localPrincipal = ticket.getClient();

     // Optional authenticator, encrypted using session key,
     // currently ignored

     // Generate premaster secret and encrypt it using session key
     EncryptionKey sessionKey = new EncryptionKey(
                                    ticket.getSessionKeyType(),
                                    ticket.getSessionKey().getEncoded());

     preMaster = new KerberosPreMasterSecret(protocolVersion,
         rand, sessionKey);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:KerberosClientKeyExchangeImpl.java

示例3: KerberosPreMasterSecret

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
/**
 * Constructor used by client to generate premaster secret.
 *
 * Client randomly creates a pre-master secret and encrypts it
 * using the Kerberos session key; only the server can decrypt
 * it, using the session key available in the service ticket.
 *
 * @param protocolVersion used to set preMaster[0,1]
 * @param generator random number generator for generating premaster secret
 * @param sessionKey Kerberos session key for encrypting premaster secret
 */
KerberosPreMasterSecret(ProtocolVersion protocolVersion,
        SecureRandom generator, EncryptionKey sessionKey) throws IOException {

    if (sessionKey.getEType() ==
            EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
        throw new IOException(
                "session keys with des3-cbc-hmac-sha1-kd encryption type " +
                        "are not supported for TLS Kerberos cipher suites");
    }

    this.protocolVersion = protocolVersion;
    preMaster = generatePreMaster(generator, protocolVersion);

    // Encrypt premaster secret
    try {
        EncryptedData eData = new EncryptedData(sessionKey, preMaster,
                KeyUsage.KU_UNKNOWN);
        encrypted = eData.getBytes();  // not ASN.1 encoded.

    } catch (KrbException e) {
        throw (SSLKeyException)new SSLKeyException
                ("Kerberos premaster secret error").initCause(e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:KerberosPreMasterSecret.java

示例4: ExchangerImpl

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
ExchangerImpl(String serverName, AccessControlContext acc,
        ProtocolVersion protocolVersion, SecureRandom rand) throws IOException {

    // Get service ticket
    KerberosTicket ticket = getServiceTicket(serverName, acc);
    encodedTicket = ticket.getEncoded();

    // Record the Kerberos principals
    peerPrincipal = ticket.getServer();
    localPrincipal = ticket.getClient();

    // Optional authenticator, encrypted using session key,
    // currently ignored

    // Generate premaster secret and encrypt it using session key
    EncryptionKey sessionKey = new EncryptionKey(
            ticket.getSessionKeyType(),
            ticket.getSessionKey().getEncoded());

    preMaster = new KerberosPreMasterSecret(protocolVersion,
            rand, sessionKey);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Krb5KeyExchangeService.java

示例5: init

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
/**
 * Creates an instance of KerberosClientKeyExchange consisting of the
 * Kerberos service ticket, authenticator and encrypted premaster secret.
 * Called by client handshaker.
 *
 * @param serverName name of server with which to do handshake;
 *             this is used to get the Kerberos service ticket
 * @param protocolVersion Maximum version supported by client (i.e,
 *          version it requested in client hello)
 * @param rand random number generator to use for generating pre-master
 *          secret
 */
@Override
public void init(String serverName, boolean isLoopback,
    AccessControlContext acc, ProtocolVersion protocolVersion,
    SecureRandom rand) throws IOException {

     // Get service ticket
     KerberosTicket ticket = getServiceTicket(serverName, isLoopback, acc);
     encodedTicket = ticket.getEncoded();

     // Record the Kerberos principals
     peerPrincipal = ticket.getServer();
     localPrincipal = ticket.getClient();

     // Optional authenticator, encrypted using session key,
     // currently ignored

     // Generate premaster secret and encrypt it using session key
     EncryptionKey sessionKey = new EncryptionKey(
                                    ticket.getSessionKeyType(),
                                    ticket.getSessionKey().getEncoded());

     preMaster = new KerberosPreMasterSecret(protocolVersion,
         rand, sessionKey);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:37,代码来源:KerberosClientKeyExchangeImpl.java

示例6: generatePreMaster

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
private static byte[] generatePreMaster(SecureRandom rand,
    ProtocolVersion ver) {

    byte[] pm = new byte[48];
    rand.nextBytes(pm);
    pm[0] = ver.major;
    pm[1] = ver.minor;

    return pm;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:KerberosPreMasterSecret.java

示例7: dumpByteBuffer

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
/**
 * Hex-dumps a ByteBuffer to stdout.
 */
private static void dumpByteBuffer(String header, ByteBuffer bBuf) {
    if (dumpBufs == false) {
        return;
    }

    int bufLen = bBuf.remaining();
    if (bufLen > 0) {
        bBuf.mark();

        // We expect the position of the buffer to be at the
        // beginning of a TLS record.  Get the type, version and length.
        int type = Byte.toUnsignedInt(bBuf.get());
        int ver_major = Byte.toUnsignedInt(bBuf.get());
        int ver_minor = Byte.toUnsignedInt(bBuf.get());
        int recLen = Short.toUnsignedInt(bBuf.getShort());
        ProtocolVersion pv = ProtocolVersion.valueOf(ver_major, ver_minor);

        log("===== " + header + " (" + tlsRecType(type) + " / " +
            pv + " / " + bufLen + " bytes) =====");
        bBuf.reset();
        for (int i = 0; i < bufLen; i++) {
            if (i != 0 && i % 16 == 0) {
                System.out.print("\n");
            }
            System.out.format("%02X ", bBuf.get(i));
        }
        log("\n===============================================");
        bBuf.reset();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:LengthCheckTest.java

示例8: generatePreMaster

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
private static byte[] generatePreMaster(SecureRandom rand,
        ProtocolVersion ver) {

    byte[] pm = new byte[48];
    rand.nextBytes(pm);
    pm[0] = ver.major;
    pm[1] = ver.minor;

    return pm;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:KerberosPreMasterSecret.java

示例9: createServerExchange

import sun.security.ssl.ProtocolVersion; //导入依赖的package包/类
public ClientKeyExchange createServerExchange(
        ProtocolVersion protocolVersion, ProtocolVersion clientVersion,
        SecureRandom rand, byte[] encodedTicket, byte[] encrypted,
        AccessControlContext acc, Object serviceCreds) throws IOException {
    return new ExchangerImpl(protocolVersion, clientVersion, rand,
            encodedTicket, encrypted, acc, serviceCreds);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Krb5KeyExchangeService.java


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