예제 #1
0
 @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);
 }
예제 #2
0
  @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));
  }
예제 #3
0
  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());
  }