Search in sources :

Example 1 with RemoteServiceAccessDenied

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);
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) File(java.io.File) RemoteFile(org.eclipse.scout.rt.shared.services.common.file.RemoteFile) IOException(java.io.IOException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) ProcessingException(org.eclipse.scout.rt.platform.exception.ProcessingException) RemoteServiceAccessDenied(org.eclipse.scout.rt.shared.servicetunnel.RemoteServiceAccessDenied)

Example 2 with RemoteServiceAccessDenied

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
}
Also used : RemoteServiceAccessDenied(org.eclipse.scout.rt.shared.servicetunnel.RemoteServiceAccessDenied) Method(java.lang.reflect.Method)

Aggregations

RemoteServiceAccessDenied (org.eclipse.scout.rt.shared.servicetunnel.RemoteServiceAccessDenied)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 ProcessingException (org.eclipse.scout.rt.platform.exception.ProcessingException)1 RemoteFile (org.eclipse.scout.rt.shared.services.common.file.RemoteFile)1