- public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException {
- boolean authorized = false;
-
- Date startTime = new Date();
- LoggingUtils.setTargetContext("CLDS", "isAuthorized");
- LoggingUtils.setTimeContext(startTime, new Date());
-
- securityLogger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission);
-
- // check if the user has the permission key or the permission key with a
- // combination of all instance and/or all action.
- if (securityContext.isUserInRole(inPermission.getKey())) {
- securityLogger.info("{} authorized for permission: {}", getPrincipalName(), inPermission.getKey());
- authorized = true;
- // the rest of these don't seem to be required - isUserInRole method
- // appears to take * as a wildcard
- } else if (securityContext.isUserInRole(inPermission.getKeyAllInstance())) {
- securityLogger.info("{} authorized because user has permission with * for instance: {}", getPrincipalName(), inPermission.getKey());
- authorized = true;
- } else if (securityContext.isUserInRole(inPermission.getKeyAllInstanceAction())) {
- securityLogger.info("{} authorized because user has permission with * for instance and * for action: {}", getPrincipalName(), inPermission.getKey());
- authorized = true;
- } else if (securityContext.isUserInRole(inPermission.getKeyAllAction())) {
- securityLogger.info("{} authorized because user has permission with * for action: {}", getPrincipalName(), inPermission.getKey());
- authorized = true;
- } else {
- String msg = getPrincipalName() + " does not have permission: " + inPermission;
- LoggingUtils.setErrorContext("100", "Authorization Error");
- securityLogger.warn(msg);
- throw new NotAuthorizedException(msg);
- }
- return authorized;
- }
+ public boolean isAuthorized(SecureServicePermission inPermission) throws NotAuthorizedException {
+ Date startTime = new Date();
+ LoggingUtils.setTargetContext("CLDS", "isAuthorized");
+ LoggingUtils.setTimeContext(startTime, new Date());
+ securityLogger.debug("checking if {} has permission: {}", getPrincipalName(), inPermission);
+ try {
+ return isUserPermitted(inPermission);
+ } catch (NotAuthorizedException nae) {
+ String msg = getPrincipalName() + " does not have permission: " + inPermission;
+ LoggingUtils.setErrorContext("100", "Authorization Error");
+ securityLogger.warn(msg);
+ throw new NotAuthorizedException(msg);
+ }
+ }