Search in sources :

Example 1 with Authorize

use of gov.ca.cwds.security.annotations.Authorize in project perry by ca-cwds.

the class TestServiceImpl method testFilter.

@Override
@Authorize("case:read:caseDTO.caseObject.id")
public List<CaseDTO> testFilter() {
    List<CaseDTO> result = new ArrayList<>();
    CaseDTO caseDTO = new CaseDTO();
    caseDTO.setCaseObject(new Case(1L, "valid"));
    result.add(caseDTO);
    caseDTO = new CaseDTO();
    caseDTO.setCaseObject(new Case(2L, "name"));
    result.add(caseDTO);
    return result;
}
Also used : CaseDTO(gov.ca.cwds.testapp.domain.CaseDTO) ArrayList(java.util.ArrayList) Case(gov.ca.cwds.testapp.domain.Case) Authorize(gov.ca.cwds.security.annotations.Authorize)

Example 2 with Authorize

use of gov.ca.cwds.security.annotations.Authorize in project perry by ca-cwds.

the class AbacMethodInterceptor method checkParametersPermissions.

private void checkParametersPermissions(MethodInvocation methodInvocation) throws ScriptException {
    Parameter[] parameters = methodInvocation.getMethod().getParameters();
    for (int i = 0; i < parameters.length; i++) {
        Authorize authorize = parameters[i].getAnnotation(Authorize.class);
        if (authorize != null) {
            Object arg = methodInvocation.getArguments()[i];
            checkPermissions(authorize, arg);
        }
    }
}
Also used : Parameter(java.lang.reflect.Parameter) Authorize(gov.ca.cwds.security.annotations.Authorize)

Example 3 with Authorize

use of gov.ca.cwds.security.annotations.Authorize in project perry by ca-cwds.

the class TestServiceImpl method testReturnProtectedInstance.

@Override
@Authorize("case:read:caseDTO.caseObject.id")
public CaseDTO testReturnProtectedInstance() {
    Case caseObject = new Case(2L, "");
    CaseDTO caseDTO = new CaseDTO();
    caseDTO.setCaseObject(caseObject);
    return caseDTO;
}
Also used : CaseDTO(gov.ca.cwds.testapp.domain.CaseDTO) Case(gov.ca.cwds.testapp.domain.Case) Authorize(gov.ca.cwds.security.annotations.Authorize)

Example 4 with Authorize

use of gov.ca.cwds.security.annotations.Authorize in project perry by ca-cwds.

the class TestServiceImpl method testReturnInstance.

@Override
@Authorize("case:read:caseDTO.caseObject")
public CaseDTO testReturnInstance() {
    Case caseObject = new Case(1L, "");
    CaseDTO caseDTO = new CaseDTO();
    caseDTO.setCaseObject(caseObject);
    return caseDTO;
}
Also used : CaseDTO(gov.ca.cwds.testapp.domain.CaseDTO) Case(gov.ca.cwds.testapp.domain.Case) Authorize(gov.ca.cwds.security.annotations.Authorize)

Aggregations

Authorize (gov.ca.cwds.security.annotations.Authorize)4 Case (gov.ca.cwds.testapp.domain.Case)3 CaseDTO (gov.ca.cwds.testapp.domain.CaseDTO)3 Parameter (java.lang.reflect.Parameter)1 ArrayList (java.util.ArrayList)1