protected void updateGroups ( final LoginContext _login , final Person _person ) throws EFapsException { for ( final JAASSystem system : JAASSystem . getAllJAASSystems ( ) ) { if ( system . getGroupJAASPrincipleClass ( ) != null ) { final Set < ? > groupsJaas = _login . getSubject ( ) . getPrincipals ( system . getGroupJAASPrincipleClass ( ) ) ; final Set < Group > groupsEfaps = new HashSet <> ( ) ; for ( final Object groupObj : groupsJaas ) { try { final String groupKey = ( String ) system . getGroupMethodKey ( ) . invoke ( groupObj ) ; final Group groupEfaps = Group . getWithJAASKey ( system , groupKey ) ; if ( groupEfaps != null ) { groupsEfaps . add ( groupEfaps ) ; } } catch ( final IllegalAccessException e ) { LoginHandler . LOG . error ( "could not execute group key method for system " + system . getName ( ) , e ) ; } catch ( final IllegalArgumentException e ) { LoginHandler . LOG . error ( "could not execute group key method for system " + system . getName ( ) , e ) ; } catch ( final InvocationTargetException e ) { LoginHandler . LOG . error ( "could not execute group key method for system " + system . getName ( ) , e ) ; } } _person . setGroups ( system , groupsEfaps ) ; } } }
The groups of the given person are updated with the information from the JAAS login context .