public class CredentialStore extends Object
| Modifier and Type | Field and Description |
|---|---|
protected HashMap<String,rst.domotic.authentication.LoginCredentialsType.LoginCredentials> |
credentials |
static String |
SERVICE_SERVER_ID |
| Constructor and Description |
|---|
CredentialStore(String filename) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCredentials(String id,
byte[] credentials,
boolean admin)
Adds new credentials to the credentialStore.
|
byte[] |
getCredentials(String userId)
Get the encrypted login credentials for a given user.
|
AbstractMap.SimpleEntry<String,rst.domotic.authentication.LoginCredentialsType.LoginCredentials> |
getFirstEntry()
Get an entry by the specified index.
|
boolean |
hasEntry(String id)
Determines if there is an entry with given id.
|
boolean |
hasOnlyServiceServer()
Return whether the internal map only holds one entry for the service server.
|
void |
init() |
boolean |
isAdmin(String userId)
Tells whether a given user has administrator permissions.
|
boolean |
isEmpty()
Return whether the internal map is empty.
|
void |
removeEntry(String id)
Removes entry from credentialStore given id.
|
protected void |
saveStore()
Stores the credentials in a protobuf JSON file.
|
void |
setAdmin(String userId,
boolean isAdmin)
Changes the admin flag of an entry.
|
void |
setCredentials(String userId,
byte[] credentials)
Sets the login credentials for a given user.
|
void |
shutdown() |
public static final String SERVICE_SERVER_ID
public CredentialStore(String filename)
public void init()
throws org.openbase.jul.exception.InitializationException
org.openbase.jul.exception.InitializationExceptionprotected void saveStore()
public boolean isEmpty()
public boolean hasOnlyServiceServer()
public boolean hasEntry(String id)
id - the id to checkpublic AbstractMap.SimpleEntry<String,rst.domotic.authentication.LoginCredentialsType.LoginCredentials> getFirstEntry()
public void removeEntry(String id)
id - the credentials to removepublic byte[] getCredentials(String userId) throws org.openbase.jul.exception.NotAvailableException
userId - ID of the user whose credentials should be retrieved.org.openbase.jul.exception.NotAvailableException - If the user does not exist in the
credentials storage.public void setCredentials(String userId, byte[] credentials)
userId - ID of the user to modify.credentials - New encrypted credentials.public void addCredentials(String id, byte[] credentials, boolean admin)
id - id of client or usercredentials - password, public or private keyadmin - admin flagpublic boolean isAdmin(String userId) throws org.openbase.jul.exception.NotAvailableException
userId - ID of the user whose credentials should be retrieved.org.openbase.jul.exception.NotAvailableException - If the user does not exist in the
credentials storage.public void setAdmin(String userId, boolean isAdmin) throws org.openbase.jul.exception.NotAvailableException
userId - user to change flag ofisAdmin - boolean whether user is admin or notorg.openbase.jul.exception.NotAvailableException - Throws if there is no user given userIdpublic void shutdown()
Copyright © 2017–2018 openbase.org. All rights reserved.