mirror of https://github.com/apache/archiva.git
applied codestyle formatting
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches@702357 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ac11c556bd
commit
4d43fd26f3
|
@ -33,8 +33,11 @@ public abstract class AbstractArchivaXmlTestCase
|
||||||
extends TestCase
|
extends TestCase
|
||||||
{
|
{
|
||||||
protected static final String OSLASH = "\u00f8";
|
protected static final String OSLASH = "\u00f8";
|
||||||
|
|
||||||
protected static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l";
|
protected static final String TRYGVIS = "Trygve Laugst" + OSLASH + "l";
|
||||||
|
|
||||||
protected static final String INFIN = "\u221e";
|
protected static final String INFIN = "\u221e";
|
||||||
|
|
||||||
protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva";
|
protected static final String INFINITE_ARCHIVA = "The " + INFIN + " Archiva";
|
||||||
|
|
||||||
protected File getExampleXml( String filename )
|
protected File getExampleXml( String filename )
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
package org.apache.maven.archiva.xmlrpc.security;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
@ -18,8 +19,6 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.maven.archiva.xmlrpc.security;
|
|
||||||
|
|
||||||
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||||
import org.apache.xmlrpc.XmlRpcException;
|
import org.apache.xmlrpc.XmlRpcException;
|
||||||
import org.apache.xmlrpc.XmlRpcRequest;
|
import org.apache.xmlrpc.XmlRpcRequest;
|
||||||
|
@ -34,7 +33,8 @@ import org.codehaus.plexus.redback.system.SecuritySession;
|
||||||
import org.codehaus.plexus.redback.system.SecuritySystem;
|
import org.codehaus.plexus.redback.system.SecuritySystem;
|
||||||
import org.codehaus.plexus.redback.users.UserNotFoundException;
|
import org.codehaus.plexus.redback.users.UserNotFoundException;
|
||||||
|
|
||||||
public class XmlRpcAuthenticator implements AuthenticationHandler
|
public class XmlRpcAuthenticator
|
||||||
|
implements AuthenticationHandler
|
||||||
{
|
{
|
||||||
private final SecuritySystem securitySystem;
|
private final SecuritySystem securitySystem;
|
||||||
|
|
||||||
|
@ -43,11 +43,15 @@ public class XmlRpcAuthenticator implements AuthenticationHandler
|
||||||
this.securitySystem = securitySystem;
|
this.securitySystem = securitySystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(XmlRpcRequest pRequest) throws XmlRpcException {
|
public boolean isAuthorized( XmlRpcRequest pRequest )
|
||||||
|
throws XmlRpcException
|
||||||
|
{
|
||||||
if ( pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl )
|
if ( pRequest.getConfig() instanceof XmlRpcHttpRequestConfigImpl )
|
||||||
{
|
{
|
||||||
XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl) pRequest.getConfig();
|
XmlRpcHttpRequestConfigImpl config = (XmlRpcHttpRequestConfigImpl) pRequest.getConfig();
|
||||||
SecuritySession session = authenticate(new PasswordBasedAuthenticationDataSource(config.getBasicUserName(), config.getBasicPassword()));
|
SecuritySession session =
|
||||||
|
authenticate( new PasswordBasedAuthenticationDataSource( config.getBasicUserName(),
|
||||||
|
config.getBasicPassword() ) );
|
||||||
AuthorizationResult result = authorize( session );
|
AuthorizationResult result = authorize( session );
|
||||||
return result.isAuthorized();
|
return result.isAuthorized();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
* or more contributor license agreements. See the NOTICE file
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
@ -37,12 +36,15 @@ import org.codehaus.plexus.redback.users.User;
|
||||||
import org.codehaus.plexus.redback.users.UserManager;
|
import org.codehaus.plexus.redback.users.UserManager;
|
||||||
import org.codehaus.plexus.redback.users.UserNotFoundException;
|
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 USERNAME = "username";
|
||||||
|
|
||||||
private static final String PASSWORD = "password";
|
private static final String PASSWORD = "password";
|
||||||
|
|
||||||
public void testAuthentication() throws Exception
|
public void testAuthentication()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
MockSecuritySystem securitySystem = new MockSecuritySystem( true, true, USERNAME, PASSWORD );
|
MockSecuritySystem securitySystem = new MockSecuritySystem( true, true, USERNAME, PASSWORD );
|
||||||
XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator( securitySystem );
|
XmlRpcAuthenticator authenticator = new XmlRpcAuthenticator( securitySystem );
|
||||||
|
@ -51,7 +53,8 @@ public class XmlRpcAuthenticatorTest extends TestCase
|
||||||
assertTrue( authenticator.isAuthorized( request ) );
|
assertTrue( authenticator.isAuthorized( request ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockXmlRpcRequest implements XmlRpcRequest
|
class MockXmlRpcRequest
|
||||||
|
implements XmlRpcRequest
|
||||||
{
|
{
|
||||||
private final XmlRpcHttpRequestConfigImpl configImpl;
|
private final XmlRpcHttpRequestConfigImpl configImpl;
|
||||||
|
|
||||||
|
@ -62,28 +65,36 @@ public class XmlRpcAuthenticatorTest extends TestCase
|
||||||
configImpl.setBasicPassword( password );
|
configImpl.setBasicPassword( password );
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlRpcRequestConfig getConfig() {
|
public XmlRpcRequestConfig getConfig()
|
||||||
|
{
|
||||||
return configImpl;
|
return configImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMethodName() {
|
public String getMethodName()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getParameter(int pIndex) {
|
public Object getParameter( int pIndex )
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParameterCount() {
|
public int getParameterCount()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockSecuritySystem implements SecuritySystem
|
class MockSecuritySystem
|
||||||
|
implements SecuritySystem
|
||||||
{
|
{
|
||||||
private final boolean authorized;
|
private final boolean authorized;
|
||||||
|
|
||||||
private final boolean authenticate;
|
private final boolean authenticate;
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
|
|
||||||
private final String password;
|
private final String password;
|
||||||
|
|
||||||
public MockSecuritySystem( boolean authorized, boolean authenticate, String username, String password )
|
public MockSecuritySystem( boolean authorized, boolean authenticate, String username, String password )
|
||||||
|
@ -94,64 +105,86 @@ public class XmlRpcAuthenticatorTest extends TestCase
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecuritySession authenticate(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException {
|
public SecuritySession authenticate( AuthenticationDataSource dataSource )
|
||||||
return new SecuritySession() {
|
throws AuthenticationException, UserNotFoundException, AccountLockedException
|
||||||
|
{
|
||||||
|
return new SecuritySession()
|
||||||
|
{
|
||||||
|
|
||||||
public AuthenticationResult getAuthenticationResult() {
|
public AuthenticationResult getAuthenticationResult()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser() {
|
public User getUser()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthenticated() {
|
public boolean isAuthenticated()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthorizationResult authorize(SecuritySession session, Object arg1) throws AuthorizationException {
|
public AuthorizationResult authorize( SecuritySession session, Object arg1 )
|
||||||
|
throws AuthorizationException
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthorizationResult authorize(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException {
|
public AuthorizationResult authorize( SecuritySession session, Object arg1, Object arg2 )
|
||||||
|
throws AuthorizationException
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthenticatorId() {
|
public String getAuthenticatorId()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthorizerId() {
|
public String getAuthorizerId()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyManager getKeyManager() {
|
public KeyManager getKeyManager()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserSecurityPolicy getPolicy() {
|
public UserSecurityPolicy getPolicy()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUserManagementId() {
|
public String getUserManagementId()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserManager getUserManager() {
|
public UserManager getUserManager()
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthenticated(AuthenticationDataSource dataSource) throws AuthenticationException, UserNotFoundException, AccountLockedException {
|
public boolean isAuthenticated( AuthenticationDataSource dataSource )
|
||||||
|
throws AuthenticationException, UserNotFoundException, AccountLockedException
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(SecuritySession session, Object arg1) throws AuthorizationException {
|
public boolean isAuthorized( SecuritySession session, Object arg1 )
|
||||||
|
throws AuthorizationException
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(SecuritySession session, Object arg1, Object arg2) throws AuthorizationException {
|
public boolean isAuthorized( SecuritySession session, Object arg1, Object arg2 )
|
||||||
|
throws AuthorizationException
|
||||||
|
{
|
||||||
throw new UnsupportedOperationException( "Not supported yet." );
|
throw new UnsupportedOperationException( "Not supported yet." );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue