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


Java Request.getServerName方法代码示例

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


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

示例1: setAuthenticateHeader

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Generates the WWW-Authenticate header.
 * <p>
 * The header MUST follow this template :
 * <pre>
 *      WWW-Authenticate    = "WWW-Authenticate" ":" "Digest"
 *                            digest-challenge
 *
 *      digest-challenge    = 1#( realm | [ domain ] | nOnce |
 *                  [ digest-opaque ] |[ stale ] | [ algorithm ] )
 *
 *      realm               = "realm" "=" realm-value
 *      realm-value         = quoted-string
 *      domain              = "domain" "=" <"> 1#URI <">
 *      nonce               = "nonce" "=" nonce-value
 *      nonce-value         = quoted-string
 *      opaque              = "opaque" "=" quoted-string
 *      stale               = "stale" "=" ( "true" | "false" )
 *      algorithm           = "algorithm" "=" ( "MD5" | token )
 * </pre>
 *
 * @param request HTTP Servlet request
 * @param response HTTP Servlet response
 * @param config    Login configuration describing how authentication
 *              should be performed
 * @param nOnce nonce token
 */
protected void setAuthenticateHeader(Request request,
                                     Response response,
                                     LoginConfig config,
                                     String nOnce) {

    // Get the realm name
    String realmName = config.getRealmName();
    if (realmName == null)
        realmName = request.getServerName() + ":"
            + request.getServerPort();

    byte[] buffer = null;
    synchronized (md5Helper) {
        buffer = md5Helper.digest(nOnce.getBytes());
    }

    String authenticateHeader = "Digest realm=\"" + realmName + "\", "
        +  "qop=\"auth\", nonce=\"" + nOnce + "\", " + "opaque=\""
        + md5Encoder.encode(buffer) + "\"";
    response.setHeader("WWW-Authenticate", authenticateHeader);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:50,代码来源:DigestAuthenticator.java


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