Class InternalUserSource
- java.lang.Object
-
- com.inductiveautomation.ignition.gateway.user.UserSourceProfileKernelWrapper
-
- com.inductiveautomation.ignition.gateway.user.AbstractUserSourceProfile
-
- com.inductiveautomation.ignition.gateway.authentication.impl.InternalUserSource
-
- All Implemented Interfaces:
UserSourceProfile
,UserSourceProfileKernel
- Direct Known Subclasses:
ADInternalHybridUserSource
public class InternalUserSource extends AbstractUserSourceProfile
This user source stores users, groups, extended properties, and contact info inside the internal database. It is fully compliant with the user-source editing capabilities of Ignition.
Relevant persistent records:
-
-
Field Summary
-
Fields inherited from interface com.inductiveautomation.ignition.gateway.user.UserSourceProfile
PWD_EXPIRATION_BYPASS
-
-
Constructor Summary
Constructors Constructor Description InternalUserSource(UserSourceProfileKernel delegate)
InternalUserSource(UserSourceProfileKernel kernel, int pwdHistory, int pwdMinLength, int pwdComplexity, int pwdMaxAge)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRole(java.lang.String newName, UICallback ui)
void
addUser(User user, UICallback ui)
protected InternalUserRecord
addUserInternal(User user, UICallback ui, PersistenceSession session)
void
alterPassword(User user, java.lang.String oldPassword, java.lang.String newPassword)
void
alterUser(User user, UICallback ui)
AuthenticatedUser
authenticate(AuthChallenge challenge)
Called to both verify authentication for a given username/password pair, and to find the security roles for that user.static long
createDefaultUserSource(GatewayContext context, java.lang.String userSourceProfileName, java.lang.String userSourceProfileDescription)
Creates an internal user source called "default" with user "admin"/"password" and role "Administrator".static long
createFirstUser(GatewayContext context, java.lang.String userSourceProfileName, java.lang.String userSourceProfileDescription, java.lang.String username, java.lang.String password, boolean preHashed)
Creates an internal user source called "default" with the supplied username and password and role "Administrator".protected java.util.Optional<InternalUserRecord>
findInternalUser(PersistenceSession session, java.lang.String uname)
Looks up the internal user record keyed on username, NOT case sensitiveprotected java.lang.Long
findUserInternalId(PersistenceSession session, User user)
java.util.Set<UserSourceEditCapability>
getEditFlags()
Which of the editing functions are supported?java.util.Collection<java.lang.String>
getRoles()
java.util.Optional<User>
getUser(java.lang.String userName)
Fetch aUser
with the given user name.java.util.Collection<User>
getUsers()
Retrieve all users from this profile.void
removeRole(java.lang.String group, UICallback ui)
void
removeUser(User user, UICallback ui)
void
renameRole(java.lang.String oldName, java.lang.String newName, UICallback ui)
java.lang.String
toString()
java.lang.String
validatePassword(User user, java.lang.String password)
Validate the given password.-
Methods inherited from class com.inductiveautomation.ignition.gateway.user.AbstractUserSourceProfile
getName, getRoles, getUser, getUsers
-
Methods inherited from class com.inductiveautomation.ignition.gateway.user.UserSourceProfileKernelWrapper
getCacheValidationTimeout, getContext, getManager, getProfileId, getProfileName, isLockedOut, notifyFailedAttempt, shutdown, startup
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.inductiveautomation.ignition.gateway.user.UserSourceProfile
getCacheValidationTimeout, getProfileId, shutdown, startup
-
-
-
-
Constructor Detail
-
InternalUserSource
public InternalUserSource(UserSourceProfileKernel delegate)
-
InternalUserSource
public InternalUserSource(UserSourceProfileKernel kernel, int pwdHistory, int pwdMinLength, int pwdComplexity, int pwdMaxAge)
-
-
Method Detail
-
createDefaultUserSource
public static long createDefaultUserSource(GatewayContext context, java.lang.String userSourceProfileName, java.lang.String userSourceProfileDescription) throws java.lang.Exception
Creates an internal user source called "default" with user "admin"/"password" and role "Administrator". Returns the long id of the new profile.- Throws:
java.lang.Exception
-
createFirstUser
public static long createFirstUser(GatewayContext context, java.lang.String userSourceProfileName, java.lang.String userSourceProfileDescription, java.lang.String username, java.lang.String password, boolean preHashed) throws java.lang.Exception
Creates an internal user source called "default" with the supplied username and password and role "Administrator". Returns the long id of the new profile.- Parameters:
context
- The GatewayContext instanceuserSourceProfileName
- The name of the internal user source profile to be createduserSourceProfileDescription
- The description of the internal user source profile to be createdusername
- The username, Must not be nullpassword
- The password either pre-encrypted or not. Must not be nullpreHashed
- true if the password is already hashed, false if it is not yet hashed- Returns:
- The profile id.
- Throws:
java.lang.Exception
-
authenticate
public AuthenticatedUser authenticate(AuthChallenge challenge) throws java.lang.Exception
Description copied from interface:UserSourceProfile
Called to both verify authentication for a given username/password pair, and to find the security roles for that user.- Returns:
- An AuthenticatedUser that contains the user's roles if authentication succeeded, or null if it did not.
- Throws:
java.lang.Exception
-
getUsers
@Nonnull public java.util.Collection<User> getUsers() throws java.lang.Exception
Description copied from interface:UserSourceProfile
Retrieve all users from this profile. This can execute slowly (block) if need be. It will be called periodically by the manager and the results will be cached. Users from failover sources will be returned if hard failover is configured and triggered.- Specified by:
getUsers
in interfaceUserSourceProfile
- Specified by:
getUsers
in classAbstractUserSourceProfile
- Throws:
java.lang.Exception
-
findInternalUser
@Nonnull protected java.util.Optional<InternalUserRecord> findInternalUser(PersistenceSession session, java.lang.String uname)
Looks up the internal user record keyed on username, NOT case sensitive
-
getUser
@Nonnull public java.util.Optional<User> getUser(java.lang.String userName) throws java.lang.Exception
Description copied from interface:UserSourceProfile
Fetch aUser
with the given user name. If more than one user exists with the given user name, the first user returned from the underlying data source is returned. Failover sources will be queried if hard failover is configured and the primary sources are unable to fetch the user due to an error. Failover sources will also be queried if soft failover is configured and the user is not found in the primary sources.- Specified by:
getUser
in interfaceUserSourceProfile
- Overrides:
getUser
in classAbstractUserSourceProfile
- Parameters:
userName
- the user name of theUser
to fetch- Returns:
- an
Optional
User
with the given user name. the user may be from a failover user source (checkUser.getProfileName()
to confirm) - Throws:
java.lang.Exception
- if there is an unexpected problem fetching the user with the given user name- See Also:
UserSourceProfile.getUser(String, String)
-
getRoles
@Nonnull public java.util.Collection<java.lang.String> getRoles() throws java.lang.Exception
- Specified by:
getRoles
in interfaceUserSourceProfile
- Specified by:
getRoles
in classAbstractUserSourceProfile
- Returns:
- a collection of all possible role names for this profile. May be empty. Roles from failover sources will be returned if hard failover is configured and triggered.
- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getEditFlags
public java.util.Set<UserSourceEditCapability> getEditFlags()
Description copied from interface:UserSourceProfile
Which of the editing functions are supported?- Specified by:
getEditFlags
in interfaceUserSourceProfile
- Overrides:
getEditFlags
in classAbstractUserSourceProfile
-
validatePassword
public java.lang.String validatePassword(@Nonnull User user, java.lang.String password)
Description copied from interface:UserSourceProfile
Validate the given password. Note that this doesn't mean it checks to see if this password matches the user's current password. Rather, it means that this password would be an acceptable new password for the user.- Returns:
- A i18n key for the error message describing why the password is invalid, or null if the password is valid.
-
addUserInternal
protected InternalUserRecord addUserInternal(User user, @Nullable UICallback ui, PersistenceSession session) throws java.lang.Exception
- Throws:
java.lang.Exception
-
addUser
public void addUser(@Nonnull User user, UICallback ui) throws java.lang.Exception
- Specified by:
addUser
in interfaceUserSourceProfile
- Overrides:
addUser
in classAbstractUserSourceProfile
- Throws:
java.lang.Exception
-
findUserInternalId
protected java.lang.Long findUserInternalId(PersistenceSession session, User user)
-
alterPassword
public void alterPassword(User user, java.lang.String oldPassword, java.lang.String newPassword)
- Specified by:
alterPassword
in interfaceUserSourceProfile
- Overrides:
alterPassword
in classAbstractUserSourceProfile
-
alterUser
public void alterUser(User user, UICallback ui) throws java.lang.Exception
- Specified by:
alterUser
in interfaceUserSourceProfile
- Overrides:
alterUser
in classAbstractUserSourceProfile
- Throws:
java.lang.Exception
-
removeUser
public void removeUser(User user, UICallback ui) throws java.lang.Exception
- Specified by:
removeUser
in interfaceUserSourceProfile
- Overrides:
removeUser
in classAbstractUserSourceProfile
- Throws:
java.lang.Exception
-
addRole
public void addRole(java.lang.String newName, UICallback ui)
- Specified by:
addRole
in interfaceUserSourceProfile
- Overrides:
addRole
in classAbstractUserSourceProfile
-
renameRole
public void renameRole(java.lang.String oldName, java.lang.String newName, UICallback ui)
- Specified by:
renameRole
in interfaceUserSourceProfile
- Overrides:
renameRole
in classAbstractUserSourceProfile
-
removeRole
public void removeRole(java.lang.String group, UICallback ui) throws java.lang.Exception
- Specified by:
removeRole
in interfaceUserSourceProfile
- Overrides:
removeRole
in classAbstractUserSourceProfile
- Throws:
java.lang.Exception
-
-