@Test public void testCreate() { UsernamePasswordAuthenticationTokenFactory factory = new UsernamePasswordAuthenticationTokenFactory(); User u = new User("username", "pass", "salt", "role"); UsernamePasswordAuthenticationToken auth = factory.create(u); assertNotNull(auth); assertEquals(u.getUsername(), auth.getPrincipal().toString()); assertEquals(u.getPassword(), auth.getCredentials().toString()); assertEquals(u.getRole(), auth.getAuthorities().toArray()[0].toString()); }
public UsernamePasswordAuthenticationToken create(User u) { SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(u.getRole()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), Arrays.asList(simpleGrantedAuthority)); return authentication; }
UsernamePasswordAuthenticationTokenFactory { public UsernamePasswordAuthenticationToken create(User u) { SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(u.getRole()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), Arrays.asList(simpleGrantedAuthority)); return authentication; } }
UsernamePasswordAuthenticationTokenFactory { public UsernamePasswordAuthenticationToken create(User u) { SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(u.getRole()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), Arrays.asList(simpleGrantedAuthority)); return authentication; }  }
UsernamePasswordAuthenticationTokenFactory { public UsernamePasswordAuthenticationToken create(User u) { SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(u.getRole()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), Arrays.asList(simpleGrantedAuthority)); return authentication; }  UsernamePasswordAuthenticationToken create(User u); }
UsernamePasswordAuthenticationTokenFactory { public UsernamePasswordAuthenticationToken create(User u) { SimpleGrantedAuthority simpleGrantedAuthority = new SimpleGrantedAuthority(u.getRole()); UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), Arrays.asList(simpleGrantedAuthority)); return authentication; }  UsernamePasswordAuthenticationToken create(User u);  }