From 5beb56e139f4e8ca0ef2ef67c3aa49b59dbf2f09 Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Tue, 7 Oct 2008 06:09:00 +0000 Subject: [PATCH] applied codestyle formatting git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-124@702357 13f79535-47bb-0310-9956-ffa450edef68 --- .../xml/AbstractArchivaXmlTestCase.java | 5 +- .../xmlrpc/security/XmlRpcAuthenticator.java | 52 +++---- .../security/XmlRpcAuthenticatorTest.java | 135 +++++++++++------- 3 files changed, 116 insertions(+), 76 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java index 7fd49274a..c26889d55 100644 --- a/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java +++ b/archiva-modules/archiva-base/archiva-xml-tools/src/test/java/org/apache/maven/archiva/xml/AbstractArchivaXmlTestCase.java @@ -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" ); diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticator.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticator.java index 3e3762673..bf658ed66 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticator.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/main/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticator.java @@ -1,3 +1,4 @@ +package org.apache.maven.archiva.xmlrpc.security; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -18,8 +19,6 @@ * under the License. */ -package org.apache.maven.archiva.xmlrpc.security; - import org.apache.maven.archiva.security.ArchivaRoleConstants; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcRequest; @@ -34,58 +33,63 @@ 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 +public class XmlRpcAuthenticator + implements AuthenticationHandler { private final SecuritySystem securitySystem; - public XmlRpcAuthenticator(SecuritySystem securitySystem) + public XmlRpcAuthenticator( SecuritySystem securitySystem ) { this.securitySystem = securitySystem; } - public boolean isAuthorized(XmlRpcRequest pRequest) throws XmlRpcException { - if (pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl) + 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); + 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)"); + throw new XmlRpcException( "Unsupported transport (must be http)" ); } - - private SecuritySession authenticate(PasswordBasedAuthenticationDataSource authenticationDataSource) + + private SecuritySession authenticate( PasswordBasedAuthenticationDataSource authenticationDataSource ) throws XmlRpcException { try { - return securitySystem.authenticate(authenticationDataSource); + return securitySystem.authenticate( authenticationDataSource ); } - catch (AccountLockedException e) + catch ( AccountLockedException e ) { - throw new XmlRpcException(401, e.getMessage(), e); + throw new XmlRpcException( 401, e.getMessage(), e ); } - catch (AuthenticationException e) + catch ( AuthenticationException e ) { - throw new XmlRpcException(401, e.getMessage(), e); + throw new XmlRpcException( 401, e.getMessage(), e ); } - catch (UserNotFoundException e) + catch ( UserNotFoundException e ) { - throw new XmlRpcException(401, e.getMessage(), e); + throw new XmlRpcException( 401, e.getMessage(), e ); } } - - private AuthorizationResult authorize(SecuritySession session) + + private AuthorizationResult authorize( SecuritySession session ) throws XmlRpcException { try { - return securitySystem.authorize(session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE); + return securitySystem.authorize( session, ArchivaRoleConstants.GLOBAL_REPOSITORY_MANAGER_ROLE ); } - catch (AuthorizationException e) + catch ( AuthorizationException e ) { - throw new XmlRpcException(401, e.getMessage(), e); + throw new XmlRpcException( 401, e.getMessage(), e ); } } } diff --git a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java index e858a7d14..ef01659ab 100644 --- a/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java +++ b/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-security/src/test/java/org/apache/maven/archiva/xmlrpc/security/XmlRpcAuthenticatorTest.java @@ -1,4 +1,3 @@ - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -37,56 +36,68 @@ import org.codehaus.plexus.redback.users.User; import org.codehaus.plexus.redback.users.UserManager; import org.codehaus.plexus.redback.users.UserNotFoundException; -public class XmlRpcAuthenticatorTest extends TestCase +public class XmlRpcAuthenticatorTest + extends TestCase { private static final String USERNAME = "username"; + private static final String PASSWORD = "password"; - public void testAuthentication() throws Exception + public void testAuthentication() + throws Exception { - MockSecuritySystem securitySystem = new MockSecuritySystem(true, true, USERNAME, PASSWORD); - XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator(securitySystem); - MockXmlRpcRequest request = new MockXmlRpcRequest(USERNAME, PASSWORD); - - assertTrue(authenticator.isAuthorized(request)); + MockSecuritySystem securitySystem = new MockSecuritySystem( true, true, USERNAME, PASSWORD ); + XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator( securitySystem ); + MockXmlRpcRequest request = new MockXmlRpcRequest( USERNAME, PASSWORD ); + + assertTrue( authenticator.isAuthorized( request ) ); } - class MockXmlRpcRequest implements XmlRpcRequest + class MockXmlRpcRequest + implements XmlRpcRequest { private final XmlRpcHttpRequestConfigImpl configImpl; - - public MockXmlRpcRequest(String username, String password) + + public MockXmlRpcRequest( String username, String password ) { configImpl = new XmlRpcHttpRequestConfigImpl(); - configImpl.setBasicUserName(username); - configImpl.setBasicPassword(password); + configImpl.setBasicUserName( username ); + configImpl.setBasicPassword( password ); } - public XmlRpcRequestConfig getConfig() { + public XmlRpcRequestConfig getConfig() + { return configImpl; } - public String getMethodName() { - throw new UnsupportedOperationException("Not supported yet."); + public String getMethodName() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public Object getParameter(int pIndex) { - throw new UnsupportedOperationException("Not supported yet."); + public Object getParameter( int pIndex ) + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public int getParameterCount() { - throw new UnsupportedOperationException("Not supported yet."); + public int getParameterCount() + { + throw new UnsupportedOperationException( "Not supported yet." ); } } - class MockSecuritySystem implements SecuritySystem + class MockSecuritySystem + implements SecuritySystem { private final boolean authorized; + private final boolean authenticate; + private final String username; + private final String password; - public MockSecuritySystem(boolean authorized, boolean authenticate, String username, String password) + public MockSecuritySystem( boolean authorized, boolean authenticate, String username, String password ) { this.authorized = authorized; this.authenticate = authenticate; @@ -94,65 +105,87 @@ public class XmlRpcAuthenticatorTest extends TestCase this.password = password; } - public SecuritySession authenticate(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException { - return new SecuritySession() { + public SecuritySession authenticate( AuthenticationDataSource dataSource ) + throws AuthenticationException, UserNotFoundException, AccountLockedException + { + return new SecuritySession() + { - public AuthenticationResult getAuthenticationResult() { - throw new UnsupportedOperationException("Not supported yet."); + public AuthenticationResult getAuthenticationResult() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public User getUser() { - throw new UnsupportedOperationException("Not supported yet."); + public User getUser() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public boolean isAuthenticated() { + public boolean isAuthenticated() + { throw new UnsupportedOperationException(); } }; } - public AuthorizationResult authorize(SecuritySession session, Object arg1) throws AuthorizationException { - throw new UnsupportedOperationException("Not supported yet."); + public AuthorizationResult authorize( SecuritySession session, Object arg1 ) + throws AuthorizationException + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public AuthorizationResult authorize(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException { - throw new UnsupportedOperationException("Not supported yet."); + public AuthorizationResult authorize( SecuritySession session, Object arg1, Object arg2 ) + throws AuthorizationException + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public String getAuthenticatorId() { - throw new UnsupportedOperationException("Not supported yet."); + public String getAuthenticatorId() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public String getAuthorizerId() { - throw new UnsupportedOperationException("Not supported yet."); + public String getAuthorizerId() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public KeyManager getKeyManager() { - throw new UnsupportedOperationException("Not supported yet."); + public KeyManager getKeyManager() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public UserSecurityPolicy getPolicy() { - throw new UnsupportedOperationException("Not supported yet."); + public UserSecurityPolicy getPolicy() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public String getUserManagementId() { - throw new UnsupportedOperationException("Not supported yet."); + public String getUserManagementId() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public UserManager getUserManager() { - throw new UnsupportedOperationException("Not supported yet."); + public UserManager getUserManager() + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public boolean isAuthenticated(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException { - throw new UnsupportedOperationException("Not supported yet."); + public boolean isAuthenticated( AuthenticationDataSource dataSource ) + throws AuthenticationException, UserNotFoundException, AccountLockedException + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public boolean isAuthorized(SecuritySession session, Object arg1) throws AuthorizationException { - throw new UnsupportedOperationException("Not supported yet."); + public boolean isAuthorized( SecuritySession session, Object arg1 ) + throws AuthorizationException + { + throw new UnsupportedOperationException( "Not supported yet." ); } - public boolean isAuthorized(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException { - throw new UnsupportedOperationException("Not supported yet."); + public boolean isAuthorized( SecuritySession session, Object arg1, Object arg2 ) + throws AuthorizationException + { + throw new UnsupportedOperationException( "Not supported yet." ); } } } -- 2.39.5