Search in sources :

Example 1 with SecurityTokenTicket

use of org.apereo.cas.ticket.SecurityTokenTicket in project cas by apereo.

the class BaseWSFederationRequestController method getSecurityTokenFromRequest.

/**
     * Gets security token from request.
     *
     * @param request the request
     * @return the security token from request
     */
protected SecurityToken getSecurityTokenFromRequest(final HttpServletRequest request) {
    final String cookieValue = this.ticketGrantingTicketCookieGenerator.retrieveCookieValue(request);
    if (StringUtils.isNotBlank(cookieValue)) {
        final String sts = securityTokenTicketFactory.createLinkedId(cookieValue);
        final SecurityTokenTicket stt = ticketRegistry.getTicket(sts, SecurityTokenTicket.class);
        if (stt == null || stt.isExpired()) {
            LOGGER.warn("Security token ticket [{}] is not found or has expired", sts);
            return null;
        }
        if (stt.getSecurityToken().isExpired()) {
            LOGGER.warn("Security token linked to ticket [{}] has expired", sts);
            return null;
        }
        return stt.getSecurityToken();
    }
    return null;
}
Also used : SecurityTokenTicket(org.apereo.cas.ticket.SecurityTokenTicket)

Aggregations

SecurityTokenTicket (org.apereo.cas.ticket.SecurityTokenTicket)1