continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r427069 - in /maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi: ./ src/main/java/org/apache/maven/continuum/security/acegi/aspectj/ src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ src/tes...
Date Mon, 31 Jul 2006 10:45:48 GMT
Author: carlos
Date: Mon Jul 31 03:45:47 2006
New Revision: 427069

URL: http://svn.apache.org/viewvc?rev=427069&view=rev
Log:
First working prototype for method level authorization

Added:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityAspect.aj
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
  (with props)
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
  (with props)
Modified:
    maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/pom.xml

Modified: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/pom.xml?rev=427069&r1=427068&r2=427069&view=diff
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/pom.xml
(original)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/pom.xml
Mon Jul 31 03:45:47 2006
@@ -11,23 +11,52 @@
   <artifactId>continuum-security-acegi</artifactId>
   <name>Continuum Security - Acegi implementation</name>
   <version>1.1-SNAPSHOT</version>
+
   <dependencies>
     <dependency>
-      <groupId>org.acegisecurity</groupId>
-      <artifactId>acegi-security</artifactId>
-      <version>1.1-SNAPSHOT</version>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-acegi-integration</artifactId>
+      <version>1.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-api</artifactId>
+      <artifactId>continuum-store</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-model</artifactId>
+      <artifactId>continuum-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.apache.maven.continuum</groupId>
-      <artifactId>continuum-store</artifactId>
+      <groupId>org.acegisecurity</groupId>
+      <artifactId>acegi-security</artifactId>
+      <version>1.1-SNAPSHOT</version>
+      <type>test-jar</type>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>aspectj-maven-plugin</artifactId>
+        <configuration>
+          <weaveDependencies>
+            <weaveDependency>
+              <groupId>org.apache.maven.continuum</groupId>
+              <artifactId>continuum-core</artifactId>
+            </weaveDependency>
+          </weaveDependencies>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>compile</goal>
+              <goal>test-compile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityAspect.aj
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityAspect.aj?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityAspect.aj
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/main/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityAspect.aj
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import org.apache.maven.continuum.Continuum;
+import org.codehaus.plexus.acegi.intercept.method.aspectj.SecurityAspect;
+
+/**
+ * <p>Acegi interceptor for {@link Continuum} method calls.</p>
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id: ContinuumUserDetailsService.java 421005 2006-07-11 22:00:29Z carlos $
+ */
+public aspect MethodSecurityAspect extends SecurityAspect
+{
+
+    protected pointcut securedExecution():
+        target(Continuum) &&
+        execution(public * *(..)) &&
+        !within(MethodSecurityAspect);
+
+}

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,134 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import junit.framework.TestCase;
+
+import org.acegisecurity.AccessDecisionManager;
+import org.acegisecurity.AccessDeniedException;
+import org.acegisecurity.Authentication;
+import org.acegisecurity.AuthenticationException;
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.context.SecurityContextHolder;
+import org.acegisecurity.providers.TestingAuthenticationToken;
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.model.project.Project;
+
+/**
+ * Test for {@link MethodSecurityAspect}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public abstract class AbstractMethodSecurityTest
+    extends TestCase
+{
+    private Continuum continuum;
+
+    public void setContinuum( Continuum continuum )
+    {
+        this.continuum = continuum;
+    }
+
+    public Continuum getContinuum()
+    {
+        return continuum;
+    }
+
+    public MethodSecurityAspect getAspect()
+    {
+        return MethodSecurityAspect.aspectOf();
+    }
+
+    /**
+     * Get an {@link Authentication} with provided role object that can
+     * be used with the chosen {@link AccessDecisionManager} 
+     * 
+     * @param role eg. <code>ADMIN</code>, <code>USER</code>, ...
+     * @return
+     */
+    protected Authentication getAuthentication( String role )
+    {
+        return new TestingAuthenticationToken( "marissa", "koala",
+                                               new GrantedAuthority[] { new GrantedAuthorityImpl(
"MOCK_" + role ) } );
+    }
+
+    /**
+     * Check that method call proceeds when user has the required role.
+     * 
+     * @throws Exception
+     */
+    public void testMethodSecurity()
+        throws Exception
+    {
+        assertNotNull( "continuum property is not set", getContinuum() );
+        assertNotNull( "securityInterceptor property in aspect is not set", getAspect().getSecurityInterceptor()
);
+
+        SecurityContextHolder.getContext().setAuthentication( getAuthentication( "ADMIN"
) );
+
+        getContinuum().addProject( new Project(), "" );
+    }
+
+    /**
+     * Check that method call doesn't proceed when user doesn't have the required role.
+     * 
+     * @throws Exception
+     */
+    public void testMethodSecurityWithWrongRole()
+        throws Exception
+    {
+        assertNotNull( "continuum property is not set", getContinuum() );
+        assertNotNull( "securityInterceptor property in aspect is not set", getAspect().getSecurityInterceptor()
);
+
+        SecurityContextHolder.getContext().setAuthentication( getAuthentication( "USER" )
);
+
+        try
+        {
+            getContinuum().addProject( new Project(), "" );
+            fail( AuthenticationException.class.getName() + " was not thrown." );
+        }
+        catch ( AccessDeniedException e )
+        {
+            // expected
+        }
+    }
+
+    /**
+     * Check that method call proceeds when user doesn't have the required role
+     * but security interceptor is not defined.
+     * 
+     * @throws Exception
+     */
+    public void testMethodSecurityWithoutSecurityInterceptor()
+        throws Exception
+    {
+        assertNotNull( "continuum property is not set", getContinuum() );
+
+        SecurityContextHolder.getContext().setAuthentication( getAuthentication( "USER" )
);
+        getAspect().setSecurityInterceptor( null );
+
+        getContinuum().addProject( new Project(), "" );
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        SecurityContextHolder.getContext().setAuthentication( null );
+        super.tearDown();
+    }
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/AbstractMethodSecurityTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,444 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.continuum.Continuum;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectNotifier;
+import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.model.system.ContinuumUser;
+import org.apache.maven.continuum.model.system.UserGroup;
+import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
+import org.apache.maven.continuum.security.ContinuumSecurity;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+
+/**
+ * Stub implementation of {@link Continuum} with empty implementations.
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class ContinuumStub
+    implements Continuum
+{
+
+    public void addBuildDefinition( int projectId, BuildDefinition buildDefinition )
+        throws ContinuumException
+    {
+    }
+
+    public void addBuildDefinitionFromParams( int projectId, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public ContinuumProjectBuildingResult addMavenOneProject( String metadataUrl )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public ContinuumProjectBuildingResult addMavenTwoProject( String metadataUrl )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public void addNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException
+    {
+    }
+
+    public void addNotifier( int projectId, String notifierType, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public int addProject( Project project, String executorId )
+        throws ContinuumException
+    {
+        return 0;
+    }
+
+    public void addSchedule( Schedule schedule )
+        throws ContinuumException
+    {
+    }
+
+    public void addUser( ContinuumUser user )
+        throws ContinuumException
+    {
+    }
+
+    public void addUser( Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public void addUserGroup( UserGroup userGroup )
+    {
+    }
+
+    public void addUserGroup( Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public void buildProject( int projectId )
+        throws ContinuumException
+    {
+    }
+
+    public void buildProject( int projectId, int trigger )
+        throws ContinuumException
+    {
+    }
+
+    public void buildProject( int projectId, int buildDefinitionId, int trigger )
+        throws ContinuumException
+    {
+    }
+
+    public void buildProjects()
+        throws ContinuumException
+    {
+    }
+
+    public void buildProjects( int trigger )
+        throws ContinuumException
+    {
+    }
+
+    public void buildProjects( Schedule schedule )
+        throws ContinuumException
+    {
+    }
+
+    public void checkoutProject( int projectId )
+        throws ContinuumException
+    {
+    }
+
+    public Collection getAllProjects( int start, int end )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getAllProjectsWithAllDetails( int start, int end )
+    {
+        return null;
+    }
+
+    public BuildDefinition getBuildDefinition( int projectId, int buildDefinitionId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getBuildDefinitions( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public String getBuildOutput( int projectId, int buildId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public BuildResult getBuildResult( int buildId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public BuildResult getBuildResultByBuildNumber( int projectId, int buildNumber )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Collection getBuildResultsForProject( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Map getBuildResultsInSuccess()
+    {
+        return null;
+    }
+
+    public List getChangesSinceLastSuccess( int projectId, int buildResultId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public ConfigurationService getConfiguration()
+    {
+        return null;
+    }
+
+    public BuildDefinition getDefaultBuildDefinition( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public String getFileContent( int projectId, String directory, String filename )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getFiles( int projectId, String currentDirectory )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public BuildResult getLatestBuildResultForProject( int projectId )
+    {
+        return null;
+    }
+
+    public Map getLatestBuildResults()
+    {
+        return null;
+    }
+
+    public ProjectNotifier getNotifier( int projectId, int notifierId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Project getProject( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Project getProjectWithAllDetails( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Project getProjectWithBuilds( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Project getProjectWithCheckoutResult( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Collection getProjects()
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getProjectsInBuildOrder()
+        throws CycleDetectedException, ContinuumException
+    {
+        return null;
+    }
+
+    public Collection getProjectsWithDependencies()
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Schedule getSchedule( int id )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public Collection getSchedules()
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public ContinuumSecurity getSecurity()
+    {
+        return null;
+    }
+
+    public ContinuumUser getUser( int userId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public UserGroup getUserGroup( int userGroupId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getUserGroups()
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public List getUsers()
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public File getWorkingDirectory( int projectId )
+        throws ContinuumException
+    {
+        return null;
+    }
+
+    public boolean isInBuildingQueue( int projectId )
+        throws ContinuumException
+    {
+        return false;
+    }
+
+    public boolean isInBuildingQueue( int projectId, int buildDefinitionId )
+        throws ContinuumException
+    {
+        return false;
+    }
+
+    public boolean isInCheckoutQueue( int projectId )
+        throws ContinuumException
+    {
+        return false;
+    }
+
+    public void reloadConfiguration()
+        throws ContinuumException
+    {
+    }
+
+    public void removeBuildDefinition( int projectId, int buildDefinitionId )
+        throws ContinuumException
+    {
+    }
+
+    public void removeNotifier( int projectId, int notifierId )
+        throws ContinuumException
+    {
+    }
+
+    public void removeProject( int projectId )
+        throws ContinuumException
+    {
+    }
+
+    public void removeSchedule( int scheduleId )
+        throws ContinuumException
+    {
+    }
+
+    public void removeUser( int userId )
+        throws ContinuumException
+    {
+    }
+
+    public void removeUserGroup( int userGroupId )
+        throws ContinuumException
+    {
+    }
+
+    public void updateBuildDefinition( BuildDefinition buildDefinition, int projectId )
+        throws ContinuumException
+    {
+    }
+
+    public void updateBuildDefinition( int projectId, int buildDefinitionId, Map configuration
)
+        throws ContinuumException
+    {
+    }
+
+    public void updateConfiguration( Map parameters )
+        throws ContinuumException
+    {
+    }
+
+    public void updateNotifier( int projectId, int notifierId, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public void updateNotifier( int projectId, ProjectNotifier notifier )
+        throws ContinuumException
+    {
+    }
+
+    public void updateProject( Project project )
+        throws ContinuumException
+    {
+    }
+
+    public void updateSchedule( Schedule schedule )
+        throws ContinuumException
+    {
+    }
+
+    public void updateSchedule( int scheduleId, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public void updateUser( ContinuumUser user )
+        throws ContinuumException
+    {
+    }
+
+    public void updateUser( int userId, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+    public void updateUserGroup( UserGroup userGroup )
+        throws ContinuumException
+    {
+    }
+
+    public void updateUserGroup( int userGroupId, Map configuration )
+        throws ContinuumException
+    {
+    }
+
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/ContinuumStub.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,63 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.acegisecurity.Authentication;
+import org.acegisecurity.GrantedAuthority;
+import org.acegisecurity.GrantedAuthorityImpl;
+import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
+import org.apache.maven.continuum.Continuum;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusContainer;
+
+public class MethodSecurityPlexusTest
+    extends AbstractMethodSecurityTest
+{
+
+    private PlexusContainer pc;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        InputStream is = Thread.currentThread().getContextClassLoader()
+            .getResourceAsStream( "org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml"
);
+
+        pc = new DefaultPlexusContainer();
+        pc.setConfigurationResource( new InputStreamReader( is ) );
+        pc.initialize();
+        pc.start();
+        setContinuum( (Continuum) pc.lookup( "org.apache.maven.continuum.Continuum" ) );
+    }
+
+    protected Authentication getAuthentication( String role )
+    {
+        return new UsernamePasswordAuthenticationToken( "marissa", "koala",
+                                                        new GrantedAuthority[] { new GrantedAuthorityImpl(
"ROLE_"
+                                                            + role ) } );
+    }
+
+    protected void tearDown()
+        throws Exception
+    {
+        pc.dispose();
+        super.tearDown();
+    }
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,69 @@
+package org.apache.maven.continuum.security.acegi.aspectj;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.acegisecurity.MockAccessDecisionManager;
+import org.acegisecurity.MockAuthenticationManager;
+import org.acegisecurity.MockRunAsManager;
+import org.acegisecurity.intercept.method.MethodDefinitionMap;
+import org.acegisecurity.intercept.method.MethodDefinitionSourceMapping;
+import org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor;
+import org.apache.maven.continuum.Continuum;
+import org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper;
+
+/**
+ * Test for {@link MethodSecurityAspect}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class MethodSecurityTest
+    extends AbstractMethodSecurityTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        MethodDefinitionSourceMapping mapping = new MethodDefinitionSourceMapping();
+        mapping.setMethodName( Continuum.class.getCanonicalName() + ".addProject" );
+        mapping.setConfigAttributes( Arrays.asList( new String[] { "MOCK_ADMIN" } ) );
+
+        List mappings = new ArrayList();
+        mappings.add( mapping );
+
+        MethodDefinitionMap methodDefinitionSource = new MethodDefinitionMap();
+        methodDefinitionSource.setMappings( mappings );
+
+        AspectJSecurityInterceptor si = new AspectJSecurityInterceptor();
+        si.setObjectDefinitionSource( methodDefinitionSource );
+        si.setAccessDecisionManager(new MockAccessDecisionManager());
+        si.setAuthenticationManager(new MockAuthenticationManager());
+        si.setRunAsManager(new MockRunAsManager());
+
+        setContinuum( new ContinuumStub() );
+        AspectJSecurityInterceptorHelper helper = new AspectJSecurityInterceptorHelper();
+        helper.setAspectName( "org.apache.maven.continuum.security.acegi.aspectj.MethodSecurityAspect"
);
+        helper.setSecurityInterceptor( si );
+        helper.initialize();
+        //        aspect = MethodSecurityAspect.aspectOf();
+    }
+}

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/java/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml?rev=427069&view=auto
==============================================================================
--- maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
(added)
+++ maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
Mon Jul 31 03:45:47 2006
@@ -0,0 +1,134 @@
+<plexus>
+
+  <!-- load on start to inject values into the aspect -->
+  <load-on-start>
+    <component>
+      <role>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</role>
+    </component>
+  </load-on-start>
+
+  <components>
+
+    <component>
+      <role>org.apache.maven.continuum.Continuum</role>
+      <implementation>org.apache.maven.continuum.security.acegi.aspectj.ContinuumStub</implementation>
+      <requirements>
+      </requirements>
+    </component>
+
+    <!--
+     | ACEGI Configuration
+     -->
+     
+    <!-- Authentication -->
+
+    <component>
+      <role>org.acegisecurity.providers.ProviderManager</role>
+      <implementation>org.acegisecurity.providers.ProviderManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.providers.dao.DaoAuthenticationProvider</role>
+          <field-name>providers</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <!-- In memory database used only for testing -->
+    <component>
+      <role>org.acegisecurity.userdetails.UserDetailsService</role>
+      <implementation>org.acegisecurity.userdetails.memory.InMemoryDaoImpl</implementation>
+      <configuration>
+        <userProperties>
+          <property>
+            <name>marissa</name>
+            <value>koala,ROLE_USER,ROLE_SUPERVISOR</value>
+          </property>
+          <property>
+            <name>dianne</name>
+            <value>emu,ROLE_USER</value>
+          </property>
+          <property>
+            <name>scott</name>
+            <value>wombat,ROLE_USER</value>
+          </property>
+        </userProperties>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.providers.dao.DaoAuthenticationProvider</role>
+      <implementation>org.acegisecurity.providers.dao.DaoAuthenticationProvider</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.userdetails.UserDetailsService</role>
+          <field-name>userDetailsService</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <!-- authorization -->
+
+    <component>
+      <role>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</role>
+      <implementation>org.codehaus.plexus.acegi.intercept.method.aspectj.AspectJSecurityInterceptorHelper</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</role>
+          <field-name>securityInterceptor</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <aspectName>org.apache.maven.continuum.security.acegi.aspectj.MethodSecurityAspect</aspectName>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</role>
+      <implementation>org.acegisecurity.intercept.method.aspectj.AspectJSecurityInterceptor</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.providers.ProviderManager</role>
+          <field-name>authenticationManager</field-name>
+        </requirement>
+        <requirement>
+          <role>org.acegisecurity.AccessDecisionManager</role>
+          <field-name>accessDecisionManager</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <objectDefinitionSource implementation="org.acegisecurity.intercept.method.MethodDefinitionMap">
+          <mappings>
+            <methodDefinitionSourceMapping>
+              <methodName>org.apache.maven.continuum.Continuum.addProject</methodName>
+              <configAttributes>
+                <configAttribute>ROLE_ADMIN</configAttribute>
+              </configAttributes>
+            </methodDefinitionSourceMapping>
+          </mappings>
+        </objectDefinitionSource>
+      </configuration>
+    </component>
+
+    <!-- An access decision manager used by the business objects -->
+    <component>
+      <role>org.acegisecurity.AccessDecisionManager</role>
+      <implementation>org.acegisecurity.vote.AffirmativeBased</implementation>
+      <requirements>
+        <requirement>
+          <role>org.acegisecurity.vote.RoleVoter</role>
+          <field-name>decisionVoters</field-name>
+        </requirement>
+      </requirements>
+      <configuration>
+        <allowIfAllAbstainDecisions>false</allowIfAllAbstainDecisions>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.acegisecurity.vote.RoleVoter</role>
+      <implementation>org.acegisecurity.vote.RoleVoter</implementation>
+    </component>
+
+  </components>
+
+</plexus>

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-acegi/continuum-security/continuum-security-acegi/src/test/resources/org/apache/maven/continuum/security/acegi/aspectj/MethodSecurityPlexusTest.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message