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 `AuthInfo` must be added to the `Core`
in 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 authentication
information 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 Type
Method
Description
`void`
`addAvailableAlgorithm(String algorithm)`
Add an unique algorithm in the the available algorithms list : Algorithms that
already exist will not be added.
`void`
`clearAvailableAlgorithms()`
Remove all algorithms from the available algorithms list.
`AuthInfo`
`clone()`
Instantiates a new auth info with values from source.
`BearerToken`
`getAccessToken()`
Return a previously set access token.
`String`
`getAlgorithm()`
Gets the algorithm.
`String`
`getAuthorizationServer()`
Get the previously set authorization server uri.
`String[]`
`getAvailableAlgorithms()`
Gets all available algorithms.
`String`
`getClientId()`
Get the previously set OAUTH2 client_id.
`String`
`getClientSecret()`
Get the previously set OAUTH2 client_secret.
`String`
`getDomain()`
Gets the domain.
`long`
`getExpires()`
Get the expiration time for the current authentication information.
`String`
`getHa1()`
Gets the ha1.
`long`
`getNativePointer()`
Gets the native pointer used by this class to make native method calls.
`String`
`getPassword()`
Gets the password.
`String`
`getRealm()`
Gets the realm.
`BearerToken`
`getRefreshToken()`
Return a previously set refresh token.
`String`
`getTlsCert()`
Gets the TLS certificate.
`String`
`getTlsCertPath()`
Gets the TLS certificate path.
`String`
`getTlsKey()`
Gets the TLS key.
`String`
`getTlsKeyPath()`
Gets the TLS key path.
`String`
`getTokenEndpointUri()`
Get the previously set token endpoint https uri (OAUTH2).
`Object`
`getUserData()`
Gets the object stored in this object user's data
`String`
`getUserid()`
Gets the user id.
`String`
`getUsername()`
Gets the username.
`boolean`
`isEqualButAlgorithms(AuthInfo authInfo2)`
Check if Authinfos are the same without taking account algorithms.
`void`
`setAccessToken(BearerToken token)`
Set an access token to authenticate, to be used when the server supports the
"bearer" authentication method.
`void`
`setAlgorithm(String algorithm)`
Sets the algorithm to use.
`void`
`setAuthorizationServer(String uri)`
Set the authorization server uri.
`void`
`setAvailableAlgorithms(String[] algorithms)`
Sets the available algorithms list without testing unicity.
`void`
`setClientId(String clientId)`
Set the OAUTH2 client_id.
`void`
`setClientSecret(String clientSecret)`
Set the OAUTH2 client_secret.
`void`
`setDomain(String domain)`
Sets the domain for which this authentication is valid.
`void`
`setExpires(long expires)`
Set the expiration time for the current authentication information.
`void`
`setHa1(String ha1)`
Sets the ha1.
`void`
`setPassword(String password)`
Sets the password.
`void`
`setRealm(String realm)`
Sets the realm.
`void`
`setRefreshToken(BearerToken token)`
Set a refresh token to use when the access token set with `setAccessToken(org.linphone.core.BearerToken)`
expires.
`void`
`setTlsCert(String tlsCert)`
Sets the TLS certificate.
`void`
`setTlsCertPath(String tlsCertPath)`
Sets the TLS certificate path.
`void`
`setTlsKey(String tlsKey)`
Sets the TLS key.
`void`
`setTlsKeyPath(String tlsKeyPath)`
Sets the TLS key path.
`void`
`setTokenEndpointUri(String uri)`
Set the token endpoint https uri (OAUTH2).
`void`
`setUserData(Object data)`
Sets the object to store in this object user's data
`void`
`setUserid(String userId)`
Sets the user ID.
`void`
`setUsername(String username)`
Sets the username.
`String`
`toString()`

## Method Details

### getAccessToken

@Nullable BearerToken getAccessToken()
Return a previously set access token.

Returns:
  the access token, as a `BearerToken` object

### setAccessToken

void setAccessToken(@Nullable BearerToken token)
Set an access token to authenticate, to be used when the server supports the
"bearer" authentication method.
The `AuthInfo` takes a reference to the supplied token, it is not making
any copy.

Parameters:
  `token` - The `BearerToken` object representing the access token.

### getAlgorithm

@Nullable String getAlgorithm()
Gets the algorithm.

Returns:
  The algorithm.

### setAlgorithm

void setAlgorithm(@Nullable String algorithm)
Sets the algorithm to use.

Parameters:
  `algorithm` - The algorithm.

### getAuthorizationServer

@Nullable String getAuthorizationServer()
Get the previously set authorization server uri.

Returns:
  the authorization server uri.

### setAuthorizationServer

void setAuthorizationServer(@Nullable String uri)
Set the authorization server uri.

Parameters:
  `uri` - the authorization server uri.

### getAvailableAlgorithms

@NonNull String[] getAvailableAlgorithms()
Gets all available algorithms.

Returns:
  A list of available algorithms.

### setAvailableAlgorithms

