use of eu.bcvsolutions.idm.core.security.api.dto.DefaultGrantedAuthorityDto in project CzechIdMng by bcvsolutions.
the class JwtAuthenticationMapper method fromDto.
/**
* Converts dto to authentication.
*
* @param dto
* @return
*/
public IdmJwtAuthentication fromDto(IdmJwtAuthenticationDto dto) {
Assert.notNull(dto);
//
Collection<DefaultGrantedAuthorityDto> authorities = dto.getAuthorities();
List<GrantedAuthority> grantedAuthorities = new ArrayList<>();
if (authorities != null) {
for (DefaultGrantedAuthorityDto a : authorities) {
grantedAuthorities.add(new DefaultGrantedAuthority(a.getAuthority()));
}
}
IdmJwtAuthentication authentication = new IdmJwtAuthentication(new IdmIdentityDto(dto.getCurrentIdentityId(), dto.getCurrentUsername()), new IdmIdentityDto(dto.getOriginalIdentityId(), dto.getOriginalUsername()), dto.getExpiration(), dto.getIssuedAt(), grantedAuthorities, dto.getFromModule());
return authentication;
}
use of eu.bcvsolutions.idm.core.security.api.dto.DefaultGrantedAuthorityDto in project CzechIdMng by bcvsolutions.
the class AuthenticationTestUtils method getAuthDto.
public static IdmJwtAuthenticationDto getAuthDto(IdmIdentityDto user, Collection<GrantedAuthority> authorities) {
IdmJwtAuthenticationDto d = new IdmJwtAuthenticationDto();
d.setCurrentUsername(user.getUsername());
d.setCurrentIdentityId(user.getId());
d.setIssuedAt(getIat());
d.setExpiration(getExp());
d.setAuthorities(new ArrayList<>());
d.setFromModule("test");
d.setAuthorities(authorities.stream().map(a -> new DefaultGrantedAuthorityDto(a.toString())).collect(Collectors.toList()));
return d;
}
use of eu.bcvsolutions.idm.core.security.api.dto.DefaultGrantedAuthorityDto in project CzechIdMng by bcvsolutions.
the class JwtAuthenticationMapper method getDtoAuthorities.
/**
* @param authentication
* @return
* @deprecated will be private
*/
@Deprecated
@SuppressWarnings("unchecked")
public List<DefaultGrantedAuthorityDto> getDtoAuthorities(Authentication authentication) {
Collection<DefaultGrantedAuthority> authorities = (Collection<DefaultGrantedAuthority>) authentication.getAuthorities();
List<DefaultGrantedAuthorityDto> grantedAuthorities = new ArrayList<>();
if (authorities != null) {
for (DefaultGrantedAuthority a : authorities) {
grantedAuthorities.add(new DefaultGrantedAuthorityDto(a.getAuthority()));
}
}
return grantedAuthorities;
}
Aggregations