Package alpine.persistence
Class AlpineQueryManager
java.lang.Object
alpine.persistence.AbstractAlpineQueryManager
alpine.persistence.AlpineQueryManager
- All Implemented Interfaces:
AutoCloseable
This QueryManager provides a concrete extension of
AbstractAlpineQueryManager by
providing methods that operate on the default Alpine models such as ManagedUser and Team.- Since:
- 1.0.0
- Author:
- Steve Springett
-
Field Summary
Fields inherited from class alpine.persistence.AbstractAlpineQueryManager
filter, orderBy, orderDirection, pagination, pm, principal -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.AlpineQueryManager(AlpineRequest request) Constructs a new AlpineQueryManager.AlpineQueryManager(javax.jdo.PersistenceManager pm) Constructs a new AlpineQueryManager.AlpineQueryManager(javax.jdo.PersistenceManager pm, AlpineRequest request) Constructs a new AlpineQueryManager. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddUserToTeam(UserPrincipal user, Team team) Associates a UserPrincipal to a Team.addUserToTeams(OidcUser user, List<String> teamNames) This method adds the specified user to teams with the specified names.createApiKey(Team team) Creates a new ApiKey object, including a cryptographically secure API key string.createConfigProperty(String groupName, String propertyName, String propertyValue, IConfigProperty.PropertyType propertyType, String description) Creates a ConfigProperty object.createEventServiceLog(Class<? extends Subscriber> clazz) Creates a new EventServiceLog.createLdapUser(String username) Creates a new LdapUser object with the specified username.createManagedUser(String username, String passwordHash) Creates a new ManagedUser object.createManagedUser(String username, String fullname, String email, String passwordHash, boolean forcePasswordChange, boolean nonExpiryPassword, boolean suspended) Creates a new ManagedUser object.createMappedLdapGroup(Team team, String dn) Creates a MappedLdapGroup object.createMappedOidcGroup(Team team, OidcGroup group) Creates a MappedOidcGroup object.createOidcGroup(String name) Creates a OidcGroup.createOidcUser(String username) Creates a new OidcUser object with the specified username.createPermission(String name, String description) Creates a Permission object.createTeam(String name, boolean createApiKey) Creates a new Team with the specified name.Returns an API key.Returns a list of ConfigProperty objects.getConfigProperties(String groupName) Returns a list of ConfigProperty objects with the specified groupName.getConfigProperty(String groupName, String propertyName) Returns a ConfigProperty with the specified groupName and propertyName.Determines the effective permissions for the specified user by collecting a List of all permissions assigned to the user either directly, or through team membership.Returns the most recent log entry for the specified Subscriber.getLdapUser(String username) Retrieves an LdapUser containing the specified username.Returns a complete list of all LdapUser objects, in ascending order by username.getManagedUser(String username) Returns a ManagedUser with the specified username.Returns a complete list of all ManagedUser objects, in ascending order by username.getMappedLdapGroup(Team team, String dn) Retrieves a MappedLdapGroup object for the specified Team and LDAP group.getMappedLdapGroups(Team team) Retrieves a List of MappedLdapGroup objects for the specified Team.Retrieves a List of MappedLdapGroup objects for the specified DN.getMappedOidcGroup(Team team, OidcGroup group) Retrieves a MappedOidcGroup object for the specified Team and OIDC group.getMappedOidcGroups(OidcGroup group) Retrieves a List of MappedOidcGroup objects for the specified group.getMappedOidcGroups(Team team) Retrieves a List of MappedOidcGroup objects for the specified Team.getOidcGroup(String name) Returns an OidcGroup containing the specified name.Returns a complete list of all OidcGroup objects, in ascending order by name.getOidcUser(String username) Retrieves an OidcUser containing the specified username.Returns a complete list of all OidcUser objects, in ascending order by username.getPermission(String name) Retrieves a Permission by its name.Returns a list of all Permissions defined in the system.Returns a Team containing the specified name.getTeams()Returns a complete list of all Team objects, in ascending order by name.getUserPrincipal(String username) Resolves a UserPrincipal.booleanhasPermission(ApiKey apiKey, String permissionName) Determines if the specified ApiKey has been assigned the specified permission.booleanhasPermission(Team team, String permissionName) Determines if the specified Team has been assigned the specified permission.booleanhasPermission(UserPrincipal user, String permissionName) Determines if the specified UserPrincipal has been assigned the specified permission.booleanhasPermission(UserPrincipal user, String permissionName, boolean includeTeams) Determines if the specified UserPrincipal has been assigned the specified permission.booleanDetermines if the specified Team is mapped to the specified LDAP group.booleanisOidcGroupMapped(Team team, OidcGroup group) Determines if the specified Team is mapped to the specified OpenID Connect group.regenerateApiKey(ApiKey apiKey) Regenerates an API key.booleanremoveUserFromTeam(UserPrincipal user, Team team) Removes the association of a UserPrincipal to a Team.synchronizeTeamMembership(LdapUser user, List<String> groupDNs) This method dynamically assigns team membership to the specified user from the list of LDAP group DN's the user is a member of.synchronizeTeamMembership(OidcUser user, List<String> groupNames) This method dynamically assigns team membership to the specified user from the list of OpenID Connect groups the user is a member of.updateApiKey(ApiKey transientApiKey) updateEventServiceLog(EventServiceLog eventServiceLog) Updates a EventServiceLog.updateLdapUser(LdapUser transientUser) Updates the specified LdapUser.updateManagedUser(ManagedUser transientUser) Updates the specified ManagedUser.updateOidcGroup(OidcGroup oidcGroup) Updates a OidcGroup.updateOidcUser(OidcUser transientUser) Updates the specified OidcUser.updateTeam(Team transientTeam) Updates the specified Team.Methods inherited from class alpine.persistence.AbstractAlpineQueryManager
advancePagination, close, decorate, delete, delete, detach, detach, detach, execute, execute, execute, execute, execute, execute, getCount, getCount, getCount, getCount, getCount, getCount, getCount, getObjectById, getObjectByUuid, getObjectByUuid, getObjectByUuid, getObjectByUuid, getPersistenceManager, getPersistenceManagerFactory, persist, persist, persist, singleResult
-
Constructor Details
-
AlpineQueryManager
public AlpineQueryManager()Default constructor. -
AlpineQueryManager
public AlpineQueryManager(javax.jdo.PersistenceManager pm) Constructs a new AlpineQueryManager.- Parameters:
pm- a PersistenceManager
-
AlpineQueryManager
Constructs a new AlpineQueryManager.- Parameters:
request- an AlpineRequest
-
AlpineQueryManager
Constructs a new AlpineQueryManager.- Parameters:
pm- a PersistenceManagerrequest- an AlpineRequest- Since:
- 1.9.3
-
-
Method Details
-
getApiKey
Returns an API key.- Parameters:
key- the key to return- Returns:
- an ApiKey
- Since:
- 1.0.0
-
regenerateApiKey
Regenerates an API key. This method does not create a new ApiKey object, rather it uses the existing ApiKey object and simply creates a new key string.- Parameters:
apiKey- the ApiKey object to regenerate the key of.- Returns:
- an ApiKey
- Since:
- 1.0.0
-
createApiKey
Creates a new ApiKey object, including a cryptographically secure API key string.- Parameters:
team- The team to create the key for- Returns:
- an ApiKey
-
updateApiKey
-
createOidcUser
Creates a new OidcUser object with the specified username.- Parameters:
username- The username of the new OidcUser. This must reference an existing username in the OpenID Connect identity provider.- Returns:
- an LdapUser
- Since:
- 1.8.0
-
updateOidcUser
Updates the specified OidcUser.- Parameters:
transientUser- the optionally detached OidcUser object to update.- Returns:
- an OidcUser
- Since:
- 1.8.0
-
getOidcUser
Retrieves an OidcUser containing the specified username. If the username does not exist, returns null.- Parameters:
username- The username to retrieve- Returns:
- an OidcUser
- Since:
- 1.8.0
-
getOidcUsers
Returns a complete list of all OidcUser objects, in ascending order by username.- Returns:
- a list of OidcUser
- Since:
- 1.8.0
-
createOidcGroup
Creates a OidcGroup.- Parameters:
name- Name of the group to create- Returns:
- a OidcGroup
- Since:
- 1.8.0
-
updateOidcGroup
Updates a OidcGroup.- Parameters:
oidcGroup- The group to update- Returns:
- a refreshed OidcGroup
- Since:
- 1.8.0
-
getOidcGroups
Returns a complete list of all OidcGroup objects, in ascending order by name.- Returns:
- a list of OidcGroup
- Since:
- 1.8.0
-
getOidcGroup
Returns an OidcGroup containing the specified name. If the name does not exist, returns null.- Parameters:
name- Name of the group to retrieve- Returns:
- an OidcGroup
- Since:
- 1.8.0
-
synchronizeTeamMembership
This method dynamically assigns team membership to the specified user from the list of OpenID Connect groups the user is a member of. The method will look up anyMappedOidcGroups and ensure the user is only a member of the teams that have a mapping to an OpenID Connect group for which the user is a member.- Parameters:
user- the OpenID Connect user to sync team membership forgroupNames- a list of OpenID Connect groups the user is a member of- Returns:
- a refreshed OidcUser object
- Since:
- 1.8.0
-
addUserToTeams
This method adds the specified user to teams with the specified names. It does not remove the user from any teams, and silently ignores references to teams that do not exist.- Parameters:
user- the OpenID Connect user to sync team membership forteamNames- a list of teams the user is a member of- Returns:
- a refreshed OidcUser object
- Since:
- 2.2.5
-
getLdapUser
Retrieves an LdapUser containing the specified username. If the username does not exist, returns null.- Parameters:
username- The username to retrieve- Returns:
- an LdapUser
- Since:
- 1.0.0
-
getLdapUsers
Returns a complete list of all LdapUser objects, in ascending order by username.- Returns:
- a list of LdapUsers
- Since:
- 1.0.0
-
createLdapUser
Creates a new LdapUser object with the specified username.- Parameters:
username- The username of the new LdapUser. This must reference an existing username in the directory service- Returns:
- an LdapUser
- Since:
- 1.0.0
-
updateLdapUser
Updates the specified LdapUser.- Parameters:
transientUser- the optionally detached LdapUser object to update.- Returns:
- an LdapUser
- Since:
- 1.0.0
-
synchronizeTeamMembership
This method dynamically assigns team membership to the specified user from the list of LDAP group DN's the user is a member of. The method will look up anyMappedLdapGroups and ensure the user is only a member of the teams that have a mapping to an LDAP group for which the user is a member.- Parameters:
user- the LDAP user to sync team membership forgroupDNs- a list of LDAP group DNs the user is a member of- Returns:
- a refreshed LdapUser object
- Since:
- 1.4.0
-
createManagedUser
Creates a new ManagedUser object.- Parameters:
username- The username for the userpasswordHash- The hashed password.- Returns:
- a ManagedUser
- Since:
- 1.0.0
-
createManagedUser
public ManagedUser createManagedUser(String username, String fullname, String email, String passwordHash, boolean forcePasswordChange, boolean nonExpiryPassword, boolean suspended) Creates a new ManagedUser object.- Parameters:
username- The username for the userfullname- The fullname of the useremail- The users email addresspasswordHash- The hashed passwordforcePasswordChange- Whether or not user needs to change password on next login or notnonExpiryPassword- Whether or not the users password ever expires or notsuspended- Whether or not user being created is suspended or not- Returns:
- a ManagedUser
- Since:
- 1.1.0
-
updateManagedUser
Updates the specified ManagedUser.- Parameters:
transientUser- the optionally detached ManagedUser object to update.- Returns:
- an ManagedUser
- Since:
- 1.0.0
-
getManagedUser
Returns a ManagedUser with the specified username. If the username does not exist, returns null.- Parameters:
username- The username to retrieve- Returns:
- a ManagedUser
- Since:
- 1.0.0
-
getManagedUsers
Returns a complete list of all ManagedUser objects, in ascending order by username.- Returns:
- a List of ManagedUsers
- Since:
- 1.0.0
-
getUserPrincipal
Resolves a UserPrincipal. Default order resolution is to first match on ManagedUser then on LdapUser and finally on OidcUser. This may be configurable in a future release.- Parameters:
username- the username of the principal to retrieve- Returns:
- a UserPrincipal if found, null if not found
- Since:
- 1.0.0
-
createTeam
Creates a new Team with the specified name. If createApiKey is true, thencreateApiKey(alpine.model.Team)is invoked and a cryptographically secure API key is generated.- Parameters:
name- The name of th teamcreateApiKey- whether or not to create an API key for the team- Returns:
- a Team
- Since:
- 1.0.0
-
getTeams
Returns a complete list of all Team objects, in ascending order by name.- Returns:
- a List of Teams
- Since:
- 1.0.0
-
getTeam
Returns a Team containing the specified name. If the name does not exist, returns null.- Parameters:
name- Name of the team to retrieve- Returns:
- a Team
- Since:
- 2.2.5
-
updateTeam
Updates the specified Team.- Parameters:
transientTeam- the optionally detached Team object to update- Returns:
- a Team
- Since:
- 1.0.0
-
addUserToTeam
Associates a UserPrincipal to a Team.- Parameters:
user- The user to bindteam- The team to bind- Returns:
- true if operation was successful, false if not. This is not an indication of team association, an unsuccessful return value may be due to the team or user not existing, or a binding that already exists between the two.
- Since:
- 1.0.0
-
removeUserFromTeam
Removes the association of a UserPrincipal to a Team.- Parameters:
user- The user to unbindteam- The team to unbind- Returns:
- true if operation was successful, false if not. This is not an indication of team disassociation, an unsuccessful return value may be due to the team or user not existing, or a binding that may not exist.
- Since:
- 1.0.0
-
createPermission
Creates a Permission object.- Parameters:
name- The name of the permissiondescription- the permissions description- Returns:
- a Permission
- Since:
- 1.1.0
-
getPermission
Retrieves a Permission by its name.- Parameters:
name- The name of the permission- Returns:
- a Permission
- Since:
- 1.1.0
-
getPermissions
Returns a list of all Permissions defined in the system.- Returns:
- a List of Permission objects
- Since:
- 1.1.0
-
getEffectivePermissions
Determines the effective permissions for the specified user by collecting a List of all permissions assigned to the user either directly, or through team membership.- Parameters:
user- the user to retrieve permissions for- Returns:
- a List of Permission objects
- Since:
- 1.1.0
-
hasPermission
Determines if the specified UserPrincipal has been assigned the specified permission.- Parameters:
user- the UserPrincipal to querypermissionName- the name of the permission- Returns:
- true if the user has the permission assigned, false if not
- Since:
- 1.0.0
-
hasPermission
Determines if the specified UserPrincipal has been assigned the specified permission.- Parameters:
user- the UserPrincipal to querypermissionName- the name of the permissionincludeTeams- if true, will query all Team membership assigned to the user for the specified permission- Returns:
- true if the user has the permission assigned, false if not
- Since:
- 1.0.0
-
hasPermission
Determines if the specified Team has been assigned the specified permission.- Parameters:
team- the Team to querypermissionName- the name of the permission- Returns:
- true if the team has the permission assigned, false if not
- Since:
- 1.0.0
-
hasPermission
Determines if the specified ApiKey has been assigned the specified permission.- Parameters:
apiKey- the ApiKey to querypermissionName- the name of the permission- Returns:
- true if the apiKey has the permission assigned, false if not
- Since:
- 1.1.1
-
getMappedLdapGroup
Retrieves a MappedLdapGroup object for the specified Team and LDAP group.- Parameters:
team- a Team objectdn- a String representation of Distinguished Name- Returns:
- a MappedLdapGroup if found, or null if no mapping exists
- Since:
- 1.4.0
-
getMappedLdapGroups
Retrieves a List of MappedLdapGroup objects for the specified Team.- Parameters:
team- a Team object- Returns:
- a List of MappedLdapGroup objects
- Since:
- 1.4.0
-
getMappedLdapGroups
Retrieves a List of MappedLdapGroup objects for the specified DN.- Parameters:
dn- a String representation of Distinguished Name- Returns:
- a List of MappedLdapGroup objects
- Since:
- 1.4.0
-
isMapped
Determines if the specified Team is mapped to the specified LDAP group.- Parameters:
team- a Team objectdn- a String representation of Distinguished Name- Returns:
- true if a mapping exists, false if not
- Since:
- 1.4.0
-
createMappedLdapGroup
Creates a MappedLdapGroup object.- Parameters:
team- The team to mapdn- the distinguished name of the LDAP group to map- Returns:
- a MappedLdapGroup
- Since:
- 1.4.0
-
createMappedOidcGroup
Creates a MappedOidcGroup object.- Parameters:
team- The team to mapgroup- The OIDC group to map- Returns:
- a MappedOidcGroup
- Since:
- 1.8.0
-
getMappedOidcGroup
Retrieves a MappedOidcGroup object for the specified Team and OIDC group.- Parameters:
team- a Team objectgroup- a OidcGroup object- Returns:
- a MappedOidcGroup if found, or null if no mapping exists
- Since:
- 1.8.0
-
getMappedOidcGroups
Retrieves a List of MappedOidcGroup objects for the specified Team.- Parameters:
team- The team to retrieve mappings for- Returns:
- a List of MappedOidcGroup objects
- Since:
- 1.8.0
-
getMappedOidcGroups
Retrieves a List of MappedOidcGroup objects for the specified group.- Parameters:
group- The group to retrieve mappings for- Returns:
- a List of MappedOidcGroup objects
- Since:
- 1.8.0
-
isOidcGroupMapped
Determines if the specified Team is mapped to the specified OpenID Connect group.- Parameters:
team- a Team objectgroup- a OidcGroup object- Returns:
- true if a mapping exists, false if not
- Since:
- 1.8.0
-
createEventServiceLog
Creates a new EventServiceLog. This method will automatically determine if the subscriber is an implementation ofLoggableSubscriberand if so, will log the event. If not, then nothing will be logged and this method will return null.- Parameters:
clazz- the class of the subscriber task that handles the event- Returns:
- a new EventServiceLog
-
updateEventServiceLog
Updates a EventServiceLog.- Parameters:
eventServiceLog- the EventServiceLog to update- Returns:
- an updated EventServiceLog
-
getLatestEventServiceLog
Returns the most recent log entry for the specified Subscriber. If no log entries are found, this method will return null.- Parameters:
clazz- The LoggableSubscriber class to query on- Returns:
- a EventServiceLog
- Since:
- 1.0.0
-
getConfigProperty
Returns a ConfigProperty with the specified groupName and propertyName.- Parameters:
groupName- the group name of the config propertypropertyName- the name of the property- Returns:
- a ConfigProperty object
- Since:
- 1.3.0
-
getConfigProperties
Returns a list of ConfigProperty objects with the specified groupName.- Parameters:
groupName- the group name of the properties- Returns:
- a List of ConfigProperty objects
- Since:
- 1.3.0
-
getConfigProperties
Returns a list of ConfigProperty objects.- Returns:
- a List of ConfigProperty objects
- Since:
- 1.3.0
-
createConfigProperty
public ConfigProperty createConfigProperty(String groupName, String propertyName, String propertyValue, IConfigProperty.PropertyType propertyType, String description) Creates a ConfigProperty object.- Parameters:
groupName- the group name of the propertypropertyName- the name of the propertypropertyValue- the value of the propertypropertyType- the type of propertydescription- a description of the property- Returns:
- a ConfigProperty object
- Since:
- 1.3.0
-