Example usage for java.lang SecurityException getMessage

List of usage examples for java.lang SecurityException getMessage

Introduction

In this page you can find the example usage for java.lang SecurityException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.directory.fortress.core.GroupMgrConsole.java

/**
 * Description of the Method/* w  ww .ja v a2  s.  c o  m*/
 */
void add() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        String name = ReaderUtil.readLn();
        System.out.println("Enter description:");
        String desc = ReaderUtil.readLn();
        Group group = new Group(name, desc);
        System.out.println("Enter protocol:");
        String protocol = ReaderUtil.readLn();
        group.setProtocol(protocol);
        System.out.println("Enter userId:");
        String userId = ReaderUtil.readLn();
        group.setMember(userId);
        groupMgr.add(group);
        System.out.println("Group successfully added");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("add caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.sakaiproject.kernel.webapp.filter.SakaiAuthenticationFilter.java

/**
 * {@inheritDoc}/*from w ww .  jav a  2 s.co m*/
 *
 * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
 *      javax.servlet.ServletResponse, javax.servlet.FilterChain)
 */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest hrequest = (HttpServletRequest) request;
    HttpServletResponse hresponse = (HttpServletResponse) response;
    if (hrequest.getHeader("Authorization") != null) {
        try {
            doBasicAuth(hrequest);
        } catch (SecurityException se) {
            // catch any Security exceptions and send a 401
            LOG.info("Login Failed: " + se.getMessage());
            hresponse.reset();
            hresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, se.getMessage());
            return;
        }
    } else {
        if ("1".equals(hrequest.getParameter("l"))) {
            try {
                AuthenticationType authNType = AuthenticationType.valueOf(request.getParameter("a"));
                if (debug) {
                    LOG.debug("Authentication Filter: " + authNType);
                }
                switch (authNType) {
                case BASIC:
                    doBasicAuth(hrequest);
                    break;
                case FORM:
                    doForm(hrequest);
                    break;
                case TRUSTED:
                    doTrusted(hrequest);
                    break;
                }
            } catch (SecurityException se) {
                // catch any Security exceptions and send a 401
                LOG.info("Login Failed " + se.getMessage());
                hresponse.reset();
                hresponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, se.getMessage());
                return;
            } catch (IllegalArgumentException e) {
                LOG.info("Authentication type " + request.getParameter("a")
                        + " is not supported by this filter");
            }
        }
    }

    chain.doFilter(request, response);

}

From source file:com.cws.esolutions.agent.AgentDaemon.java

