code: function(params) {
                  var data = {
                      validity: 10 * 365 * 24 * 60 * 60, // 10 Years
                      renew: false
                  };
  
                  if (params) {
                      if (params.keyAlgorithm != 'undefined') {
                          data.keyAlgorithm = params.keyAlgorithm;
                      }
  
                      if (parseInt(params.keySize) > 0) {
                          data.keySize = params.keySize;
                      }
                  }
  
                  var httpRequestParams = {
                      url: SERVICE_ADDRESSES.SSO_ADDRESS + SERVICES_PATH.SSO_GENERATE_KEY,
                      method: 'POST',
                      data: data,
                      headers: {
                          'Authorization': 'Bearer ' + token
                      }
                  };
  
                  httpRequest(httpRequestParams, function(result) {
                      if (!result.hasError) {
                          try {
                              var response = JSON.parse(result.result.responseText);
                          }
                          catch (e) {
                              console.log(e);
                          }
  
                          /**
                           * Save new Key Id in cache and update cacheSecret
                           */
                          if (canUseCache) {
                              if (db) {
                                  db.users
                                      .update(userInfo.id, {keyId: response.keyId})
                                      .then(function() {
                                          getEncryptionKey({
                                              keyId: response.keyId
                                          }, function(result) {
                                              if (!result.hasError) {
                                                  cacheSecret = result.secretKey;
                                              }
                                          });
                                      })
                                      .catch(function(error) {
                                          fireEvent('error', {
                                              code: error.code,
                                              message: error.message,
                                              error: error
                                          });
                                      });
                              }
                              else {
                                  fireEvent('error', {
                                      code: 6601,
                                      message: CHAT_ERRORS[6601],
                                      error: null
                                  });
                              }
                          }
  
                          // callback && callback({
                          //     hasError: false,
                          //     keyId: response.keyId
                          // });
                      }
                      else {
                          // callback && callback({
                          //     hasError: true,
                          //     code: result.error,
                          //     message: result.error_description
                          // });
  
                          fireEvent('error', {
                              code: result.error,
                              message: result.error_description,
                              error: result
                          });
                      }
                  });
              }
docs: *****************************************************
  P R I V A T E   M E T H O D S            *
  *****************************************************