當前位置: 首頁>>代碼示例>>Java>>正文


Java DefaultHandlerResult類代碼示例

本文整理匯總了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);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:22,代碼來源:ClientAuthenticationHandler.java

示例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);
}
 
開發者ID:xuchengdong,項目名稱:cas4.1.9,代碼行數:23,代碼來源:ClientAuthenticationHandler.java

示例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();
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:13,代碼來源:MockTicketGrantingTicket.java

示例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());
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:68,代碼來源:NtlmAuthenticationHandler.java


注:本文中的org.jasig.cas.authentication.DefaultHandlerResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。