protected function response( $uri )
    {
        switch( self::redirectMode() )
        {
            case self::LOGIN_REDIRECT_MODE_HTTP:
                header( "Location: $uri" );
                break;
            case self::LOGIN_REDIRECT_MODE_JS:
                header( "Content-type: application/json");
                if ( SolrSafeOperatorHelper::featureIsActive( 'UUMP' ) )
                {
                    header( "Accept: application/json");
                }
                echo json_encode( $uri );
                break;
            case self::LOGIN_REDIRECT_MODE_JSON:
                header('Content-type: application/json');

                $result = array();

                $result['status']           = $this->_isLoginSuccessful ? 0 : 1;
                $result['LoginRedirect']    = $this->_isLoginSuccessful ? $this->_destUrl : $uri;

                $mmUser = MMUsers::getCurrentUserObject();

                if ( $this->_isLoginSuccessful )
                {
                    $result['User']                     = $this->_esbResult->toArray();
                    $result['User']['mmSettings']       = $mmUser->getMMSettings();
                    $result['User']['unorderedAppList'] = $mmUser->getApplicationList();
                    $result['User']['alterboxMsgReset'] = $mmUser->hasPreference('alterboxMsgReset') ? $mmUser->getPreferences('alterboxMsgReset') : true;
                    
                    $result['cookies'] = CookieTool::setCookies();

                    $salutations    = SolrSafeOperatorHelper::clusterIni('Salutations', 'Salutation', 'merck.ini' );
                    $localeMap      = SolrSafeOperatorHelper::clusterIni('ESBSettings', 'ESBLocaleMap', 'merck.ini' );
                    $locale         = $this->_esbResult->language;
                    if ( isset($localeMap[$locale]) )
                        $locale = $localeMap[$locale];

                    $result['commonauth']       = array(
                        'user_id'           => $this->_esbResult->userName,
                        'MSDID'             => ( isset( $this->_esbResult->othersParams['crmMemberId'] ) && !empty($this->_esbResult->othersParams['crmMemberId']) ) ? $this->_esbResult->othersParams['crmMemberId'] : $this->_esbResult->countryOfRegistration.'000000X',
                        'userId'            => $this->_esbResult->userId,
                        'UUMPID'            => $this->_esbResult->userId,
                        'UVDSPam'           => null,
                        'ValidationStatus'  => $this->_esbResult->getValidationStatus(),
                        'ODMNum'            => null,
                        'ValidationDate'    => ($this->_esbResult->registrationDate) ? date('d-M-y', strtotime($this->_esbResult->registrationDate)) : null,
                        'TVFCode'           => 'MSD',
                        'Email'             => $this->_esbResult->emailAddress,
                        'cc'                => $this->_esbResult->countryOfRegistration,
                        'PhoneNum'          => isset($this->_esbResult->othersParams['phoneNumber']) ? $this->_esbResult->othersParams['phoneNumber'] : null,
                        'ZipCode'           => $this->_esbResult->postalCode,
                        'zipCode'           => $this->_esbResult->postalCode,
                        'Salutation'        => isset($salutations[$this->_esbResult->othersParams['salutation']]) ? $salutations[$this->_esbResult->othersParams['salutation']] : null,
                        'City'              => $this->_esbResult->city,
                        'Street'            => isset($this->_esbResult->othersParams['addressLine2']) ? $this->_esbResult->othersParams['addressLine2'] : null,
                        'Address'           => isset($this->_esbResult->othersParams['addressLine1']) ? $this->_esbResult->othersParams['addressLine1'] : null,
                        'Country'           => $this->_esbResult->countryOfRegistration,
                        'CustomerType'      => $this->_esbResult->customerType,
                        'SiteCRMStatus'     => null,
                        'LastName'          => $this->_esbResult->lastName,
                        'FirstName'         => $this->_esbResult->firstName,
                        'specialty'         => $this->_esbResult->userSpecialty,
                        'lng'               => LocaleTool::languageISO639Code($locale).'_'.LocaleTool::countryISO3166Code($locale),
                        'hostName'          => preg_replace('#^https?://#', '', ContextTool::instance()->domain()),
                        'LicenseNumber'     => isset($this->_esbResult->othersParams['licenseNumber']) ? $this->_esbResult->othersParams['licenseNumber'] : null,
                    );

                }
                echo json_encode($result);
                break;
        }
        eZExecution::cleanExit();
    }