clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r901250 - in /incubator/clerezza: issues/CLEREZZA-80/ trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/ trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platfor...
Date Wed, 20 Jan 2010 15:59:11 GMT
Author: reto
Date: Wed Jan 20 15:59:10 2010
New Revision: 901250

URL: http://svn.apache.org/viewvc?rev=901250&view=rev
Log:
CLEREZZA-80: closing

Removed:
    incubator/clerezza/issues/CLEREZZA-80/
Modified:
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/
  (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/
  (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security/
  (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/
  (props changed)
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
    incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan 20 15:59:10 2010
@@ -0,0 +1 @@
+/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting:900994-901238

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java?rev=901250&r1=901249&r2=901250&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
Wed Jan 20 15:59:10 2010
@@ -39,6 +39,10 @@
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.ontologies.SCRIPT;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 
 /**
  * This class handles HTTP GET requests to resources of type ScriptGeneratedResource.
@@ -47,25 +51,20 @@
  * 
  * @see org.apache.clerezza.rdf.ontologies.SCRIPT#ScriptGeneratedResource
  *
- * @scr.component
- * @scr.service interface="java.lang.Object"
- * @scr.property name="org.apache.clerezza.platform.typehandler" type="Boolean" value="true"
- *
  */
+@Component
+@Service(Object.class)
+@Property(name="org.apache.clerezza.platform.typehandler", boolValue=true)
 @SupportedTypes(types = { "http://clerezza.org/2009/07/script#ScriptGeneratedResource" },
prioritize = true)
 public class ScriptGeneratedResourceTypeHandler {
 
 	private static final Logger logger =
 			LoggerFactory.getLogger(ScriptGeneratedResourceTypeHandler.class);
 
-	/**
-	 * @scr.reference
-	 */
+        @Reference
 	private ContentGraphProvider cgProvider;
 
-	/**
-	 * @scr.reference
-	 */
+        @Reference
 	private ScriptExecution scriptExecution;
 
 	/**

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan 20 15:59:10 2010
@@ -0,0 +1 @@
+/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic:900994-901238

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java?rev=901250&r1=901249&r2=901250&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
Wed Jan 20 15:59:10 2010
@@ -25,6 +25,10 @@
 import java.security.AccessControlException;
 import org.osgi.service.component.ComponentContext;
 import org.apache.clerezza.platform.security.auth.*;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.wymiwyg.commons.util.Base64;
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
@@ -37,10 +41,10 @@
  *
  * @author mir
  *
- * @scr.component
- * @scr.service interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"
- * @scr.property name="weight" type="Integer" value="10"
  */
+@Component
+@Service(WeightedAuthenticationMethod.class)
+@Property(name="weight", intValue=10)
 public class BasicAuthentication implements WeightedAuthenticationMethod{
 	
 	/**
@@ -48,9 +52,7 @@
 	 */
 	private int weight = 10;
 
-	/**
-	 * @scr.reference
-	 */
+        @Reference
 	AuthenticationChecker authenticationChecker;
 
 	public void activate(ComponentContext componentContext) {

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan 20 15:59:10 2010
@@ -0,0 +1 @@
+/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security:900994-901238

Propchange: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan 20 15:59:10 2010
@@ -0,0 +1 @@
+/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie:900994-901238

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
URL: http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java?rev=901250&r1=901249&r2=901250&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
(original)
+++ incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
Wed Jan 20 15:59:10 2010
@@ -28,6 +28,10 @@
 import javax.ws.rs.core.Cookie;
 import org.osgi.service.component.ComponentContext;
 import org.apache.clerezza.platform.security.auth.*;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.wymiwyg.commons.util.Base64;
 import org.wymiwyg.wrhapi.HandlerException;
 import org.wymiwyg.wrhapi.HeaderName;
@@ -40,10 +44,10 @@
  *
  * @author mir
  *
- * @scr.component
- * @scr.service interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"
- * @scr.property name="weight" type="Integer" value="20"
  */
+@Component
+@Service(WeightedAuthenticationMethod.class)
+@Property(name="weight", intValue=20)
 public class CookieAuthentication implements WeightedAuthenticationMethod{
 
 	/**
@@ -57,9 +61,7 @@
 	 */
 	private int weight = 20;
 
-	/**
-	 * @scr.reference
-	 */
+        @Reference
 	AuthenticationChecker authenticationChecker;
 
 	public void activate(ComponentContext componentContext) {

Modified: incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.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.webapp.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java?rev=901250&r1=901249&r2=901250&view=diff
==============================================================================
--- incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.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.webapp.parent/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
Wed Jan 20 15:59:10 2010
@@ -16,141 +16,145 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.clerezza.platform.security.auth;
-
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import javax.security.auth.Subject;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.wymiwyg.wrhapi.Handler;
-import org.wymiwyg.wrhapi.HandlerException;
-import org.wymiwyg.wrhapi.Request;
-import org.wymiwyg.wrhapi.Response;
-import org.wymiwyg.wrhapi.filter.Filter;
-
-/**
- * 
- * @author reto
- * 
- * @scr.component 
- *                name="org.apache.clerezza.platform.security.auth.AuthenticatingFilter"
- * @scr.service interface="org.wymiwyg.wrhapi.filter.Filter"
- * @scr.reference name="weightedAuthenticationMethod"
- *     cardinality="1..n" policy="dynamic"
- *     interface="org.apache.clerezza.platform.security.auth.WeightedAuthenticationMethod"
- */
-public class AuthenticatingFilter implements Filter {
-
-	private final Logger logger = LoggerFactory.getLogger(AuthenticatingFilter.class);
-	private SortedSet<WeightedAuthenticationMethod> methodList =
-			new TreeSet<WeightedAuthenticationMethod>(new WeightedAuthMethodComparator());
-	public static final Subject ANONYMOUS_SUBJECT = new Subject(true,
-			Collections.singleton(new PrincipalImpl("anonymous")), Collections.EMPTY_SET,
-			Collections.EMPTY_SET);
-
-	@Override
-	public void handle(final Request request, final Response response,
-			final Handler wrapped) throws HandlerException {
-
-		String userName = null;
-		AuthenticationMethod authenticationMethod = null;
-		try {
-			for (Iterator<WeightedAuthenticationMethod> it = methodList.iterator(); it.hasNext();)
{
-				authenticationMethod = it.next();
-				userName = authenticationMethod.authenticate(request);
-				if (userName != null) {
-					break;
-				}
-			}
-		} catch (LoginException ex) {
-			if (!authenticationMethod.writeLoginResponse(request, response, ex)) {
-				writeLoginResponse(request, response, ex);
-			}
-			return;
-		}
-
-		Subject subject;
-		if (userName == null) {
-			subject = ANONYMOUS_SUBJECT;
-		} else {
-			subject = new Subject();
-			subject.getPrincipals().add(new PrincipalImpl(userName));
-		}
-		try {
-			Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
-
-				@Override
-				public Object run() throws Exception {
-					wrapped.handle(request, response);
-					return null;
-				}
-			}, null);
-
-		} catch (PrivilegedActionException e) {
-			Throwable cause = e.getCause();
-			if (cause instanceof HandlerException) {
-				throw (HandlerException) cause;
-			}
-			if (cause instanceof RuntimeException) {
-				throw (RuntimeException) cause;
-			}
-			throw new RuntimeException(e);
-		} catch (SecurityException e) {
-			logger.debug("SecurityException: {}", e);
-			writeLoginResponse(request, response, e);
-		}
-	}
-
-	/**
-	 * Registers a <code>WeightedAuthenticationMethod</code>
-	 *
-	 * @param method the method to be registered
-	 */
-	protected void bindWeightedAuthenticationMethod(WeightedAuthenticationMethod method) {
-		methodList.add(method);
-	}
-
-	/**
-	 * Unregister a <code>WeightedAuthenticationMethod</code>
-	 *
-	 * @param method the method to be deregistered
-	 */
-	protected void unbindWeightedAuthenticationMethod(WeightedAuthenticationMethod method) {
-		methodList.remove(method);
-	}
-
-	/**
-	 * Compares the WeightedAuthenticationMethods, descending for weight and ascending by name
-	 */
-	static class WeightedAuthMethodComparator
-			implements Comparator<WeightedAuthenticationMethod> {
-
-		@Override
-		public int compare(WeightedAuthenticationMethod o1,
-				WeightedAuthenticationMethod o2) {
-			int o1Weight = o1.getWeight();
-			int o2Weight = o2.getWeight();
-			if (o1Weight != o2Weight) {
-				return o2Weight - o1Weight;
-			}
-			return o1.getClass().toString().compareTo(o2.getClass().toString());
-		}
-	}
-
-	private void writeLoginResponse(final Request request, final Response response, Throwable
e) throws HandlerException {
-		for (AuthenticationMethod authMethod : methodList) {
-			if (authMethod.writeLoginResponse(request, response, e)) {
-				break;
-			}
-		}
-	}
-}
+package org.apache.clerezza.platform.security.auth;
+
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import javax.security.auth.Subject;
+import org.apache.felix.scr.annotations.Component;
+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.Service;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.wymiwyg.wrhapi.Handler;
+import org.wymiwyg.wrhapi.HandlerException;
+import org.wymiwyg.wrhapi.Request;
+import org.wymiwyg.wrhapi.Response;
+import org.wymiwyg.wrhapi.filter.Filter;
+
+/**
+ * 
+ * @author reto
+ */
+@Component
+@Service(Filter.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());
+	public static final Subject ANONYMOUS_SUBJECT = new Subject(true,
+			Collections.singleton(new PrincipalImpl("anonymous")), Collections.EMPTY_SET,
+			Collections.EMPTY_SET);
+
+	@Override
+	public void handle(final Request request, final Response response,
+			final Handler wrapped) throws HandlerException {
+
+		String userName = null;
+		AuthenticationMethod authenticationMethod = null;
+		try {
+			for (Iterator<WeightedAuthenticationMethod> it = methodList.iterator(); it.hasNext();)
{
+				authenticationMethod = it.next();
+				userName = authenticationMethod.authenticate(request);
+				if (userName != null) {
+					break;
+				}
+			}
+		} catch (LoginException ex) {
+			if (!authenticationMethod.writeLoginResponse(request, response, ex)) {
+				writeLoginResponse(request, response, ex);
+			}
+			return;
+		}
+
+		Subject subject;
+		if (userName == null) {
+			subject = ANONYMOUS_SUBJECT;
+		} else {
+			subject = new Subject();
+			subject.getPrincipals().add(new PrincipalImpl(userName));
+		}
+		try {
+			Subject.doAsPrivileged(subject, new PrivilegedExceptionAction() {
+
+				@Override
+				public Object run() throws Exception {
+					wrapped.handle(request, response);
+					return null;
+				}
+			}, null);
+
+		} catch (PrivilegedActionException e) {
+			Throwable cause = e.getCause();
+			if (cause instanceof HandlerException) {
+				throw (HandlerException) cause;
+			}
+			if (cause instanceof RuntimeException) {
+				throw (RuntimeException) cause;
+			}
+			throw new RuntimeException(e);
+		} catch (SecurityException e) {
+			logger.debug("SecurityException: {}", e);
+			writeLoginResponse(request, response, e);
+		}
+	}
+
+	/**
+	 * Registers a <code>WeightedAuthenticationMethod</code>
+	 *
+	 * @param method the method to be registered
+	 */
+	protected void bindWeightedAuthenticationMethod(WeightedAuthenticationMethod method) {
+		methodList.add(method);
+	}
+
+	/**
+	 * Unregister a <code>WeightedAuthenticationMethod</code>
+	 *
+	 * @param method the method to be deregistered
+	 */
+	protected void unbindWeightedAuthenticationMethod(WeightedAuthenticationMethod method) {
+		methodList.remove(method);
+	}
+
+	/**
+	 * Compares the WeightedAuthenticationMethods, descending for weight and ascending by name
+	 */
+	static class WeightedAuthMethodComparator
+			implements Comparator<WeightedAuthenticationMethod> {
+
+		@Override
+		public int compare(WeightedAuthenticationMethod o1,
+				WeightedAuthenticationMethod o2) {
+			int o1Weight = o1.getWeight();
+			int o2Weight = o2.getWeight();
+			if (o1Weight != o2Weight) {
+				return o2Weight - o1Weight;
+			}
+			return o1.getClass().toString().compareTo(o2.getClass().toString());
+		}
+	}
+
+	private void writeLoginResponse(final Request request, final Response response, Throwable
e) throws HandlerException {
+		for (AuthenticationMethod authMethod : methodList) {
+			if (authMethod.writeLoginResponse(request, response, e)) {
+				break;
+			}
+		}
+	}
+}



Mime
View raw message