CAS 数据库校验

1. UnknownUsernameAuthenticationException --> BadUsernameOrPasswordAuthenticationException --> BadCredentialsAuthenticationException --> AuthenticationException -->

  Exception

2. AuthenticationManagerImpl类

    调用authenticateAndObtainPrincipal先检查是否支持credentials,

    然后authenticationHandler.authenticate(credentials),

    然后doAuthentication(credentials) ,

    然后authenticateUsernamePasswordInternal((UsernamePasswordCredentials) credentials),

    然后QueryDatabaseAuthenticationHandler调用,authenticateUsernamePasswordInternal验证数据库

3. 抛出BadCredentialsAuthenticationException.ERROR异常

    

    /**
     * @throws IllegalArgumentException
     *             if the ServiceTicketId or the Credentials are null.
     */
    @Audit(action = "PROXY_GRANTING_TICKET",
            actionResolverName = "GRANT_PROXY_GRANTING_TICKET_RESOLVER",
            resourceResolverName = "GRANT_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER")
    @Profiled(tag = "GRANT_PROXY_GRANTING_TICKET", logFailuresSeparately = false)
    @Transactional(readOnly = false)
    public String delegateTicketGrantingTicket(final String serviceTicketId,
            final Credentials credentials) throws TicketException

    转化为AuthenticationException e,

    转化为TicketCreationException(e)

4. CaptchaAuthenticationViaFormAction类

    

        try {
            WebUtils.putTicketGrantingTicketInRequestScope(context, this.centralAuthenticationService.createTicketGrantingTicket(credentials));
            putWarnCookieIfRequestParameterPresent(context);
            return "success";
        } catch (final TicketException e) {
            populateErrorsInstance(e, messageContext);
            return "error";
        }
     捕获异常,进入populateErrorsInstance(e, messageContext);

     

    private void populateErrorsInstance(final TicketException e, final MessageContext messageContext) {

        try {
            messageContext.addMessage(new MessageBuilder().error().code(e.getCode()).defaultText(e.getCode()).build());
        } catch (final Exception fe) {
            logger.error(fe.getMessage(), fe);
        }
    }
       通过MessageContext,Spring的机制输出到页面<form:form errors/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值