protected function associate()
    {
        # Rejecting no-encryption without TLS.
        if(empty($_SERVER['HTTPS']) && $this->data['openid_session_type'] == 'no-encryption') {
            $this->directErrorResponse();
        }
        
        # Checking whether we support DH at all.
        if (!$this->dh && substr($this->data['openid_session_type'], 0, 2) == 'DH') {
            $this->redirect($this->response(array(
                'openid.error' => 'DH not supported',
                'openid.error_code' => 'unsupported-type',
                'openid.session_type' => 'no-encryption'
                )));
        }
        
        # Creating the association
        $this->assoc = array();
        $this->assoc['hash'] = $this->data['openid_assoc_type'] == 'HMAC-SHA256' ? 'sha256' : 'sha1';
        $this->assoc['handle'] = $this->assoc_handle();
        
        # Getting the shared secret
        if($this->data['openid_session_type'] == 'no-encryption') {
            $this->assoc['mac'] = base64_encode($this->shared_secret($this->assoc['hash']));
        } else {
            $this->dh();
        }
        
        # Preparing the direct response...
        $response = array(
            'ns'           => $this->ns,
            'assoc_handle' => $this->assoc['handle'],
            'assoc_type'   => $this->data['openid_assoc_type'],
            'session_type' => $this->data['openid_session_type'],
            'expires_in'   => $this->assoc_lifetime
            );
        
        if(isset($this->assoc['dh_server_public'])) {
            $response['dh_server_public'] = $this->assoc['dh_server_public'];
            $response['enc_mac_key'] = $this->assoc['mac'];
        } else {
            $response['mac_key'] = $this->assoc['mac'];
        }
        
        # ...and sending it.
        echo $this->keyValueForm($response);
        die();
    }
protected function associate()
    {
        # Rejecting no-encryption without TLS.
        if(empty($_SERVER['HTTPS']) && $this->data['openid_session_type'] == 'no-encryption') {
            $this->directErrorResponse();
        }
        
        # Checking whether we support DH at all.
        if (!$this->dh && substr($this->data['openid_session_type'], 0, 2) == 'DH') {
            $this->redirect($this->response(array(
                'openid.error' => 'DH not supported',
                'openid.error_code' => 'unsupported-type',
                'openid.session_type' => 'no-encryption'
                )));
        }
        
        # Creating the association
        $this->assoc = array();
        $this->assoc['hash'] = $this->data['openid_assoc_type'] == 'HMAC-SHA256' ? 'sha256' : 'sha1';
        $this->assoc['handle'] = $this->assoc_handle();
        
        # Getting the shared secret
        if($this->data['openid_session_type'] == 'no-encryption') {
            $this->assoc['mac'] = base64_encode($this->shared_secret($this->assoc['hash']));
        } else {
            $this->dh();
        }
        
        # Preparing the direct response...
        $response = array(
            'ns'           => $this->ns,
            'assoc_handle' => $this->assoc['handle'],
            'assoc_type'   => $this->data['openid_assoc_type'],
            'session_type' => $this->data['openid_session_type'],
            'expires_in'   => $this->assoc_lifetime
            );
        
        if(isset($this->assoc['dh_server_public'])) {
            $response['dh_server_public'] = $this->assoc['dh_server_public'];
            $response['enc_mac_key'] = $this->assoc['mac'];
        } else {
            $response['mac_key'] = $this->assoc['mac'];
        }
        
        # ...and sending it.
        echo $this->keyValueForm($response);
        die();
    }
protected function associate ( ) { # Rejecting no-encryption without TLS. if ( empty ( $ _SERVER [ 'HTTPS' ] ) && $ this -> data [ 'openid_session_type' ] == 'no-encryption' ) { $ this -> directErrorResponse ( ) ; } # Checking whether we support DH at all. if ( ! $ this -> dh && substr ( $ this -> data [ 'openid_session_type' ] , 0 , 2 ) == 'DH' ) { $ this -> redirect ( $ this -> response ( array ( 'openid.error' => 'DH not supported' , 'openid.error_code' => 'unsupported-type' , 'openid.session_type' => 'no-encryption' ) ) ) ; } # Creating the association $ this -> assoc = array ( ) ; $ this -> assoc [ 'hash' ] = $ this -> data [ 'openid_assoc_type' ] == 'HMAC-SHA256' ? 'sha256' : 'sha1' ; $ this -> assoc [ 'handle' ] = $ this -> assoc_handle ( ) ; # Getting the shared secret if ( $ this -> data [ 'openid_session_type' ] == 'no-encryption' ) { $ this -> assoc [ 'mac' ] = base64_encode ( $ this -> shared_secret ( $ this -> assoc [ 'hash' ] ) ) ; } else { $ this -> dh ( ) ; } # Preparing the direct response... $ response = array ( 'ns' => $ this -> ns , 'assoc_handle' => $ this -> assoc [ 'handle' ] , 'assoc_type' => $ this -> data [ 'openid_assoc_type' ] , 'session_type' => $ this -> data [ 'openid_session_type' ] , 'expires_in' => $ this -> assoc_lifetime ) ; if ( isset ( $ this -> assoc [ 'dh_server_public' ] ) ) { $ response [ 'dh_server_public' ] = $ this -> assoc [ 'dh_server_public' ] ; $ response [ 'enc_mac_key' ] = $ this -> assoc [ 'mac' ] ; } else { $ response [ 'mac_key' ] = $ this -> assoc [ 'mac' ] ; } # ...and sending it. echo $ this -> keyValueForm ( $ response ) ; die ( ) ; }
Performs association with an RP.
Performs association with an RP .