@ServiceDependency(removed = "authorizationHandlerRemoved", required = false) public void authorizationHandlerAdded( ServiceReference<AuthorizationHandler> ref, AuthorizationHandler handler) { System.out.println("Registering Authorization Handler: " + handler.getClass().getName()); authorizationHandlers.put(ref, handler); authorizationInstanceMap.put(handler.getClass().getName(), handler); }
@Override public boolean checkAccess(Request request, String identifier) throws SystemException { AuthorizationHandler authHandler = null; log.debug("Checking access for request " + request.getClass() + " identifier " + identifier); if (request instanceof UploadRequest) { // Upload request handling. log.debug("Handle auth request for upload!"); UploadRequest upRquest = (UploadRequest) request; UploadHandlerMapping mapTo = uploadHandlers.get(upRquest.getDataType()); authHandler = authorizationInstanceMap.get(mapTo.getAuthorizationHandlerClassName()); } else { HandlerMapping requestToHandlerMapping = handlerMapping.get(request.getClass().getName()); authHandler = authorizationInstanceMap.get(requestToHandlerMapping.authorizationHandlerClassName); } if (authHandler == null) { return false; } return authHandler.isAuthorized(request, permissionAdapter.getPermissions(identifier)); }
public void authorizationHandlerRemoved(ServiceReference<AuthorizationHandler> ref) { AuthorizationHandler handler = authorizationHandlers.remove(ref); System.out.println("Un-Registering Authorization Handler: " + handler.getClass().getName()); authorizationInstanceMap.remove(handler.getClass().getName()); }