use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class ClientConditionUtils method toClientCondition.
// TODO(dd): Consider to move this to drools
/**
* @param sensitivity sensitivity
* @param clientCountyCodes client county codes
* @return client condition
*/
public static ClientCondition toClientCondition(Sensitivity sensitivity, List<Short> clientCountyCodes) {
final PerryAccount perryAccount = PerrySubject.getPerryAccount();
final Short staffPersonCountyCode = getStaffPersonCountyCode(perryAccount.getCountyCwsCode());
if (sensitivity == null || sensitivity == Sensitivity.NOT_APPLICABLE) {
return ClientCondition.NO_CONDITIONS;
}
return sensitivity == Sensitivity.SENSITIVE ? getConditionWhenSensitive(clientCountyCodes, staffPersonCountyCode) : getConditionWhenSealed(clientCountyCodes, staffPersonCountyCode);
}
use of gov.ca.cwds.security.realm.PerryAccount in project perry by ca-cwds.
the class PrincipalUtils method getPrincipal.
public static PerryAccount getPrincipal() {
Optional<PerryAccount> perryAccount = Optional.empty();
Subject currentUser = SecurityUtils.getSubject();
if (currentUser.getPrincipals() != null) {
perryAccount = currentUser.getPrincipals().asList().stream().filter(principal -> principal instanceof PerryAccount).findAny();
}
return perryAccount.orElseThrow(IllegalStateException::new);
}
use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class PlacementHomeCreateAuthorizerTest 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 StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_empty_whenUnknownPerryPrivileges.
@Test
public void toStaffPersonPrivilegeTypes_empty_whenUnknownPerryPrivileges() {
// given
final PerryAccount input = initPerryAccountWithPrivileges("a", "bbb");
// when
final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
// then
assertThat(actual.isEmpty(), is(true));
}
use of gov.ca.cwds.security.realm.PerryAccount in project api-core by ca-cwds.
the class StaffPrivilegeUtilTest method toStaffPersonPrivilegeTypes_success_whenSocialWorker.
@Test
public void toStaffPersonPrivilegeTypes_success_whenSocialWorker() {
// given
final PerryAccount input = initPerryAccountWithPrivileges("CWS Case Management System");
// when
final Set<StaffPrivilegeType> actual = StaffPrivilegeUtil.toStaffPersonPrivilegeTypes(input);
// then
assertThat(actual.size(), is(1));
assertThat(actual, contains(SOCIAL_WORKER_ONLY));
}
Aggregations