Java Code Examples for java.sql.SQLPermission

The following examples show how to use java.sql.SQLPermission. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gemfirexd-oss   Source File: ClientConnection.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void abort(Executor executor) throws SQLException {
  // no locking here since it is supposed to be used by admins when the socket
  // may be already in use
  checkClosedConnection();
  // check permission
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(new SQLPermission("callAbort"));
  }
  if (executor == null) {
    throw ThriftExceptionUtil.newSQLException(
        SQLState.LANG_UNEXPECTED_USER_EXCEPTION, null,
        "ClientConnection.abort: null executor passed");
  }
  executor.execute(new Runnable() {
    @Override
    public void run() {
      // input and output protocol are identical in our usage
      clientService.getInputProtocol().getTransport().close();
    }
  });
  this.isOpen = false;
}
 
Example 2
Source Project: gemfirexd-oss   Source File: ClientConnection.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void abort(Executor executor) throws SQLException {
  // no locking here since it is supposed to be used by admins when the socket
  // may be already in use
  checkClosedConnection();
  // check permission
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(new SQLPermission("callAbort"));
  }
  if (executor == null) {
    throw ThriftExceptionUtil.newSQLException(
        SQLState.LANG_UNEXPECTED_USER_EXCEPTION, null,
        "ClientConnection.abort: null executor passed");
  }
  executor.execute(new Runnable() {
    @Override
    public void run() {
      // input and output protocol are identical in our usage
      clientService.getInputProtocol().getTransport().close();
    }
  });
  this.isOpen = false;
}
 
Example 3
Source Project: ignite   Source File: JdbcThinConnection.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override public void setNetworkTimeout(Executor executor, int ms) throws SQLException {
    ensureNotClosed();

    if (ms < 0)
        throw new SQLException("Network timeout cannot be negative.");

    SecurityManager secMgr = System.getSecurityManager();

    if (secMgr != null)
        secMgr.checkPermission(new SQLPermission(SET_NETWORK_TIMEOUT_PERM));

    netTimeout = ms;

    if (partitionAwareness) {
        for (JdbcThinTcpIo clioIo : ios.values())
            clioIo.timeout(ms);
    }
    else
        singleIo.timeout(ms);
}
 
Example 4
Source Project: dragonwell8_jdk   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 5
Source Project: TencentKona-8   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 6
Source Project: jdk8u60   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 7
Source Project: openjdk-jdk8u   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 8
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 9
Source Project: openjdk-jdk9   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 10
Source Project: jdk8u-jdk   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 11
Source Project: hottub   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 12
Source Project: gemfirexd-oss   Source File: ClientConnection.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setNetworkTimeout(Executor executor, int milliseconds)
    throws SQLException {
  // no locking here since it is supposed to be used by admins when the socket
  // may be already in use
  checkClosedConnection();
  // check permission
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(new SQLPermission("setNetworkTimeout"));
  }
  setTimeout(milliseconds);
}
 
Example 13
Source Project: jdk8u_jdk   Source File: TestPolicy.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TestPolicy(String policy) {

        switch (policy) {
            case "all":
                permissions.add(new AllPermission());
                break;
            case "setLog":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setLog"));
                break;
            case "deregisterDriver":
                setMinimalPermissions();
                permissions.add(new SQLPermission("deregisterDriver"));
                break;
            case "setSyncFactory":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                break;
            case "setSyncFactoryLogger":
                setMinimalPermissions();
                permissions.add(new SQLPermission("setSyncFactory"));
                permissions.add(new LoggingPermission("control", null));
                break;
            default:
                setMinimalPermissions();
        }
    }
 
Example 14
Source Project: gemfirexd-oss   Source File: ClientConnection.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setNetworkTimeout(Executor executor, int milliseconds)
    throws SQLException {
  // no locking here since it is supposed to be used by admins when the socket
  // may be already in use
  checkClosedConnection();
  // check permission
  SecurityManager sm = System.getSecurityManager();
  if (sm != null) {
    sm.checkPermission(new SQLPermission("setNetworkTimeout"));
  }
  setTimeout(milliseconds);
}
 
