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


Java SSLSession.getPeerPrincipal方法代码示例

本文整理汇总了Java中javax.net.ssl.SSLSession.getPeerPrincipal方法的典型用法代码示例。如果您正苦于以下问题:Java SSLSession.getPeerPrincipal方法的具体用法?Java SSLSession.getPeerPrincipal怎么用?Java SSLSession.getPeerPrincipal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.net.ssl.SSLSession的用法示例。


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

示例1: verify

import javax.net.ssl.SSLSession; //导入方法依赖的package包/类
/**
 * Verify that the host name is an acceptable match with
 * the server's authentication scheme.
 *
 * @param hostname the host name
 * @param session SSLSession used on the connection to host
 * @return true if the host name is acceptable
 */
@Override
public boolean verify(String hostname, SSLSession session) {
    ParamUtil.requireNonNull("hostname", hostname);
    if (trustAll) {
        return true;
    }

    LOG.info("hostname: {}", hostname);
    String commonName = null;
    try {
        Principal peerPrincipal = session.getPeerPrincipal();
        if (peerPrincipal == null) {
            return false;
        }
        commonName = X509Util.getCommonName(new X500Name(peerPrincipal.getName()));
        LOG.info("commonName: {}", commonName);
    } catch (Exception ex) {
        LogUtil.error(LOG, ex);
        return false;
    }

    Set<String> hostnames = hostnameMap.get(commonName);
    return (hostnames == null) ? false : hostnames.contains(hostname);
}
 
开发者ID:xipki,项目名称:xitk,代码行数:33,代码来源:HttpsHostnameVerifier.java

示例2: getPeerPrincipal

import javax.net.ssl.SSLSession; //导入方法依赖的package包/类
private static Principal getPeerPrincipal(SSLSession session)
        throws SSLPeerUnverifiedException {
    Principal principal;
    try {
        principal = session.getPeerPrincipal();
    } catch (AbstractMethodError e) {
        // if the JSSE provider does not support it, return null, since
        // we need it only for Kerberos.
        principal = null;
    }
    return principal;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:StartTlsResponseImpl.java

示例3: verifyHostname

import javax.net.ssl.SSLSession; //导入方法依赖的package包/类
/**
 * Verify hostname against certificate
 * @param sslSocket Socket
 * @param host Host name
 * @throws IOException Exception if host name is not verified
 */
private void verifyHostname(SSLSocket sslSocket, String host) throws IOException {
    // Make sure we started handshake before verifying
    sslSocket.startHandshake();

    SSLSession session = sslSocket.getSession();
    if (session == null) {
        throw new SSLException("Hostname '" + host + "' was not verified (no session)");
    }
    if (!hostnameVerifier.verify(host, session)) {
        throw new SSLPeerUnverifiedException("Hostname '" + host + "' was not verified (" + session.getPeerPrincipal() + ")");
    }
    if (Logger.DEBUG) { Log.d(TAG, "Connected to " + session.getPeerHost() + " using " + session.getProtocol() + " (" + session.getCipherSuite() + ")"); }
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:20,代码来源:TlsSocketFactory.java


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