Package org.linphone.core
Interface AuthInfo
public interface AuthInfo
Object holding authentication information.
In most case, authentication information consists of a username and password.
If realm isn't set, it will be deduced automatically from the first
authentication challenge as for the hash algorithm. Sometimes, a userid is
required by the proxy and then domain can be useful to discriminate different
credentials. You can also use this object if you need to use a client
certificate.
Once created and filled, a
in order to become known and used automatically when needed. Use
for that purpose.
The
information when needed to the application through the
authentication_requested() callback of it's
The application can respond to this information request later using
. This will unblock all pending authentication transactions and retry them with
authentication headers.
In most case, authentication information consists of a username and password.
If realm isn't set, it will be deduced automatically from the first
authentication challenge as for the hash algorithm. Sometimes, a userid is
required by the proxy and then domain can be useful to discriminate different
credentials. You can also use this object if you need to use a client
certificate.
Once created and filled, a
AuthInfo must be added to the Corein order to become known and used automatically when needed. Use
Core.addAuthInfo(org.linphone.core.AuthInfo)for that purpose.
The
Core object can take the initiative to request authenticationinformation when needed to the application through the
authentication_requested() callback of it's
CoreListener.The application can respond to this information request later using
Core.addAuthInfo(org.linphone.core.AuthInfo). This will unblock all pending authentication transactions and retry them with
authentication headers.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddAvailableAlgorithm(String algorithm) Add an unique algorithm in the the available algorithms list : Algorithms that
already exist will not be added.voidRemove all algorithms from the available algorithms list.clone()Instantiates a new auth info with values from source.Return a previously set access token.Gets the algorithm.Get the previously set authorization server uri.String[]Gets all available algorithms.Get the previously set OAUTH2 client_id.Gets the domain.longGet the expiration time for the current authentication information.getHa1()Gets the ha1.longGets the native pointer used by this class to make native method calls.Gets the password.getRealm()Gets the realm.Return a previously set refresh token.Gets the TLS certificate.Gets the TLS certificate path.Gets the TLS key.Gets the TLS key path.Get the previously set token endpoint https uri (OAUTH2).Gets the object stored in this object user's dataGets the user id.Gets the username.booleanisEqualButAlgorithms(AuthInfo authInfo2) Check if Authinfos are the same without taking account algorithms.voidsetAccessToken(BearerToken token) Set an access token to authenticate, to be used when the server supports the
"bearer" authentication method.voidsetAlgorithm(String algorithm) Sets the algorithm to use.voidSet the authorization server uri.voidsetAvailableAlgorithms(String[] algorithms) Sets the available algorithms list without testing unicity.voidsetClientId(String clientId) Set the OAUTH2 client_id.voidSets the domain for which this authentication is valid.voidsetExpires(long expires) Set the expiration time for the current authentication information.voidSets the ha1.voidsetPassword(String password) Sets the password.voidSets the realm.voidsetRefreshToken(BearerToken token) Set a refresh token to use when the access token set withsetAccessToken(org.linphone.core.BearerToken)
expires.voidsetTlsCert(String tlsCert) Sets the TLS certificate.voidsetTlsCertPath(String tlsCertPath) Sets the TLS certificate path.voidSets the TLS key.voidsetTlsKeyPath(String tlsKeyPath) Sets the TLS key path.voidSet the token endpoint https uri (OAUTH2).voidsetUserData(Object data) Sets the object to store in this object user's datavoidSets the user ID.voidsetUsername(String username) Sets the username.toString()
-
Method Details
-
getAccessToken
Return a previously set access token.
- Returns:
- the access token, as a
BearerTokenobject
-
setAccessToken
Set an access token to authenticate, to be used when the server supports the
"bearer" authentication method.
TheAuthInfotakes a reference to the supplied token, it is not making
any copy.- Parameters:
token- TheBearerTokenobject representing the access token.
-
getAlgorithm
Gets the algorithm.
- Returns:
- The algorithm.
-
setAlgorithm
Sets the algorithm to use.
- Parameters:
algorithm- The algorithm.
-
getAuthorizationServer
Get the previously set authorization server uri.
- Returns:
- the authorization server uri.
-
setAuthorizationServer
Set the authorization server uri.
- Parameters:
uri- the authorization server uri.
-
getAvailableAlgorithms
Gets all available algorithms.
- Returns:
- A list of available algorithms.
-
setAvailableAlgorithms
Sets the available algorithms list without testing unicity.
- Parameters:
algorithms- The available algorithms list.
-
getClientId
Get the previously set OAUTH2 client_id.
- Returns:
- the client_id.
-
setClientId
Set the OAUTH2 client_id.
The client_id may be used to renew access token from refresh token. see:setRefreshToken(org.linphone.core.BearerToken)- Parameters:
clientId- the client_id.
-
getDomain
Gets the domain.
- Returns:
- The domain.
-
setDomain
Sets the domain for which this authentication is valid.
- Parameters:
domain- The domain. This should not be necessary because realm is
supposed to be unique and sufficient. However, many SIP servers don't set realm
correctly, then domain has to be used to distinguish between several SIP
account bearing the same username.
-
getExpires
long getExpires()Get the expiration time for the current authentication information.
- Returns:
- The expiration time as a number of seconds since the Epoch, 1970-01-01
00:00:00 +0000 (UTC)
-
setExpires
void setExpires(long expires) Set the expiration time for the current authentication information.
- Parameters:
expires- The new expiration time in seconds. Use 0 to indicate no
expiration.
-
getHa1
Gets the ha1.
- Returns:
- The ha1.
-
setHa1
Sets the ha1.
- Parameters:
ha1- The ha1.
-
getPassword
Gets the password.
- Returns:
- The password.
-
setPassword
Sets the password.
- Parameters:
password- The password.
-
getRealm
Gets the realm.
- Returns:
- The realm.
-
setRealm
Sets the realm.
- Parameters:
realm- The realm.
-
getRefreshToken
Return a previously set refresh token.
- Returns:
- the refresh token, as a
BearerTokenobject.
-
setRefreshToken
Set a refresh token to use when the access token set withsetAccessToken(org.linphone.core.BearerToken)
expires.
TheAuthInfotakes a reference to the supplied token, it is not making
any copy. Provided that the token endpoint uri was assigned withsetTokenEndpointUri(java.lang.String)
, once theAuthInfois pushed in theCore,AuthInfo
object automatically obtains new access token when needed, from the supplied
refresh token.- Parameters:
token- TheBearerTokenobject representing the refresh token.
-
getTlsCert
Gets the TLS certificate.
- Returns:
- The TLS certificate.
-
setTlsCert
Sets the TLS certificate.
- Parameters:
tlsCert- The TLS certificate.
-
getTlsCertPath
Gets the TLS certificate path.
- Returns:
- The TLS certificate path.
-
setTlsCertPath
Sets the TLS certificate path.
- Parameters:
tlsCertPath- The TLS certificate path.
-
getTlsKey
Gets the TLS key.
- Returns:
- The TLS key.
-
setTlsKey
Sets the TLS key.
- Parameters:
tlsKey- The TLS key.
-
getTlsKeyPath
Gets the TLS key path.
- Returns:
- The TLS key path.
-
setTlsKeyPath
Sets the TLS key path.
- Parameters:
tlsKeyPath- The TLS key path.
-
getTokenEndpointUri
Get the previously set token endpoint https uri (OAUTH2).
- Returns:
- the token endpoint uri.
-
setTokenEndpointUri
Set the token endpoint https uri (OAUTH2).
The token endpoint uri is used to renew access token from refresh token. see:
setRefreshToken(org.linphone.core.BearerToken)- Parameters:
uri- the token endpoint uri.
-
getUserid
Gets the user id.
- Returns:
- The user id.
-
setUserid
Sets the user ID.
- Parameters:
userId- The userid.
-
getUsername
Gets the username.
- Returns:
- The username.
-
setUsername
Sets the username.
- Parameters:
username- The username.
-
addAvailableAlgorithm
Add an unique algorithm in the the available algorithms list : Algorithms that
already exist will not be added.
- Parameters:
algorithm- The algorithm to add.
-
clearAvailableAlgorithms
void clearAvailableAlgorithms()Remove all algorithms from the available algorithms list.
-
clone
Instantiates a new auth info with values from source.
- Returns:
- The newly created
AuthInfoobject.
-
isEqualButAlgorithms
Check if Authinfos are the same without taking account algorithms.
- Parameters:
authInfo2- The secondAuthInfoobject.- Returns:
- true if all fields (Username, UserId, Realm, Domain) are the same.
-
setUserData
Sets the object to store in this object user's data- Parameters:
data- the object to store
-
getUserData
Object getUserData()Gets the object stored in this object user's data- Returns:
- the object store if any, null otherwise
-
getNativePointer
long getNativePointer()Gets the native pointer used by this class to make native method calls.- Returns:
- the nativer pointer, as long
-
toString
String toString()
-