use of net.sf.acegisecurity.providers.dao.User in project alfresco-repository by Alfresco.
the class AbstractAuthenticationComponent method setCurrentUserImpl.
/**
* Explicitly set the current user to be authenticated.
*
* @param userName
* String
* @return Authentication
*/
private Authentication setCurrentUserImpl(String userName) throws AuthenticationException {
if (userName == null) {
throw new AuthenticationException("Null user name");
}
if (isSystemUserName(userName)) {
return setSystemUserAsCurrentUser(getUserDomain(userName));
}
try {
UserDetails ud = null;
if (isGuestUserName(userName)) {
String tenantDomain = getUserDomain(userName);
if (logger.isTraceEnabled()) {
logger.trace("Setting the current user to the guest user of tenant domain \"" + tenantDomain + '"');
}
GrantedAuthority[] gas = new GrantedAuthority[0];
ud = new User(userName, "", true, true, true, true, gas);
} else {
if (logger.isTraceEnabled()) {
logger.trace("Setting the current user to \"" + AuthenticationUtil.maskUsername(userName) + '"');
}
ud = getUserDetails(userName);
if (!userName.equals(ud.getUsername())) {
ud = new User(userName, ud.getPassword(), ud.isEnabled(), ud.isAccountNonExpired(), ud.isCredentialsNonExpired(), ud.isAccountNonLocked(), ud.getAuthorities());
}
}
return setUserDetails(ud);
} catch (net.sf.acegisecurity.AuthenticationException ae) {
throw new AuthenticationException(ae.getMessage(), ae);
}
}
use of net.sf.acegisecurity.providers.dao.User in project alfresco-repository by Alfresco.
the class AbstractAuthenticationComponent method getUserDetails.
/**
* Default implementation that makes an ACEGI object on the fly
*
* @param userName String
* @return UserDetails
*/
protected UserDetails getUserDetails(String userName) {
GrantedAuthority[] gas = new GrantedAuthority[1];
gas[0] = new GrantedAuthorityImpl("ROLE_AUTHENTICATED");
UserDetails ud = new User(userName, "", true, true, true, true, gas);
return ud;
}
use of net.sf.acegisecurity.providers.dao.User in project alfresco-repository by Alfresco.
the class TestAuthenticationServiceImpl method getUserDetails.
/**
* Default implementation that makes an ACEGI object on the fly
*
* @param userName
* @return
*/
protected UserDetails getUserDetails(String userName) {
GrantedAuthority[] gas = new GrantedAuthority[1];
gas[0] = new GrantedAuthorityImpl("ROLE_AUTHENTICATED");
UserDetails ud = new User(userName, "", true, true, true, true, gas);
return ud;
}
use of net.sf.acegisecurity.providers.dao.User in project alfresco-repository by Alfresco.
the class AuthenticationContextImpl method setSystemUserAsCurrentUser.
public Authentication setSystemUserAsCurrentUser(String tenantDomain) {
GrantedAuthority[] gas = new GrantedAuthority[1];
gas[0] = new GrantedAuthorityImpl("ROLE_SYSTEM");
return setUserDetails(new User(getSystemUserName(tenantDomain), "", true, true, true, true, gas));
}
use of net.sf.acegisecurity.providers.dao.User in project alfresco-repository by Alfresco.
the class PermissionServiceImpl method getCoreAuthorisations.
/**
* Get the core authorisations for this {@code auth}. If {@code null} this
* will be an empty set. Otherwise it will be a Lazy loaded Set of authorities
* from the authority node structure PLUS any granted authorities.
*/
protected Set<String> getCoreAuthorisations(Authentication auth) {
if (auth == null) {
return Collections.<String>emptySet();
}
User user = (User) auth.getPrincipal();
String username = user.getUsername();
Set<String> auths = authorityService.getAuthoritiesForUser(username);
auths.add(username);
for (GrantedAuthority grantedAuthority : auth.getAuthorities()) {
auths.add(grantedAuthority.getAuthority());
}
return auths;
}
Aggregations