use of org.apache.syncope.core.spring.security.SyncopeGrantedAuthority in project syncope by apache.
the class MultitenancyTest method setAuthContext.
@BeforeAll
public static void setAuthContext() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Two"));
SecurityContextHolder.getContext().setAuthentication(auth);
}
use of org.apache.syncope.core.spring.security.SyncopeGrantedAuthority in project syncope by apache.
the class ResourceTest method findAll.
@Test
public void findAll() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Master"));
SecurityContextHolder.getContext().setAuthentication(auth);
try {
List<ExternalResource> resources = resourceDAO.findAll();
assertNotNull(resources);
assertFalse(resources.isEmpty());
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of org.apache.syncope.core.spring.security.SyncopeGrantedAuthority in project syncope by apache.
the class ConnInstanceTest method findAll.
@Test
public void findAll() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Master"));
SecurityContextHolder.getContext().setAuthentication(auth);
try {
List<ConnInstance> connectors = connInstanceDAO.findAll();
assertNotNull(connectors);
assertFalse(connectors.isEmpty());
} finally {
SecurityContextHolder.getContext().setAuthentication(null);
}
}
use of org.apache.syncope.core.spring.security.SyncopeGrantedAuthority in project syncope by apache.
the class CustomJWTSSOProvider method resolve.
@Transactional(readOnly = true)
@Override
public Pair<User, Set<SyncopeGrantedAuthority>> resolve(final JwtClaims jwtClaims) {
AttributeCond userIdCond = new AttributeCond();
userIdCond.setSchema("userId");
userIdCond.setType(AttributeCond.Type.EQ);
userIdCond.setExpression(jwtClaims.getSubject());
List<User> matching = searchDAO.search(SearchCond.getLeafCond(userIdCond), AnyTypeKind.USER);
if (matching.size() == 1) {
User user = matching.get(0);
Set<SyncopeGrantedAuthority> authorities = authDataAccessor.getAuthorities(user.getUsername());
return Pair.of(user, authorities);
}
return null;
}
use of org.apache.syncope.core.spring.security.SyncopeGrantedAuthority in project syncope by apache.
the class PlainSchemaTest method setAuthContext.
@BeforeAll
public static void setAuthContext() {
List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails("Master"));
SecurityContextHolder.getContext().setAuthentication(auth);
}
Aggregations