ch.elca.el4j.tests.services.security
Class AuthorizationDistributedTest

java.lang.Object
  extended by ch.elca.el4j.tests.services.security.AuthorizationDistributedTest

public class AuthorizationDistributedTest
extends Object

Tests various logins and authorization in a distributed environment.

Author:
Raphael Boog (RBO)
File-location:
AuthorizationDistributedTest
Last check-in date:
2010-01-15 12:21:07 +0100 (Fr, 15. Jan 2010) by jonasha for revision 4091

Field Summary
private  ConfigurableApplicationContext m_ac
          Application context.
private  String[] m_configLocationsClient
          Client config locations.
private  String[] m_configLocationsServer
          Server config locations.
private static String METHOD_ACCESS_ROLE
          Method access role.
private static org.slf4j.Logger s_logger
          Private logger.
 
Constructor Summary
AuthorizationDistributedTest()
           
 
Method Summary
private  void createSecureContext(String principal, String credential, String role)
          Create a secure context with a TestingAuthenticationToken, i.e. a token where the user can define which roles it possesses.
private  void destroySecureContext(String principal, String credential)
          Delete the secure context, i.e. logging out the user.
private  ExtendedTestingAuthenticationProvider getAuthenticationProvider()
          Returns the authentication provider of the authorization server.
private  AuthenticationService getAuthenticationService()
           
private  SampleService getSampleService()
           
 void setUp()
          
 void tearDown()
          
 void testCorrectAuthorization()
          Test does a correct authorization.
 void testCorrectAuthorizationAfterLogoutNoAccess()
          Test does a correct authorization.
 void testFailedAuthentication()
          Test tries to authenticate with a wrong username/password combination.
 void testFailedAuthorization()
          Test does a correct login with the wrong role.
 void testMethodCallWithoutLogin()
          Test tries to execute the target method without authentication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

s_logger

private static org.slf4j.Logger s_logger
Private logger.


METHOD_ACCESS_ROLE

private static final String METHOD_ACCESS_ROLE
Method access role.

See Also:
Constant Field Values

m_configLocationsServer

private String[] m_configLocationsServer
Server config locations.


m_configLocationsClient

private String[] m_configLocationsClient
Client config locations.


m_ac

private ConfigurableApplicationContext m_ac
Application context.

Constructor Detail

AuthorizationDistributedTest

public AuthorizationDistributedTest()
Method Detail

setUp

public void setUp()


tearDown

public void tearDown()


testMethodCallWithoutLogin

public void testMethodCallWithoutLogin()
                                throws Exception
Test tries to execute the target method without authentication.

Throws:
Exception - If something.

testCorrectAuthorization

public void testCorrectAuthorization()
                              throws Exception
Test does a correct authorization. Then it does a remote call to the sample service.

Throws:
Exception - If something.

testCorrectAuthorizationAfterLogoutNoAccess

public void testCorrectAuthorizationAfterLogoutNoAccess()
                                                 throws Exception
Test does a correct authorization. Then it does a remote call to the sample service. Afterwards, it logs out, tries to call the method again and fails.

Throws:
Exception - If something.

testFailedAuthorization

public void testFailedAuthorization()
                             throws Exception
Test does a correct login with the wrong role. Then it does a remote call to the sample service. Since the required permission is not given, the call should throw an exception.

Throws:
Exception - If something.

testFailedAuthentication

public void testFailedAuthentication()
                              throws Exception
Test tries to authenticate with a wrong username/password combination. An exception should be thrown.

Throws:
Exception - If something.

getAuthenticationService

private AuthenticationService getAuthenticationService()
Returns:
Returns the authentication service.

getAuthenticationProvider

private ExtendedTestingAuthenticationProvider getAuthenticationProvider()
Returns the authentication provider of the authorization server.

Returns:
The ExtendedTestingAuthenticationProvider of the server.

getSampleService

private SampleService getSampleService()
Returns:
Returns the sample service.

createSecureContext

private void createSecureContext(String principal,
                                 String credential,
                                 String role)
Create a secure context with a TestingAuthenticationToken, i.e. a token where the user can define which roles it possesses.

Parameters:
principal - The username
credential - The password
role - The role

destroySecureContext

private void destroySecureContext(String principal,
                                  String credential)
Delete the secure context, i.e. logging out the user.

Parameters:
principal - Is the principal.
credential - is the credential.


Copyright © 2005-2011 ELCA. All Rights Reserved.