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


Java X509CertificateCredential类代码示例

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


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

示例1: authenticate

import io.undertow.security.idm.X509CertificateCredential; //导入依赖的package包/类
public AuthenticationMechanismOutcome authenticate(final HttpServerExchange exchange, final SecurityContext securityContext) {
    SSLSessionInfo sslSession = exchange.getConnection().getSslSessionInfo();
    if (sslSession != null) {
        try {
            Certificate[] clientCerts = getPeerCertificates(exchange, sslSession, securityContext);
            if (clientCerts[0] instanceof X509Certificate) {
                Credential credential = new X509CertificateCredential((X509Certificate) clientCerts[0]);

                IdentityManager idm = securityContext.getIdentityManager();
                Account account = idm.verify(credential);
                if (account != null) {
                    securityContext.authenticationComplete(account, name, false);
                    return AuthenticationMechanismOutcome.AUTHENTICATED;
                }
            }
        } catch (SSLPeerUnverifiedException e) {
            // No action - this mechanism can not attempt authentication without peer certificates so allow it to drop out
            // to NOT_ATTEMPTED.
        }
    }

    /*
     * For ClientCert we do not have a concept of a failed authentication, if the client did use a key then it was deemed
     * acceptable for the connection to be established, this mechanism then just 'attempts' to use it for authentication but
     * does not mandate success.
     */

    return AuthenticationMechanismOutcome.NOT_ATTEMPTED;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ClientCertAuthenticationMechanism.java


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