本文整理汇总了Java中org.jasig.cas.authentication.DefaultHandlerResult类的典型用法代码示例。如果您正苦于以下问题:Java DefaultHandlerResult类的具体用法?Java DefaultHandlerResult怎么用?Java DefaultHandlerResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultHandlerResult类属于org.jasig.cas.authentication包,在下文中一共展示了DefaultHandlerResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
final HttpBasedServiceCredential httpCredential = (HttpBasedServiceCredential) credential;
if (!httpCredential.getService().getProxyPolicy().isAllowedProxyCallbackUrl(httpCredential.getCallbackUrl())) {
logger.warn("Proxy policy for service [{}] cannot authorize the requested callback url [{}].",
httpCredential.getService().getServiceId(), httpCredential.getCallbackUrl());
throw new FailedLoginException(httpCredential.getCallbackUrl() + " cannot be authorized");
}
logger.debug("Attempting to authenticate {}", httpCredential);
final URL callbackUrl = httpCredential.getCallbackUrl();
if (!this.httpClient.isValidEndPoint(callbackUrl)) {
throw new FailedLoginException(callbackUrl.toExternalForm() + " sent an unacceptable response status code");
}
return new DefaultHandlerResult(this, httpCredential, this.principalFactory.createPrincipal(httpCredential.getId()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:HttpBasedServiceCredentialsAuthenticationHandler.java
示例2: createResult
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
/**
* Build the handler result.
*
* @param credentials the provided credentials
* @param profile the retrieved user profile
* @return the built handler result
* @throws GeneralSecurityException On authentication failure.
* @throws PreventedException On the indeterminate case when authentication is prevented.
*/
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
if (profile != null) {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
credentials.setTypedIdUsed(typedIdUsed);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
throw new FailedLoginException("Authentication did not produce a user profile for: " + credentials);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:34,代码来源:AbstractPac4jAuthenticationHandler.java
示例3: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
final OpenIdCredential c = (OpenIdCredential) credential;
final TicketGrantingTicket t = this.ticketRegistry.getTicket(c.getTicketGrantingTicketId(),
TicketGrantingTicket.class);
if (t == null || t.isExpired()) {
throw new FailedLoginException("TGT is null or expired.");
}
final Principal principal = t.getAuthentication().getPrincipal();
if (!principal.getId().equals(c.getUsername())) {
throw new FailedLoginException("Principal ID mismatch");
}
return new DefaultHandlerResult(this, new BasicCredentialMetaData(c), principal);
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:OpenIdCredentialsAuthenticationHandler.java
示例4: verifyAuthenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
/**
* Tests the {@link X509CredentialsAuthenticationHandler#authenticate(org.jasig.cas.authentication.Credential)} method.
*/
@Test
public void verifyAuthenticate() {
try {
if (this.handler.supports(this.credential)) {
final HandlerResult result = this.handler.authenticate(this.credential);
if (this.expectedResult instanceof DefaultHandlerResult) {
assertEquals(this.expectedResult, result);
} else {
fail("Authentication succeeded when it should have failed with " + this.expectedResult);
}
}
} catch (final Exception e) {
if (this.expectedResult instanceof Exception) {
assertEquals(this.expectedResult.getClass(), e.getClass());
} else {
fail("Authentication failed when it should have succeeded.");
}
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:X509CredentialsAuthenticationHandlerTests.java
示例5: createResult
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
示例6: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
final HttpBasedServiceCredential httpCredential = (HttpBasedServiceCredential) credential;
if (!httpCredential.getService().getProxyPolicy().isAllowedProxyCallbackUrl(httpCredential.getCallbackUrl())) {
logger.warn("Proxy policy for service [{}] cannot authorize the requested callbackurl [{}]",
httpCredential.getService(), httpCredential.getCallbackUrl());
throw new FailedLoginException(httpCredential.getCallbackUrl() + " cannot be authorized");
}
logger.debug("Attempting to authenticate {}", httpCredential);
final URL callbackUrl = httpCredential.getCallbackUrl();
if (!this.httpClient.isValidEndPoint(callbackUrl)) {
throw new FailedLoginException(callbackUrl.toExternalForm() + " sent an unacceptable response status code");
}
return new DefaultHandlerResult(this, httpCredential, this.principalFactory.createPrincipal(httpCredential.getId()));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:HttpBasedServiceCredentialsAuthenticationHandler.java
示例7: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
final String username = usernamePasswordCredential.getUsername();
final String password = usernamePasswordCredential.getPassword();
final Exception exception = this.usernameErrorMap.get(username);
if (exception instanceof GeneralSecurityException) {
throw (GeneralSecurityException) exception;
} else if (exception instanceof PreventedException) {
throw (PreventedException) exception;
} else if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
} else if (exception != null) {
logger.debug("Cannot throw checked exception {} since it is not declared by method signature.", exception);
}
if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.equals(password)) {
logger.debug("User [{}] was successfully authenticated.", username);
return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential));
}
logger.debug("User [{}] failed authentication", username);
throw new FailedLoginException();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:SimpleTestUsernamePasswordAuthenticationHandler.java
示例8: createResult
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected HandlerResult createResult(final ClientCredential credentials, final UserProfile profile)
throws GeneralSecurityException, PreventedException {
final String id;
if (typedIdUsed) {
id = profile.getTypedId();
} else {
id = profile.getId();
}
if (StringUtils.isNotBlank(id)) {
credentials.setUserProfile(profile);
credentials.setTypedIdUsed(typedIdUsed);
return new DefaultHandlerResult(
this,
new BasicCredentialMetaData(credentials),
this.principalFactory.createPrincipal(id, profile.getAttributes()));
}
throw new FailedLoginException("No identifier found for this user profile: " + profile);
}
示例9: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential)
throws GeneralSecurityException, PreventedException {
final OneTimePasswordCredential otp = (OneTimePasswordCredential) credential;
final String valueOnRecord = credentialMap.get(otp.getId());
if (otp.getPassword().equals(valueOnRecord)) {
return new DefaultHandlerResult(this, new BasicCredentialMetaData(otp),
new DefaultPrincipalFactory().createPrincipal(otp.getId()));
}
throw new FailedLoginException();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:12,代码来源:TestOneTimePasswordAuthenticationHandler.java
示例10: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential)
throws GeneralSecurityException, PreventedException {
final UsernamePasswordCredential usernamePasswordCredential = (UsernamePasswordCredential) credential;
final String username = usernamePasswordCredential.getUsername();
final String password = usernamePasswordCredential.getPassword();
final Exception exception = this.usernameErrorMap.get(username);
if (exception instanceof GeneralSecurityException) {
throw (GeneralSecurityException) exception;
} else if (exception instanceof PreventedException) {
throw (PreventedException) exception;
} else if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
} else if (exception != null) {
logger.debug("Cannot throw checked exception {} since it is not declared by method signature.", exception);
}
if (StringUtils.hasText(username) && StringUtils.hasText(password) && username.equals(password)) {
logger.debug("User [{}] was successfully authenticated.", username);
return new DefaultHandlerResult(this, new BasicCredentialMetaData(credential),
this.principalFactory.createPrincipal(username));
}
logger.debug("User [{}] failed authentication", username);
throw new FailedLoginException();
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:28,代码来源:SimpleTestUsernamePasswordAuthenticationHandler.java
示例11: newBuilder
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
private AuthenticationBuilder newBuilder(final Credential credential) {
final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder(TestUtils.getPrincipal())
.addCredential(meta)
.addSuccess("test", new DefaultHandlerResult(handler, meta));
if (this.p.supports(credential)) {
this.p.populateAttributes(builder, credential);
}
return builder;
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:13,代码来源:RememberMeAuthenticationMetaDataPopulatorTests.java
示例12: newAuthenticationBuilder
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
private static AuthenticationBuilder newAuthenticationBuilder(final Principal principal) {
final CredentialMetaData meta = new BasicCredentialMetaData(new UsernamePasswordCredential());
final AuthenticationHandler handler = new SimpleTestUsernamePasswordAuthenticationHandler();
return new DefaultAuthenticationBuilder(principal)
.addCredential(meta)
.addSuccess("test", new DefaultHandlerResult(handler, meta));
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:SamlAuthenticationMetaDataPopulatorTests.java
示例13: authenticate
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
final RemoteAddressCredential c = (RemoteAddressCredential) credential;
if (this.inetNetmask != null && this.inetNetwork != null) {
try {
final InetAddress inetAddress = InetAddress.getByName(c.getRemoteAddress().trim());
if (containsAddress(this.inetNetwork, this.inetNetmask, inetAddress)) {
return new DefaultHandlerResult(this, c, this.principalFactory.createPrincipal(c.getId()));
}
} catch (final UnknownHostException e) {
logger.debug("Unknown host {}", c.getRemoteAddress());
}
}
throw new FailedLoginException(c.getRemoteAddress() + " not in allowed range.");
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:16,代码来源:RemoteAddressAuthenticationHandler.java
示例14: MockTicketGrantingTicket
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的package包/类
public MockTicketGrantingTicket(final String principal, final Credential c, final Map attributes) {
id = ID_GENERATOR.getNewTicketId("TGT");
final CredentialMetaData metaData = new BasicCredentialMetaData(c);
authentication = new DefaultAuthenticationBuilder(
new DefaultPrincipalFactory().createPrincipal(principal, attributes))
.addCredential(metaData)
.addSuccess(SimpleTestUsernamePasswordAuthenticationHandler.class.getName(),
new DefaultHandlerResult(new SimpleTestUsernamePasswordAuthenticationHandler(), metaData))
.build();
created = new Date();
}
示例15: doAuthentication
import org.jasig.cas.authentication.DefaultHandlerResult; //导入依赖的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());
}