use of org.eclipse.scout.rt.shared.servicetunnel.RemoteServiceAccessDenied in project scout.rt by eclipse.
the class RemoteFileService method putRemoteFile.
@Override
@RemoteServiceAccessDenied
@SuppressWarnings("findbugs:RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
public void putRemoteFile(RemoteFile spec) {
File file = getFileInternal(spec);
file.getParentFile().mkdirs();
try (FileOutputStream out = new FileOutputStream(file)) {
spec.writeData(out);
file.setLastModified(file.lastModified());
} catch (Exception e) {
throw new ProcessingException("error writing file: " + file.getAbsoluteFile(), e);
}
}
use of org.eclipse.scout.rt.shared.servicetunnel.RemoteServiceAccessDenied in project scout.rt by eclipse.
the class ServiceOperationInvoker method checkRemoteServiceAccessByAnnotations.
/**
* Check pass 2 on instance
* <p>
* Using blacklist {@link RemoteServiceAccessDenied}
*/
protected void checkRemoteServiceAccessByAnnotations(Class<?> interfaceClass, Class<?> implClass, Method interfaceMethod, Object[] args) {
// check: grant/deny annotation (type level is base, method level is finegrained)
Class<?> c = implClass;
while (c != null) {
// method level
Method m = null;
try {
m = c.getMethod(interfaceMethod.getName(), interfaceMethod.getParameterTypes());
} catch (NoSuchMethodException | RuntimeException t) {
LOG.debug("Could not lookup service method", t);
}
if (m != null && m.isAnnotationPresent(RemoteServiceAccessDenied.class)) {
throw new SecurityException("access denied (code 2b).");
}
// type level
if (c.isAnnotationPresent(RemoteServiceAccessDenied.class)) {
throw new SecurityException("access denied (code 2c).");
}
// next
if (c == interfaceClass) {
break;
}
c = c.getSuperclass();
if (c == Object.class) {
// use interface at last
c = interfaceClass;
}
}
// continue
}
Aggregations