use of org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails 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.SyncopeAuthenticationDetails 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.SyncopeAuthenticationDetails 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.SyncopeAuthenticationDetails in project syncope by apache.
the class DefaultPropagationTaskCallable method call.
@Override
public TaskExec call() throws Exception {
// set security context according to the one gathered at instantiation time from the calling thread
UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new User(username, "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
auth.setDetails(new SyncopeAuthenticationDetails(domain));
SecurityContextHolder.getContext().setAuthentication(auth);
LOG.debug("Execution started for {}", taskTO);
TaskExec execution = executor.execute(taskTO, reporter);
LOG.debug("Execution completed for {}, {}", taskTO, execution);
return execution;
}
use of org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails 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