Search in sources :

Example 1 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class BaseDocToolRulesTest method getPrincipal.

private static PerryAccount getPrincipal(String privilege) {
    PerryAccount perryAccount = new PerryAccount();
    Set<String> privileges = new HashSet<>();
    privileges.add(privilege);
    perryAccount.setPrivileges(privileges);
    return perryAccount;
}
Also used : PerryAccount(gov.ca.cwds.security.realm.PerryAccount) HashSet(java.util.HashSet)

Example 2 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class DataAccessServiceBase method update.

@Override
public T update(P entityAwareDTO) throws DataAccessServicesException, DroolsException {
    try {
        DataAccessBundle<P> dataAccessBundle = new DataAccessBundle<>(entityAwareDTO);
        updateLifecycle.beforeDataProcessing(dataAccessBundle);
        PerryAccount perryAccount = PrincipalUtils.getPrincipal();
        updateLifecycle.dataProcessing(dataAccessBundle, perryAccount);
        updateLifecycle.afterDataProcessing(dataAccessBundle);
        updateLifecycle.beforeBusinessValidation(dataAccessBundle);
        updateLifecycle.businessValidation(dataAccessBundle, perryAccount);
        updateLifecycle.afterBusinessValidation(dataAccessBundle);
        T t = crudDao.update(entityAwareDTO.getEntity());
        updateLifecycle.afterStore(dataAccessBundle);
        return t;
    } catch (DroolsException e) {
        throw new DataAccessServicesException(e);
    }
}
Also used : DataAccessBundle(gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle) DroolsException(gov.ca.cwds.drools.DroolsException) PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Example 3 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class DataAccessServiceBase method create.

@Override
public T create(P entityAwareDTO) throws DataAccessServicesException {
    try {
        DataAccessBundle<P> dataAccessBundle = new DataAccessBundle<>(entityAwareDTO);
        createLifecycle.beforeDataProcessing(dataAccessBundle);
        PerryAccount perryAccount = PrincipalUtils.getPrincipal();
        createLifecycle.dataProcessing(dataAccessBundle, perryAccount);
        createLifecycle.afterDataProcessing(dataAccessBundle);
        createLifecycle.beforeBusinessValidation(dataAccessBundle);
        createLifecycle.businessValidation(dataAccessBundle, perryAccount);
        createLifecycle.afterBusinessValidation(dataAccessBundle);
        T t = crudDao.create(entityAwareDTO.getEntity());
        createLifecycle.afterStore(dataAccessBundle);
        return t;
    } catch (DroolsException e) {
        throw new DataAccessServicesException(e);
    }
}
Also used : DataAccessBundle(gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle) DroolsException(gov.ca.cwds.drools.DroolsException) PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Example 4 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class ClientAbstractReadAuthorizerTest method initUserAccount.

private void initUserAccount(String userCountyCwsCode, String userCountyName, String... privileges) {
    final PerryAccount perryAccount = initPerryAccountWithPrivileges(privileges);
    perryAccount.setCountyCwsCode(userCountyCwsCode);
    perryAccount.setCountyName(userCountyName);
    mockStatic(PerrySubject.class);
    when(PerrySubject.getPerryAccount()).thenReturn(perryAccount);
}
Also used : PerryAccount(gov.ca.cwds.security.realm.PerryAccount)

Example 5 with PerryAccount

use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.

the class PlacementHomeCreateAuthorizerTest method checkInstance_returnFalse_whenPerryPrivilegesAreNull.

@Test
public void checkInstance_returnFalse_whenPerryPrivilegesAreNull() {
    final PerryAccount perryAccount = new PerryAccount();
    final boolean expectedResult = false;
    checkInstance_returnExpected_withPreparedPerryAccount(perryAccount, expectedResult);
}
Also used : PerryAccount(gov.ca.cwds.security.realm.PerryAccount) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

PerryAccount (gov.ca.cwds.security.realm.PerryAccount)28 Test (org.junit.Test)18 StaffPrivilegeType (gov.ca.cwds.authorizer.StaffPrivilegeType)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 DroolsException (gov.ca.cwds.drools.DroolsException)3 DataAccessBundle (gov.ca.cwds.cms.data.access.service.lifecycle.DataAccessBundle)2 PlacementHome (gov.ca.cwds.data.legacy.cms.entity.PlacementHome)2 SubstituteCareProvider (gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider)2 HashSet (java.util.HashSet)2 AuthorizationException (org.apache.shiro.authz.AuthorizationException)1 Subject (org.apache.shiro.subject.Subject)1