You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by av...@apache.org on 2010/06/08 15:19:18 UTC

svn commit: r952680 - in /incubator/photark/trunk: photark-jcr/src/main/java/org/apache/photark/jcr/security/ photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/ photark-security/src/main/java/org/apache/photark/security/authentica...

Author: avd
Date: Tue Jun  8 15:19:18 2010
New Revision: 952680

URL: http://svn.apache.org/viewvc?rev=952680&view=rev
Log:
Refactored photark-security module further and now security module declare AccessManager as a service.Added its JCR based implementation in photark-jcr module.

Added:
    incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/
    incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/
    incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/JCRAccessManager.java
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/AccessManager.java
Removed:
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/AccessManager.java
Modified:
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/AuthorizationFilter.java
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/FormAuthenticationServiceImpl.java
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/LogoutServiceImpl.java
    incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/OpenIDAuthenticationServiceImpl.java
    incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite

Added: incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/JCRAccessManager.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/JCRAccessManager.java?rev=952680&view=auto
==============================================================================
--- incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/JCRAccessManager.java (added)
+++ incubator/photark/trunk/photark-jcr/src/main/java/org/apache/photark/jcr/security/authorization/JCRAccessManager.java Tue Jun  8 15:19:18 2010
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.photark.jcr.security.authorization;
+
+import org.apache.photark.jcr.JCRRepositoryManager;
+import org.apache.photark.security.authorization.services.AccessManager;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Remotable;
+import org.oasisopen.sca.annotation.Scope;
+
+@Remotable
+@Scope("COMPOSITE")
+public class JCRAccessManager implements AccessManager {
+	private static String accessList;
+	private JCRRepositoryManager repositoryManager;
+
+	public JCRAccessManager(){
+
+	}
+
+	@Reference(name="repositoryManager")
+	protected void setRepositoryManager(JCRRepositoryManager repositoryManager) {
+		this.repositoryManager = repositoryManager;
+	}
+
+	public synchronized String creatAccessList(String accessList) {
+		this.accessList = accessList;
+		return accessList;
+	}
+}

Modified: incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/AuthorizationFilter.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/AuthorizationFilter.java?rev=952680&r1=952679&r2=952680&view=diff
==============================================================================
--- incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/AuthorizationFilter.java (original)
+++ incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/AuthorizationFilter.java Tue Jun  8 15:19:18 2010
@@ -31,11 +31,6 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.photark.security.authorization.AccessManager;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Scope;
-import org.oasisopen.sca.annotation.Service;
-
 /**
  * Authorization Filter. This will only allow authenticated user 
  * to access to upload.html and redirect others to OpenID authentication
@@ -86,8 +81,6 @@ public class AuthorizationFilter impleme
 		HttpServletRequest httpReq = (HttpServletRequest) request;
 		HttpServletResponse httpResp = (HttpServletResponse) response;
 		
-		AccessManager am = new AccessManager();
-		
 		if ((String)httpReq.getSession().getAttribute("accessList") != null && !((String)httpReq.getSession().getAttribute("accessList")).equals("")) {
 			System.err.println( (String)httpReq.getSession().getAttribute("accessList") +" Accessing Admin page");
 			chain.doFilter(request, response);

Modified: incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/FormAuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/FormAuthenticationServiceImpl.java?rev=952680&r1=952679&r2=952680&view=diff
==============================================================================
--- incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/FormAuthenticationServiceImpl.java (original)
+++ incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/FormAuthenticationServiceImpl.java Tue Jun  8 15:19:18 2010
@@ -27,7 +27,8 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.photark.security.authorization.AccessManager;
+import org.apache.photark.security.authorization.services.AccessManager;
+import org.oasisopen.sca.annotation.Reference;
 import org.oasisopen.sca.annotation.Scope;
 import org.oasisopen.sca.annotation.Service;
 
@@ -40,8 +41,9 @@ import com.dyuproject.openid.RelyingPart
  */
 @Service(Servlet.class)
 @Scope("COMPOSITE")
