@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 /** {@inheritDoc} */ public Authentication getAuthenticationFrom(String ticketGrantingTicketId) throws RuntimeException { TicketGrantingTicket tgt = (TicketGrantingTicket) this.ticketRegistry.getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); return tgt == null ? null : tgt.getAuthentication(); }
@Override public Authentication getAuthentication() { return getTicket().getAuthentication(); }
@Override public Collection<Map<String, Object>> getActiveSsoSessions() throws BulkRetrievalOfTicketsNotSupportedException { final List<Map<String, Object>> activeSessions = new ArrayList<Map<String, Object>>(); for(TicketGrantingTicket tgt : this.ticketSupport.getNonExpiredTicketGrantingTickets()) { final Map<String, Object> sso = new HashMap<String, Object>(3); sso.put(SsoSessionAttributeKeys.AUTHENTICATED_PRINCIPAL.toString(), tgt.getAuthentication().getPrincipal().getId()); sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE.toString(), tgt.getAuthentication().getAuthenticatedDate()); sso.put(SsoSessionAttributeKeys.NUMBER_OF_USES.toString(), tgt.getCountOfUses()); activeSessions.add(Collections.unmodifiableMap(sso)); } return Collections.unmodifiableCollection(activeSessions); } }
@Override public void addTicket(final Ticket ticket) { if (ticket instanceof TicketGrantingTicket) { final TicketGrantingTicket ticketGrantingTicket = (TicketGrantingTicket) ticket; final String ticketId = ticketGrantingTicket.getId(); final String userName = ticketGrantingTicket.getAuthentication().getPrincipal().getId().toLowerCase(); logger.debug("Creating mapping ticket {} to user name {}", ticketId, userName); this.cache.put(ticketId, userName); } this.ticketRegistry.addTicket(ticket); }
/** * Gets the authentication satisfied by policy. * * @param ticket the ticket * @param context the context * @return the authentication satisfied by policy * @throws AbstractTicketException the ticket exception */ protected final Authentication getAuthenticationSatisfiedByPolicy( final TicketGrantingTicket ticket, final ServiceContext context) throws AbstractTicketException { final ContextualAuthenticationPolicy<ServiceContext> policy = serviceContextAuthenticationPolicyFactory.createPolicy(context); if (policy.isSatisfiedBy(ticket.getAuthentication())) { logger.debug("Authentication policy {} is satisfied by the authentication associated with {}", policy, ticket.getId()); return ticket.getAuthentication(); } for (final Authentication auth : ticket.getSupplementalAuthentications()) { if (policy.isSatisfiedBy(auth)) { logger.debug("Authentication policy {} is satisfied by supplemental authentication associated with {}", policy, ticket.getId()); return auth; } } throw new UnsatisfiedAuthenticationPolicyException(policy); }
currentAuthentication = context.getAuthentication(); if (currentAuthentication != null) { final Authentication original = ticketGrantingTicket.getAuthentication(); if (!currentAuthentication.getPrincipal().equals(original.getPrincipal())) { logger.debug("Principal associated with current authentication {} does not match "
final Authentication authentication = tgt.getAuthentication(); final Principal principal = authentication.getPrincipal();
@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); }
final TicketGrantingTicket tgt = getCentralAuthenticationService() .getTicket(ticketGrantingTicketId, TicketGrantingTicket.class); userName = tgt.getAuthentication().getPrincipal().getId(); } catch (final InvalidTicketException e) { logger.error("Cannot get TGT", e);