Search in sources :

Example 1 with GetBooleanAction

use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.

the class LDAPCertStore method createInitialDirContext.

/**
     * Create InitialDirContext.
     *
     * @param server Server DNS name hosting LDAP service
     * @param port   Port at which server listens for requests
     * @throws InvalidAlgorithmParameterException if creation fails
     */
private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String, Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);
    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }
    try {
        ctx = new InitialDirContext(env);
        /*
             * By default, follow referrals unless application has
             * overridden property in an application resource file.
             */
        Hashtable<?, ?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException) ee;
    }
}
Also used : GetBooleanAction(sun.security.action.GetBooleanAction) NamingException(javax.naming.NamingException) InitialDirContext(javax.naming.directory.InitialDirContext) NamingException(javax.naming.NamingException) NameNotFoundException(javax.naming.NameNotFoundException) IOException(java.io.IOException)

Example 2 with GetBooleanAction

use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.

the class PipeWriter method main.

/**
     * Main program to start the activation system. <br>
     * The usage is as follows: rmid [-port num] [-log dir].
     */
public static void main(String[] args) {
    boolean stop = false;
    // already.
    if (System.getSecurityManager() == null) {
        System.setSecurityManager(new SecurityManager());
    }
    try {
        int port = ActivationSystem.SYSTEM_PORT;
        RMIServerSocketFactory ssf = null;
        /*
             * If rmid has an inherited channel (meaning that it was
             * launched from inetd), set the server socket factory to
             * return the inherited server socket.
             **/
        Channel inheritedChannel = AccessController.doPrivileged(new PrivilegedExceptionAction<Channel>() {

            public Channel run() throws IOException {
                return System.inheritedChannel();
            }
        });
        if (inheritedChannel != null && inheritedChannel instanceof ServerSocketChannel) {
            /*
                 * Redirect System.err output to a file.
                 */
            AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {

                public Void run() throws IOException {
                    File file = Files.createTempFile("rmid-err", null).toFile();
                    PrintStream errStream = new PrintStream(new FileOutputStream(file));
                    System.setErr(errStream);
                    return null;
                }
            });
            ServerSocket serverSocket = ((ServerSocketChannel) inheritedChannel).socket();
            port = serverSocket.getLocalPort();
            ssf = new ActivationServerSocketFactory(serverSocket);
            System.err.println(new Date());
            System.err.println(getTextResource("rmid.inherited.channel.info") + ": " + inheritedChannel);
        }
        String log = null;
        List<String> childArgs = new ArrayList<>();
        /*
             * Parse arguments
             */
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-port")) {
                if (ssf != null) {
                    bomb(getTextResource("rmid.syntax.port.badarg"));
                }
                if ((i + 1) < args.length) {
                    try {
                        port = Integer.parseInt(args[++i]);
                    } catch (NumberFormatException nfe) {
                        bomb(getTextResource("rmid.syntax.port.badnumber"));
                    }
                } else {
                    bomb(getTextResource("rmid.syntax.port.missing"));
                }
            } else if (args[i].equals("-log")) {
                if ((i + 1) < args.length) {
                    log = args[++i];
                } else {
                    bomb(getTextResource("rmid.syntax.log.missing"));
                }
            } else if (args[i].equals("-stop")) {
                stop = true;
            } else if (args[i].startsWith("-C")) {
                childArgs.add(args[i].substring(2));
            } else {
                bomb(MessageFormat.format(getTextResource("rmid.syntax.illegal.option"), args[i]));
            }
        }
        if (log == null) {
            if (ssf != null) {
                bomb(getTextResource("rmid.syntax.log.required"));
            } else {
                log = "log";
            }
        }
        debugExec = AccessController.doPrivileged(new GetBooleanAction("sun.rmi.server.activation.debugExec"));
        /**
             * Determine class name for activation exec policy (if any).
             */
        String execPolicyClassName = AccessController.doPrivileged(new GetPropertyAction("sun.rmi.activation.execPolicy", null));
        if (execPolicyClassName == null) {
            if (!stop) {
                DefaultExecPolicy.checkConfiguration();
            }
            execPolicyClassName = "default";
        }
        /**
             * Initialize method for activation exec policy.
             */
        if (!execPolicyClassName.equals("none")) {
            if (execPolicyClassName.equals("") || execPolicyClassName.equals("default")) {
                execPolicyClassName = DefaultExecPolicy.class.getName();
            }
            try {
                Class<?> execPolicyClass = getRMIClass(execPolicyClassName);
                execPolicy = execPolicyClass.newInstance();
                execPolicyMethod = execPolicyClass.getMethod("checkExecCommand", ActivationGroupDesc.class, String[].class);
            } catch (Exception e) {
                if (debugExec) {
                    System.err.println(getTextResource("rmid.exec.policy.exception"));
                    e.printStackTrace();
                }
                bomb(getTextResource("rmid.exec.policy.invalid"));
            }
        }
        if (stop == true) {
            final int finalPort = port;
            AccessController.doPrivileged(new PrivilegedAction<Void>() {

                public Void run() {
                    System.setProperty("java.rmi.activation.port", Integer.toString(finalPort));
                    return null;
                }
            });
            ActivationSystem system = ActivationGroup.getSystem();
            system.shutdown();
            System.exit(0);
        }
        /*
             * Fix for 4173960: Create and initialize activation using
             * a static method, startActivation, which will build the
             * Activation state in two ways: if when rmid is run, no
             * log file is found, the ActLogHandler.recover(...)
             * method will create a new Activation instance.
             * Alternatively, if a logfile is available, a serialized
             * instance of activation will be read from the log's
             * snapshot file.  Log updates will be applied to this
             * Activation object until rmid's state has been fully
             * recovered.  In either case, only one instance of
             * Activation is created.
             */
        startActivation(port, ssf, log, childArgs.toArray(new String[childArgs.size()]));
        // prevent activator from exiting
        while (true) {
            try {
                Thread.sleep(Long.MAX_VALUE);
            } catch (InterruptedException e) {
            }
        }
    } catch (Exception e) {
        System.err.println(MessageFormat.format(getTextResource("rmid.unexpected.exception"), e));
        e.printStackTrace();
    }
    System.exit(1);
}
Also used : ArrayList(java.util.ArrayList) ActivationSystem(java.rmi.activation.ActivationSystem) RMIServerSocketFactory(java.rmi.server.RMIServerSocketFactory) ServerSocketChannel(java.nio.channels.ServerSocketChannel) PrintStream(java.io.PrintStream) GetBooleanAction(sun.security.action.GetBooleanAction) Channel(java.nio.channels.Channel) ServerSocketChannel(java.nio.channels.ServerSocketChannel) ServerSocket(java.net.ServerSocket) ConnectIOException(java.rmi.ConnectIOException) IOException(java.io.IOException) Date(java.util.Date) ActivationException(java.rmi.activation.ActivationException) UnknownGroupException(java.rmi.activation.UnknownGroupException) ConnectIOException(java.rmi.ConnectIOException) NotBoundException(java.rmi.NotBoundException) MissingResourceException(java.util.MissingResourceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) AccessControlException(java.security.AccessControlException) UnknownObjectException(java.rmi.activation.UnknownObjectException) NoSuchObjectException(java.rmi.NoSuchObjectException) AccessException(java.rmi.AccessException) SocketException(java.net.SocketException) ConnectException(java.rmi.ConnectException) IOException(java.io.IOException) AlreadyBoundException(java.rmi.AlreadyBoundException) GetPropertyAction(sun.security.action.GetPropertyAction) FileOutputStream(java.io.FileOutputStream) ActivationGroupDesc(java.rmi.activation.ActivationGroupDesc) PolicyFile(sun.security.provider.PolicyFile) File(java.io.File)

