@ RequestMapping ( value = "/tenants" , method = RequestMethod . GET ) public String getTenants ( @ RequestParam ( "tenantId" ) Integer tenantId , Locale locale , ModelMap modelMap , Model model ) { AuthenticationProfile authenticationProfile = ( AuthenticationProfile ) modelMap . get ( "tenantAuthorization" ) ; //if there is no active user, go to the auth page. if ( authenticationProfile == null ) { setupHomePage ( locale , model ) ; return "home" ; } // if no tenant id was supplied just use the active tenantID in the user auth. if ( tenantId == null ) { tenantId = authenticationProfile . getActiveScope ( ) . getId ( ) ; } // we need to get a new auth ticket for the tenant and update the authenticationProfile in session. if ( tenantId != null && ! tenantId . equals ( authenticationProfile . getActiveScope ( ) . getId ( ) ) ) { authenticationProfile = UserAuthenticator . refreshUserAuthTicket ( authenticationProfile . getAuthTicket ( ) , tenantId ) ; model . addAttribute ( "tenantAuthorization" , authenticationProfile ) ; } // Authorize user and get tenants List < Scope > tenants = authenticationProfile . getAuthorizedScopes ( ) ; if ( tenants == null ) { tenants = new ArrayList < Scope > ( ) ; tenants . add ( authenticationProfile . getActiveScope ( ) ) ; } model . addAttribute ( "user" , authenticationProfile . getUserProfile ( ) ) ; model . addAttribute ( "availableTenants" , tenants ) ; model . addAttribute ( "tenantId" , tenantId ) ; List < Site > sites = null ; if ( tenants != null && tenants . size ( ) > 0 ) { sites = getAvailableTenantSites ( tenantId ) ; } else { sites = new ArrayList < Site > ( ) ; } model . addAttribute ( "sites" , sites ) ; return "tenants" ; }
This method is used when the application and user have been authorized