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)
AccessControlhasPermission in interface AccessControlusername - 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 AccessControlusername - 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 AccessControlusername - 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)
AccessControlcheckCredentials in interface AccessControlnull otherwise.public void changePassword(Credentials cred)
AccessControlThis is a privileged method: it works also if the respective user is not logged in.
changePassword in interface AccessControlcred - 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)
AccessControlgetUsernameTopic in interface AccessControlnull if no such Username topic exists.public Topic getPrivateWorkspace(String username)
AccessControlNote: 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 AccessControlpublic boolean isMember(String username, long workspaceId)
AccessControlisMember in interface AccessControlusername - the logged in user, or null if no user is logged in.public String getCreator(long objectId)
AccessControlgetCreator in interface AccessControlnull if no creator is set.public String getUsername(javax.servlet.http.HttpServletRequest request)
AccessControlgetUsername in interface AccessControlnull if no user is associated with the request.public Topic getUsernameTopic(javax.servlet.http.HttpServletRequest request)
AccessControlgetUsernameTopic(getUsername(request)).getUsernameTopic in interface AccessControlnull if no user is associated with the request.public String username(javax.servlet.http.HttpSession session)
AccessControlusername in interface AccessControlnull if no user is associated with the session.public Topic getWorkspace(String uri)
AccessControlThis is a privileged method: it works also if the current user has no READ permission for the workspace.
getWorkspace in interface AccessControlpublic long getDMXWorkspaceId()
AccessControlgetDMXWorkspaceId in interface AccessControlpublic long getAdministrationWorkspaceId()
AccessControlgetAdministrationWorkspaceId in interface AccessControlpublic long getSystemWorkspaceId()
AccessControlgetSystemWorkspaceId in interface AccessControlpublic long getAssignedWorkspaceId(long objectId)
AccessControlgetAssignedWorkspaceId in interface AccessControlobjectId - a topic ID, or an association ID-1 if no workspace is assigned.public void assignToWorkspace(DMXObject object, long workspaceId)
AccessControlUse 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 AccessControlpublic boolean isWorkspaceAssignment(Association assoc)
AccessControlThis is a privileged method: it works also if the current user has no READ permission for the potential workspace.
isWorkspaceAssignment in interface AccessControlpublic <V> V runWithoutWorkspaceAssignment(Callable<V> callable) throws Exception
AccessControlrunWithoutWorkspaceAssignment in interface AccessControlExceptionpublic boolean workspaceAssignmentIsSuppressed()
AccessControlworkspaceAssignmentIsSuppressed in interface AccessControlpublic void deleteAssociationMapcontext(Association assoc)
deleteAssociationMapcontext in interface AccessControlpublic RelatedTopic getConfigTopic(String configTypeUri, long topicId)
AccessControlThis is a privileged method, it bypasses the access control system.
getConfigTopic in interface AccessControlpublic 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 AccessControlpublic 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 AccessControlpublic boolean emailAddressExists(String emailAddress)
AccessControlThis is a privileged method, it bypasses the access control system.
emailAddressExists in interface AccessControlprivate 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.