Example 15
Source Project: onos   Source File: DefaultPolicyBuilder.java    License: Apache License 2.0 4 votes vote down vote up
public static org.onosproject.security.Permission getOnosPermission(Permission permission) {
    if (permission instanceof AppPermission) {
        return new org.onosproject.security.Permission(AppPermission.class.getName(), permission.getName(), "");
    } else if (permission instanceof FilePermission) {
        return new org.onosproject.security.Permission(
                FilePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof SerializablePermission) {
        return new org.onosproject.security.Permission(
                SerializablePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof NetPermission) {
        return new org.onosproject.security.Permission(
                NetPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof RuntimePermission) {
        return new org.onosproject.security.Permission(
                RuntimePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof SocketPermission) {
        return new org.onosproject.security.Permission(
                SocketPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof SQLPermission) {
        return new org.onosproject.security.Permission(
                SQLPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof PropertyPermission) {
        return new org.onosproject.security.Permission(
                PropertyPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof LoggingPermission) {
        return new org.onosproject.security.Permission(
                LoggingPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof SSLPermission) {
        return new org.onosproject.security.Permission(
                SSLPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof AuthPermission) {
        return new org.onosproject.security.Permission(
                AuthPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof PrivateCredentialPermission) {
        return new org.onosproject.security.Permission(
                PrivateCredentialPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof DelegationPermission) {
        return new org.onosproject.security.Permission(
                DelegationPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof javax.security.auth.kerberos.ServicePermission) {
        return new org.onosproject.security.Permission(
                javax.security.auth.kerberos.ServicePermission.class.getName(), permission.getName(),
                permission.getActions());
    } else if (permission instanceof AudioPermission) {
        return new org.onosproject.security.Permission(
                AudioPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof AdaptPermission) {
        return new org.onosproject.security.Permission(
                AdaptPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof BundlePermission) {
        return new org.onosproject.security.Permission(
                BundlePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof CapabilityPermission) {
        return new org.onosproject.security.Permission(
                CapabilityPermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof PackagePermission) {
        return new org.onosproject.security.Permission(
                PackagePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof ServicePermission) {
        return new org.onosproject.security.Permission(
                ServicePermission.class.getName(), permission.getName(), permission.getActions());
    } else if (permission instanceof AdminPermission) {
        return new org.onosproject.security.Permission(
                AdminPermission.class.getName(), permission.getName(), permission.getActions());
    //} else if (permission instanceof ConfigurationPermission) {
    //    return new org.onosproject.security.Permission(
    //            ConfigurationPermission.class.getName(), permission.getName(), permission.getActions());
    }
    return null;
}
 
Example 16
Source Project: onos   Source File: DefaultPolicyBuilder.java    License: Apache License 2.0 4 votes vote down vote up
private static Permission getPermission(org.onosproject.security.Permission permission) {

        String classname = permission.getClassName();
        String name = permission.getName();
        String actions = permission.getActions();

        if (classname == null || name == null) {
            return null;
        }
        classname = classname.trim();
        name = name.trim();
        actions = actions.trim();

        if (AppPermission.class.getName().equals(classname)) {
            return new AppPermission(name);
        } else if (FilePermission.class.getName().equals(classname)) {
            return new FilePermission(name, actions);
        } else if (SerializablePermission.class.getName().equals(classname)) {
            return new SerializablePermission(name, actions);
        } else if (NetPermission.class.getName().equals(classname)) {
            return new NetPermission(name, actions);
        } else if (RuntimePermission.class.getName().equals(classname)) {
            return new RuntimePermission(name, actions);
        } else if (SocketPermission.class.getName().equals(classname)) {
            return new SocketPermission(name, actions);
        } else if (SQLPermission.class.getName().equals(classname)) {
            return new SQLPermission(name, actions);
        } else if (PropertyPermission.class.getName().equals(classname)) {
            return new PropertyPermission(name, actions);
        } else if (LoggingPermission.class.getName().equals(classname)) {
            return new LoggingPermission(name, actions);
        } else if (SSLPermission.class.getName().equals(classname)) {
            return new SSLPermission(name, actions);
        } else if (AuthPermission.class.getName().equals(classname)) {
            return new AuthPermission(name, actions);
        } else if (PrivateCredentialPermission.class.getName().equals(classname)) {
            return new PrivateCredentialPermission(name, actions);
        } else if (DelegationPermission.class.getName().equals(classname)) {
            return new DelegationPermission(name, actions);
        } else if (javax.security.auth.kerberos.ServicePermission.class.getName().equals(classname)) {
            return new javax.security.auth.kerberos.ServicePermission(name, actions);
        } else if (AudioPermission.class.getName().equals(classname)) {
            return new AudioPermission(name, actions);
        } else if (AdaptPermission.class.getName().equals(classname)) {
            return new AdaptPermission(name, actions);
        } else if (BundlePermission.class.getName().equals(classname)) {
            return new BundlePermission(name, actions);
        } else if (CapabilityPermission.class.getName().equals(classname)) {
            return new CapabilityPermission(name, actions);
        } else if (PackagePermission.class.getName().equals(classname)) {
            return new PackagePermission(name, actions);
        } else if (ServicePermission.class.getName().equals(classname)) {
            return new ServicePermission(name, actions);
        } else if (AdminPermission.class.getName().equals(classname)) {
            return new AdminPermission(name, actions);
        //} else if (ConfigurationPermission.class.getName().equals(classname)) {
        //    return new ConfigurationPermission(name, actions);
        } else if (ReflectPermission.class.getName().equals(classname)) {
            return new ReflectPermission(name, actions);
        }

        //AllPermission, SecurityPermission, UnresolvedPermission
        //AWTPermission,  ReflectPermission not allowed
        return null;

    }
 
Example 17
public  void    abort( Executor executor )  throws SQLException
{
    // NOP if called on a closed connection.
    if ( isClosed() ) { return; }
    // Null executor not allowed.
    if ( executor == null )
    {
        throw newSQLException( SQLState.UU_INVALID_PARAMETER, "executor", "null" );
    }

    //
    // Must have privilege to invoke this method.
    //
    // The db jars should be granted this permission. We deliberately
    // do not wrap this check in an AccessController.doPrivileged() block.
    // If we did so, that would absolve outer code blocks of the need to
    // have this permission granted to them too. It is critical that the
    // outer code blocks enjoy this privilege. That is what allows
    // connection pools to prevent ordinary code from calling abort()
    // and restrict its usage to privileged tools.
    //
    SecurityManager securityManager = System.getSecurityManager();
    if ( securityManager != null )
    { securityManager.checkPermission( new SQLPermission( "callAbort" ) ); }

    // Mark the Connection as closed. Set the "aborting" flag to allow internal
    // processing in close() to proceed.
    beginAborting();

    //
    // Now pass the Executor a Runnable which does the real work.
    //
    executor.execute
        (
         new Runnable()
         {
             public void run()
             {
                 try {
                     rollback();
                     close(exceptionClose);
                 } catch (SQLException se) { Util.logSQLException( se ); }
             }
         }
         );
}
 
Example 18
/**
 * Initializes this operation monitor.
 * <p>
 * The provided {@link OperationAware} instance will be notified of operations occurring in the driver.
 * </p>
 * <p>
 * When a security manager is installed, the existence of the {@link SQLPermission} with name
 * {@code "org.firebirdsql.jaybird.initOperationAware"} will be checked.
 * </p>
 *
 * @param operationAware
 *         an object that implements the {@link OperationAware} interface, or {@code null} to clear the current
 *         instance
 * @throws SecurityException
 *         If a security manager is installed and the calling code does not have permission {@code
 *         "org.firebirdsql.jaybird.initOperationAware"}
 */
public static void initOperationAware(OperationAware operationAware) {
    SecurityManager securityManager = System.getSecurityManager();
    if (securityManager != null) {
        SQLPermission permission = new SQLPermission(PERMISSION_INIT_OPERATION_AWARE);
        securityManager.checkPermission(permission);
    }
    instance.set(operationAware != null
            ? operationAware
            : NoOpOperationAware.INSTANCE);
}