Author: ito
Date: Wed Nov 17 14:01:56 2010
New Revision: 1036044
URL: http://svn.apache.org/viewvc?rev=1036044&view=rev
Log:
CLEREZZA-359: reverted current approach
Removed:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/LoginListener.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.usermanager/src/main/java/org/apache/clerezza/platform/usermanager/UserLoginListener.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticationCheckerImpl.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java?rev=1036044&r1=1036043&r2=1036044&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
Wed Nov 17 14:01:56 2010
@@ -20,14 +20,9 @@ package org.apache.clerezza.platform.sec
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
-import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.security.auth.Subject;
@@ -36,7 +31,6 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.References;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
@@ -54,22 +48,15 @@ import org.wymiwyg.wrhapi.filter.Filter;
*/
@Component
@Service(Filter.class)
-...@references({
- @Reference(name="weightedAuthenticationMethod",
- cardinality=ReferenceCardinality.MANDATORY_MULTIPLE,
- policy=ReferencePolicy.DYNAMIC,
- referenceInterface=WeightedAuthenticationMethod.class),
- @Reference(name="loginListener",
- cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE,
- policy=ReferencePolicy.DYNAMIC,
- referenceInterface=LoginListener.class)
- })
+...@reference(name="weightedAuthenticationMethod",
+ cardinality=ReferenceCardinality.MANDATORY_MULTIPLE,
+ policy=ReferencePolicy.DYNAMIC,
+ referenceInterface=WeightedAuthenticationMethod.class)
public class AuthenticatingFilter implements Filter {
private final Logger logger =
LoggerFactory.getLogger(AuthenticatingFilter.class);
private SortedSet<WeightedAuthenticationMethod> methodList =
new TreeSet<WeightedAuthenticationMethod>(new
WeightedAuthMethodComparator());
- private final Set<LoginListener> loginListenerSet =
Collections.synchronizedSet(new HashSet<LoginListener>());
public static final Subject ANONYMOUS_SUBJECT =
UserUtil.createSubject("anonymous");
@Override
@@ -98,14 +85,6 @@ public class AuthenticatingFilter implem
subject = ANONYMOUS_SUBJECT;
} else {
subject = UserUtil.createSubject(userName);
- Set<LoginListener> tempLoginListenerSet = null;
- synchronized(loginListenerSet) {
- tempLoginListenerSet = new
HashSet<LoginListener>(loginListenerSet);
- }
- for (Iterator<LoginListener> it =
tempLoginListenerSet.iterator(); it.hasNext();) {
- LoginListener listener = it.next();
- listener.userLoggedIn(userName,
authenticationMethod.getClass());
- }
}
try {
Subject.doAsPrivileged(subject, new
PrivilegedExceptionAction() {
@@ -151,24 +130,6 @@ public class AuthenticatingFilter implem
}
/**
- * Registers a <code>LoginListener</code>
- *
- * @param listener the listener to be registered
- */
- protected void bindLoginListener(LoginListener listener) {
- loginListenerSet.add(listener);
- }
-
- /**
- * Unregisters a <code>LoginListener</code>
- *
- * @param listener the listener to be unregistered
- */
- protected void unbindLoginListener(LoginListener listener) {
- loginListenerSet.remove(listener);
- }
-
- /**
* Compares the WeightedAuthenticationMethods, descending for weight
and ascending by name
*/
static class WeightedAuthMethodComparator
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticationCheckerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticationCheckerImpl.java?rev=1036044&r1=1036043&r2=1036044&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticationCheckerImpl.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticationCheckerImpl.java
Wed Nov 17 14:01:56 2010
@@ -20,6 +20,7 @@ package org.apache.clerezza.platform.sec
import java.security.AccessController;
import java.util.Iterator;
+import java.util.concurrent.locks.Lock;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
@@ -34,7 +35,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.clerezza.platform.config.SystemConfig;
import org.apache.clerezza.platform.security.PasswordUtil;
-import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.access.LockableMGraph;
import org.apache.clerezza.rdf.ontologies.PLATFORM;
/**
@@ -50,7 +51,7 @@ public class AuthenticationCheckerImpl i
private final static Logger logger =
LoggerFactory.getLogger(AuthenticationCheckerImpl.class);
@Reference(target=SystemConfig.SYSTEM_GRAPH_FILTER)
- private MGraph systemGraph;
+ private LockableMGraph systemGraph;
/**
* Checks if the provided username and password matches a username and
@@ -79,21 +80,33 @@ public class AuthenticationCheckerImpl i
private NonLiteral getAgentFromGraph(String userName) throws
NoSuchAgent {
NonLiteral agent;
- Iterator<Triple> agents = systemGraph.filter(null,
PLATFORM.userName, new PlainLiteralImpl(userName));
- if (agents.hasNext()) {
- agent = agents.next().getSubject();
- } else {
- logger.info("unsuccessful authentication attempt as
non-existent user {}", userName);
- throw new NoSuchAgent();
+ Lock l = systemGraph.getLock().readLock();
+ l.lock();
+ try {
+ Iterator<Triple> agents = systemGraph.filter(null,
PLATFORM.userName, new PlainLiteralImpl(userName));
+ if (agents.hasNext()) {
+ agent = agents.next().getSubject();
+ } else {
+ logger.info("unsuccessful authentication
attempt as non-existent user {}", userName);
+ throw new NoSuchAgent();
+ }
+ } finally {
+ l.unlock();
}
return agent;
}
private String getPasswordOfAgent(NonLiteral agent) {
String storedPassword = "";
- Iterator<Triple> agentPassword = systemGraph.filter(agent,
PERMISSION.passwordSha1, null);
- if (agentPassword.hasNext()) {
- storedPassword = ((Literal)
agentPassword.next().getObject()).getLexicalForm();
+ Lock l = systemGraph.getLock().readLock();
+ l.lock();
+ try {
+ Iterator<Triple> agentPassword =
systemGraph.filter(agent, PERMISSION.passwordSha1, null);
+ if (agentPassword.hasNext()) {
+ storedPassword = ((Literal)
agentPassword.next().getObject()).getLexicalForm();
+ }
+ } finally {
+ l.unlock();
}
return storedPassword;
}