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


Java SpnegoConstants类代码示例

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


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

示例1: setResponseHeader

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
/**
 * Sets the response header based on the retrieved tocken.
 *
 * @param context the context
 * @param credential the credential
 */
private void setResponseHeader(final RequestContext context,
        final Credential credential) {
    if (credential == null) {
        return;
    }

    final HttpServletResponse response = WebUtils
            .getHttpServletResponse(context);
    final SpnegoCredential spnegoCredentials = (SpnegoCredential) credential;
    final byte[] nextToken = spnegoCredentials.getNextToken();
    if (nextToken != null) {
        logger.debug("Obtained output token: {}", new String(nextToken, Charset.defaultCharset()));
        response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, (this.ntlm
                ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
                + ' ' + CompressionUtils.encodeBase64(nextToken));
    } else {
        logger.debug("Unable to obtain the output token required.");
    }

    if (spnegoCredentials.getPrincipal() == null && send401OnAuthenticationFailure) {
        logger.debug("Setting HTTP Status to 401");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:31,代码来源:SpnegoCredentialsAction.java

示例2: constructCredentialsFromRequest

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(
        final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);

    final String authorizationHeader = request
            .getHeader(SpnegoConstants.HEADER_AUTHORIZATION);

    if (StringUtils.hasText(authorizationHeader)
            && authorizationHeader.startsWith(this.messageBeginPrefix)
            && authorizationHeader.length() > this.messageBeginPrefix.length()) {

        logger.debug("SPNEGO Authorization header found with {} bytes",
                authorizationHeader.length() - this.messageBeginPrefix.length());

        final byte[] token = CompressionUtils.decodeBase64ToByteArray(authorizationHeader.substring(this.messageBeginPrefix.length()));
        if (token == null) {
            logger.warn("Could not compress authorization header in base64");
            return null;
        }
        logger.debug("Obtained token: {}", new String(token, Charset.defaultCharset()));
        return new SpnegoCredential(token);
    }

    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:SpnegoCredentialsAction.java

示例3: setResponseHeader

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
private void setResponseHeader(final RequestContext context,
        final Credential credential) {
    if (credential == null) {
        return;
    }

    final HttpServletResponse response = WebUtils
            .getHttpServletResponse(context);
    final SpnegoCredential spnegoCredentials = (SpnegoCredential) credential;
    final byte[] nextToken = spnegoCredentials.getNextToken();
    if (nextToken != null) {
        if (logger.isDebugEnabled()) {
            logger.debug("Obtained output token: " + new String(nextToken));
        }
        response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, (this.ntlm
                ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
                + " " + Base64.encode(nextToken));
    } else {
        logger.debug("Unable to obtain the output token required.");
    }

    if (spnegoCredentials.getPrincipal() == null && send401OnAuthenticationFailure) {
        logger.debug("Setting HTTP Status to 401");
        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    }
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:27,代码来源:SpnegoCredentialsAction.java

示例4: constructCredentialsFromRequest

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);

    final String authorizationHeader = request.getHeader(SpnegoConstants.HEADER_AUTHORIZATION);
    logger.debug("SPNEGO Authorization header located as {}", authorizationHeader);
    
    if (StringUtils.hasText(authorizationHeader)
            && authorizationHeader.startsWith(this.messageBeginPrefix)
            && authorizationHeader.length() > this.messageBeginPrefix.length()) {

        logger.debug("SPNEGO Authorization header found with {} bytes",
                authorizationHeader.length() - this.messageBeginPrefix.length());

        final byte[] token = CompressionUtils.decodeBase64ToByteArray(authorizationHeader.substring(this.messageBeginPrefix.length()));
        if (token == null) {
            logger.warn("Could not compress authorization header in base64");
            return null;
        }
        logger.debug("Obtained token: {}", new String(token, Charset.defaultCharset()));
        return new SpnegoCredential(token);
    }

    logger.warn("SPNEGO Authorization header not found under {} or it does not begin with the prefix {}",
            SpnegoConstants.HEADER_AUTHORIZATION, this.messageBeginPrefix);
    return null;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:SpnegoCredentialsAction.java

示例5: doExecute

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext context) {
    final HttpServletRequest request = WebUtils
            .getHttpServletRequest(context);
    final HttpServletResponse response = WebUtils
            .getHttpServletResponse(context);
    final String authorizationHeader = request
            .getHeader(SpnegoConstants.HEADER_AUTHORIZATION);
    final String userAgent = request
            .getHeader(SpnegoConstants.HEADER_USER_AGENT);

    if (StringUtils.hasText(userAgent) && isSupportedBrowser(userAgent)) {
        if (!StringUtils.hasText(authorizationHeader)
                || !authorizationHeader.startsWith(this.messageBeginPrefix)
                || authorizationHeader.length() <= this.messageBeginPrefix
                .length()) {
            if (logger.isDebugEnabled()) {
                logger
                .debug("Authorization header not found. Sending WWW-Authenticate header");
            }
            response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE,
                    this.ntlm ? SpnegoConstants.NTLM
                            : SpnegoConstants.NEGOTIATE);
            response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
            // The responseComplete flag tells the pausing view-state not to render the response
            // because another object has taken care of it. If mixed mode authentication is allowed
            // then responseComplete should not be called so that webflow will display the login page.
            if (!this.mixedModeAuthentication) {
                context.getExternalContext().recordResponseComplete();
            }
        }
    }
    return success();
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:35,代码来源:SpnegoNegociateCredentialsAction.java

示例6: constructCredentialsFromRequest

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Credential constructCredentialsFromRequest(
        final RequestContext context) {
    final HttpServletRequest request = WebUtils
            .getHttpServletRequest(context);

    final String authorizationHeader = request
            .getHeader(SpnegoConstants.HEADER_AUTHORIZATION);

    if (StringUtils.hasText(authorizationHeader)
            && authorizationHeader.startsWith(this.messageBeginPrefix)
            && authorizationHeader.length() > this.messageBeginPrefix.length()) {
        if (logger.isDebugEnabled()) {
            logger.debug("SPNEGO Authorization header found with "
                    + (authorizationHeader.length() - this.messageBeginPrefix
                            .length()) + " bytes");
        }
        final byte[] token = Base64.decode(authorizationHeader
                .substring(this.messageBeginPrefix.length()));
        if (logger.isDebugEnabled()) {
            logger.debug("Obtained token: " + new String(token));
        }
        return new SpnegoCredential(token);
    }

    return null;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:28,代码来源:SpnegoCredentialsAction.java

示例7: isTokenNtlm

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
private boolean isTokenNtlm(final byte[] token) {
    if (token == null || token.length < 8) {
        return false;
    }
    for (int i = 0; i < 8; i++) {
        if (SpnegoConstants.NTLMSSP_SIGNATURE[i] != token[i]) {
            return false;
        }
    }
    return true;
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:12,代码来源:SpnegoCredential.java

示例8: doExecute

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final HttpServletResponse response = WebUtils.getHttpServletResponse(context);

    final String authorizationHeader = request.getHeader(SpnegoConstants.HEADER_AUTHORIZATION);
    final String userAgent = request.getHeader(SpnegoConstants.HEADER_USER_AGENT);

    LOGGER.debug("Authorization header [{}], User Agent header [{}]", authorizationHeader, userAgent);

    if (!StringUtils.hasText(userAgent) || this.supportedBrowser.isEmpty()) {
        LOGGER.debug("User Agent header [{}] is empty, or no browsers are supported", userAgent);
        return error();
    }

    if (!isSupportedBrowser(userAgent)) {
        LOGGER.debug("User Agent header [{}] is not supported in the list of supported browsers [{}]",
                userAgent, this.supportedBrowser);
        return error();
    }

    if (!StringUtils.hasText(authorizationHeader)
            || !authorizationHeader.startsWith(this.messageBeginPrefix)
            || authorizationHeader.length() <= this.messageBeginPrefix
            .length()) {

        final String wwwHeader = this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE;
        LOGGER.debug("Authorization header not found or does not match the message prefix [{}]. Sending [{}] header [{}]",
                this.messageBeginPrefix, SpnegoConstants.HEADER_AUTHENTICATE, wwwHeader);
        response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, wwwHeader);

        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        // The responseComplete flag tells the pausing view-state not to render the response
        // because another object has taken care of it. If mixed mode authentication is allowed
        // then responseComplete should not be called so that webflow will display the login page.
        if (!this.mixedModeAuthentication) {
            LOGGER.debug("Mixed-mode authentication is disabled. Executing completion of response");
            context.getExternalContext().recordResponseComplete();
        }
    }
    return success();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:43,代码来源:SpnegoNegociateCredentialsAction.java

示例9: doExecute

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
@Override
protected Event doExecute(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final HttpServletResponse response = WebUtils.getHttpServletResponse(context);

    final String authorizationHeader = request.getHeader(SpnegoConstants.HEADER_AUTHORIZATION);
    final String userAgent = request.getHeader(SpnegoConstants.HEADER_USER_AGENT);

    LOGGER.debug("Authorization header [{}], User Agent header [{}]", authorizationHeader, userAgent);

    if (!StringUtils.hasText(userAgent) || this.supportedBrowser.isEmpty()) {
        LOGGER.debug("User Agent header [{}] is empty, or no browsers are supported", userAgent);
        return success();
    }

    if (!isSupportedBrowser(userAgent)) {
        LOGGER.debug("User Agent header [{}] is not supported in the list of supported browsers [{}]",
                userAgent, this.supportedBrowser);
        return success();
    }

    if (!StringUtils.hasText(authorizationHeader)
            || !authorizationHeader.startsWith(this.messageBeginPrefix)
            || authorizationHeader.length() <= this.messageBeginPrefix
            .length()) {

        final String wwwHeader = this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE;
        LOGGER.debug("Authorization header not found or does not match the message prefix [{}]. Sending [{}] header [{}]",
                this.messageBeginPrefix, SpnegoConstants.HEADER_AUTHENTICATE, wwwHeader);
        response.setHeader(SpnegoConstants.HEADER_AUTHENTICATE, wwwHeader);

        response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
        // The responseComplete flag tells the pausing view-state not to render the response
        // because another object has taken care of it. If mixed mode authentication is allowed
        // then responseComplete should not be called so that webflow will display the login page.
        if (!this.mixedModeAuthentication) {
            LOGGER.debug("Mixed-mode authentication is disabled. Executing completion of response");
            context.getExternalContext().recordResponseComplete();
        }
    }
    return success();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:43,代码来源:SpnegoNegociateCredentialsAction.java

示例10: constructMessagePrefix

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
protected String constructMessagePrefix() {
    return (this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
            + " ";
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:5,代码来源:SpnegoNegociateCredentialsAction.java

示例11: constructMessagePrefix

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
/**
 * Construct message prefix.
 *
 * @return if {@link #ntlm} is enabled, {@link SpnegoConstants#NTLM}, otherwise
 * {@link SpnegoConstants#NEGOTIATE}. An extra space is appended to the end.
 */
protected String constructMessagePrefix() {
    return (this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
            + ' ';
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:SpnegoNegociateCredentialsAction.java

示例12: constructMessagePrefix

import org.jasig.cas.support.spnego.util.SpnegoConstants; //导入依赖的package包/类
/**
 * Construct message prefix.
 *
 * @return the string
 */
protected String constructMessagePrefix() {
    return (this.ntlm ? SpnegoConstants.NTLM : SpnegoConstants.NEGOTIATE)
            + ' ';
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:SpnegoCredentialsAction.java


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