List of usage examples for org.apache.shiro.cas CasToken CasToken
public CasToken(String ticket)
From source file:org.sonatype.nexus.plugins.cas.CasAuthenticationFilter.java
License:Open Source License
private void doCasFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { Subject subject = securitySystem.getSubject(); if (!subject.isAuthenticated() && CasUtil.isBrowser(request)) { String ticket = request.getParameter(TICKET_PARAMETER); if (Strings.isNullOrEmpty(ticket)) { sendRedirect(request, response, CasUtil.createCasLoginUrl(casPluginConfiguration)); } else {/*from w w w . ja v a 2 s . c o m*/ logger.info("create cas authentication token for ticket {}", ticket); try { Configuration config = casPluginConfiguration.getConfiguration(); securitySystem.login(new CasToken(ticket)); // redirect again to remove token from url sendRedirect(request, response, config.getCasService()); } catch (AuthenticationException ex) { throw new ServletException("authentication failed", ex); } } } else { chain.doFilter(request, response); } }
From source file:org.tynamo.security.shiro.authc.CasFilter.java
License:Apache License
/** * The token created for this authentication is a CasToken containing the CAS service ticket received on the CAS service url (on which * the filter must be configured)./*www. ja v a 2s . co m*/ * * @param request the incoming request * @param response the outgoing response * @throws Exception if there is an error processing the request. */ @Override protected AuthenticationToken createToken(ServletRequest request, ServletResponse response) throws Exception { HttpServletRequest httpRequest = (HttpServletRequest) request; String ticket = httpRequest.getParameter(TICKET_PARAMETER); return new CasToken(ticket); }