Example 3 with GetBooleanAction

use of sun.security.action.GetBooleanAction in project jdk8u_jdk by JetBrains.

the class XEmbedCanvasPeer method canvasFocusLost.

void canvasFocusLost(FocusEvent e) {
    if (isXEmbedActive() && !e.isTemporary()) {
        xembedLog.fine("Forwarding FOCUS_LOST");
        int num = 0;
        if (AccessController.doPrivileged(new GetBooleanAction("sun.awt.xembed.testing"))) {
            Component opp = e.getOppositeComponent();
            try {
                num = Integer.parseInt(opp.getName());
            } catch (NumberFormatException nfe) {
            }
        }
        xembed.sendMessage(xembed.handle, XEMBED_FOCUS_OUT, num, 0, 0);
    }
}
Also used : GetBooleanAction(sun.security.action.GetBooleanAction)

Aggregations

GetBooleanAction (sun.security.action.GetBooleanAction)3 IOException (java.io.IOException)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ServerSocket (java.net.ServerSocket)1 SocketException (java.net.SocketException)1 Channel (java.nio.channels.Channel)1 ServerSocketChannel (java.nio.channels.ServerSocketChannel)1 AccessException (java.rmi.AccessException)1 AlreadyBoundException (java.rmi.AlreadyBoundException)1 ConnectException (java.rmi.ConnectException)1 ConnectIOException (java.rmi.ConnectIOException)1 NoSuchObjectException (java.rmi.NoSuchObjectException)1 NotBoundException (java.rmi.NotBoundException)1 RemoteException (java.rmi.RemoteException)1 ActivationException (java.rmi.activation.ActivationException)1 ActivationGroupDesc (java.rmi.activation.ActivationGroupDesc)1 ActivationSystem (java.rmi.activation.ActivationSystem)1