private Collection < Map < String , Object > > getActiveSsoSessions ( final SsoSessionReportOptions option ) { val activeSessions = new ArrayList < Map < String , Object > > ( ) ; val dateFormat = new ISOStandardDateFormat ( ) ; getNonExpiredTicketGrantingTickets ( ) . stream ( ) . map ( TicketGrantingTicket . class :: cast ) . filter ( tgt -> ! ( option == SsoSessionReportOptions . DIRECT && tgt . getProxiedBy ( ) != null ) ) . forEach ( tgt -> { val authentication = tgt . getAuthentication ( ) ; val principal = authentication . getPrincipal ( ) ; val sso = new HashMap < String , Object > ( SsoSessionAttributeKeys . values ( ) . length ) ; sso . put ( SsoSessionAttributeKeys . AUTHENTICATED_PRINCIPAL . toString ( ) , principal . getId ( ) ) ; sso . put ( SsoSessionAttributeKeys . AUTHENTICATION_DATE . toString ( ) , authentication . getAuthenticationDate ( ) ) ; sso . put ( SsoSessionAttributeKeys . AUTHENTICATION_DATE_FORMATTED . toString ( ) , dateFormat . format ( DateTimeUtils . dateOf ( authentication . getAuthenticationDate ( ) ) ) ) ; sso . put ( SsoSessionAttributeKeys . NUMBER_OF_USES . toString ( ) , tgt . getCountOfUses ( ) ) ; sso . put ( SsoSessionAttributeKeys . TICKET_GRANTING_TICKET . toString ( ) , tgt . getId ( ) ) ; sso . put ( SsoSessionAttributeKeys . PRINCIPAL_ATTRIBUTES . toString ( ) , principal . getAttributes ( ) ) ; sso . put ( SsoSessionAttributeKeys . AUTHENTICATION_ATTRIBUTES . toString ( ) , authentication . getAttributes ( ) ) ; if ( option != SsoSessionReportOptions . DIRECT ) { if ( tgt . getProxiedBy ( ) != null ) { sso . put ( SsoSessionAttributeKeys . IS_PROXIED . toString ( ) , Boolean . TRUE ) ; sso . put ( SsoSessionAttributeKeys . PROXIED_BY . toString ( ) , tgt . getProxiedBy ( ) . getId ( ) ) ; } else { sso . put ( SsoSessionAttributeKeys . IS_PROXIED . toString ( ) , Boolean . FALSE ) ; } } sso . put ( SsoSessionAttributeKeys . AUTHENTICATED_SERVICES . toString ( ) , tgt . getServices ( ) ) ; activeSessions . add ( sso ) ; } ) ; return activeSessions ; }
Gets sso sessions .