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 voidaddRole(java.lang.String newName, UICallback ui)voidaddUser(User user, UICallback ui)protected InternalUserRecordaddUserInternal(User user, UICallback ui, PersistenceSession session)voidalterPassword(User user, java.lang.String oldPassword, java.lang.String newPassword)voidalterUser(User user, UICallback ui)AuthenticatedUserauthenticate(AuthChallenge challenge)Called to both verify authentication for a given username/password pair, and to find the security roles for that user.static longcreateDefaultUserSource(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 longcreateFirstUser(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.LongfindUserInternalId(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 aUserwith the given user name.java.util.Collection<User>getUsers()Retrieve all users from this profile.voidremoveRole(java.lang.String group, UICallback ui)voidremoveUser(User user, UICallback ui)voidrenameRole(java.lang.String oldName, java.lang.String newName, UICallback ui)java.lang.StringtoString()java.lang.StringvalidatePassword(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:UserSourceProfileCalled 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:UserSourceProfileRetrieve 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:
getUsersin interfaceUserSourceProfile- Specified by:
getUsersin 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:UserSourceProfileFetch aUserwith 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:
getUserin interfaceUserSourceProfile- Overrides:
getUserin classAbstractUserSourceProfile- Parameters:
userName- the user name of theUserto fetch- Returns:
- an
OptionalUserwith 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:
getRolesin interfaceUserSourceProfile- Specified by:
getRolesin 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:
toStringin classjava.lang.Object
-
getEditFlags
public java.util.Set<UserSourceEditCapability> getEditFlags()
Description copied from interface:UserSourceProfileWhich of the editing functions are supported?- Specified by:
getEditFlagsin interfaceUserSourceProfile- Overrides:
getEditFlagsin classAbstractUserSourceProfile
-
validatePassword
public java.lang.String validatePassword(@Nonnull User user, java.lang.String password)Description copied from interface:UserSourceProfileValidate 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(User user, UICallback ui) throws java.lang.Exception
- Specified by:
addUserin interfaceUserSourceProfile- Overrides:
addUserin 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:
alterPasswordin interfaceUserSourceProfile- Overrides:
alterPasswordin classAbstractUserSourceProfile
-
alterUser
public void alterUser(User user, UICallback ui) throws java.lang.Exception
- Specified by:
alterUserin interfaceUserSourceProfile- Overrides:
alterUserin classAbstractUserSourceProfile- Throws:
java.lang.Exception
-
removeUser
public void removeUser(User user, UICallback ui) throws java.lang.Exception
- Specified by:
removeUserin interfaceUserSourceProfile- Overrides:
removeUserin classAbstractUserSourceProfile- Throws:
java.lang.Exception
-
addRole
public void addRole(java.lang.String newName, UICallback ui)- Specified by:
addRolein interfaceUserSourceProfile- Overrides:
addRolein classAbstractUserSourceProfile
-
renameRole
public void renameRole(java.lang.String oldName, java.lang.String newName, UICallback ui)- Specified by:
renameRolein interfaceUserSourceProfile- Overrides:
renameRolein classAbstractUserSourceProfile
-
removeRole
public void removeRole(java.lang.String group, UICallback ui) throws java.lang.Exception- Specified by:
removeRolein interfaceUserSourceProfile- Overrides:
removeRolein classAbstractUserSourceProfile- Throws:
java.lang.Exception
-
-