Author: oching
Date: Wed Oct 8 04:04:24 2008
New Revision: 702806
URL: http://svn.apache.org/viewvc?rev=702806&view=rev
Log:
repackaged directories
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/test/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/test/java/org/apache/archiva/web/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/test/java/org/apache/archiva/web/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/test/java/org/apache/archiva/web/xmlrpc/api/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/
Removed:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/maven/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/test/java/org/apache/maven/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/maven/
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/maven/
Modified:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/mdo/archiva-service.xml
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/AdministrationService.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,47 @@
+package org.apache.archiva.web.xmlrpc.api;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+import com.atlassian.xmlrpc.ServiceObject;
+
[EMAIL PROTECTED]( "Administration" )
+public interface AdministrationService
+{
+ public boolean executeRepositoryScanner( String repoId );
+
+ public boolean executeDatabaseScanner();
+
+ public List<String> getAllDatabaseConsumers();
+
+ public boolean configureDatabaseConsumer( String consumerId, boolean
enable );
+
+ // TODO should we already implement config of consumers per repository?
+ public boolean configureRepositoryConsumer( String repoId, String
consumerId, boolean enable );
+
+ public List<String> getAllRepositoryConsumers( String repoId );
+
+ public List<ManagedRepository> getAllManagedRepositories();
+
+ public List<RemoteRepository> getAllRemoteRepositories();
+
+ public boolean deleteArtifact( String repoId, String groupId, String
artifactId, String version );
+}
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,28 @@
+package org.apache.archiva.web.xmlrpc.api;
+
+/*
+ * 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.
+ */
+
+import com.atlassian.xmlrpc.ServiceObject;
+
[EMAIL PROTECTED]("Search")
+public interface SearchService
+{
+
+}
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/TestService.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,28 @@
+package org.apache.archiva.web.xmlrpc.api;
+
+/*
+ * 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.
+ */
+
+import com.atlassian.xmlrpc.ServiceObject;
+
[EMAIL PROTECTED]("Test")
+public interface TestService
+{
+ public String ping();
+}
Modified:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/mdo/archiva-service.xml
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/mdo/archiva-service.xml?rev=702806&r1=702805&r2=702806&view=diff
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/mdo/archiva-service.xml
(original)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/mdo/archiva-service.xml
Wed Oct 8 04:04:24 2008
@@ -25,7 +25,7 @@
<defaults>
<default>
<key>package</key>
- <value>org.apache.maven.archiva.web.xmlrpc.api</value>
+ <value>org.apache.archiva.web.xmlrpc.api</value>
</default>
</defaults>
<classes>
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/archiva/web/xmlrpc/security/XmlRpcAuthenticator.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,97 @@
+package org.apache.archiva.web.xmlrpc.security;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.xmlrpc.XmlRpcException;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
+import
org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.AuthenticationHandler;
+import org.codehaus.plexus.redback.authentication.AuthenticationException;
+import
org.codehaus.plexus.redback.authentication.PasswordBasedAuthenticationDataSource;
+import org.codehaus.plexus.redback.authorization.AuthorizationException;
+import org.codehaus.plexus.redback.authorization.AuthorizationResult;
+import org.codehaus.plexus.redback.policy.AccountLockedException;
+import org.codehaus.plexus.redback.system.SecuritySession;
+import org.codehaus.plexus.redback.system.SecuritySystem;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+
+public class XmlRpcAuthenticator
+ implements AuthenticationHandler
+{
+ private final SecuritySystem securitySystem;
+
+ public XmlRpcAuthenticator( SecuritySystem securitySystem )
+ {
+ this.securitySystem = securitySystem;
+ }
+
+ public boolean isAuthorized( XmlRpcRequest pRequest )
+ throws XmlRpcException
+ {
+ if ( pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl )
+ {
+ XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl)
pRequest.getConfig();
+ SecuritySession session =
+ authenticate( new PasswordBasedAuthenticationDataSource(
config.getBasicUserName(),
+
config.getBasicPassword() ) );
+ AuthorizationResult result = authorize( session );
+ return result.isAuthorized();
+ }
+
+ throw new XmlRpcException( "Unsupported transport (must be http)" );
+ }
+
+ private SecuritySession authenticate(
PasswordBasedAuthenticationDataSource authenticationDataSource )
+ throws XmlRpcException
+ {
+ try
+ {
+ return securitySystem.authenticate( authenticationDataSource );
+ }
+ catch ( AccountLockedException e )
+ {
+ throw new XmlRpcException( 401, e.getMessage(), e );
+ }
+ catch ( AuthenticationException e )
+ {
+ throw new XmlRpcException( 401, e.getMessage(), e );
+ }
+ catch ( UserNotFoundException e )
+ {
+ throw new XmlRpcException( 401, e.getMessage(), e );
+ }
+ }
+
+ private AuthorizationResult authorize( SecuritySession session )
+ throws XmlRpcException
+ {
+ try
+ {
+ //TODO authorization/permissions should be checked depending on
the service being accessed
+
+ return securitySystem.authorize( session,
ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE );
+ }
+ catch ( AuthorizationException e )
+ {
+ throw new XmlRpcException( 401, e.getMessage(), e );
+ }
+ }
+}
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,211 @@
+package org.apache.archiva.xmlrpc.security;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.web.xmlrpc.security.XmlRpcAuthenticator;
+import org.apache.maven.archiva.security.ArchivaRoleConstants;
+import org.apache.xmlrpc.XmlRpcRequest;
+import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
+import org.codehaus.plexus.redback.role.RoleManager;
+import org.codehaus.plexus.redback.system.SecuritySystem;
+import org.codehaus.plexus.redback.users.User;
+import org.codehaus.plexus.redback.users.UserManager;
+import org.codehaus.plexus.redback.users.UserNotFoundException;
+import org.codehaus.plexus.spring.PlexusInSpringTestCase;
+import org.easymock.MockControl;
+import org.easymock.classextension.MockClassControl;
+
+/**
+ * XmlRpcAuthenticatorTest
+ *
+ * @version $Id XmlRpcAuthenticatorTest.java
+ */
+public class XmlRpcAuthenticatorTest
+//extends AbstractDependencyInjectionSpringContextTests
+ extends PlexusInSpringTestCase
+{
+ protected static final String USER_GUEST = "guest";
+
+ protected static final String USER_ADMIN = "admin";
+
+ protected static final String USER_ALPACA = "alpaca";
+
+ private static final String PASSWORD = "password123";
+
+ protected SecuritySystem securitySystem;
+
+ protected RoleManager roleManager;
+
+ private MockControl xmlRpcRequestControl;
+
+ private XmlRpcRequest xmlRpcRequest;
+
+ private XmlRpcAuthenticator authenticator;
+
+ private MockControl configControl;
+
+ private XmlRpcHttpRequestConfigImpl config;
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ securitySystem = (SecuritySystem) lookup( SecuritySystem.class,
"testable" );
+ roleManager = (RoleManager) lookup( RoleManager.class, "default" );
+
+ // Some basic asserts.
+ assertNotNull( securitySystem );
+ assertNotNull( roleManager );
+
+ // Setup Admin User.
+ User adminUser = createUser( USER_ADMIN, "Admin User", null );
+ roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_SYSTEM_ADMIN,
adminUser.getPrincipal().toString() );
+
+ // Setup Guest User.
+ User guestUser = createUser( USER_GUEST, "Guest User", null );
+ roleManager.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST,
guestUser.getPrincipal().toString() );
+
+ configControl = MockClassControl.createControl(
XmlRpcHttpRequestConfigImpl.class );
+ config = ( XmlRpcHttpRequestConfigImpl ) configControl.getMock();
+
+ xmlRpcRequestControl = MockControl.createControl( XmlRpcRequest.class
);
+ xmlRpcRequest = ( XmlRpcRequest ) xmlRpcRequestControl.getMock();
+
+ authenticator = new XmlRpcAuthenticator( securitySystem );
+ }
+
+ private User createUser( String principal, String fullname, String
password )
+ throws UserNotFoundException
+ {
+ UserManager userManager = securitySystem.getUserManager();
+
+ User user = userManager.createUser( principal, fullname, principal +
"@testable.archiva.apache.org" );
+ securitySystem.getPolicy().setEnabled( false );
+ userManager.addUser( user );
+ securitySystem.getPolicy().setEnabled( true );
+
+ user.setPassword( password );
+ userManager.updateUser( user );
+
+ return user;
+ }
+
+ public void testIsAuthorizedUserExistsButNotAuthorized()
+ throws Exception
+ {
+ createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD );
+
+ UserManager userManager = securitySystem.getUserManager();
+ try
+ {
+ User user = userManager.findUser( USER_ALPACA );
+ assertEquals( USER_ALPACA, user.getPrincipal() );
+ }
+ catch ( UserNotFoundException e )
+ {
+ fail( "User should exist in the database." );
+ }
+
+ xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(),
config, 2 );
+
+ configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA
);
+
+ configControl.expectAndReturn( config.getBasicPassword(), PASSWORD );
+
+ xmlRpcRequestControl.replay();
+ configControl.replay();
+
+ boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest );
+
+ xmlRpcRequestControl.verify();
+ configControl.verify();
+
+ assertFalse( isAuthorized );
+ }
+
+ public void testIsAuthorizedUserExistsAndAuthorized()
+ throws Exception
+ {
+ createUser( USER_ALPACA, "Al 'Archiva' Paca", PASSWORD );
+
+ UserManager userManager = securitySystem.getUserManager();
+ try
+ {
+ User user = userManager.findUser( USER_ALPACA );
+ assertEquals( USER_ALPACA, user.getPrincipal() );
+ }
+ catch ( UserNotFoundException e )
+ {
+ fail( "User should exist in the database." );
+ }
+
+ //TODO cannot assign global repo manager role - it says role does not
exist :|
+
+ //roleManager.assignRole(
ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE, USER_ALPACA );
+
+ xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(),
config, 2 );
+
+ configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA
);
+
+ configControl.expectAndReturn( config.getBasicPassword(), PASSWORD );
+
+ xmlRpcRequestControl.replay();
+ configControl.replay();
+
+ boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest );
+
+ xmlRpcRequestControl.verify();
+ configControl.verify();
+
+ //assertTrue( isAuthorized );
+ }
+
+ public void testIsAuthorizedUserDoesNotExist()
+ throws Exception
+ {
+ UserManager userManager = securitySystem.getUserManager();
+ try
+ {
+ userManager.findUser( USER_ALPACA );
+ fail( "User should not exist in the database." );
+ }
+ catch ( UserNotFoundException e )
+ {
+ assertEquals( "Unable to find user 'alpaca'", e.getMessage() );
+ }
+
+ xmlRpcRequestControl.expectAndReturn( xmlRpcRequest.getConfig(),
config, 2 );
+
+ configControl.expectAndReturn( config.getBasicUserName(), USER_ALPACA
);
+
+ configControl.expectAndReturn( config.getBasicPassword(), PASSWORD );
+
+ xmlRpcRequestControl.replay();
+ configControl.replay();
+
+ boolean isAuthorized = authenticator.isAuthorized( xmlRpcRequest );
+
+ xmlRpcRequestControl.verify();
+ configControl.verify();
+
+ assertFalse( isAuthorized );
+ }
+}
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/resources/org/apache/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.xml
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,192 @@
+<?xml version="1.0" ?>
+<component-set>
+ <components>
+
+ <!-- x
+ <component>
+ <role>org.apache.maven.archiva.security.UserRepositories</role>
+ <role-hint>default</role-hint>
+
<implementation>org.apache.maven.archiva.security.DefaultUserRepositories</implementation>
+ <description>DefaultUserRepositories</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
+ <role-hint>testable</role-hint>
+ <field-name>securitySystem</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.role.RoleManager</role>
+ <role-hint>default</role-hint>
+ <field-name>roleManager</field-name>
+ </requirement>
+ <requirement>
+
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <field-name>archivaConfiguration</field-name>
+ </requirement>
+ </requirements>
+ </component>
+ -->
+
+ <component>
+ <role>org.codehaus.plexus.redback.system.SecuritySystem</role>
+ <role-hint>testable</role-hint>
+
<implementation>org.codehaus.plexus.redback.system.DefaultSecuritySystem</implementation>
+ <description>DefaultSecuritySystem:</description>
+ <requirements>
+ <requirement>
+
<role>org.codehaus.plexus.redback.authentication.AuthenticationManager</role>
+ <field-name>authnManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
+ <role-hint>rbac</role-hint>
+ <field-name>authorizer</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.keys.KeyManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>keyManager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.policy.UserSecurityPolicy</role>
+ <field-name>policy</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.authorization.Authorizer</role>
+ <role-hint>rbac</role-hint>
+
<implementation>org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer</implementation>
+ <description>RbacAuthorizer:</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>manager</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ <requirement>
+
<role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
+ <role-hint>default</role-hint>
+ <field-name>evaluator</field-name>
+ </requirement>
+ <requirement>
+
<role>org.codehaus.plexus.redback.configuration.UserConfiguration</role>
+ <role-hint>default</role-hint>
+ <field-name>config</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+
<role>org.codehaus.plexus.redback.authorization.rbac.evaluator.PermissionEvaluator</role>
+ <role-hint>default</role-hint>
+
<implementation>org.codehaus.plexus.redback.authorization.rbac.evaluator.DefaultPermissionEvaluator</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.users.UserManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>userManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>org.codehaus.plexus.redback.role.RoleManager</role>
+ <role-hint>default</role-hint>
+
<implementation>org.codehaus.plexus.redback.role.DefaultRoleManager</implementation>
+ <description>RoleProfileManager:</description>
+ <requirements>
+ <requirement>
+
<role>org.codehaus.plexus.redback.role.validator.RoleModelValidator</role>
+ <role-hint>default</role-hint>
+ <field-name>modelValidator</field-name>
+ </requirement>
+ <requirement>
+
<role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>modelProcessor</field-name>
+ </requirement>
+ <requirement>
+
<role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+ <field-name>templateProcessor</field-name>
+ </requirement>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+
<role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
+ <role-hint>default</role-hint>
+
<implementation>org.codehaus.plexus.redback.role.processor.DefaultRoleModelProcessor</implementation>
+ <description>DefaultRoleModelProcessor: inserts the components of the
model that can be populated into the rbac manager</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+
<role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
+ <role-hint>default</role-hint>
+
<implementation>org.codehaus.plexus.redback.role.template.DefaultRoleTemplateProcessor</implementation>
+ <description>DefaultRoleTemplateProcessor: inserts the components of a
template into the rbac manager</description>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.redback.rbac.RBACManager</role>
+ <role-hint>memory</role-hint>
+ <field-name>rbacManager</field-name>
+ </requirement>
+ </requirements>
+ </component>
+
+ <!--
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+
<implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>configured</role-hint>
+
<implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <system/>
+ <xml fileName="${basedir}/target/test-conf/archiva.xml"
+ config-name="org.apache.maven.archiva.base"
config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+ -->
+
+ </components>
+</component-set>
\ No newline at end of file
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/AdministrationServiceImpl.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,83 @@
+package org.apache.archiva.web.xmlrpc.services;
+
+/*
+ * 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.
+ */
+
+import java.util.List;
+
+import org.apache.archiva.web.xmlrpc.api.AdministrationService;
+import org.apache.archiva.web.xmlrpc.api.ManagedRepository;
+import org.apache.archiva.web.xmlrpc.api.RemoteRepository;
+
+public class AdministrationServiceImpl
+ implements AdministrationService
+{
+
+ public boolean configureDatabaseConsumer( String consumerId, boolean
enable )
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean configureRepositoryConsumer( String repoId, String
consumerId, boolean enable )
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean deleteArtifact( String repoId, String groupId, String
artifactId, String version )
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean executeDatabaseScanner()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean executeRepositoryScanner( String repoId )
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public List<String> getAllDatabaseConsumers()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<String> getAllRepositoryConsumers( String repoId )
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<ManagedRepository> getAllManagedRepositories()
+ {
+ return null;
+ }
+
+ public List<RemoteRepository> getAllRemoteRepositories()
+ {
+ return null;
+ }
+}
Added:
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java
URL:
http://svn.apache.org/viewvc/archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java?rev=702806&view=auto
==============================================================================
---
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java
(added)
+++
archiva/branches/MRM-124/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/PingServiceImpl.java
Wed Oct 8 04:04:24 2008
@@ -0,0 +1,30 @@
+package org.apache.archiva.web.xmlrpc.services;
+
+/*
+ * 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.
+ */
+
+import org.apache.archiva.web.xmlrpc.api.TestService;
+
+public class PingServiceImpl implements TestService
+{
+ public String ping()
+ {
+ return "pong";
+ }
+}