/*
 * Copyright (c) 2010-2022 Belledonne Communications SARL.
 *
 * This file is part of Liblinphone 
 * (see https://gitlab.linphone.org/BC/public/liblinphone).
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif // _MSC_VER

#ifndef _BEARER_TOKEN_HH
#define _BEARER_TOKEN_HH

#include <string>
#include "object.hh"




struct _LinphoneBearerToken;


namespace linphone {


	/**
	 * @brief Object that represents a bearer token (eg OAUTH). 
	 *
	 * SIP servers may support "bearer" kind of authentication, in which case an
	 * authentication token needs to be supplied in order to authenticate to the SIP
	 * service. Applications are responsible to obtain the token from an
	 * authentication server. In order to pass it to liblinphone for usage, the token
	 * needs to be encapsulated into a @ref BearerToken, together with its expiration
	 * time and target server name for which it is intended to use, then passed into a
	 * @ref AuthInfo object. Both access and refresh tokens may be represented. If
	 * both are provided to the @ref AuthInfo, then liblinphone automatically uses the
	 * refresh token to obtain a new access token when the latter is expired. 
	 */
	class BearerToken: public Object {
	
		public:

			LINPHONECXX_PUBLIC BearerToken(void *ptr, bool takeRef=true);
			LINPHONECXX_PUBLIC _LinphoneBearerToken *cPtr() {return (_LinphoneBearerToken *)mPrivPtr;}

	
		public:
			
		
			/**
			 * @brief Get the token exiration time, as a number of seconds since EPOCH. 
			 *
			 * @return the expiration time 
			 */
			LINPHONECXX_PUBLIC time_t getExpirationTime() const;
			
			/**
			 * @brief Get the token as a string. 
			 *
			 * @return the token.    
			 */
			LINPHONECXX_PUBLIC std::string getToken() const;
			
			
	};

};

#endif // _BEARER_TOKEN_HH

#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif // _MSC_VER