-public class FormAuthenticationServiceImpl extends HttpServlet {
+public class FormAuthenticationServiceImpl extends HttpServlet implements Servlet {
 
+	private AccessManager accessManager;
     /**
      * 
      */
@@ -60,7 +62,7 @@ public class FormAuthenticationServiceIm
     @Override
     public void doPost(HttpServletRequest request, HttpServletResponse response)
 	    throws IOException, ServletException {
-	AccessManager am = new AccessManager();
+
 	
 	//check whether the Super Admin is authenticated
 	if (request.getUserPrincipal() != null) {
@@ -69,7 +71,7 @@ public class FormAuthenticationServiceIm
 	    RelyingParty.getInstance().invalidate(request, response);
 	    
 	    //Creating the accessList
-	    String accesList=am.creatAccessList("SuperAdmin");
+	    String accesList=accessManager.creatAccessList("SuperAdmin");
 	    request.getSession().setAttribute("accessList", accesList);
 	    System.err.println("Super Admin authenticated");
 
@@ -82,5 +84,10 @@ public class FormAuthenticationServiceIm
 	}
 
     }
-
+    
+    
+    @Reference(name="accessmanager")
+	protected void setAccessService(AccessManager accessManager) {
+		this.accessManager = accessManager;
+	}
 }
\ No newline at end of file

Modified: incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/LogoutServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/LogoutServiceImpl.java?rev=952680&r1=952679&r2=952680&view=diff
==============================================================================
--- incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/LogoutServiceImpl.java (original)
+++ incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/LogoutServiceImpl.java Tue Jun  8 15:19:18 2010
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.photark.security.authorization.AccessManager;
 import org.oasisopen.sca.annotation.Scope;
 import org.oasisopen.sca.annotation.Service;
 

Modified: incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/OpenIDAuthenticationServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/OpenIDAuthenticationServiceImpl.java?rev=952680&r1=952679&r2=952680&view=diff
==============================================================================
--- incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/OpenIDAuthenticationServiceImpl.java (original)
+++ incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authentication/services/OpenIDAuthenticationServiceImpl.java Tue Jun  8 15:19:18 2010
@@ -30,7 +30,8 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.photark.security.authorization.AccessManager;
+import org.apache.photark.security.authorization.services.AccessManager;
+import org.oasisopen.sca.annotation.Reference;
 import org.oasisopen.sca.annotation.Scope;
 import org.oasisopen.sca.annotation.Service;
 
@@ -49,10 +50,8 @@ import com.dyuproject.util.http.UrlEncod
  */
 @Service(Servlet.class)
 @Scope("COMPOSITE")
-public class OpenIDAuthenticationServiceImpl extends HttpServlet implements Servlet 
-{
-  
-    private static final long serialVersionUID = -5304887357860915253L;
+public class OpenIDAuthenticationServiceImpl extends HttpServlet implements Servlet {
+	private  static AccessManager accessManager;
 
     static
     {
@@ -82,14 +81,12 @@ public class OpenIDAuthenticationService
             public void onAuthenticate(OpenIdUser user, HttpServletRequest request)
             {
                 System.err.println("newly authenticated user: " + user.getIdentity());
-                
-            	AccessManager am= new AccessManager();
             	
             	//Invalidating the Super Admin user
             	request.getSession().invalidate();
             	//Creating the accessList for the newly authenticated user
         	    //Creating the accessList
-        	    String accesList=am.creatAccessList(user.getIdentity());
+        	    String accesList=accessManager.creatAccessList(user.getIdentity());
         	    request.getSession().setAttribute("accessList", accesList);
 
                 Map<String,String> sreg = SRegExtension.remove(user);
@@ -115,6 +112,11 @@ public class OpenIDAuthenticationService
 
     RelyingParty _relyingParty = RelyingParty.getInstance();
     
+    @Reference(name="accessmanager")
+    protected void setAccessService(AccessManager accessManager) {
+        this.accessManager = accessManager;
+    }
+    
     @Override
     public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException

Added: incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/AccessManager.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/AccessManager.java?rev=952680&view=auto
==============================================================================
--- incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/AccessManager.java (added)
+++ incubator/photark/trunk/photark-security/src/main/java/org/apache/photark/security/authorization/services/AccessManager.java Tue Jun  8 15:19:18 2010
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.photark.security.authorization.services;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface AccessManager {
+	
+	String creatAccessList(String accessList );
+}

Modified: incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite?rev=952680&r1=952679&r2=952680&view=diff
==============================================================================
--- incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite (original)
+++ incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite Tue Jun  8 15:19:18 2010
@@ -66,7 +66,10 @@
 		<implementation.java class="org.apache.photark.security.authentication.services.OpenIDAuthenticationServiceImpl"/>
 		<service name="Servlet">
 			<tuscany:binding.http uri="/home/authenticate"/>
-		</service>  	  	
+		</service>
+		<reference name="accessmanager" target="AccessManager">
+			<binding.sca name="local"/>
+		</reference> 	  	
 	</component> 
 	
     <!-- Component responsible for providing FORM Authentication for PhotArk -->
@@ -74,7 +77,10 @@
 		<implementation.java class="org.apache.photark.security.authentication.services.FormAuthenticationServiceImpl"/>
 		<service name="Servlet">
 			<tuscany:binding.http uri="/admin/authenticate"/>
-		</service>  	  	
+		</service> 
+		<reference name="accessmanager" target="AccessManager">
+			<binding.sca name="local"/>
+		</reference>	  	
 	</component> 
 	
 	<!-- Component responsible for providing logging out from the active user-->
@@ -85,17 +91,13 @@
 		</service>  	  	
 	</component> 
 	
-    <!-- Component responsible for providing filter support for uploading -->
-    <!--<component name="UploadFilterAuthenticationServiceComponent">
-		<implementation.java class="org.apache.photark.security.authentication.AuthorizationFilter"/>
-		<service name="Filter">
-			<tuscany:binding.http uri="/admin/upload"/>
-		</service>  	  	
-		<property name="redirectPage">/home/authenticate</property>
-	</component> -->
-	
 	<!-- Component responsible for providing Access Management for gallery/album -->
-    <component name="AccessManager">
-		<implementation.java class="org.apache.photark.security.authorization.AccessManager"/>
-	</component>    
+	<component name="AccessManager">
+   		<implementation.java class="org.apache.photark.jcr.security.authorization.JCRAccessManager"/>
+   		<service name="AccessManager">
+   			<interface.java interface="org.apache.photark.security.authorization.services.AccessManager"/>
+   			<binding.sca name="local"/>
+		</service>  
+   		<reference name="repositoryManager" target="RepositoryManager"/>
+    </component> 
 </composite>