Examples of SecuredCommandProcessorImpl


Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

    }

    public void run() {
        try {
            threadIO.setStreams(consoleInput, out, err);
            SecuredCommandProcessorImpl secCP = null;
            if (secured) {
                secCP = createSecuredCommandProcessor();
            }
            thread = Thread.currentThread();
            CommandSessionHolder.setSession(session);
            running = true;
            pipe.start();
            Properties brandingProps = Branding.loadBrandingProperties(terminal);
            welcome(brandingProps);
            setSessionProperties(brandingProps);
            String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
            executeScript(scriptFileName);
            while (running) {
                try {
                    String command = readAndParseCommand();
                    if (command == null) {
                        break;
                    }
                    //session.getConsole().println("Executing: " + line);
                    Object result = session.execute(command);
                    if (result != null) {
                        session.getConsole().println(session.format(result, Converter.INSPECT));
                    }
                } catch (InterruptedIOException e) {
                    //System.err.println("^C");
                    // TODO: interrupt current thread
                } catch (InterruptedException e) {
                    //interrupt current thread
                } catch (CloseShellException e) {
                    break;
                } catch (Throwable t) {
                    ShellUtil.logException(session, t);
                }
            }
            if (secured) {
                try {
                    secCP.close();
                } catch (Throwable t) {
                    // Ignore
                }
            }
            close(true);
View Full Code Here

Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

            throw new IllegalStateException("Should be an Delegate Session here, about to set the delegate");
        }
        DelegateSession is = (DelegateSession) session;

        // make it active
        SecuredCommandProcessorImpl secCP = new SecuredCommandProcessorImpl(bundleContext);
        CommandSession s = secCP.createSession(consoleInput, out, err);

        // before the session is activated attributes may have been set on it. Pass these on to the real session now
        is.setDelegate(s);
        return secCP;
    }
View Full Code Here

Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

        subject.getPrincipals().add(new RolePrincipal("myrole"));

        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                SecuredCommandProcessorImpl secCP = console.createSecuredCommandProcessor();
                assertNotNull(ds.delegate);
                assertEquals("Attributes set before the delegate was set should have been transferred",
                        "bar", ds.get("foo"));
                assertEquals("Attributes set before the delegate was set should have been transferred",
                        "bar", ds.delegate.get("foo"));
                assertSame(System.out, ds.delegate.getConsole());
                assertSame(System.out, ds.getConsole());

                assertTrue(secCP.getCommands().contains("myscope:myfunction"));

                return null;
            }
        });
    }
View Full Code Here

Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

    }

    public void run() {
        try {
            threadIO.setStreams(consoleInput, out, err);
            SecuredCommandProcessorImpl secCP = createSecuredCommandProcessor();
            thread = Thread.currentThread();
            CommandSessionHolder.setSession(session);
            running = true;
            pipe.start();
            Properties brandingProps = Branding.loadBrandingProperties(terminal);
            welcome(brandingProps);
            setSessionProperties(brandingProps);
            String scriptFileName = System.getProperty(SHELL_INIT_SCRIPT);
            executeScript(scriptFileName);
            while (running) {
                try {
                    String command = readAndParseCommand();
                    if (command == null) {
                        break;
                    }
                    //session.getConsole().println("Executing: " + line);
                    Object result = session.execute(command);
                    if (result != null) {
                        session.getConsole().println(session.format(result, Converter.INSPECT));
                    }
                } catch (InterruptedIOException e) {
                    //System.err.println("^C");
                    // TODO: interrupt current thread
                } catch (InterruptedException e) {
                    //interrupt current thread
                } catch (CloseShellException e) {
                    break;
                } catch (Throwable t) {
                    ShellUtil.logException(session, t);
                }
            }
            secCP.close();
            close(true);
        } finally {
            threadIO.close();
        }
    }
View Full Code Here

Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

            throw new IllegalStateException("Should be an Delegate Session here, about to set the delegate");
        }
        DelegateSession is = (DelegateSession) session;

        // make it active
        SecuredCommandProcessorImpl secCP = new SecuredCommandProcessorImpl(bundleContext);
        CommandSession s = secCP.createSession(consoleInput, out, err);

        // before the session is activated attributes may have been set on it. Pass these on to the real session now
        is.setDelegate(s);
        return secCP;
    }
View Full Code Here

Examples of org.apache.karaf.shell.security.impl.SecuredCommandProcessorImpl

        subject.getPrincipals().add(new RolePrincipal("myrole"));

        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                SecuredCommandProcessorImpl secCP = console.createSecuredCommandProcessor();
                assertNotNull(ds.delegate);
                assertEquals("Attributes set before the delegate was set should have been transferred",
                        "bar", ds.get("foo"));
                assertEquals("Attributes set before the delegate was set should have been transferred",
                        "bar", ds.delegate.get("foo"));
                assertSame(System.out, ds.delegate.getConsole());
                assertSame(System.out, ds.getConsole());

                assertTrue(secCP.getCommands().contains("myscope:myfunction"));

                return null;
            }
        });
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.