Search in sources :

Example 6 with SyncopeAuthenticationDetails

use of org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails in project syncope by apache.

the class ResourceDataBinderTest 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);
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) Autowired(org.springframework.beans.factory.annotation.Autowired) HashSet(java.util.HashSet) AnyTypeKind(org.apache.syncope.common.lib.types.AnyTypeKind) AfterAll(org.junit.jupiter.api.AfterAll) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) BeforeAll(org.junit.jupiter.api.BeforeAll) ItemTO(org.apache.syncope.common.lib.to.ItemTO) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) SyncopeAuthenticationDetails(org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) MappingTO(org.apache.syncope.common.lib.to.MappingTO) PlainSchemaDAO(org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO) Set(java.util.Set) ResourceDataBinder(org.apache.syncope.core.provisioning.api.data.ResourceDataBinder) Collectors(java.util.stream.Collectors) AnyTypeDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeDAO) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Test(org.junit.jupiter.api.Test) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) List(java.util.List) MappingPurpose(org.apache.syncope.common.lib.types.MappingPurpose) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) Transactional(org.springframework.transaction.annotation.Transactional) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) SyncopeAuthenticationDetails(org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

SyncopeAuthenticationDetails (org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails)6 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 SyncopeConstants (org.apache.syncope.common.lib.SyncopeConstants)5 StandardEntitlement (org.apache.syncope.common.lib.types.StandardEntitlement)5 SyncopeGrantedAuthority (org.apache.syncope.core.spring.security.SyncopeGrantedAuthority)5 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)5 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)5 Test (org.junit.jupiter.api.Test)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 GrantedAuthority (org.springframework.security.core.GrantedAuthority)5 SecurityContextHolder (org.springframework.security.core.context.SecurityContextHolder)5 Transactional (org.springframework.transaction.annotation.Transactional)5 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)4 HashSet (java.util.HashSet)3 Set (java.util.Set)3 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)3 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)3 PlainSchemaDAO (org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO)3