@Test void checkPermissionWhenNoSpecificSchemeCheckerAndAllowed() throws Exception { VfsResourceReference reference = new VfsResourceReference(URI.create("customscheme:whatever"), "whatever"); AuthorizationManager authorizationManager = this.componentManager.registerMockComponent(AuthorizationManager.class); when(authorizationManager.hasAccess(Right.PROGRAM, this.contextUser, null)).thenReturn(true); this.checker.checkPermission(reference); }
@Override public void checkPermission(VfsResourceReference resourceReference) throws VfsException { String scheme = resourceReference.getScheme(); if (HINT.equals(scheme)) { throw new VfsException(String.format("[%s] is a reserved VFS URI scheme and cannot be used.", HINT)); } VfsPermissionChecker resolvedChecker; ComponentManager componentManager = this.componentManagerProvider.get(); try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class, scheme); } catch (ComponentLookupException e) { try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class); } catch (ComponentLookupException ee) { throw new VfsException(String.format("No VFS Permission Checked has been found in the system. " + "Refusing access to VFS URI scheme [%s]", scheme), ee); } } resolvedChecker.checkPermission(resourceReference); }
CascadingVfsPermissionChecker implements VfsPermissionChecker { @Override public void checkPermission(VfsResourceReference resourceReference) throws VfsException { String scheme = resourceReference.getScheme(); if (HINT.equals(scheme)) { throw new VfsException(String.format("[%s] is a reserved VFS URI scheme and cannot be used.", HINT)); } VfsPermissionChecker resolvedChecker; ComponentManager componentManager = this.componentManagerProvider.get(); try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class, scheme); } catch (ComponentLookupException e) { try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class); } catch (ComponentLookupException ee) { throw new VfsException(String.format("No VFS Permission Checked has been found in the system. " + "Refusing access to VFS URI scheme [%s]", scheme), ee); } } resolvedChecker.checkPermission(resourceReference); } }
CascadingVfsPermissionChecker implements VfsPermissionChecker { @Override public void checkPermission(VfsResourceReference resourceReference) throws VfsException { String scheme = resourceReference.getScheme(); if (HINT.equals(scheme)) { throw new VfsException(String.format("[%s] is a reserved VFS URI scheme and cannot be used.", HINT)); } VfsPermissionChecker resolvedChecker; ComponentManager componentManager = this.componentManagerProvider.get(); try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class, scheme); } catch (ComponentLookupException e) { try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class); } catch (ComponentLookupException ee) { throw new VfsException(String.format("No VFS Permission Checked has been found in the system. " + "Refusing access to VFS URI scheme [%s]", scheme), ee); } } resolvedChecker.checkPermission(resourceReference); }  }
CascadingVfsPermissionChecker implements VfsPermissionChecker { @Override public void checkPermission(VfsResourceReference resourceReference) throws VfsException { String scheme = resourceReference.getScheme(); if (HINT.equals(scheme)) { throw new VfsException(String.format("[%s] is a reserved VFS URI scheme and cannot be used.", HINT)); } VfsPermissionChecker resolvedChecker; ComponentManager componentManager = this.componentManagerProvider.get(); try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class, scheme); } catch (ComponentLookupException e) { try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class); } catch (ComponentLookupException ee) { throw new VfsException(String.format("No VFS Permission Checked has been found in the system. " + "Refusing access to VFS URI scheme [%s]", scheme), ee); } } resolvedChecker.checkPermission(resourceReference); }  @Override void checkPermission(VfsResourceReference resourceReference); }
CascadingVfsPermissionChecker implements VfsPermissionChecker { @Override public void checkPermission(VfsResourceReference resourceReference) throws VfsException { String scheme = resourceReference.getScheme(); if (HINT.equals(scheme)) { throw new VfsException(String.format("[%s] is a reserved VFS URI scheme and cannot be used.", HINT)); } VfsPermissionChecker resolvedChecker; ComponentManager componentManager = this.componentManagerProvider.get(); try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class, scheme); } catch (ComponentLookupException e) { try { resolvedChecker = componentManager.getInstance(VfsPermissionChecker.class); } catch (ComponentLookupException ee) { throw new VfsException(String.format("No VFS Permission Checked has been found in the system. " + "Refusing access to VFS URI scheme [%s]", scheme), ee); } } resolvedChecker.checkPermission(resourceReference); }  @Override void checkPermission(VfsResourceReference resourceReference);  }