Package org.springframework.security.core.userdetails.memory

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


        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

        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

        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

    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

  Iterator<Object> it = prop.keySet().iterator();
  while  (it.hasNext()){
    String username = (String)it.next();
    uae.setAsText(prop.getProperty(username));
    UserAttribute attrs = (UserAttribute) uae.getValue();
    if (attrs != null) {
      myDetailStorage.put(username, makeUser(username, attrs));
    }
  }
      }
View Full Code Here

           
            for (Iterator<Object> iter = props.keySet().iterator(); iter.hasNext();) {
                String username = (String) iter.next();
               
                configAttribEd.setAsText(props.getProperty(username));
                UserAttribute attr = (UserAttribute) configAttribEd.getValue();
                if (attr == null) continue;

                // The master password policy is not yet available, the default is to
                // have a minimum of 8 chars --> all passwords shorter than 8 chars
                // are no candidates
                if (attr.getPassword()==null || attr.getPassword().length() <8 )
                    continue;
               
                // The default password is not allowed
                if (defaultPasswordAsString.equals(attr.getPassword()))
                    continue;
               
                // the  user named "admin" having a non default password is the primary candiate               
                if (GeoServerUser.ADMIN_USERNAME.equals(username))  {
                    candidates.put(GeoServerUser.ADMIN_USERNAME,attr.getPassword());
                    continue;
                }

                // other users having the amin role are secondary candidates
                if (attr.getAuthorities().contains(GeoServerRole.ADMIN_ROLE)) {
                    candidates.put(username,attr.getPassword());
                }
            }
        }
       
        String username = GeoServerUser.ADMIN_USERNAME;
View Full Code Here

                // flag
                String username = (String) iter.next();
                configAttribEd.setAsText(props.getProperty(username));

                // if the parsing succeeded turn that into a user object
                UserAttribute attr = (UserAttribute) configAttribEd.getValue();
                if (attr != null) {
                    GeoServerUser user =
                        userGroupStore.createUserObject(username, attr.getPassword(), attr.isEnabled());
                    userGroupStore.addUser(user);

                    for (GrantedAuthority auth : attr.getAuthorities()) {
                        String roleName = GeoServerRole.ADMIN_ROLE.getAuthority().equals(auth.getAuthority()) ?
                                XMLRoleService.DEFAULT_LOCAL_ADMIN_ROLE : auth.getAuthority();
                        GeoServerRole role =
                            roleStore.getRoleByName(roleName);
                        if (role==null) {
View Full Code Here

            // flag
            String username = (String) iter.next();
            configAttribEd.setAsText(props.getProperty(username));

            // if the parsing succeeded turn that into a user object
            UserAttribute attr = (UserAttribute) configAttribEd.getValue();
            if (attr != null) {
                User user = createUserObject(username, attr.getPassword(), attr.isEnabled(), attr.getAuthorities());
                users.put(username, user);
            }
        }
        return users;
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.memory.UserAttribute

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.