Examples of UserAttribute


Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testEmptyStringReturnsNull() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText("");

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user == null);
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testEnabledKeyword() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText("password,ROLE_ONE,enabled,ROLE_TWO");

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user.isValid());
        assertTrue(user.isEnabled());
        assertEquals("password", user.getPassword());
        assertEquals(2, user.getAuthorities().size());
        assertEquals("ROLE_ONE", user.getAuthorities().get(0).getAuthority());
        assertEquals("ROLE_TWO", user.getAuthorities().get(1).getAuthority());
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testMalformedStringReturnsNull() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText("MALFORMED_STRING");

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user == null);
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testNoPasswordOrRolesReturnsNull() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText("disabled");

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user == null);
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testNoRolesReturnsNull() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText("password,enabled");

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user == null);
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    public void testNullReturnsNull() {
        UserAttributeEditor editor = new UserAttributeEditor();
        editor.setAsText(null);

        UserAttribute user = (UserAttribute) editor.getValue();
        assertTrue(user == null);
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

        UserAttributeEditor editor = new UserAttributeEditor();

        while(names.hasMoreElements()) {
            String name = (String) names.nextElement();
            editor.setAsText(users.getProperty(name));
            UserAttribute attr = (UserAttribute) editor.getValue();
            UserDetails user = new User(name, attr.getPassword(), attr.isEnabled(), true, true, true,
                    attr.getAuthorities());
            createUser(user);
        }
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

        SecurityContextHolder.clearContext();
    }

    @Test(expected=IllegalArgumentException.class)
    public void testDetectsMissingKey() throws Exception {
        UserAttribute user = new UserAttribute();
        user.setPassword("anonymousUsername");
        user.addAuthority(new SimpleGrantedAuthority("ROLE_ANONYMOUS"));

        AnonymousAuthenticationFilter filter = new AnonymousAuthenticationFilter();
        filter.setUserAttribute(user);
        filter.afterPropertiesSet();
    }
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

        assertEquals(originalAuth, SecurityContextHolder.getContext().getAuthentication());
    }

    @Test
    public void testOperationWhenNoAuthenticationInSecurityContextHolder() throws Exception {
        UserAttribute user = new UserAttribute();
        user.setPassword("anonymousUsername");
        user.addAuthority(new SimpleGrantedAuthority("ROLE_ANONYMOUS"));

        AnonymousAuthenticationFilter filter = new AnonymousAuthenticationFilter();
        filter.setKey("qwerty");
        filter.setUserAttribute(user);
        filter.afterPropertiesSet();
View Full Code Here

Examples of org.springframework.security.core.userdetails.memory.UserAttribute

    while (names.hasMoreElements()) {
      String name = (String) names.nextElement();
      if (name.startsWith(prefix)) {
        editor.setAsText(properties.getProperty(name));
        final UserAttribute attr = (UserAttribute) editor.getValue();
        // rename the name after the editor extracted the attributes
        name = name.replaceFirst(prefix, "");
        final UserDetails user = new User(name, attr.getPassword(), attr.isEnabled(), true, true, true, attr.getAuthorities());
       
        users.add(user);
      }
    }
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.