use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class SubstituteCareProviderCreateAuthorizerTest method checkInstance_returnFalse_whenPerryPrivilegesAreNull.
@Test
public void checkInstance_returnFalse_whenPerryPrivilegesAreNull() {
final PerryAccount perryAccount = new PerryAccount();
final boolean expectedResult = false;
checkInstance_returnExpected_withPreparedPerryAccount(perryAccount, expectedResult);
}
use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class SubstituteCareProviderCreateAuthorizerTest method checkInstance_returnFalse_whenPerryPrivilegesAreEmpty.
@Test
public void checkInstance_returnFalse_whenPerryPrivilegesAreEmpty() {
final PerryAccount perryAccount = initPerryAccountWithPrivileges();
final boolean expectedResult = false;
checkInstance_returnExpected_withPreparedPerryAccount(perryAccount, expectedResult);
}
use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class AbstractBaseAuthorizer method authorizeInstanceOperation.
protected boolean authorizeInstanceOperation(final T instance, List<Object> authorizationFacts) {
try {
final PerryAccount perryAccount = PerrySubject.getPerryAccount();
final Set<StaffPrivilegeType> staffPrivilegeTypes = toStaffPersonPrivilegeTypes(perryAccount);
if (staffPrivilegeTypes.isEmpty()) {
return false;
}
if (authorizationFacts == null) {
authorizationFacts = new ArrayList<>();
}
authorizationFacts.add(instance);
authorizationFacts.add(perryAccount);
final boolean authorizationResult = droolsAuthorizationService.authorizeObjectOperation(staffPrivilegeTypes, droolsConfiguration, authorizationFacts);
logAuthorization(perryAccount, staffPrivilegeTypes, instance, authorizationResult);
return authorizationResult;
} catch (DroolsException e) {
throw new AuthorizationException(e.getMessage(), e);
}
}
Aggregations