Class InternalUserStore
java.lang.Object
com.inductiveautomation.ignition.gateway.authentication.impl.InternalUserStore
Utility class for persisting internal users and roles to disk for
InternalUserSource
profiles.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.inductiveautomation.ignition.common.gson.Gson
-
Constructor Summary
ConstructorsConstructorDescriptionInternalUserStore
(GatewayContext context, String profileName, LoggerEx log) Create a newInternalUserStore
for the specified profile. -
Method Summary
Modifier and TypeMethodDescriptionGet the read lock to read the users and roles from disk.Get the write lock to write the users and roles to disk.void
persist
(List<InternalUserResource> users, List<InternalRoleResource> roles) Persist the users and roles to disk for the specified profile.read()
Read the users and roles resource.
-
Field Details
-
GSON
public static final com.inductiveautomation.ignition.common.gson.Gson GSON
-
-
Constructor Details
-
InternalUserStore
Create a newInternalUserStore
for the specified profile.- Parameters:
context
- TheGatewayContext
.profileName
- The name of the profile.log
- TheLoggerEx
to log to.
-
-
Method Details
-
getReadLock
Get the read lock to read the users and roles from disk.- Returns:
- The read lock.
- See Also:
-
getWriteLock
Get the write lock to write the users and roles to disk.- Returns:
- The write lock.
- See Also:
-
persist
public void persist(List<InternalUserResource> users, List<InternalRoleResource> roles) throws PushException Persist the users and roles to disk for the specified profile.userStore.getWriteLock().lock(); try { Optional<UsersJsonResource> optional = userStore.read(); if (optional.isPresent()) { UsersJsonResource resource = optional.get(); // Modify the resource based on existing state. userStore.persist(resource.getUsers(), resource.getRoles()); } } finally { userStore.getWriteLock().unlock(); }
- Parameters:
users
- The users to write.roles
- The roles to write.- Throws:
PushException
- If there is an error pushing the changes to disk.- See Also:
-
read
Read the users and roles resource.- Returns:
- An
Optional
containing the users and roles if they exist, or an empty optional if they don't. - See Also:
-