void setAvailableAlgorithms(@Nullable String[] algorithms)
Sets the available algorithms list without testing unicity.

Parameters:
  `algorithms` - The available algorithms list.

### getClientId

@Nullable String getClientId()
Get the previously set OAUTH2 client_id.

Returns:
  the client_id.

### setClientId

void setClientId(@Nullable String clientId)
Set the OAUTH2 client_id.
The client_id may be used to renew access token from refresh token. If a
client_secret is required, it has to be set through `setClientSecret(java.lang.String)`.
see: `setRefreshToken(org.linphone.core.BearerToken)`

Parameters:
  `clientId` - the client_id.

### getClientSecret

@Nullable String getClientSecret()
Get the previously set OAUTH2 client_secret.

Returns:
  the client_secret.

### setClientSecret

void setClientSecret(@Nullable String clientSecret)
Set the OAUTH2 client_secret.
The client_secret may be used to renew access token from refresh token.
see: `setRefreshToken(org.linphone.core.BearerToken)`

Parameters:
  `clientSecret` - the client_secret.

### getDomain

@Nullable String getDomain()
Gets the domain.

Returns:
  The domain.

### setDomain

void setDomain(@Nullable String domain)
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

@Nullable String getHa1()
Gets the ha1.

Returns:
  The ha1.

### setHa1

void setHa1(@Nullable String ha1)
Sets the ha1.

Parameters:
  `ha1` - The ha1.

### getPassword

@Nullable String getPassword()
Gets the password.

Returns:
  The password.

### setPassword

void setPassword(@Nullable String password)
Sets the password.

Parameters:
  `password` - The password.

### getRealm

@Nullable String getRealm()
Gets the realm.

Returns:
  The realm.

### setRealm

void setRealm(@Nullable String realm)
Sets the realm.

Parameters:
  `realm` - The realm.

### getRefreshToken

@Nullable BearerToken getRefreshToken()
Return a previously set refresh token.

Returns:
  the refresh token, as a `BearerToken` object.

### setRefreshToken

void setRefreshToken(@Nullable BearerToken token)
Set a refresh token to use when the access token set with `setAccessToken(org.linphone.core.BearerToken)`
expires.
The `AuthInfo` takes a reference to the supplied token, it is not making
any copy. Provided that the token endpoint uri was assigned with `setTokenEndpointUri(java.lang.String)`
, once the `AuthInfo` is pushed in the `Core`, `AuthInfo`
object automatically obtains new access token when needed, from the supplied
refresh token.

Parameters:
  `token` - The `BearerToken` object representing the refresh token.

### getTlsCert

@Nullable String getTlsCert()
Gets the TLS certificate.

Returns:
  The TLS certificate.

### setTlsCert

void setTlsCert(@Nullable String tlsCert)
Sets the TLS certificate.

Parameters:
  `tlsCert` - The TLS certificate.

### getTlsCertPath

@Nullable String getTlsCertPath()
Gets the TLS certificate path.

Returns:
  The TLS certificate path.

### setTlsCertPath

void setTlsCertPath(@Nullable String tlsCertPath)
Sets the TLS certificate path.

Parameters:
  `tlsCertPath` - The TLS certificate path.

### getTlsKey

@Nullable String getTlsKey()
Gets the TLS key.

Returns:
  The TLS key.

### setTlsKey

void setTlsKey(@Nullable String tlsKey)
Sets the TLS key.

Parameters:
  `tlsKey` - The TLS key.

### getTlsKeyPath

@Nullable String getTlsKeyPath()
Gets the TLS key path.

Returns:
  The TLS key path.

### setTlsKeyPath

void setTlsKeyPath(@Nullable String tlsKeyPath)
Sets the TLS key path.

Parameters:
  `tlsKeyPath` - The TLS key path.

### getTokenEndpointUri

@Nullable String getTokenEndpointUri()
Get the previously set token endpoint https uri (OAUTH2).

Returns:
  the token endpoint uri.

### setTokenEndpointUri

void setTokenEndpointUri(@Nullable String uri)
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

@Nullable String getUserid()
Gets the user id.

Returns:
  The user id.

### setUserid

void setUserid(@Nullable String userId)
Sets the user ID.

Parameters:
  `userId` - The userid.

### getUsername

@Nullable String getUsername()
Gets the username.

Returns:
  The username.

### setUsername

void setUsername(@Nullable String username)
Sets the username.

Parameters:
  `username` - The username.

### addAvailableAlgorithm

void addAvailableAlgorithm(@Nullable String algorithm)
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

@NonNull AuthInfo clone()
Instantiates a new auth info with values from source.

Returns:
  The newly created `AuthInfo` object.

### isEqualButAlgorithms

boolean isEqualButAlgorithms(@Nullable AuthInfo authInfo2)
Check if Authinfos are the same without taking account algorithms.

Parameters:
  `authInfo2` - The second `AuthInfo` object.
Returns:
  true if all fields (Username, UserId, Realm, Domain) are the same.

### setUserData

void setUserData(Object data)
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()

Overrides:
  `toString` in class `Object`