Search in sources :

Example 6 with SecurityFunctionEntity

use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.

the class SecurityFunctionDaoTest method createSecurityFunctionEntity.

/**
 * Creates and persists a security function entity.
 *
 * @param code the name of the security function role
 *
 * @return the security role entity
 */
private SecurityFunctionEntity createSecurityFunctionEntity(String code) {
    SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
    securityFunctionEntity.setCode(code);
    return herdDao.saveAndRefresh(securityFunctionEntity);
}
Also used : SecurityFunctionEntity(org.finra.herd.model.jpa.SecurityFunctionEntity)

Example 7 with SecurityFunctionEntity

use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.

the class HttpHeaderAuthenticationFilterTest method setupTestFunctions.

private void setupTestFunctions(String roleId) {
    SecurityRoleEntity securityRoleEntity = new SecurityRoleEntity();
    securityRoleEntity.setCode(roleId);
    herdDao.saveAndRefresh(securityRoleEntity);
    for (String function : TEST_FUNCTIONS) {
        SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
        securityFunctionEntity.setCode(function);
        herdDao.saveAndRefresh(securityFunctionEntity);
        SecurityRoleFunctionEntity securityRoleFunctionEntity = new SecurityRoleFunctionEntity();
        securityRoleFunctionEntity.setSecurityRole(securityRoleEntity);
        securityRoleFunctionEntity.setSecurityFunction(securityFunctionEntity);
        herdDao.saveAndRefresh(securityRoleFunctionEntity);
    }
}
Also used : SecurityRoleFunctionEntity(org.finra.herd.model.jpa.SecurityRoleFunctionEntity) SecurityFunctionEntity(org.finra.herd.model.jpa.SecurityFunctionEntity) SecurityRoleEntity(org.finra.herd.model.jpa.SecurityRoleEntity)

Example 8 with SecurityFunctionEntity

use of org.finra.herd.model.jpa.SecurityFunctionEntity in project herd by FINRAOS.

the class SecurityHelperTest method testGetUnrestrictedFunctions.

@Test
public void testGetUnrestrictedFunctions() {
    // Create a security function not mapped to any of the security roles.
    SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity();
    securityFunctionEntity.setCode(SECURITY_FUNCTION);
    herdDao.saveAndRefresh(securityFunctionEntity);
    // Clear the cache.
    cacheManager.getCache(DaoSpringModuleConfig.HERD_CACHE_NAME).clear();
    // Get unrestricted functions.
    Set<GrantedAuthority> result = securityHelper.getUnrestrictedFunctions();
    // Validate that result list contains the test security function.
    assertTrue(result.contains(new SimpleGrantedAuthority(SECURITY_FUNCTION)));
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SecurityFunctionEntity(org.finra.herd.model.jpa.SecurityFunctionEntity) Test(org.junit.Test) AbstractAppTest(org.finra.herd.app.AbstractAppTest)

Aggregations

SecurityFunctionEntity (org.finra.herd.model.jpa.SecurityFunctionEntity)8 SecurityRoleFunctionEntity (org.finra.herd.model.jpa.SecurityRoleFunctionEntity)5 SecurityRoleEntity (org.finra.herd.model.jpa.SecurityRoleEntity)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)3 Test (org.junit.Test)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 AbstractAppTest (org.finra.herd.app.AbstractAppTest)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1