protected final String getPrimaryUserAttribute ( PortletRequest request ) { final PortletPreferences preferences = request . getPreferences ( ) ; @ SuppressWarnings ( "unchecked" ) final Map < String , String > userAttributes = ( Map < String , String > ) request . getAttribute ( PortletRequest . USER_INFO ) ; final String [ ] attributeNames = preferences . getValues ( primaryUserAttributesPreference , new String [ 0 ] ) ; for ( final String attributeName : attributeNames ) { final String emplid = userAttributes . get ( attributeName ) ; if ( StringUtils . isNotEmpty ( emplid ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Found emplid '" + emplid + "' for under attribute: " + attributeName ) ; } return emplid ; } } logger . warn ( "Could not find a value for any of the user attributes " + Arrays . toString ( attributeNames ) + " specified by preference: " + primaryUserAttributesPreference ) ; throw new AccessDeniedException ( "No primary attribute found in attributes: " + Arrays . toString ( attributeNames ) ) ; }
Get the user s primary attribute .