AuthorityGranter.grant now returns a java.util.Set of role names, instead of a single role name
This commit is contained in:
@@ -141,13 +141,16 @@ public class JaasAuthenticationProviderTests extends TestCase {
|
||||
|
||||
List list = Arrays.asList(auth.getAuthorities());
|
||||
|
||||
assertTrue("GrantedAuthorities does not contain ROLE_TEST",
|
||||
list.contains(new GrantedAuthorityImpl("ROLE_TEST")));
|
||||
assertTrue("GrantedAuthorities should contain ROLE_TEST1",
|
||||
list.contains(new GrantedAuthorityImpl("ROLE_TEST1")));
|
||||
|
||||
assertTrue("GrantedAuthorities does not contain ROLE_1",
|
||||
assertTrue("GrantedAuthorities should contain ROLE_TEST2",
|
||||
list.contains(new GrantedAuthorityImpl("ROLE_TEST2")));
|
||||
|
||||
assertTrue("GrantedAuthorities should contain ROLE_1",
|
||||
list.contains(role1));
|
||||
|
||||
assertTrue("GrantedAuthorities does not contain ROLE_2",
|
||||
assertTrue("GrantedAuthorities should contain ROLE_2",
|
||||
list.contains(role2));
|
||||
|
||||
boolean foundit = false;
|
||||
@@ -195,8 +198,8 @@ public class JaasAuthenticationProviderTests extends TestCase {
|
||||
assertTrue(jaasProvider.supports(UsernamePasswordAuthenticationToken.class));
|
||||
|
||||
Authentication auth = jaasProvider.authenticate(token);
|
||||
assertTrue("Only ROLE_TEST should have been returned",
|
||||
auth.getAuthorities().length == 1);
|
||||
assertTrue("Only ROLE_TEST1 and ROLE_TEST2 should have been returned",
|
||||
auth.getAuthorities().length == 2);
|
||||
}
|
||||
|
||||
public void testGetApplicationContext() throws Exception {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2004 Acegi Technology Pty Limited
|
||||
/* Copyright 2004, 2005 Acegi Technology Pty Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,9 @@ package net.sf.acegisecurity.providers.jaas;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* DOCUMENT ME!
|
||||
@@ -27,13 +30,14 @@ import java.security.Principal;
|
||||
public class TestAuthorityGranter implements AuthorityGranter {
|
||||
//~ Methods ================================================================
|
||||
|
||||
public String grant(Principal principal) {
|
||||
String role = null;
|
||||
public Set grant(Principal principal) {
|
||||
Set rtnSet = new HashSet();
|
||||
|
||||
if (principal.getName().equals("TEST_PRINCIPAL")) {
|
||||
role = "ROLE_TEST";
|
||||
rtnSet.add("ROLE_TEST1");
|
||||
rtnSet.add("ROLE_TEST2");
|
||||
}
|
||||
|
||||
return role;
|
||||
return rtnSet;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user