Update of
/var/cvs/applications/cloudcontext/src/org/mmbase/security/implementation/cloudcontext
In directory james.mmbase.org:/tmp/cvs-serv4303
Modified Files:
Authenticate.java Verify.java
Added Files:
BasicContextProvider.java BasicUserProvider.java
BuilderNames.java Caches.java ContextProvider.java
Log Message:
MMB-1757, MMB-1759
See also:
http://cvs.mmbase.org/viewcvs/applications/cloudcontext/src/org/mmbase/security/implementation/cloudcontext
See also: http://www.mmbase.org/jira/browse/MMB-1757
See also: http://www.mmbase.org/jira/browse/MMB-1759
BasicContextProvider.java is new
BasicUserProvider.java is new
BuilderNames.java is new
Caches.java is new
ContextProvider.java is new
Index: Authenticate.java
===================================================================
RCS file:
/var/cvs/applications/cloudcontext/src/org/mmbase/security/implementation/cloudcontext/Authenticate.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- Authenticate.java 9 Dec 2008 11:51:43 -0000 1.29
+++ Authenticate.java 23 Dec 2008 17:30:42 -0000 1.30
@@ -31,7 +31,7 @@
* @author Eduard Witteveen
* @author Pierre van Rooden
* @author Michiel Meeuwissen
- * @version $Id: Authenticate.java,v 1.29 2008/12/09 11:51:43 michiel Exp $
+ * @version $Id: Authenticate.java,v 1.30 2008/12/23 17:30:42 michiel Exp $
*/
public class Authenticate extends Authentication {
private static final Logger log =
Logging.getLoggerInstance(Authenticate.class);
@@ -60,17 +60,17 @@
}
}
/**
- * @since MMBase-1.8.7
+ * @since MMBase-1.9.1
*/
public final static Authenticate getInstance() {
return (Authenticate)
MMBase.getMMBase().getMMBaseCop().getAuthentication();
}
/**
- * @since MMBase-1.8.7
+ * @since MMBase-1.9.1
*/
- public Provider getUserProvider() {
- return Users.getBuilder();
+ public UserProvider getUserProvider() {
+ return Users.getBuilder().getProvider();
}
@@ -79,16 +79,9 @@
*/
@Override protected void load() throws SecurityException {
attributes.put(STORES_CONTEXT_IN_OWNER, Boolean.TRUE);
- Provider users = getUserProvider();
+ UserProvider users = getUserProvider();
if (users == null) {
- String msg = "builders for security not installed, if you are
trying to install the application belonging to this security, please restart
the application after all data has been imported)";
- log.fatal(msg);
- throw new SecurityException(msg);
- }
- if (!users.check()) {
- String msg = "builder mmbaseusers was not configured correctly";
- log.error(msg);
- throw new SecurityException(msg);
+ throw new SecurityException("builders for security not installed,
if you are trying to install the application belonging to this security, please
restart the application after all data has been imported)");
}
ResourceWatcher adminsWatcher = new
ResourceWatcher(MMBaseCopConfig.securityLoader) {
@@ -112,7 +105,7 @@
}
@Override public String getUserBuilder() {
- return "mmbaseusers";
+ return getUserProvider().getUserBuilder().getTableName();
}
private boolean warnedNoAnonymousUser = false;
@@ -125,13 +118,13 @@
log.trace("login-module: '" + s + "'");
}
MMObjectNode node = null;
- Provider users = getUserProvider();
+ UserProvider users = getUserProvider();
if (users == null) {
String msg = "builders for security not installed, if you are
trying to install the application belonging to this security, please restart
the application after all data has been imported)";
log.fatal(msg);
throw new SecurityException(msg);
}
- allowEncodedPassword = users.allowEncodedPassword();
+ allowEncodedPassword =
org.mmbase.util.Casting.toBoolean(users.getUserBuilder().getInitParameter("allowencodedpassword"));
if ("anonymous".equals(s)) {
node = users.getAnonymousUser();
if (node == null) {
Index: Verify.java
===================================================================
RCS file:
/var/cvs/applications/cloudcontext/src/org/mmbase/security/implementation/cloudcontext/Verify.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- Verify.java 7 Aug 2008 20:01:24 -0000 1.14
+++ Verify.java 23 Dec 2008 17:30:42 -0000 1.15
@@ -10,10 +10,14 @@
package org.mmbase.security.implementation.cloudcontext;
import org.mmbase.bridge.Query;
-import java.util.Set;
+import org.mmbase.module.core.MMObjectNode;
+import java.util.*;
import org.mmbase.security.implementation.cloudcontext.builders.*;
import org.mmbase.security.*;
+import org.mmbase.security.SecurityException;
import org.mmbase.util.functions.*;
+import org.mmbase.util.logging.Logger;
+import org.mmbase.util.logging.Logging;
/**
* Implementation of Authorization. Most implementation is delegated to the
Contexts builder.
@@ -21,20 +25,36 @@
* @author Eduard Witteveen
* @author Pierre van Rooden
* @author Michiel Meeuwissen
- * @version $Id: Verify.java,v 1.14 2008/08/07 20:01:24 michiel Exp $
+ * @version $Id: Verify.java,v 1.15 2008/12/23 17:30:42 michiel Exp $
* @see org.mmbase.security.implementation.cloudcontext.builders.Contexts
*/
public class Verify extends Authorization {
+ private static final Logger log = Logging.getLoggerInstance(Verify.class);
+
protected void load() {
}
- @Override
- public void create(UserContext userContext, int nodeId) {
+ /**
+ * @since MMBase-1.9.1
+ */
+ public final static Verify getInstance() {
+ return (Verify)
org.mmbase.module.core.MMBase.getMMBase().getMMBaseCop().getAuthorization();
+ }
+
+ /**
+ * @since MMBase-1.9.1
+ */
+ public ContextProvider getContextProvider() {
+ return Contexts.getBuilder().getProvider();
+ }
+
+
+ @Override public void create(UserContext userContext, int nodeId) {
User user = (User) userContext;
// odd, getOwnerField is called in BasicNodeManager yet, so I wonder
when this is called.
- Contexts.getBuilder().setContext(user, nodeId, user.getOwnerField());
+ setContext(userContext, nodeId, user.getOwnerField());
}
@Override
@@ -51,36 +71,36 @@
return Contexts.getBuilder().mayDo((User) userContext, nodeId,
operation);
}
- @Override
- public boolean check(UserContext userContext, int nodeId, int
sourceNodeId, int destinationNodeId, Operation operation) {
- //log.debug("check if operation: " + operation + " is valid for: " +
usercontext + " for node with number # " + i + "(between 2 nodes..)");
- return Contexts.getBuilder().mayDo((User) userContext, nodeId,
sourceNodeId, destinationNodeId, operation);
+ @Override public boolean check(UserContext userContext, int nodeId, int
sourceNodeId, int destinationNodeId, Operation operation) {
+ // admin bypasses security system
+ if (userContext.getRank().getInt() >= Rank.ADMIN_INT) {
+ return true;
+ }
+ return check(userContext, nodeId, operation);
}
- @Override
- public String getContext(UserContext userContext, int nodeId) throws
org.mmbase.security.SecurityException {
- //log.debug("check if we may read the node with # " + i + " nodeid?");
- return Contexts.getBuilder().getContext((User) userContext, nodeId);
+
+
+ @Override public String getContext(UserContext userContext, int nodeId)
throws org.mmbase.security.SecurityException {
+ // userContext ignored
+ return getContextProvider().getContext(getContextNode(nodeId, true));
}
- @Override
- public void setContext(UserContext userContext, int nodeId, String
context) throws org.mmbase.security.SecurityException {
- //log.debug("[node #" + i + "] changed to context: " + s + " by [" +
usercontext.getIdentifier() + "]");
- Contexts.getBuilder().setContext((User) userContext, nodeId, context);
+ @Override public void setContext(UserContext user, int nodeId, String
context) throws org.mmbase.security.SecurityException {
+ getContextProvider().setContext((User) user, getContextNode(nodeId,
true), context);
}
- @Override
- public Set<String> getPossibleContexts(UserContext userContext, int
nodeId) throws org.mmbase.security.SecurityException {
- return Contexts.getBuilder().getPossibleContexts((User) userContext,
nodeId);
+ @Override public Set<String> getPossibleContexts(UserContext userContext,
int nodeId) throws org.mmbase.security.SecurityException {
+ return getContextProvider().getPossibleContexts((User) userContext,
getContextNode(nodeId, true));
}
- @Override
- public Set<String> getPossibleContexts(UserContext userContext) throws
org.mmbase.security.SecurityException {
- return Contexts.getBuilder().getPossibleContexts((User) userContext);
+
+ @Override public Set<String> getPossibleContexts(UserContext userContext)
throws org.mmbase.security.SecurityException {
+ return getContextProvider().getPossibleContexts((User) userContext);
}
@Override
public QueryCheck check(UserContext userContext, Query query, Operation
operation) {
- return Contexts.getBuilder().check((User) userContext, query,
operation);
+ return getContextProvider().check((User) userContext, query,
operation);
}
@@ -88,4 +108,23 @@
public boolean check(UserContext user, Action ac, Parameters parameters) {
return Actions.getBuilder().check((User) user, ac, parameters);
}
+
+
+
+
+ protected MMObjectNode getContextNode(int nodeId, boolean exception) {
+ MMObjectNode node =
getContextProvider().getContextBuilders().iterator().next().getNode(nodeId);
+ if (node == null) {
+ if (exception) {
+ throw new SecurityException("node #" + nodeId + " not found");
+ } else {
+ log.warn("node #" + nodeId + " not found");
+ }
+ }
+ return node;
+ }
+
+
+
+
}
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs