private void userInfoInit ( ) { boolean first = true ; userId = null ; userLocale = null ; userName = null ; userOrganization = null ; userDivision = null ; if ( null != authentications ) { for ( Authentication auth : authentications ) { userId = combine ( userId , auth . getUserId ( ) ) ; userName = combine ( userName , auth . getUserName ( ) ) ; if ( first ) { userLocale = auth . getUserLocale ( ) ; first = false ; } else { if ( null != auth . getUserLocale ( ) && ( null == userLocale || ! userLocale . equals ( auth . getUserLocale ( ) ) ) ) { userLocale = null ; } } userOrganization = combine ( userOrganization , auth . getUserOrganization ( ) ) ; userDivision = combine ( userDivision , auth . getUserDivision ( ) ) ; } } // now calculate the "id" for this context, this should be independent of the data order, so sort Map < String , List < String > > idParts = new HashMap < String , List < String > > ( ) ; if ( null != authentications ) { for ( Authentication auth : authentications ) { List < String > auths = new ArrayList < String > ( ) ; for ( BaseAuthorization ba : auth . getAuthorizations ( ) ) { auths . add ( ba . getId ( ) ) ; } Collections . sort ( auths ) ; idParts . put ( auth . getSecurityServiceId ( ) , auths ) ; } } StringBuilder sb = new StringBuilder ( ) ; List < String > sortedKeys = new ArrayList < String > ( idParts . keySet ( ) ) ; Collections . sort ( sortedKeys ) ; for ( String key : sortedKeys ) { if ( sb . length ( ) > 0 ) { sb . append ( ' ' ) ; } List < String > auths = idParts . get ( key ) ; first = true ; for ( String ak : auths ) { if ( first ) { first = false ; } else { sb . append ( ' ' ) ; } sb . append ( ak ) ; } sb . append ( ' ' ) ; sb . append ( key ) ; } id = sb . toString ( ) ; }
Calculate UserInfo strings .