class AccessControlImpl extends Object implements AccessControl
Modifier and Type | Field and Description |
---|---|
private static String |
ADMINISTRATION_WORKSPACE_URI |
private static String |
ASSOC_TYPE_CONFIGURATION |
private static String |
ASSOC_TYPE_USER_MAILBOX |
private static String |
ASSOCIATION_MAPCONTEXT |
private ContextTracker |
contextTracker |
private static String |
DMX_WORKSPACE_URI |
private Logger |
logger |
private ModelFactoryImpl |
mf |
private PersistenceLayer |
pl |
private static String |
PROP_CREATOR |
private static String |
PROP_OWNER |
private static String |
PROP_WORKSPACE_ID |
private static String |
ROLE_TYPE_CONFIGURABLE |
private static String |
ROLE_TYPE_DEFAULT |
private static String |
SYSTEM_WORKSPACE_URI |
private long |
systemWorkspaceId |
private static String |
TYPE_EMAIL_ADDRESS |
private static String |
TYPE_MEMBERSHIP |
private static String |
TYPE_USERNAME |
Constructor and Description |
---|
AccessControlImpl(PersistenceLayer pl) |
Modifier and Type | Method and Description |
---|---|
private String |
_getEmailAddress(String username) |
private TopicModel |
_getPasswordTopic(TopicModel userAccount)
Prerequisite: userAccount is not
null . |
private TopicModelImpl |
_getUserAccount(TopicModel usernameTopic)
Prerequisite: usernameTopic is not
null . |
private String |
_getUsername(String emailAddress) |
private TopicModelImpl |
_getUsernameTopic(String username) |
private TopicModelImpl |
_getUsernameTopicOrThrow(String username) |
private boolean |
_hasPermission(String username,
Operation operation,
long workspaceId) |
void |
assignToWorkspace(DMXObject object,
long workspaceId)
Performs the initial workspace assignment for an object.
|
void |
changePassword(Credentials cred)
Changes the password of an existing user account.
|
Topic |
checkCredentials(Credentials cred)
Checks if the given credentials are valid.
|
private void |
checkWorkspaceId(long workspaceId) |
void |
deleteAssociationMapcontext(Association assoc) |
boolean |
emailAddressExists(String emailAddress)
Returns true if an "Email Address" (dmx.contacts.email_address) topic with the given value exists,
false otherwise.
|
private TopicModelImpl |
fetchTopic(String key,
Object value)
Fetches a topic by key/value.
|
private List<TopicModelImpl> |
fetchTopicsByOwner(String username,
String typeUri)
Fetches topics by owner, and filter by type.
|
long |
getAdministrationWorkspaceId()
Returns the ID of the "Administration" workspace.
|
long |
getAssignedWorkspaceId(long objectId)
Returns the ID of the workspace a topic or association is assigned to.
|
RelatedTopic |
getConfigTopic(String configTypeUri,
long topicId)
Returns the configuration topic of the given type for the given topic.
|
String |
getCreator(long objectId)
Returns the creator of a topic or an association.
|
long |
getDMXWorkspaceId()
Returns the ID of the "DMX" workspace.
|
String |
getEmailAddress(String username)
Returns the email address for the given username.
|
private String |
getOwner(long workspaceId) |
private TopicModel |
getPasswordTopic(TopicModel usernameTopic)
Prerequisite: usernameTopic is not
null . |
Topic |
getPrivateWorkspace(String username)
Returns the private workspace of the given user.
|
private SharingMode |
getSharingMode(long workspaceId) |
long |
getSystemWorkspaceId()
Returns the ID of the "System" workspace.
|
private String |
getTypeUri(long objectId) |
String |
getUsername(javax.servlet.http.HttpServletRequest request)
Returns the username that is associated with a request.
|
String |
getUsername(String emailAddress)
Returns the username for the given email address.
|
Topic |
getUsernameTopic(javax.servlet.http.HttpServletRequest request)
Convenience method that returns the Username topic that corresponds to a request.
|
Topic |
getUsernameTopic(String username)
Returns the Username topic that corresponds to a username.
|
Topic |
getWorkspace(String uri)
Returns a workspace by URI.
|
boolean |
hasPermission(String username,
Operation operation,
long objectId)
Checks if a user is permitted to perform an operation on an object (topic or association).
|
boolean |
hasReadPermission(String username,
long workspaceId) |
boolean |
hasWritePermission(String username,
long workspaceId) |
private boolean |
isCreator(String username,
long objectId) |
boolean |
isMember(String username,
long workspaceId)
Checks if a user is a member of a given workspace.
|
private boolean |
isOwner(String username,
long workspaceId)
Checks if a user is the owner of a workspace.
|
private boolean |
isTopicmapPrivate(long topicmapId) |
boolean |
isWorkspaceAssignment(Association assoc)
Checks if an association represents a workspace assignment.
|
private boolean |
matches(TopicModel usernameTopic,
String password)
Prerequisite: usernameTopic is not
null . |
private boolean |
permissionIfNoWorkspaceIsAssigned(Operation operation,
long objectId,
String typeUri) |
private List<TopicModelImpl> |
queryTopics(String key,
Object value)
Queries topics by key/value.
|
<V> V |
runWithoutWorkspaceAssignment(Callable<V> callable)
Runs a code block while suppressing the standard workspace assignment for all topics/associations
created within that code block.
|
private String |
userInfo(String username) |
String |
username(javax.servlet.http.HttpSession session)
Returns the username that is associated with a session.
|
boolean |
workspaceAssignmentIsSuppressed()
Returns true if standard workspace assignment is currently suppressed for the current thread.
|
private static final String TYPE_MEMBERSHIP
private static final String TYPE_USERNAME
private static final String ASSOCIATION_MAPCONTEXT
private static final String TYPE_EMAIL_ADDRESS
private static final String ASSOC_TYPE_USER_MAILBOX
private static final String ASSOC_TYPE_CONFIGURATION
private static final String ROLE_TYPE_CONFIGURABLE
private static final String ROLE_TYPE_DEFAULT
private static final String PROP_CREATOR
private static final String PROP_OWNER
private static final String PROP_WORKSPACE_ID
private static final String DMX_WORKSPACE_URI
private static final String ADMINISTRATION_WORKSPACE_URI
private static final String SYSTEM_WORKSPACE_URI
private long systemWorkspaceId
private ContextTracker contextTracker
private PersistenceLayer pl
private ModelFactoryImpl mf
AccessControlImpl(PersistenceLayer pl)
public boolean hasPermission(String username, Operation operation, long objectId)
AccessControl
hasPermission
in interface AccessControl
username
- the logged in user, or null
if no user is logged in.objectId
- a topic ID, or an association ID.true
if permission is granted, false
otherwise.public boolean hasReadPermission(String username, long workspaceId)
hasReadPermission
in interface AccessControl
username
- the logged in user, or null
if no user is logged in.workspaceId
- the ID of the workspace that is relevant for the permission check. Is never -1.public boolean hasWritePermission(String username, long workspaceId)
hasWritePermission
in interface AccessControl
username
- the logged in user, or null
if no user is logged in.workspaceId
- the ID of the workspace that is relevant for the permission check. Is never -1.public Topic checkCredentials(Credentials cred)
AccessControl
checkCredentials
in interface AccessControl
null
otherwise.public void changePassword(Credentials cred)
AccessControl
This is a privileged method: it works also if the respective user is not logged in.
changePassword
in interface AccessControl
cred
- the username and new password.
An user account with the given username must exist. (The username can't be changed.)public Topic getUsernameTopic(String username)
AccessControl
getUsernameTopic
in interface AccessControl
null
if no such Username topic exists.public Topic getPrivateWorkspace(String username)
AccessControl
Note: a user can have more than one private workspace. This method returns only the first one.
This is a privileged method, it bypasses the access control system.
getPrivateWorkspace
in interface AccessControl
public boolean isMember(String username, long workspaceId)
AccessControl
isMember
in interface AccessControl
username
- the logged in user, or null
if no user is logged in.public String getCreator(long objectId)
AccessControl
getCreator
in interface AccessControl
null
if no creator is set.public String getUsername(javax.servlet.http.HttpServletRequest request)
AccessControl
getUsername
in interface AccessControl
null
if no user is associated with the request.public Topic getUsernameTopic(javax.servlet.http.HttpServletRequest request)
AccessControl
getUsernameTopic(getUsername(request))
.getUsernameTopic
in interface AccessControl
null
if no user is associated with the request.public String username(javax.servlet.http.HttpSession session)
AccessControl
username
in interface AccessControl
null
if no user is associated with the session.public Topic getWorkspace(String uri)
AccessControl
This is a privileged method: it works also if the current user has no READ permission for the workspace.
getWorkspace
in interface AccessControl
public long getDMXWorkspaceId()
AccessControl
getDMXWorkspaceId
in interface AccessControl
public long getAdministrationWorkspaceId()
AccessControl
getAdministrationWorkspaceId
in interface AccessControl
public long getSystemWorkspaceId()
AccessControl
getSystemWorkspaceId
in interface AccessControl
public long getAssignedWorkspaceId(long objectId)
AccessControl
getAssignedWorkspaceId
in interface AccessControl
objectId
- a topic ID, or an association ID-1
if no workspace is assigned.public void assignToWorkspace(DMXObject object, long workspaceId)
AccessControl
Use this method only for objects which have no workspace assignment already, that is e.g. objects created in a migration or objects created while workspace assignment is deliberately suppressed.
assignToWorkspace
in interface AccessControl
public boolean isWorkspaceAssignment(Association assoc)
AccessControl
This is a privileged method: it works also if the current user has no READ permission for the potential workspace.
isWorkspaceAssignment
in interface AccessControl
public <V> V runWithoutWorkspaceAssignment(Callable<V> callable) throws Exception
AccessControl
runWithoutWorkspaceAssignment
in interface AccessControl
Exception
public boolean workspaceAssignmentIsSuppressed()
AccessControl
workspaceAssignmentIsSuppressed
in interface AccessControl
public void deleteAssociationMapcontext(Association assoc)
deleteAssociationMapcontext
in interface AccessControl
public RelatedTopic getConfigTopic(String configTypeUri, long topicId)
AccessControl
This is a privileged method, it bypasses the access control system.
getConfigTopic
in interface AccessControl
public String getUsername(String emailAddress)
AccessControl
The username is determined by traversing from the Email Address topic along a
org.deepamehta.signup.user_mailbox
association.
This is a privileged method, it bypasses the access control system.
getUsername
in interface AccessControl
public String getEmailAddress(String username)
AccessControl
The email address is determined by traversing from the Username topic along a
org.deepamehta.signup.user_mailbox
association.
This is a privileged method, it bypasses the access control system.
getEmailAddress
in interface AccessControl
public boolean emailAddressExists(String emailAddress)
AccessControl
This is a privileged method, it bypasses the access control system.
emailAddressExists
in interface AccessControl
private boolean matches(TopicModel usernameTopic, String password)
null
.password
- The encoded password.private TopicModel getPasswordTopic(TopicModel usernameTopic)
null
.private TopicModelImpl _getUserAccount(TopicModel usernameTopic)
null
.private TopicModel _getPasswordTopic(TopicModel userAccount)
null
.private boolean permissionIfNoWorkspaceIsAssigned(Operation operation, long objectId, String typeUri)
private boolean _hasPermission(String username, Operation operation, long workspaceId)
private boolean isOwner(String username, long workspaceId)
username
- the logged in user, or null
if no user is logged in.true
if the user is the owner, false
otherwise.private SharingMode getSharingMode(long workspaceId)
private void checkWorkspaceId(long workspaceId)
private boolean isTopicmapPrivate(long topicmapId)
private String getTypeUri(long objectId)
private TopicModelImpl _getUsernameTopic(String username)
private TopicModelImpl _getUsernameTopicOrThrow(String username)
private String _getUsername(String emailAddress)
private String _getEmailAddress(String username)
private TopicModelImpl fetchTopic(String key, Object value)
IMPORTANT: only applicable to values indexed with dmx.core.key
.
null
if no such topic exists.private List<TopicModelImpl> queryTopics(String key, Object value)
IMPORTANT: only applicable to values indexed with dmx.core.fulltext
or
dmx.core.fulltext_key
.
private List<TopicModelImpl> fetchTopicsByOwner(String username, String typeUri)
Copyright © 2018. All Rights Reserved.