]> source.dussan.org Git - archiva.git/commitdiff
applied codestyle formatting
authorMaria Odea B. Ching <oching@apache.org>
Tue, 7 Oct 2008 06:09:00 +0000 (06:09 +0000)
committerMaria Odea B. Ching <oching@apache.org>
Tue, 7 Oct 2008 06:09:00 +0000 (06:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-124@702357 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticator.java
archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java

index 7fd49274a228949207e2dfceab560a9cc4ee4953..c26889d55c747d9eeaa020b3aaf9c1ebad271857 100644 (file)
@@ -33,10 +33,13 @@ public abstract class AbstractArchivaXmlTestCase
     extends TestCase
 {
     protected static final String OSLASH = "\u00f8";
+
     protected static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l";
+
     protected static final String INFIN = "\u221e";
+
     protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva";
-    
+
     protected File getExampleXml( String filename )
     {
         File examplesDir = new File( "src/test/examples" );
index 3e3762673bbc7eb5f365ac09684dfdcac3bd3c74..bf658ed66067c945eec0372cad46d053caa7f9db 100644 (file)
@@ -1,3 +1,4 @@
+package org.apache.maven.archiva.xmlrpc.security;\r
 \r
 /*\r
  * Licensed to the Apache Software Foundation (ASF) under one\r
@@ -18,8 +19,6 @@
  * under the License.\r
  */\r
 \r
-package org.apache.maven.archiva.xmlrpc.security;\r
-\r
 import org.apache.maven.archiva.security.ArchivaRoleConstants;\r
 import org.apache.xmlrpc.XmlRpcException;\r
 import org.apache.xmlrpc.XmlRpcRequest;\r
@@ -34,58 +33,63 @@ import org.codehaus.plexus.redback.system.SecuritySession;
 import org.codehaus.plexus.redback.system.SecuritySystem;\r
 import org.codehaus.plexus.redback.users.UserNotFoundException;\r
 \r
-public class XmlRpcAuthenticator implements AuthenticationHandler\r
+public class XmlRpcAuthenticator\r
+    implements AuthenticationHandler\r
 {\r
     private final SecuritySystem securitySystem;\r
 \r
-    public XmlRpcAuthenticator(SecuritySystem securitySystem)\r
+    public XmlRpcAuthenticator( SecuritySystem securitySystem )\r
     {\r
         this.securitySystem = securitySystem;\r
     }\r
 \r
-    public boolean isAuthorized(XmlRpcRequest pRequest) throws XmlRpcException {\r
-        if (pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl)\r
+    public boolean isAuthorized( XmlRpcRequest pRequest )\r
+        throws XmlRpcException\r
+    {\r
+        if ( pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl )\r
         {\r
-            XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl)pRequest.getConfig();\r
-            SecuritySession session = authenticate(new PasswordBasedAuthenticationDataSource(config.getBasicUserName(), config.getBasicPassword()));\r
-            AuthorizationResult result = authorize(session);\r
+            XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl) pRequest.getConfig();\r
+            SecuritySession session =\r
+                authenticate( new PasswordBasedAuthenticationDataSource( config.getBasicUserName(),\r
+                                                                         config.getBasicPassword() ) );\r
+            AuthorizationResult result = authorize( session );\r
             return result.isAuthorized();\r
         }\r
 \r
-        throw new XmlRpcException("Unsupported transport (must be http)");\r
+        throw new XmlRpcException( "Unsupported transport (must be http)" );\r
     }\r
-    \r
-    private SecuritySession authenticate(PasswordBasedAuthenticationDataSource authenticationDataSource)\r
+\r
+    private SecuritySession authenticate( PasswordBasedAuthenticationDataSource authenticationDataSource )\r
         throws XmlRpcException\r
     {\r
         try\r
         {\r
-            return securitySystem.authenticate(authenticationDataSource);\r
+            return securitySystem.authenticate( authenticationDataSource );\r
         }\r
-        catch (AccountLockedException e)\r
+        catch ( AccountLockedException e )\r
         {\r
-            throw new XmlRpcException(401, e.getMessage(), e);\r
+            throw new XmlRpcException( 401, e.getMessage(), e );\r
         }\r
-        catch (AuthenticationException e)\r
+        catch ( AuthenticationException e )\r
         {\r
-            throw new XmlRpcException(401, e.getMessage(), e);\r
+            throw new XmlRpcException( 401, e.getMessage(), e );\r
         }\r
-        catch (UserNotFoundException e)\r
+        catch ( UserNotFoundException e )\r
         {\r
-            throw new XmlRpcException(401, e.getMessage(), e);\r
+            throw new XmlRpcException( 401, e.getMessage(), e );\r
         }\r
     }\r
-    \r
-    private AuthorizationResult authorize(SecuritySession session)\r
+\r
+    private AuthorizationResult authorize( SecuritySession session )\r
         throws XmlRpcException\r
     {\r
         try\r
         {\r
-            return securitySystem.authorize(session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE);\r
+            return securitySystem.authorize( session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE );\r
         }\r
-        catch (AuthorizationException e)\r
+        catch ( AuthorizationException e )\r
         {\r
-            throw new XmlRpcException(401, e.getMessage(), e);\r
+            throw new XmlRpcException( 401, e.getMessage(), e );\r
         }\r
     }\r
 }\r
index e858a7d14f875cf35b4e6642b155ce4b378cb67e..ef01659ab560694611ce069a7412c35e5ae57181 100644 (file)
@@ -1,4 +1,3 @@
-\r
 /*\r
  * Licensed to the Apache Software Foundation (ASF) under one\r
  * or more contributor license agreements.  See the NOTICE file\r
@@ -37,56 +36,68 @@ import org.codehaus.plexus.redback.users.User;
 import org.codehaus.plexus.redback.users.UserManager;\r
 import org.codehaus.plexus.redback.users.UserNotFoundException;\r
 \r
-public class XmlRpcAuthenticatorTest extends TestCase\r
+public class XmlRpcAuthenticatorTest\r
+    extends TestCase\r
 {\r
     private static final String USERNAME = "username";\r
+\r
     private static final String PASSWORD = "password";\r
 \r
-    public void testAuthentication() throws Exception\r
+    public void testAuthentication()\r
+        throws Exception\r
     {\r
-        MockSecuritySystem securitySystem = new MockSecuritySystem(true, true, USERNAME, PASSWORD);\r
-        XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator(securitySystem);\r
-        MockXmlRpcRequest request = new MockXmlRpcRequest(USERNAME, PASSWORD);\r
-        \r
-        assertTrue(authenticator.isAuthorized(request));\r
+        MockSecuritySystem securitySystem = new MockSecuritySystem( true, true, USERNAME, PASSWORD );\r
+        XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator( securitySystem );\r
+        MockXmlRpcRequest request = new MockXmlRpcRequest( USERNAME, PASSWORD );\r
+\r
+        assertTrue( authenticator.isAuthorized( request ) );\r
     }\r
 \r
-    class MockXmlRpcRequest implements XmlRpcRequest\r
+    class MockXmlRpcRequest\r
+        implements XmlRpcRequest\r
     {\r
         private final XmlRpcHttpRequestConfigImpl configImpl;\r
-        \r
-        public MockXmlRpcRequest(String username, String password)\r
+\r
+        public MockXmlRpcRequest( String username, String password )\r
         {\r
             configImpl = new XmlRpcHttpRequestConfigImpl();\r
-            configImpl.setBasicUserName(username);\r
-            configImpl.setBasicPassword(password);\r
+            configImpl.setBasicUserName( username );\r
+            configImpl.setBasicPassword( password );\r
         }\r
 \r
-        public XmlRpcRequestConfig getConfig() {\r
+        public XmlRpcRequestConfig getConfig()\r
+        {\r
             return configImpl;\r
         }\r
 \r
-        public String getMethodName() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public String getMethodName()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public Object getParameter(int pIndex) {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public Object getParameter( int pIndex )\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public int getParameterCount() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public int getParameterCount()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
     }\r
 \r
-    class MockSecuritySystem implements SecuritySystem\r
+    class MockSecuritySystem\r
+        implements SecuritySystem\r
     {\r
         private final boolean authorized;\r
+\r
         private final boolean authenticate;\r
+\r
         private final String username;\r
+\r
         private final String password;\r
 \r
-        public MockSecuritySystem(boolean authorized, boolean authenticate, String username, String password)\r
+        public MockSecuritySystem( boolean authorized, boolean authenticate, String username, String password )\r
         {\r
             this.authorized = authorized;\r
             this.authenticate = authenticate;\r
@@ -94,65 +105,87 @@ public class XmlRpcAuthenticatorTest extends TestCase
             this.password = password;\r
         }\r
 \r
-        public SecuritySession authenticate(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException {\r
-            return new SecuritySession() {\r
+        public SecuritySession authenticate( AuthenticationDataSource dataSource )\r
+            throws AuthenticationException, UserNotFoundException, AccountLockedException\r
+        {\r
+            return new SecuritySession()\r
+            {\r
 \r
-                public AuthenticationResult getAuthenticationResult() {\r
-                    throw new UnsupportedOperationException("Not supported yet.");\r
+                public AuthenticationResult getAuthenticationResult()\r
+                {\r
+                    throw new UnsupportedOperationException( "Not supported yet." );\r
                 }\r
 \r
-                public User getUser() {\r
-                    throw new UnsupportedOperationException("Not supported yet.");\r
+                public User getUser()\r
+                {\r
+                    throw new UnsupportedOperationException( "Not supported yet." );\r
                 }\r
 \r
-                public boolean isAuthenticated() {\r
+                public boolean isAuthenticated()\r
+                {\r
                     throw new UnsupportedOperationException();\r
                 }\r
             };\r
         }\r
 \r
-        public AuthorizationResult authorize(SecuritySession session, Object arg1) throws AuthorizationException {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public AuthorizationResult authorize( SecuritySession session, Object arg1 )\r
+            throws AuthorizationException\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public AuthorizationResult authorize(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public AuthorizationResult authorize( SecuritySession session, Object arg1, Object arg2 )\r
+            throws AuthorizationException\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public String getAuthenticatorId() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public String getAuthenticatorId()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public String getAuthorizerId() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public String getAuthorizerId()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public KeyManager getKeyManager() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public KeyManager getKeyManager()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public UserSecurityPolicy getPolicy() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public UserSecurityPolicy getPolicy()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public String getUserManagementId() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public String getUserManagementId()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public UserManager getUserManager() {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public UserManager getUserManager()\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public boolean isAuthenticated(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public boolean isAuthenticated( AuthenticationDataSource dataSource )\r
+            throws AuthenticationException, UserNotFoundException, AccountLockedException\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public boolean isAuthorized(SecuritySession session, Object arg1) throws AuthorizationException {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public boolean isAuthorized( SecuritySession session, Object arg1 )\r
+            throws AuthorizationException\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
 \r
-        public boolean isAuthorized(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException {\r
-            throw new UnsupportedOperationException("Not supported yet.");\r
+        public boolean isAuthorized( SecuritySession session, Object arg1, Object arg2 )\r
+            throws AuthorizationException\r
+        {\r
+            throw new UnsupportedOperationException( "Not supported yet." );\r
         }\r
     }\r
 }\r