本文整理汇总了Java中org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential类的典型用法代码示例。如果您正苦于以下问题:Java SpnegoCredential类的具体用法?Java SpnegoCredential怎么用?Java SpnegoCredential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpnegoCredential类属于org.jasig.cas.support.spnego.authentication.principal包,在下文中一共展示了SpnegoCredential类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setResponseHeader
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的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.authentication.principal.SpnegoCredential; //导入依赖的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.authentication.principal.SpnegoCredential; //导入依赖的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.authentication.principal.SpnegoCredential; //导入依赖的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: doAuthentication
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Override
protected final HandlerResult doAuthentication(
final Credential credential) throws GeneralSecurityException, PreventedException {
final SpnegoCredential ntlmCredential = (SpnegoCredential) credential;
final byte[] src = ntlmCredential.getInitToken();
UniAddress dc = null;
boolean success = false;
try {
if (this.loadBalance) {
// find the first dc that matches the includepattern
if (StringUtils.isNotBlank(this.includePattern)) {
final NbtAddress[] dcs = NbtAddress.getAllByName(this.domainController, NBT_ADDRESS_TYPE, null, null);
for (final NbtAddress dc2 : dcs) {
if(dc2.getHostAddress().matches(this.includePattern)){
dc = new UniAddress(dc2);
break;
}
}
} else {
dc = new UniAddress(NbtAddress.getByName(this.domainController, NBT_ADDRESS_TYPE, null));
}
} else {
dc = UniAddress.getByName(this.domainController, true);
}
final byte[] challenge = SmbSession.getChallenge(dc);
switch (src[NTLM_TOKEN_TYPE_FIELD_INDEX]) {
case NTLM_TOKEN_TYPE_ONE:
logger.debug("Type 1 received");
final Type1Message type1 = new Type1Message(src);
final Type2Message type2 = new Type2Message(type1,
challenge, null);
logger.debug("Type 2 returned. Setting next token.");
ntlmCredential.setNextToken(type2.toByteArray());
break;
case NTLM_TOKEN_TYPE_THREE:
logger.debug("Type 3 received");
final Type3Message type3 = new Type3Message(src);
final byte[] lmResponse = type3.getLMResponse() == null ? new byte[0] : type3.getLMResponse();
final byte[] ntResponse = type3.getNTResponse() == null ? new byte[0] : type3.getNTResponse();
final NtlmPasswordAuthentication ntlm = new NtlmPasswordAuthentication(
type3.getDomain(), type3.getUser(), challenge,
lmResponse, ntResponse);
logger.debug("Trying to authenticate {} with domain controller", type3.getUser());
try {
SmbSession.logon(dc, ntlm);
ntlmCredential.setPrincipal(this.principalFactory.createPrincipal(type3.getUser()));
success = true;
} catch (final SmbAuthException sae) {
throw new FailedLoginException(sae.getMessage());
}
break;
default:
logger.debug("Unknown type: {}", src[NTLM_TOKEN_TYPE_FIELD_INDEX]);
}
} catch (final Exception e) {
throw new FailedLoginException(e.getMessage());
}
if (!success) {
throw new FailedLoginException();
}
return new DefaultHandlerResult(this, new BasicCredentialMetaData(ntlmCredential), ntlmCredential.getPrincipal());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:68,代码来源:NtlmAuthenticationHandler.java
示例6: verifySuccessfulAuthenticationWithDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(true);
this.authenticationHandler.setAuthentication(new MockJcifsAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:JcifsSpnegoAuthenticationHandlerTests.java
示例7: verifySuccessfulAuthenticationWithoutDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithoutDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(false);
this.authenticationHandler.setAuthentication(new MockJcifsAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:JcifsSpnegoAuthenticationHandlerTests.java
示例8: verifyUnsuccessfulAuthentication
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifyUnsuccessfulAuthentication() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setAuthentication(new MockJcifsAuthentication(false));
try {
this.authenticationHandler.authenticate(credentials);
fail("An exception should have been thrown");
} catch (final PreventedException e) {
assertNull(credentials.getNextToken());
assertNull(credentials.getPrincipal());
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:JcifsSpnegoAuthenticationHandlerTests.java
示例9: verifySuccessfulAuthenticationWithDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(true);
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例10: verifySuccessfulAuthenticationWithoutDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifySuccessfulAuthenticationWithoutDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(false);
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例11: verifyUnsuccessfulAuthentication
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifyUnsuccessfulAuthentication() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(false));
try {
this.authenticationHandler.authenticate(credentials);
fail("An AuthenticationException should have been thrown");
} catch (final GeneralSecurityException e) {
assertNull(credentials.getNextToken());
assertNull(credentials.getPrincipal());
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例12: constructCredentialsFromRequest
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的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
示例13: testSuccessfulAuthenticationWithDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void testSuccessfulAuthenticationWithDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(true);
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:10,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例14: testSuccessfulAuthenticationWithoutDomainName
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void testSuccessfulAuthenticationWithoutDomainName() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setPrincipalWithDomainName(false);
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(true));
assertNotNull(this.authenticationHandler.authenticate(credentials));
assertEquals("test", credentials.getPrincipal().getId());
assertNotNull(credentials.getNextToken());
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:10,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例15: testUnsuccessfulAuthentication
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void testUnsuccessfulAuthentication() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setAuthentication(new MockJCSIFAuthentication(false));
try {
this.authenticationHandler.authenticate(credentials);
fail("An AuthenticationException should have been thrown");
} catch (final GeneralSecurityException e) {
assertNull(credentials.getNextToken());
assertNull(credentials.getPrincipal());
}
}
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:13,代码来源:JCSIFSpnegoAuthenticationHandlerTests.java
示例16: verifyUnsuccessfulAuthentication
import org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential; //导入依赖的package包/类
@Test
public void verifyUnsuccessfulAuthentication() throws Exception {
final SpnegoCredential credentials = new SpnegoCredential(new byte[] {0, 1, 2});
this.authenticationHandler.setAuthentication(new MockJcifsAuthentication(false));
try {
this.authenticationHandler.authenticate(credentials);
fail("An AbstractAuthenticationException should have been thrown");
} catch (final GeneralSecurityException e) {
assertNull(credentials.getNextToken());
assertNull(credentials.getPrincipal());
}
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:13,代码来源:JcifsSpnegoAuthenticationHandlerTests.java
注:本文中的org.jasig.cas.support.spnego.authentication.principal.SpnegoCredential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论