@Override public Ticket getTicket(final String ticketId) { return this.ticketRegistry.getTicket(ticketId); }
@Override /** {@inheritDoc} */ public Authentication getAuthenticationFrom(final String ticketGrantingTicketId) throws RuntimeException { final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
@Override public Authentication getAuthenticationFrom(final String ticketGrantingTicketId) throws RuntimeException { final TicketGrantingTicket tgt = this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
@Override public boolean ticketGrantingTicketExistsAndExpired(String ticketGrantingTicketId) { final Ticket ticket = this.ticketRegistry.getTicket(ticketGrantingTicketId); if (ticket != null && ticket instanceof TicketGrantingTicket) { return TicketGrantingTicket.class.cast(ticket).isExpired(); } return false; }
@Override /** {@inheritDoc} */ public Authentication getAuthenticationFrom(String ticketGrantingTicketId) throws RuntimeException { TicketGrantingTicket tgt = (TicketGrantingTicket) this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
throws InvalidTicketException { Assert.notNull(ticketId, "ticketId cannot be null"); final Ticket ticket = this.ticketRegistry.getTicket(ticketId, clazz);
@Override public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { final WebApplicationService service = this.argExtractor.extractService(request); if (service == null) { return super.handleRequest(request, response); } Ticket st = this.ticketRegistry.getTicket(service.getArtifactId()); if (st == null) { return super.handleRequest(request, response); } //Make the tgt available in ThreadLocal for access in "onSuccessfulValidation()" tgtHolder.set(st.getGrantingTicket()); return super.handleRequest(request, response); }
@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); }
@Audit( action = "PROXY_GRANTING_TICKET", actionResolverName = "CREATE_PROXY_GRANTING_TICKET_RESOLVER", resourceResolverName = "CREATE_PROXY_GRANTING_TICKET_RESOURCE_RESOLVER") @Timed(name = "CREATE_PROXY_GRANTING_TICKET_TIMER") @Metered(name = "CREATE_PROXY_GRANTING_TICKET_METER") @Counted(name = "CREATE_PROXY_GRANTING_TICKET_COUNTER", monotonic = true) @Override public ProxyGrantingTicket createProxyGrantingTicket(final String serviceTicketId, final AuthenticationContext context) throws AuthenticationException, AbstractTicketException { final ServiceTicket serviceTicket = this.ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class); if (serviceTicket == null || serviceTicket.isExpired()) { logger.debug("ServiceTicket [{}] has expired or cannot be found in the ticket registry", serviceTicketId); throw new InvalidTicketException(serviceTicketId); } final RegisteredService registeredService = this.servicesManager .findServiceBy(serviceTicket.getService()); verifyRegisteredServiceProperties(registeredService, serviceTicket.getService()); if (!registeredService.getProxyPolicy().isAllowedToProxy()) { logger.warn("ServiceManagement: Service [{}] attempted to proxy, but is not allowed.", serviceTicket.getService().getId()); throw new UnauthorizedProxyingException(); } final Authentication authentication = context.getAuthentication(); final ProxyGrantingTicketFactory factory = this.ticketFactory.get(ProxyGrantingTicket.class); final ProxyGrantingTicket proxyGrantingTicket = factory.create(serviceTicket, authentication); logger.debug("Generated proxy granting ticket [{}] based off of [{}]", proxyGrantingTicket, serviceTicketId); this.ticketRegistry.addTicket(proxyGrantingTicket); doPublishEvent(new CasProxyGrantingTicketCreatedEvent(this, proxyGrantingTicket)); return proxyGrantingTicket; }
verifyRegisteredServiceProperties(registeredService, service); final ServiceTicket serviceTicket = this.ticketRegistry.getTicket(serviceTicketId, ServiceTicket.class);