public void start() {
    final String methodName = AgentDaemon.CNAME + "#start()";

    if (DEBUG) {/*from w  w w  . j ava2 s .c  om*/
        DEBUGGER.debug(methodName);
    }

    try {
        this.connFactory = new ActiveMQConnectionFactory(
                AgentDaemon.agentBean.getConfigData().getServerConfig().getConnectionName());

        if (DEBUG) {
            DEBUGGER.debug("ConnectionFactory: {}", this.connFactory);
        }

        this.conn = this.connFactory.createConnection(
                AgentDaemon.agentBean.getConfigData().getServerConfig().getUsername(),
                PasswordUtils.decryptText(AgentDaemon.agentBean.getConfigData().getServerConfig().getPassword(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getSalt(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionAlgorithm(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getIterations(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getKeyBits(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionAlgorithm(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getEncryptionInstance(),
                        AgentDaemon.agentBean.getConfigData().getServerConfig().getEncoding()));

        this.conn.setExceptionListener(new MQExceptionHandler());
        this.conn.setClientID(AgentDaemon.agentBean.getConfigData().getServerConfig().getClientId());
        this.conn.start();

        if (DEBUG) {
            DEBUGGER.debug("Connection: {}", this.conn);
        }

        this.session = this.conn.createSession(false, Session.AUTO_ACKNOWLEDGE);

        if (DEBUG) {
            DEBUGGER.debug("Session: {}", this.session);
        }

        this.request = this.session
                .createTopic(AgentDaemon.agentBean.getConfigData().getServerConfig().getRequestQueue());
        this.response = this.session
                .createQueue(AgentDaemon.agentBean.getConfigData().getServerConfig().getResponseQueue());

        if (DEBUG) {
            DEBUGGER.debug("Destination: {}", this.request);
            DEBUGGER.debug("Destination: {}", this.response);
        }

        this.consumer = this.session.createConsumer(this.request,
                "targetHost='" + AgentDaemon.agentBean.getHostName() + "'");
        this.consumer.setMessageListener(new MQMessageHandler());

        if (DEBUG) {
            DEBUGGER.debug("MessageConsumer: {}", this.consumer);
        }

        this.producer = this.session.createProducer(this.response);

        if (DEBUG) {
            DEBUGGER.debug("MessageProducer: {}", this.producer);
        }

        AgentDaemon.agentBean.setResponseQueue(this.response);
        AgentDaemon.agentBean.setSession(this.session);
        AgentDaemon.agentBean.setProducer(this.producer);
    } catch (SecurityException sx) {
        ERROR_RECORDER.error(sx.getMessage(), sx);

        this.exitCode = 1;
        stop();
    } catch (JMSException jx) {
        ERROR_RECORDER.error(jx.getMessage(), jx);

        this.exitCode = 1;
        stop();
    }
}

From source file:org.apache.directory.fortress.core.GroupMgrConsole.java

void addProperty() {
    try {/*from  w  ww. ja  v  a2 s. c  o  m*/
        Group group = new Group();
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        group.setName(ReaderUtil.readLn());
        System.out.println("Enter property key:");
        String key = ReaderUtil.readLn();
        System.out.println("Enter property value:");
        String value = ReaderUtil.readLn();
        groupMgr.add(group, key, value);
        System.out.println("Add property to Group successful");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("addProperty caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}

From source file:org.rifidi.emulator.io.comm.ip.tcpserver.TCPServerCommunicationIncomingMessageHandler.java

/**
 * The main logic of the monitor. Reads in data from the client socket until
 * the client socket is closed/disconnected.
 * /*  w ww  .  j a v a  2s .  c  o m*/
 * @see java.lang.Runnable#run()
 */
@SuppressWarnings("unchecked")
public void run() {
    Socket clientSocket = this.hostCommunication.getClientSocket();

    /* Make a reader to get data from the client socket. */
    AbstractStreamReader socketIn = null;

    Constructor c = null;
    try {
        /* The class has to have a single paramater of type InputStream */
        c = readerClass.getConstructor(new Class[] { InputStream.class });
    } catch (SecurityException e1) {
        logger.error("Security exception while getting the Constructor\n" + e1.getMessage());
        throw (new RuntimeException("Security exception while getting constructor"));
    } catch (NoSuchMethodException e1) {
        logger.error("No such method exception while getting the constructor.  "
                + "Make sure that the class has a signle paramater of type Input Stream\n " + e1.getMessage());
        throw (new RuntimeException("No such method exception while getting the constructor"));
    }

    try {
        socketIn = (AbstractStreamReader) c.newInstance(clientSocket.getInputStream());
    } catch (IllegalArgumentException e1) {
        logger.error("Arugment of type java.io.Reader expected, but not found\n " + e1.getMessage());
        throw (new RuntimeException("Arugment of type java.io.Reader expected, but not found"));
    } catch (InstantiationException e1) {
        logger.error("Instantion exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Instantion exception while instantiating a new bufferedreader"));
    } catch (IllegalAccessException e1) {
        logger.error("Illegal Access Exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Illegal Access Exception while instantiating a new bufferedreader\n"));
    } catch (InvocationTargetException e1) {
        logger.error(
                "Invocation Target Exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Invocation Target Exception while instantiating a new bufferedreader\n"));
    } catch (IOException e1) {
        logger.error(
                "IO exception while opening the input stelse return bytes.toArray();ream\n " + e1.getMessage());
        throw (new RuntimeException("IO exception while opening the input stream\n"));
    }

    /* Only proceed if we grabbed a valid reader */
    if (socketIn != null) {

        /* Variable to control reading. */
        boolean keepRunning = true;

        /* Read in while this connection is open. */
        while (keepRunning) {
            // synchronized (synch) {

            /* Some buffers to hold single line and whole message */
            byte[] buffer = null;

            /* Read lines into the buffer */
            if (socketIn != null) {

                /* Read the first line in */
                try {
                    buffer = socketIn.read();
                } catch (IOException e) {
                    /* Drop the socket */
                    buffer = null;
                }
            }

            /* Throw the received data into the received buffer */
            if (buffer != null) {
                /* Grab the bytes of the received data */
                /* Remove protocol before throwing in the buffer. */
                try {

                    List<byte[]> listOfBytes = this.hostCommunication.getProtocol().removeProtocol(buffer);
                    for (byte[] b : listOfBytes) {

                        String message = this.hostCommunication.getLogFormatter().formatMessage(b);

                        this.hostCommunication.getConsoleLogger().info("<INPUT> " + message + "</INPUT>");

                        this.hostCommunication.getReceiveBuffer().addToBuffer(b);
                    }
                } catch (DataBufferInterruptedException e) {
                    /* The DataBuffer has been interrupted, close client */
                    keepRunning = false;

                } catch (ProtocolValidationException e) {
                    /*
                     * Received a malformed message, report to debug logs
                     */
                    logger.debug(e.getMessage());

                }

            } else {
                keepRunning = false;

            }
            // }

        } /* end: while(isDisconnected) */

        /* Socket disconnected/closed -- disconnect the communication. */
        this.hostCommunication.disconnect();

    } /* end: if(socketIn != null)... */

}

From source file:org.apache.directory.fortress.core.GroupMgrConsole.java

void deleteProperty() {
    try {//from  ww w. j  a va2  s .c om
        Group group = new Group();
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        group.setName(ReaderUtil.readLn());
        System.out.println("Enter property key:");
        String key = ReaderUtil.readLn();
        System.out.println("Enter property value:");
        String value = ReaderUtil.readLn();
        groupMgr.delete(group, key, value);
        System.out.println("Delete property from Group successful");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("deleteProperty caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(),
                e);
    }
    ReaderUtil.readChar();
}

From source file:org.rifidi.emulator.io.comm.ip.tcpclient.TCPClientCommunicationIncomingMessageHandler.java

/**
 * The main logic of the monitor. Reads in data from the client socket until
 * the client socket is closed/disconnected.
 * /*from   w  ww  .j av  a 2 s .  co  m*/
 * @see java.lang.Runnable#run()
 */
@SuppressWarnings("unchecked")
public void run() {
    Socket clientSocket = this.hostCommunication.getClientSocket();

    /* Make a reader to get data from the client socket. */
    AbstractStreamReader socketIn = null;

    Constructor c = null;
    try {
        /* The class has to have a single parameter of type InputStream */
        c = readerClass.getConstructor(new Class[] { InputStream.class });
    } catch (SecurityException e1) {
        logger.error("Security exception while getting the Constructor\n" + e1.getMessage());
        throw (new RuntimeException("Security exception while getting constructor"));
    } catch (NoSuchMethodException e1) {
        logger.error("No such method exception while getting the constructor.  "
                + "Make sure that the class has a signle paramater of type Input Stream\n " + e1.getMessage());
        throw (new RuntimeException("No such method exception while getting the constructor"));
    }

    try {
        socketIn = (AbstractStreamReader) c.newInstance(clientSocket.getInputStream());
    } catch (IllegalArgumentException e1) {
        logger.error("Arugment of type java.io.Reader expected, but not found\n " + e1.getMessage());
        throw (new RuntimeException("Arugment of type java.io.Reader expected, but not found"));
    } catch (InstantiationException e1) {
        logger.error("Instantion exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Instantion exception while instantiating a new bufferedreader"));
    } catch (IllegalAccessException e1) {
        logger.error("Illegal Access Exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Illegal Access Exception while instantiating a new bufferedreader\n"));
    } catch (InvocationTargetException e1) {
        logger.error(
                "Invocation Target Exception while instantiating a new bufferedreader\n " + e1.getMessage());
        throw (new RuntimeException("Invocation Target Exception while instantiating a new bufferedreader\n"));
    } catch (IOException e1) {
        logger.error(
                "IO exception while opening the input stelse return bytes.toArray();ream\n " + e1.getMessage());
        throw (new RuntimeException("IO exception while opening the input stream\n"));
    }

    /* Only proceed if we grabbed a valid reader */
    if (socketIn != null) {

        /* Variable to control reading. */
        boolean keepRunning = true;

        /* Read in while this connection is open. */
        while (keepRunning) {
            // synchronized (synch) {

            /* Some buffers to hold single line and whole message */
            byte[] buffer = null;

            /* Read lines into the buffer */
            if (socketIn != null) {

                /* Read the first line in */
                try {
                    buffer = socketIn.read();
                    logger.debug("The Incoming message is:" + ByteAndHexConvertingUtility.toHexString(buffer));
                } catch (IOException e) {
                    /* Drop the socket */
                    buffer = null;
                }
            }

            /* Throw the received data into the received buffer */
            if (buffer != null) {
                /* Grab the bytes of the received data */
                /* Remove protocol before throwing in the buffer. */
                try {

                    this.hostCommunication.getConsoleLogger().info("<INPUT> "
                            + this.hostCommunication.getLogFormatter().formatMessage(buffer) + "</INPUT>");

                    List<byte[]> listOfBytes = this.hostCommunication.getProtocol().removeProtocol(buffer);
                    for (byte[] b : listOfBytes) {
                        this.hostCommunication.getReceiveBuffer().addToBuffer(b);
                    }
                } catch (DataBufferInterruptedException e) {
                    /* The DataBuffer has been interrupted, close client */
                    keepRunning = false;

                } catch (ProtocolValidationException e) {
                    /*
                     * Received a malformed message, report to debug logs
                     */
                    logger.debug(e.getMessage());

                }

            } else {
                keepRunning = false;

            }
            // }

        } /* end: while(isDisconnected) */

        /* Socket disconnected/closed -- disconnect the communication. */
        this.hostCommunication.disconnect();

    } /* end: if(socketIn != null)... */

}

From source file:com.interop.webapp.WebApp.java

@PostConstruct
public void setUpQueue() throws Exception {

    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost(config.getQueueHostName());
    connection = factory.newConnection();
    channel = connection.createChannel();

    replyQueueName = channel.queueDeclare().getQueue();
    consumer = new QueueingConsumer(channel);
    channel.basicConsume(replyQueueName, true, consumer);
    // Create the folder that will hold the processed files
    String foldername = config.getImageFilesRoot() + '/' + processedFilesWebPath;
    File folder = new File(URI.create(foldername));
    if (folder.exists()) {
        return;//from   w w  w  .  ja  v  a  2  s  .  c o  m
    }
    log.info("creating directory: " + foldername);
    try {
        folder.mkdir();
    } catch (SecurityException se) {
        log.error(String.format("creating directory: %s (%s)", foldername, se.getMessage()));
    } catch (Exception e) {
        log.error(String.format("creating directory: %s (%s)", foldername, e.getMessage()));
    }
}

From source file:org.openmrs.module.pcslabinterface.impl.PcsLabInterfaceServiceImpl.java

public void deleteLabMessage(LabMessage labMessage) {

    if ((labMessage == null) || (labMessage.getFileSystemUrl() == null)) {
        throw new PcsLabInterfaceException("Unable to load LabMessage with empty file system url");
    }//from  www .j a  v  a 2  s .  co m
    File file = new File(labMessage.getFileSystemUrl());
    log.debug("file path is " + file.getAbsolutePath());
    if (file.exists()) {
        String deleteError = "Unable to delete file from queue: " + file.getAbsolutePath();
        // TODO: move file to an archive, not delete it
        try {
            Process p = Runtime.getRuntime().exec("rm -f " + file.getAbsolutePath());
            if (p.waitFor() == 0) {
                log.debug("File deleted " + file.getAbsolutePath());
            }
        } catch (SecurityException se) {
            throw new PcsLabInterfaceException(
                    deleteError + " -- check file and folder write permissions" + se.getMessage());
        } catch (IOException ioe) {
            throw new PcsLabInterfaceException(deleteError + ioe.getMessage());
        } catch (InterruptedException e) {
            log.error("Unable to delete file from queue: ", e);
        }
    }
}

From source file:org.apache.directory.fortress.core.GroupMgrConsole.java

/**
 * Description of the Method/*from w w w .j a  va  2  s . c om*/
 */
void update() {
    try {
        ReaderUtil.clearScreen();
        System.out.println("Enter group name:");
        String name = ReaderUtil.readLn();
        System.out.println("Enter description:");
        String desc = ReaderUtil.readLn();
        Group group = new Group(name, desc);
        System.out.println("Enter protocol:");
        String protocol = ReaderUtil.readLn();
        group.setProtocol(protocol);

        System.out.println("Enter member userId or NULL to skip");
        String userId = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(userId))
            group.setMember(userId);

        System.out.println("Enter property key or NULL to skip");
        String key = ReaderUtil.readLn();
        if (StringUtils.isNotEmpty(key)) {
            System.out.println("Enter property value");
            String value = ReaderUtil.readLn();
            group.addProperty(key, value);
        }

        groupMgr.update(group);
        System.out.println("Group successfully updated");
        System.out.println("ENTER to continue");
    } catch (SecurityException e) {
        LOG.error("update caught SecurityException rc=" + e.getErrorId() + ", msg=" + e.getMessage(), e);
    }
    ReaderUtil.readChar();
}