|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.deepamehta.core.osgi.PluginActivator
de.deepamehta.plugins.accesscontrol.AccessControlPlugin
public class AccessControlPlugin
| Field Summary | |
|---|---|
private static String |
AUTHENTICATION_REALM
|
private static AccessControlList |
DEFAULT_INSTANCE_ACL
|
private static String |
DEFAULT_PASSWORD
|
private static AccessControlList |
DEFAULT_TYPE_ACL
|
private static AccessControlList |
DEFAULT_USER_ACCOUNT_ACL
|
private static String |
DEFAULT_USERNAME
|
private Logger |
logger
|
private static DeepaMehtaEvent |
POST_LOGIN_USER
|
private static DeepaMehtaEvent |
POST_LOGOUT_USER
|
private static boolean |
READ_REQUIRES_LOGIN
|
private javax.servlet.http.HttpServletRequest |
request
|
private static String |
SUBNET_FILTER
|
private static String |
URI_ACL
|
private static String |
URI_CREATOR
|
private static String |
URI_OWNER
|
private static boolean |
WRITE_REQUIRES_LOGIN
|
private WorkspacesService |
wsService
|
| Fields inherited from class de.deepamehta.core.osgi.PluginActivator |
|---|
bundle, dms |
| Constructor Summary | |
|---|---|
AccessControlPlugin()
|
|
| Method Summary | |
|---|---|
private void |
_login(String username,
javax.servlet.http.HttpServletRequest request)
|
private void |
_logout(javax.servlet.http.HttpServletRequest request)
|
void |
allPluginsActive()
Setup access control for the default user and the default topicmap. |
private void |
assignToDefaultWorkspace(Topic topic,
String info)
|
private void |
checkAuthorization(javax.servlet.http.HttpServletRequest request)
|
private boolean |
checkCredentials(Credentials cred)
|
private void |
checkRequestOrigin(javax.servlet.http.HttpServletRequest request)
|
private Permissions |
createPermissions(boolean write)
|
private Permissions |
createPermissions(boolean write,
boolean create)
|
private Topic |
createUserAccount(Credentials cred)
|
private void |
enrichWithPermissions(Type type,
Permissions permissions)
|
private Topic |
fetchDefaultTopicmap()
|
private Topic |
fetchDefaultUser()
Fetches the default user ("admin"). |
private Topic |
fetchUserAccount(Topic username)
Prerequisite: username is not null. |
AccessControlList |
getACL(DeepaMehtaObject object)
Returns the Access Control List of a topic or an association. |
Permissions |
getAssociationPermissions(long assocId)
|
Collection<Association> |
getAssociationsByCreator(String username)
|
Collection<Association> |
getAssociationsByOwner(String username)
|
String |
getCreator(DeepaMehtaObject object)
Returns the creator of a topic or an association. |
String |
getOwner(DeepaMehtaObject object)
Returns the owner of a topic or an association. |
private Permissions |
getPermissions(DeepaMehtaObject object)
|
private Permissions |
getPermissions(Type type)
|
Permissions |
getTopicPermissions(long topicId)
|
Collection<Topic> |
getTopicsByCreator(String username)
|
Collection<Topic> |
getTopicsByOwner(String username)
|
String |
getUsername()
Returns the username of the logged in user. |
Topic |
getUsername(String username)
Returns the "Username" topic for the specified username. |
private Topic |
getUsernameOrThrow(String username)
|
private boolean |
hasPermission(String username,
Operation operation,
DeepaMehtaObject object)
Checks if a user is allowed to perform an operation on an object (topic or association). |
private String |
info(DeepaMehtaObject object)
|
private String |
info(javax.servlet.http.HttpServletRequest request)
|
private String |
info(javax.servlet.http.HttpSession session)
|
void |
init()
|
void |
introduceAssociationType(AssociationType assocType)
|
void |
introduceTopicType(TopicType topicType)
|
private boolean |
isLoginRequired(javax.servlet.http.HttpServletRequest request)
|
private boolean |
isUserAccount(Topic topic)
|
private void |
joinIfWorkspace(Topic topic)
|
void |
joinWorkspace(String username,
long workspaceId)
|
void |
joinWorkspace(Topic username,
long workspaceId)
|
void |
login()
Checks weather the credentials in the authorization string match an existing User Account, and if so, creates an HTTP session. |
void |
logout()
Logs the user out. |
private boolean |
matches(Topic username,
String password)
Prerequisite: username is not null. |
private String |
password(Topic userAccount)
|
private ChildTopicsModel |
permissions(DeepaMehtaObject object)
|
void |
postCreateAssociation(Association assoc)
|
void |
postCreateTopic(Topic topic)
|
void |
postInstall()
|
void |
postUpdateTopic(Topic topic,
TopicModel newModel,
TopicModel oldModel)
|
void |
preSendAssociationType(AssociationType assocType)
|
void |
preSendTopicType(TopicType topicType)
|
private void |
requestFilter(javax.servlet.http.HttpServletRequest request)
|
void |
resourceRequestFilter(javax.servlet.http.HttpServletRequest servletRequest)
|
void |
serviceRequestFilter(com.sun.jersey.spi.container.ContainerRequest containerRequest)
|
void |
setACL(DeepaMehtaObject object,
AccessControlList acl)
Sets the Access Control List for a topic or an association. |
void |
setCreator(DeepaMehtaObject object,
String username)
Sets the creator of a topic or an association. |
void |
setOwner(DeepaMehtaObject object,
String username)
Sets the owner of a topic or an association. |
private void |
setupAccessControl(DeepaMehtaObject object,
AccessControlList acl)
|
private void |
setupAccessControl(DeepaMehtaObject object,
AccessControlList acl,
String username)
|
private void |
setupAccessControlForDefaultTopicmap(Topic defaultTopicmap)
|
private void |
setupDefaultAccessControl(DeepaMehtaObject object)
Sets the logged in user as the creator and the owner of the specified object and creates a default access control entry for it. |
private void |
setupDefaultAccessControl(Type type)
|
private void |
setupUserAccountAccessControl(Topic topic)
|
private void |
setupViewConfigAccessControl(ViewConfiguration viewConfig)
|
private void |
throw401Unauthorized()
|
private void |
throw403Forbidden()
|
private boolean |
tryLogin(Credentials cred,
javax.servlet.http.HttpServletRequest request)
Checks weather the credentials are valid and if so logs the user in. |
private String |
userInfo(String username)
|
private boolean |
userIsCreator(String username,
DeepaMehtaObject object)
Checks if a user is the creator of the object. |
private boolean |
userIsMember(String username,
DeepaMehtaObject object)
Checks if a user is a member of any workspace the object is assigned to. |
private boolean |
userIsOwner(String username,
DeepaMehtaObject object)
Checks if a user is the owner of the object. |
private String |
username(javax.servlet.http.HttpSession session)
|
private boolean |
userOccupiesRole(String username,
UserRole userRole,
DeepaMehtaObject object)
Checks if a user occupies a role with regard to the specified object. |
| Methods inherited from class de.deepamehta.core.osgi.PluginActivator |
|---|
getBundleContext, getPluginName, getStaticResource, getUri, publishDirectory, serviceArrived, serviceGone, setCoreService, shutdown, start, stop, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final boolean READ_REQUIRES_LOGIN
private static final boolean WRITE_REQUIRES_LOGIN
private static final String SUBNET_FILTER
private static final String AUTHENTICATION_REALM
private static final String DEFAULT_USERNAME
private static final String DEFAULT_PASSWORD
private static final AccessControlList DEFAULT_INSTANCE_ACL
private static final AccessControlList DEFAULT_TYPE_ACL
private static final AccessControlList DEFAULT_USER_ACCOUNT_ACL
private static String URI_CREATOR
private static String URI_OWNER
private static String URI_ACL
private static DeepaMehtaEvent POST_LOGIN_USER
private static DeepaMehtaEvent POST_LOGOUT_USER
private WorkspacesService wsService
@Context private javax.servlet.http.HttpServletRequest request
private Logger logger
| Constructor Detail |
|---|
public AccessControlPlugin()
| Method Detail |
|---|
public void login()
AccessControlService
login in interface AccessControlServicepublic void logout()
AccessControlService
logout in interface AccessControlServicepublic String getUsername()
AccessControlService
getUsername in interface AccessControlServicenull if no user is logged in.public Topic getUsername(String username)
AccessControlService
getUsername in interface AccessControlServicedm4.accesscontrol.username),
or null if no such username exists.public Permissions getTopicPermissions(long topicId)
getTopicPermissions in interface AccessControlServicepublic Permissions getAssociationPermissions(long assocId)
getAssociationPermissions in interface AccessControlServicepublic String getCreator(DeepaMehtaObject object)
AccessControlService
getCreator in interface AccessControlServicenull if no creator is set.
public void setCreator(DeepaMehtaObject object,
String username)
AccessControlService
setCreator in interface AccessControlServicepublic String getOwner(DeepaMehtaObject object)
AccessControlService
getOwner in interface AccessControlServicenull if no owner is set.
public void setOwner(DeepaMehtaObject object,
String username)
AccessControlService
setOwner in interface AccessControlServicepublic AccessControlList getACL(DeepaMehtaObject object)
AccessControlService
getACL in interface AccessControlService
public void setACL(DeepaMehtaObject object,
AccessControlList acl)
AccessControlService
setACL in interface AccessControlService
public void joinWorkspace(String username,
long workspaceId)
joinWorkspace in interface AccessControlService
public void joinWorkspace(Topic username,
long workspaceId)
joinWorkspace in interface AccessControlServicepublic Collection<Topic> getTopicsByCreator(String username)
getTopicsByCreator in interface AccessControlServicepublic Collection<Topic> getTopicsByOwner(String username)
getTopicsByOwner in interface AccessControlServicepublic Collection<Association> getAssociationsByCreator(String username)
getAssociationsByCreator in interface AccessControlServicepublic Collection<Association> getAssociationsByOwner(String username)
getAssociationsByOwner in interface AccessControlServicepublic void postInstall()
postInstall in interface PluginContextpostInstall in class PluginActivatorpublic void init()
init in interface PluginContextinit in class PluginActivatorpublic void allPluginsActive()
allPluginsActive in interface AllPluginsActiveListenerpublic void postCreateTopic(Topic topic)
postCreateTopic in interface PostCreateTopicListenerpublic void postCreateAssociation(Association assoc)
postCreateAssociation in interface PostCreateAssociationListener
public void postUpdateTopic(Topic topic,
TopicModel newModel,
TopicModel oldModel)
postUpdateTopic in interface PostUpdateTopicListenerpublic void introduceTopicType(TopicType topicType)
introduceTopicType in interface IntroduceTopicTypeListenerpublic void introduceAssociationType(AssociationType assocType)
introduceAssociationType in interface IntroduceAssociationTypeListenerpublic void serviceRequestFilter(com.sun.jersey.spi.container.ContainerRequest containerRequest)
serviceRequestFilter in interface ServiceRequestFilterListenerpublic void resourceRequestFilter(javax.servlet.http.HttpServletRequest servletRequest)
resourceRequestFilter in interface ResourceRequestFilterListenerpublic void preSendTopicType(TopicType topicType)
preSendTopicType in interface PreSendTopicTypeListenerpublic void preSendAssociationType(AssociationType assocType)
preSendAssociationType in interface PreSendAssociationTypeListenerprivate Topic createUserAccount(Credentials cred)
private boolean isUserAccount(Topic topic)
private Topic fetchDefaultUser()
dm4.accesscontrol.username).
RuntimeException - If the default user doesn't exist.private Topic getUsernameOrThrow(String username)
private void joinIfWorkspace(Topic topic)
private void assignToDefaultWorkspace(Topic topic,
String info)
private void setupAccessControlForDefaultTopicmap(Topic defaultTopicmap)
private Topic fetchDefaultTopicmap()
private void requestFilter(javax.servlet.http.HttpServletRequest request)
private void checkRequestOrigin(javax.servlet.http.HttpServletRequest request)
private void checkAuthorization(javax.servlet.http.HttpServletRequest request)
private boolean isLoginRequired(javax.servlet.http.HttpServletRequest request)
private boolean tryLogin(Credentials cred,
javax.servlet.http.HttpServletRequest request)
private boolean checkCredentials(Credentials cred)
private void _login(String username,
javax.servlet.http.HttpServletRequest request)
private void _logout(javax.servlet.http.HttpServletRequest request)
private boolean matches(Topic username,
String password)
null.
password - The encrypted password.private Topic fetchUserAccount(Topic username)
null.
private String username(javax.servlet.http.HttpSession session)
private String password(Topic userAccount)
private void throw401Unauthorized()
private void throw403Forbidden()
private void setupDefaultAccessControl(DeepaMehtaObject object)
private void setupDefaultAccessControl(Type type)
private void setupUserAccountAccessControl(Topic topic)
private void setupViewConfigAccessControl(ViewConfiguration viewConfig)
private void setupAccessControl(DeepaMehtaObject object,
AccessControlList acl)
private void setupAccessControl(DeepaMehtaObject object,
AccessControlList acl,
String username)
username - must not be null.private Permissions getPermissions(DeepaMehtaObject object)
private Permissions getPermissions(Type type)
private boolean hasPermission(String username,
Operation operation,
DeepaMehtaObject object)
true is returned.
username - the logged in user (a Topic of type "Username" / dm4.accesscontrol.username),
or null if no user is logged in.
private boolean userOccupiesRole(String username,
UserRole userRole,
DeepaMehtaObject object)
true is returned.
username - the logged in user (a Topic of type "Username" / dm4.accesscontrol.username),
or null if no user is logged in.
private boolean userIsMember(String username,
DeepaMehtaObject object)
true is returned.
Prerequisite: a user is logged in (username is not null).
username - a Topic of type "Username" (dm4.accesscontrol.username). ### FIXDOCobject - the object in question.
private boolean userIsOwner(String username,
DeepaMehtaObject object)
true is returned.
Prerequisite: a user is logged in (username is not null).
username - a Topic of type "Username" (dm4.accesscontrol.username). ### FIXDOC
private boolean userIsCreator(String username,
DeepaMehtaObject object)
true is returned.
Prerequisite: a user is logged in (username is not null).
username - a Topic of type "Username" (dm4.accesscontrol.username). ### FIXDOC
private void enrichWithPermissions(Type type,
Permissions permissions)
private ChildTopicsModel permissions(DeepaMehtaObject object)
private Permissions createPermissions(boolean write)
private Permissions createPermissions(boolean write,
boolean create)
private String info(DeepaMehtaObject object)
private String userInfo(String username)
private String info(javax.servlet.http.HttpSession session)
private String info(javax.servlet.http.HttpServletRequest request)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||