<commit_before><?php
/**
 * Manage details for the administrative user
 *
 * @service adminUser
 * @package api
 * @subpackage services
 * @deprecated use user service instead
 */
class AdminUserService extends KalturaBaseUserService 
{
	
	protected function partnerRequired($actionName)
	{
		if ($actionName === 'updatePassword') {
			return false;
		}
		if ($actionName === 'resetPassword') {
			return false;
		}
		if ($actionName === 'login') {
			return false;
		}
		if ($actionName === 'setInitialPassword') {
			return false;
		}
		return parent::partnerRequired($actionName);
	}	
	

	/**
	 * keep backward compatibility with changed error codes
	 * @param KalturaAPIException $e
	 * @throws KalturaAPIException
	 */
	private function throwTranslatedException(KalturaAPIException $e)
	{
		$code = $e->getCode();
		if ($code == KalturaErrors::USER_NOT_FOUND) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		else if ($code == KalturaErrors::WRONG_OLD_PASSWORD) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_WRONG_OLD_PASSWORD, "wrong password" );
		}
		else if ($code == KalturaErrors::USER_WRONG_PASSWORD) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		else if ($code == KalturaErrors::LOGIN_DATA_NOT_FOUND) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		throw $e;
	}
	
	
	/**
	 * Update admin user password and email
	 * 
	 * @action updatePassword
	 * @param string $email
	 * @param string $password
	 * @param string $newEmail Optional, provide only when you want to update the email
	 * @param string $newPassword
	 * @return KalturaAdminUser
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::ADMIN_KUSER_WRONG_OLD_PASSWORD
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
	 * @throws KalturaErrors::PASSWORD_ALREADY_USED
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::LOGIN_ID_ALREADY_USED
	 * 
	 * @deprecated
	 */
	public function updatePasswordAction( $email , $password , $newEmail = "" , $newPassword = "" )
	{
		try
		{
			parent::updateLoginDataImpl($email, $password, $newEmail, $newPassword);
			
			// copy required parameters to a KalturaAdminUser object for backward compatibility
			$adminUser = new KalturaAdminUser();
			$adminUser->email = $newEmail ? $newEmail : $email;
			$adminUser->password = $<PASSWORD>;
			
			return $adminUser;
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	
	/**
	 * Reset admin user password and send it to the users email address
	 * 
	 * @action resetPassword
	 * @param string $email
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
	 * @throws KalturaErrors::PASSWORD_ALREADY_USED
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::LOGIN_ID_ALREADY_USED
	 */	
	public function resetPasswordAction($email)
	{
		try
		{
			return parent::resetPasswordImpl($email);
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	/**
	 * Get an admin session using admin email and password (Used for login to the KMC application)
	 * 
	 * @action login
	 * @param string $email
	 * @param string $password
	 * @param int $partnerId
	 * @return string
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @thrown KalturaErrors::INVALID_PARTNER_ID
	 * @thrown KalturaErrors::LOGIN_RETRIES_EXCEEDED
	 * @thrown KalturaErrors::LOGIN_BLOCKED
	 * @thrown KalturaErrors::PASSWORD_EXPIRED
	 * @thrown KalturaErrors::INVALID_PARTNER_ID
	 * @thrown KalturaErrors::INTERNAL_SERVERL_ERROR
	 * @throws KalturaErrors::DIRECT_LOGIN_BLOCKED
	 */		
	public function loginAction($email, $password, $partnerId = null)
	{
		try
		{
			$ks = parent::loginImpl(null, $email, $password, $partnerId);
			$tempKs = kSessionUtils::crackKs($ks);
			if (!$tempKs->isAdmin()) {
				throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND); 
			}
			return $ks;
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	
	
	/**
	 * Set initial users password
	 * 
	 * @action setInitialPassword
	 * @param string $hashKey<commit_msg>PLAT-9841:block ability to use loginByLoginId with partner configuration<commit_after><?php
/**
 * Manage details for the administrative user
 *
 * @service adminUser
 * @package api
 * @subpackage services
 * @deprecated use user service instead
 */
class AdminUserService extends KalturaBaseUserService 
{
	
	protected function partnerRequired($actionName)
	{
		if ($actionName === 'updatePassword') {
			return false;
		}
		if ($actionName === 'resetPassword') {
			return false;
		}
		if ($actionName === 'login') {
			return false;
		}
		if ($actionName === 'setInitialPassword') {
			return false;
		}
		return parent::partnerRequired($actionName);
	}	
	

	/**
	 * keep backward compatibility with changed error codes
	 * @param KalturaAPIException $e
	 * @throws KalturaAPIException
	 */
	private function throwTranslatedException(KalturaAPIException $e)
	{
		$code = $e->getCode();
		if ($code == KalturaErrors::USER_NOT_FOUND) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		else if ($code == KalturaErrors::WRONG_OLD_PASSWORD) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_WRONG_OLD_PASSWORD, "wrong password" );
		}
		else if ($code == KalturaErrors::USER_WRONG_PASSWORD) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		else if ($code == KalturaErrors::LOGIN_DATA_NOT_FOUND) {
			throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND);
		}
		throw $e;
	}
	
	
	/**
	 * Update admin user password and email
	 * 
	 * @action updatePassword
	 * @param string $email
	 * @param string $password
	 * @param string $newEmail Optional, provide only when you want to update the email
	 * @param string $newPassword
	 * @return KalturaAdminUser
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::ADMIN_KUSER_WRONG_OLD_PASSWORD
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
	 * @throws KalturaErrors::PASSWORD_ALREADY_USED
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::LOGIN_ID_ALREADY_USED
	 * 
	 * @deprecated
	 */
	public function updatePasswordAction( $email , $password , $newEmail = "" , $newPassword = "" )
	{
		try
		{
			parent::updateLoginDataImpl($email, $password, $newEmail, $newPassword);
			
			// copy required parameters to a KalturaAdminUser object for backward compatibility
			$adminUser = new KalturaAdminUser();
			$adminUser->email = $newEmail ? $newEmail : $email;
			$adminUser->password = $<PASSWORD> ? $<PASSWORD> : $password;
			
			return $adminUser;
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	
	/**
	 * Reset admin user password and send it to the users email address
	 * 
	 * @action resetPassword
	 * @param string $email
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @throws KalturaErrors::PASSWORD_STRUCTURE_INVALID
	 * @throws KalturaErrors::PASSWORD_ALREADY_USED
	 * @throws KalturaErrors::INVALID_FIELD_VALUE
	 * @throws KalturaErrors::LOGIN_ID_ALREADY_USED
	 */	
	public function resetPasswordAction($email)
	{
		try
		{
			return parent::resetPasswordImpl($email);
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	/**
	 * Get an admin session using admin email and password (Used for login to the KMC application)
	 * 
	 * @action login
	 * @param string $email
	 * @param string $password
	 * @param int $partnerId
	 * @return string
	 * @ksIgnored
	 *
	 * @throws KalturaErrors::ADMIN_KUSER_NOT_FOUND
	 * @thrown KalturaErrors::INVALID_PARTNER_ID
	 * @thrown KalturaErrors::LOGIN_RETRIES_EXCEEDED
	 * @thrown KalturaErrors::LOGIN_BLOCKED
	 * @thrown KalturaErrors::PASSWORD_EXPIRED
	 * @thrown KalturaErrors::INVALID_PARTNER_ID
	 * @thrown KalturaErrors::INTERNAL_SERVERL_ERROR
	 * @thrown KalturaErrors::DIRECT_LOGIN_BLOCKED
	 */		
	public function loginAction($email, $password, $partnerId = null)
	{
		try
		{
			$ks = parent::loginImpl(null, $email, $password, $partnerId);
			$tempKs = kSessionUtils::crackKs($ks);
			if (!$tempKs->isAdmin()) {
				throw new KalturaAPIException(KalturaErrors::ADMIN_KUSER_NOT_FOUND); 
			}
			return $ks;
		}
		catch (KalturaAPIException $e) // keep backward compatibility with changed error codes
		{
			$this->throwTranslatedException($e);
		}
	}
	
	
	
	/**
	 * Set initial users password
	 * 
	 * @action setInitialPassword
	 * @param string $hashKey
{'fraction_non_alphanumeric': 0.10752451250413132, 'fraction_numerical': 0.00044067423157430867, 'mean_word_length': 4.51183970856102, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3813901', 'n_tokens_mistral': 3250, 'n_tokens_neox': 2894, 'n_words': 648}