Package org.restlet.security

Examples of org.restlet.security.Role


* @author Thierry Boileau
*/
public class RoleTestCase extends RestletTestCase {

    public void testRoleEquality() {
        Role role1 = new Role("role", "");
        Role role2 = new Role("role", "");
        assertEquals(role1, role2);

        Role role3 = new Role("role3", "");
        Role role4 = new Role("role4", "");

        role1.getChildRoles().add(role3);
        role1.getChildRoles().add(role4);
        assertNotSame(role1, role2);

View Full Code Here


    }

    public SaasApplication(Context context) {
        super(context);

        Role admin = new Role("admin", "Application administrators");
        getRoles().add(admin);

        Role user = new Role("user", "Application users");
        getRoles().add(user);
    }
View Full Code Here

     *         request belongs to a given role; <code>false</code> if the user
     *         has not been authenticated
     * @see SecurityContext#isUserInRole(String)
     */
    public boolean isUserInRole(String roleName) {
        Role role = Application.getCurrent().getRole(roleName);
        return (role != null)
                && this.request.getClientInfo().getRoles().contains(role);
    }
View Full Code Here

            throw new IllegalArgumentException("Role name cannot contain space");
        return rname;
    }

    public static Role toRole(String scope) {
        return new Role(scope, null);
    }
View Full Code Here

    public static List<Role> toRoles(String scopes) {
        String[] tmp = parseScope(scopes);
        List<Role> toRet = new ArrayList<Role>(tmp.length);
        for (String scope : tmp) {
            toRet.add(new Role(scope, null));
        }
        return toRet;
    }
View Full Code Here

TOP

Related Classes of org.restlet.security.Role

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.