]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.core/src/org/argeo/security/jcr/NewUserDetails.java
1 package org
.argeo
.security
.jcr
;
3 import java
.util
.ArrayList
;
4 import java
.util
.Collection
;
8 import javax
.jcr
.RepositoryException
;
10 import org
.springframework
.security
.core
.GrantedAuthority
;
11 import org
.springframework
.security
.core
.authority
.SimpleGrantedAuthority
;
12 import org
.springframework
.security
.core
.userdetails
.User
;
14 /** Used to create a new user */
15 public class NewUserDetails
extends User
{
16 private static final long serialVersionUID
= -8331941336984083297L;
18 public NewUserDetails(String username
, char[] password
) {
19 this(username
, password
, null);
22 public NewUserDetails(String username
, char[] password
, String
[] roles
) {
23 super(username
, new String(password
), false, false, false, false,
24 rolesToAuthorities(roles
));
27 /** To be overriden */
28 public void mapToProfileNode(Node userProfile
) throws RepositoryException
{
29 // does nothing by default
32 private static Collection
<GrantedAuthority
> rolesToAuthorities(
34 List
<GrantedAuthority
> authorities
= new ArrayList
<GrantedAuthority
>();
36 for (String role
: roles
) {
37 authorities
.add(new SimpleGrantedAuthority(role
));