Author: hasan
Date: Wed Jan 20 00:49:11 2010
New Revision: 901017

URL: http://svn.apache.org/viewvc?rev=901017&view=rev
Log:
CLEREZZA-80: used java annotations instead of javadoc annotations for service 
declarations

Added:
    incubator/clerezza/issues/CLEREZZA-80/
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/
      - copied from r900993, 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.scripting/
    incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security/
      - copied from r900993, 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security/
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic/
      - copied from r900993, 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.platform.security.auth.basic/
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie/
      - copied from r900993, 
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.platform.security.auth.cookie/
Modified:
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
    
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java

Modified: 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java?rev=901017&r1=900993&r2=901017&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.scripting/src/main/java/org/apache/clerezza/platform/scripting/ScriptGeneratedResourceTypeHandler.java
 Wed Jan 20 00:49:11 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;
 
        /**

Modified: 
incubator/clerezza/issues/CLEREZZA-80/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/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java?rev=901017&r1=900993&r2=901017&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.basic/src/main/java/org/apache/clerezza/platform/security/auth/basic/BasicAuthentication.java
 Wed Jan 20 00:49:11 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) {

Modified: 
incubator/clerezza/issues/CLEREZZA-80/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/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java?rev=901017&r1=900993&r2=901017&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security.auth.cookie/src/main/java/org/apache/clerezza/platform/security/auth/cookie/CookieAuthentication.java
 Wed Jan 20 00:49:11 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/issues/CLEREZZA-80/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java?rev=901017&r1=900993&r2=901017&view=diff
==============================================================================
--- 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
 (original)
+++ 
incubator/clerezza/issues/CLEREZZA-80/org.apache.clerezza.platform.security/src/main/java/org/apache/clerezza/platform/security/auth/AuthenticatingFilter.java
 Wed Jan 20 00:49:11 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;
+                       }
+               }
+       }
+}


Reply via email to