Package org.geomajas.security

Examples of org.geomajas.security.Authentication


  @Test
  public void testTwoFilters() {
    SecurityContextImpl securityContext = (SecurityContextImpl)this.securityContext;
    List<Authentication> authentications = new ArrayList<Authentication>();
    Authentication auth1 = getFilterAuthentication();
    Authentication auth2 = getFilterAuthentication();
    auth2.setSecurityServiceId("ss2");
    authentications.add(auth1);
    authentications.add(auth2);
    securityContext.setAuthentications("token", authentications);
    Filter filter = securityContext.getFeatureFilter(LAYER_ID);
    Assert.assertNotNull(filter);
View Full Code Here


    Assert.assertEquals("org.geotools.filter.AndImpl", filter.getClass().getName());
    Assert.assertEquals("[[ name is like bla% ] AND [ name is like bla% ]]", filter.toString());
  }

  private Authentication getAuthentication() {
    Authentication auth = new Authentication();
    auth.setAuthorizations(new BaseAuthorization[]{new AllowAllAuthorization()});
    auth.setSecurityServiceId(SECURITY_SERVICE_ID);
    auth.setUserId(USER_ID);
    return auth;
  }
View Full Code Here

    auth.setUserId(USER_ID);
    return auth;
  }

  private Authentication getFilterAuthentication() {
    Authentication auth = new Authentication();
    auth.setAuthorizations(new BaseAuthorization[]{new FilterAuthorization()});
    auth.setSecurityServiceId(SECURITY_SERVICE_ID);
    auth.setUserId(USER_ID);
    return auth;
  }
View Full Code Here

  @Autowired
  private StaticSecurityService staticSecurityService;

  @Test
  public void testService() throws Exception {
    Authentication auth = new Authentication();
    String token = tokenService.login(auth);
    Authentication res = staticSecurityService.getAuthentication(token);
    Assert.assertEquals(auth, res);
    tokenService.logout(token);
    res = staticSecurityService.getAuthentication(token);
    Assert.assertNull(res);
  }
View Full Code Here

public class LoginAllowedSecurityServiceTest {

  @Test
  public void testLoginAllowedService() {
    LoginAllowedSecurityService service = new LoginAllowedSecurityService();
    Authentication auth = service.getAuthentication("bla");
    Assert.assertNotNull(auth);
    Assert.assertEquals(1, auth.getAuthorizations().length);
    BaseAuthorization authorization = auth.getAuthorizations()[0];
    Assert.assertTrue(authorization.isCommandAuthorized(LoginRequest.COMMAND));
    Assert.assertTrue(authorization.isCommandAuthorized(LogoutRequest.COMMAND));
    Assert.assertFalse(authorization.isCommandAuthorized("command.staticsecurity.Other"));
  }
View Full Code Here

  @DirtiesContext
  public void testBaseAuthorization() throws Exception {
    SecurityContextImpl securityContext = (SecurityContextImpl)this.securityContext;
    securityContext.setAuthentications(null, null);
    List<Authentication> authentications = new ArrayList<Authentication>();
    Authentication auth1 = getAuthentication(0); // allow nothing
    Authentication auth2 = getAuthentication(1); // base, allow all
    authentications.add(auth1);
    authentications.add(auth2);
    securityContext.setAuthentications("token", authentications);

    InternalFeature feature = new InternalFeatureImpl();
View Full Code Here

  @Test
  @DirtiesContext
  public void testAllAndFeatureAuthorization() throws Exception {
    SecurityContextImpl securityContext = (SecurityContextImpl)this.securityContext;
    List<Authentication> authentications = new ArrayList<Authentication>();
    Authentication auth1 = getAuthentication(1); // base, allow all
    Authentication auth2 = getFeatureAuthentication();
    authentications.add(auth1);
    authentications.add(auth2);
    securityContext.setAuthentications("token", authentications);

    InternalFeature feature = new InternalFeatureImpl();
View Full Code Here

  @Test
  @DirtiesContext
  public void testFeatureAuthorization() throws Exception {
    SecurityContextImpl securityContext = (SecurityContextImpl)this.securityContext;
    List<Authentication> authentications = new ArrayList<Authentication>();
    Authentication auth1 = getAuthentication(0); // allow nothing
    Authentication auth2 = getFeatureAuthentication();
    authentications.add(auth1);
    authentications.add(auth2);
    securityContext.setAuthentications("token", authentications);

    InternalFeature feature = new InternalFeatureImpl();
View Full Code Here

    Assert.assertFalse(securityContext.isFeatureDeleteAuthorized(LAYER_ID, feature));
    Assert.assertTrue(securityContext.isFeatureCreateAuthorized(LAYER_ID, feature));
  }

  private Authentication getAuthentication(int which) {
    Authentication auth = new Authentication();
    auth.setAuthorizations(
        new BaseAuthorization[] {which == 1 ? new AllowAllAuthorization() : new AllowNoneAuthorization()});
    auth.setSecurityServiceId(SECURITY_SERVICE_ID + which);
    auth.setUserId(USER_ID);
    return auth;
  }
View Full Code Here

    auth.setUserId(USER_ID);
    return auth;
  }

  private Authentication getFeatureAuthentication() {
    Authentication auth = new Authentication();
    auth.setAuthorizations(new BaseAuthorization[]{new TestAuthorization()});
    auth.setSecurityServiceId(SECURITY_SERVICE_ID);
    auth.setUserId(USER_ID);
    return auth;
  }
View Full Code Here

TOP

Related Classes of org.geomajas.security.Authentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.