Example usage for java.lang IllegalArgumentException getLocalizedMessage

List of usage examples for java.lang IllegalArgumentException getLocalizedMessage

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.continuent.tungsten.common.jmx.JmxManager.java

/**
 * Starts the JMX connector for the server.
 *//*from  w  w  w  . j a v a2s. c  o  m*/
protected void startJmxConnector() {
    String serviceAddress = null;
    try {
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        serviceAddress = generateServiceAddress(host, beanPort, registryPort, serviceName);
        JMXServiceURL address = new JMXServiceURL(serviceAddress);

        // --- Define security attributes ---
        HashMap<String, Object> env = new HashMap<String, Object>();

        // --- Authentication based on password and access files---
        if (authenticationInfo != null && authenticationInfo.isAuthenticationNeeded()) {

            if (authenticationInfo.isUseTungstenAuthenticationRealm())
                env.put(JMXConnectorServer.AUTHENTICATOR, new RealmJMXAuthenticator(authenticationInfo));
            else
                env.put("jmx.remote.x.password.file", authenticationInfo.getPasswordFileLocation());

            env.put("jmx.remote.x.access.file", authenticationInfo.getAccessFileLocation());
        }

        // --- SSL encryption ---
        if (authenticationInfo != null && authenticationInfo.isEncryptionNeeded()) {
            // Keystore
            System.setProperty("javax.net.ssl.keyStore", authenticationInfo.getKeystoreLocation());
            System.setProperty("javax.net.ssl.keyStorePassword", authenticationInfo.getKeystorePassword());
            /**
             * Configure SSL. Protocols and ciphers are set in
             * securityHelper.setSecurityProperties and used by
             * SslRMIClientSocketFactory
             */
            try {
                String[] protocolArray = authenticationInfo.getEnabledProtocols().toArray(new String[0]);
                String[] allowedCipherSuites = authenticationInfo.getEnabledCipherSuites()
                        .toArray(new String[0]);
                String[] cipherArray;

                if (protocolArray.length == 0)
                    protocolArray = null;
                if (allowedCipherSuites.length == 0)
                    cipherArray = null;
                else {
                    // Ensure we choose an allowed cipher suite.
                    cipherArray = authenticationInfo.getJvmEnabledCipherSuites().toArray(new String[0]);
                    if (cipherArray.length == 0) {
                        // We don't have any cipher suites in common. This
                        // is not good!
                        String message = "Unable to find approved ciphers in the supported cipher suites on this JVM";
                        StringBuffer sb = new StringBuffer(message).append("\n");
                        sb.append(String.format("JVM supported cipher suites: %s\n",
                                StringUtils.join(SecurityHelper.getJvmSupportedCiphers())));
                        sb.append(String.format("Approved cipher suites from security.properties: %s\n",
                                StringUtils.join(allowedCipherSuites)));
                        logger.error(sb.toString());
                        throw new RuntimeException(message);
                    }
                }

                logger.info("Setting allowed JMX server protocols: " + StringUtils.join(protocolArray, ","));
                logger.info("Setting allowed JMX server ciphers: " + StringUtils.join(cipherArray, ","));
                SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
                SslRMIServerSocketFactory ssf = new SslRMIServerSocketFactory(cipherArray, protocolArray,
                        false);
                env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE, csf);
                env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, ssf);
            } catch (IllegalArgumentException ie) {
                logger.warn("Some of the protocols or ciphers are not supported. " + ie.getMessage());
                throw new RuntimeException(ie.getLocalizedMessage(), ie);
            }
        }

        env.put(RMIConnectorServer.JNDI_REBIND_ATTRIBUTE, "true");
        JMXConnectorServer connector = JMXConnectorServerFactory.newJMXConnectorServer(address, env, mbs);
        connector.start();

        logger.info(MessageFormat.format("JMXConnector: security.properties={0}",
                (authenticationInfo != null) ? authenticationInfo.getParentPropertiesFileLocation()
                        : "No security.properties file found !..."));
        if (authenticationInfo != null)
            logger.info(authenticationInfo.toString());
        logger.info(String.format("JMXConnector started at address %s", serviceAddress));

        jmxConnectorServer = connector;
    } catch (Throwable e) {
        throw new ServerRuntimeException(
                MessageFormat.format("Unable to create RMI listener: {0} -> {1}", getServiceProps(), e), e);
    }
}

From source file:io.getlime.security.powerauth.app.server.service.PowerAuthServiceImpl.java

@Override
@Transactional// w  w  w. j a va 2  s.  c  o  m
public PrepareActivationResponse prepareActivation(PrepareActivationRequest request) throws Exception {
    try {
        // Get request parameters
        String activationIdShort = request.getActivationIdShort();
        String activationNonceBase64 = request.getActivationNonce();
        String cDevicePublicKeyBase64 = request.getEncryptedDevicePublicKey();
        String activationName = request.getActivationName();
        String ephemeralPublicKey = request.getEphemeralPublicKey();
        String applicationKey = request.getApplicationKey();
        String applicationSignature = request.getApplicationSignature();
        String extras = request.getExtras();
        return behavior.getActivationServiceBehavior().prepareActivation(activationIdShort,
                activationNonceBase64, ephemeralPublicKey, cDevicePublicKeyBase64, activationName, extras,
                applicationKey, applicationSignature, keyConversionUtilities);
    } catch (IllegalArgumentException ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw localizationProvider.buildExceptionForCode(ServiceError.INVALID_INPUT_FORMAT);
    } catch (GenericServiceException ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw ex;
    } catch (Exception ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw new GenericServiceException(ServiceError.UNKNOWN_ERROR, ex.getMessage(),
                ex.getLocalizedMessage());
    }
}

From source file:io.getlime.security.powerauth.app.server.service.PowerAuthServiceImpl.java

@Override
@Transactional//from   ww w  .j  a  v  a2s  . c  om
public CreateActivationResponse createActivation(CreateActivationRequest request) throws Exception {
    try {
        // Get request parameters
        String applicationKey = request.getApplicationKey();
        String userId = request.getUserId();
        Long maxFailedCount = request.getMaxFailureCount();
        Date activationExpireTimestamp = ModelUtil.dateWithCalendar(request.getTimestampActivationExpire());
        String identity = request.getIdentity();
        String activationOtp = request.getActivationOtp();
        String activationNonceBase64 = request.getActivationNonce();
        String cDevicePublicKeyBase64 = request.getEncryptedDevicePublicKey();
        String activationName = request.getActivationName();
        String ephemeralPublicKey = request.getEphemeralPublicKey();
        String applicationSignature = request.getApplicationSignature();
        String extras = request.getExtras();
        return behavior.getActivationServiceBehavior().createActivation(applicationKey, userId, maxFailedCount,
                activationExpireTimestamp, identity, activationOtp, activationNonceBase64, ephemeralPublicKey,
                cDevicePublicKeyBase64, activationName, extras, applicationSignature, keyConversionUtilities);
    } catch (IllegalArgumentException ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw localizationProvider.buildExceptionForCode(ServiceError.INVALID_INPUT_FORMAT);
    } catch (GenericServiceException ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw ex;
    } catch (Exception ex) {
        Logger.getLogger(PowerAuthServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
        throw new GenericServiceException(ServiceError.UNKNOWN_ERROR, ex.getMessage(),
                ex.getLocalizedMessage());
    }
}

From source file:de.uni_potsdam.hpi.asg.logictool.mapping.SequenceBasedAndGateDecomposer.java

private Set<Set<Set<Signal>>> getTailCombinations(Set<Signal> sigs) {
    try {/*from  w  w  w . ja va 2 s . c o m*/
        Set<Set<Set<Signal>>> retVal = new HashSet<>();
        for (Set<Signal> s : Sets.powerSet(sigs)) {
            if (s.isEmpty()) {
                continue;
            }
            SetView<Signal> diff = Sets.difference(sigs, s);
            if (diff.isEmpty()) {
                Set<Set<Signal>> tmp = new HashSet<>();
                tmp.add(s);
                retVal.add(tmp);
            } else {
                Set<Set<Set<Signal>>> tail = getTailCombinations(diff);
                for (Set<Set<Signal>> x : tail) {
                    Set<Set<Signal>> tmp = new HashSet<>();
                    tmp.add(s);
                    for (Set<Signal> s2 : x) {
                        tmp.add(s2);
                    }
                    retVal.add(tmp);
                }
            }
        }
        return retVal;
    } catch (IllegalArgumentException e) {
        logger.error(e.getLocalizedMessage());
        return null;
    }
}

From source file:org.eclipse.jubula.communication.Communicator.java

/**
 * send a message through this communicator. ICommand.execute will be called on the other site.
 * @param message  the message object, must not be null, otherwise an CommunicationException is thrown.
 * @throws CommunicationException/* w  ww .  j  ava 2s. c o  m*/
 *             if any error or exception occurs. A CommnunicationException
 *             is also thrown if this communicator is not connected, e.g.
 *             run() was not called, or exceptions at creation time were
 *             ignored
 */
public void send(Message message) throws CommunicationException {
    checkConnectionState("send()"); //$NON-NLS-1$
    // check parameter
    if (message == null) {
        log.debug("method send() with null parameter called"); //$NON-NLS-1$
        throw new CommunicationException("no message to send", //$NON-NLS-1$
                MessageIDs.E_NO_MESSAGE_TO_SEND);
    }
    try {
        message.setMessageId(new MessageIdentifier(m_connection.getNextSequenceNumber()));
        // create string message
        String messageToSend = m_serializer.serialize(message);
        // send message
        m_connection.send(new MessageHeader(MessageHeader.MESSAGE, message), messageToSend);
    } catch (SerialisationException se) {
        log.error(se.getLocalizedMessage(), se);
        throw new CommunicationException("could not send message:" //$NON-NLS-1$
                + se.getMessage(), MessageIDs.E_MESSAGE_NOT_SEND);
    } catch (IOException ioe) {
        log.error(ioe.getLocalizedMessage(), ioe);
        throw new CommunicationException("io error occured during sending a message:" //$NON-NLS-1$
                + ioe.getMessage(), MessageIDs.E_MESSAGE_SEND);
    } catch (IllegalArgumentException iae) {
        log.error(iae.getLocalizedMessage(), iae);
        throw new CommunicationException("message could not send", MessageIDs.E_MESSAGE_NOT_SEND); //$NON-NLS-1$
    }
}

From source file:net.sf.jabref.JabRef.java

private static Optional<ParserResult> importFile(String argument) {
    String[] data = argument.split(",");
    try {/*from www .j av a2s.c  o m*/
        if ((data.length > 1) && !"*".equals(data[1])) {
            System.out.println(Localization.lang("Importing") + ": " + data[0]);
            try {
                List<BibEntry> entries;
                if (OS.WINDOWS) {
                    entries = Globals.importFormatReader.importFromFile(data[1], data[0], JabRef.jrf);
                } else {
                    entries = Globals.importFormatReader.importFromFile(data[1],
                            data[0].replaceAll("~", System.getProperty("user.home")), JabRef.jrf);
                }
                return Optional.of(new ParserResult(entries));
            } catch (IllegalArgumentException ex) {
                System.err.println(Localization.lang("Unknown import format") + ": " + data[1]);
                return Optional.empty();
            }
        } else {
            // * means "guess the format":
            System.out.println(Localization.lang("Importing in unknown format") + ": " + data[0]);

            ImportFormatReader.UnknownFormatImport importResult;
            if (OS.WINDOWS) {
                importResult = Globals.importFormatReader.importUnknownFormat(data[0]);
            } else {
                importResult = Globals.importFormatReader
                        .importUnknownFormat(data[0].replaceAll("~", System.getProperty("user.home")));
            }

            if (importResult == null) {
                System.out.println(Localization.lang("Could not find a suitable import format."));
            } else {
                System.out.println(Localization.lang("Format used") + ": " + importResult.format);

                return Optional.of(importResult.parserResult);
            }
        }
    } catch (IOException ex) {
        System.err.println(
                Localization.lang("Error opening file") + " '" + data[0] + "': " + ex.getLocalizedMessage());
    }
    return Optional.empty();
}

From source file:org.eclipse.jubula.communication.Communicator.java

/**
 * establish the connection, either connecting to a server or accepting
 * connections. This method will not block. If a connection could not made,
 * the listeners are notified with connectingFailed() and acceptingFailed
 * respectively./*from  w w  w  . j  a v a  2s  . c om*/
 * 
 * @return the Thread responsible for accepting connections, or 
 *         <code>null</code> if the the receiver is acting as a client.
 * @throws SecurityException
 *             if the security manager does not allow connections.
 * @throws JBVersionException
 *             in case of version error between Client and AutStarter
 */
public synchronized Thread run() throws SecurityException, JBVersionException {

    Thread acceptingThread = null;
    if (m_serverSocket != null && !isAccepting()) {
        // it's a server that hasn't yet started accepting connections
        setAccepting(true);
        acceptingThread = new AcceptingThread();
        acceptingThread.start();
    } else if (m_inetAddress != null) {
        // it's a client
        try {
            DefaultSocket socket = new DefaultSocket(m_inetAddress, m_port, m_initConnectionTimeout * THOUSAND);
            if (socket.isConnectionEstablished()) {
                setup(socket);
            } else {
                log.info("connecting failed with server state: " //$NON-NLS-1$
                        + String.valueOf(socket.getState()));
                fireConnectingFailed(m_inetAddress, m_port);
            }
        } catch (IllegalArgumentException iae) {
            log.debug(iae.getLocalizedMessage(), iae);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (IOException ioe) {
            log.debug(ioe.getLocalizedMessage(), ioe);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (SecurityException se) {
            log.debug(se.getLocalizedMessage(), se);
            fireConnectingFailed(m_inetAddress, m_port);
            throw se;
        }
    }

    return acceptingThread;
}

From source file:org.eclipse.jubula.communication.internal.Communicator.java

/**
 * establish the connection, either connecting to a server or accepting
 * connections. This method will not block. If a connection could not made,
 * the listeners are notified with connectingFailed() and acceptingFailed
 * respectively./*from  w  w w . j  a  va 2s. c om*/
 * 
 * @return the Thread responsible for accepting connections, or 
 *         <code>null</code> if the the receiver is acting as a client.
 * @throws SecurityException
 *             if the security manager does not allow connections.
 * @throws JBVersionException
 *             in case of version error between Client and AutStarter
 */
public synchronized Thread run() throws SecurityException, JBVersionException {

    Thread acceptingThread = null;
    if (m_serverSocket != null && !isAccepting()) {
        // it's a server that hasn't yet started accepting connections
        setAccepting(true);
        acceptingThread = new AcceptingThread();
        acceptingThread.start();
    } else if (m_inetAddress != null) {
        // it's a client
        try {
            DefaultClientSocket socket = new DefaultClientSocket(m_inetAddress, m_port,
                    DEFAULT_CONNECTING_TIMEOUT * THOUSAND);
            if (socket.isConnectionEstablished()) {
                setup(socket);
            } else {
                log.info("connecting failed with server state: " //$NON-NLS-1$
                        + String.valueOf(socket.getState()));
                fireConnectingFailed(m_inetAddress, m_port);
            }
        } catch (IllegalArgumentException iae) {
            log.debug(iae.getLocalizedMessage(), iae);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (IOException ioe) {
            log.debug(ioe.getLocalizedMessage(), ioe);
            fireConnectingFailed(m_inetAddress, m_port);
        } catch (SecurityException se) {
            log.debug(se.getLocalizedMessage(), se);
            fireConnectingFailed(m_inetAddress, m_port);
            throw se;
        }
    }

    return acceptingThread;
}

From source file:org.eclipse.jubula.communication.internal.Communicator.java

/**
 * Send a message through this communicator and expect a response of type
 * command. ICommand.request will be called at the other site. If a response
 * was received the corresponding data will be set to the command object via
 * setData(). If the response was received during the given timeout,
 * command.response will be called. Otherwise command.timeout will be
 * called. This method will not block.//from  www  .j a va  2 s  . c o m
 * 
 * @param message -
 *            the Message to send, must not be null otherwise an
 *            CommunicationException is thrown.
 * @param command -
 *            the expected command, must not be null or a
 *            CommunicationException is thrown. If the command arrives in
 *            good time, the method execute() of the given instance will be
 *            called. If the commands arrives to late timeout() will be
 *            called.
 * @param timeout -
 *            max milliseconds to wait for a response. Only values greater 
 *            than zero are valid. For values less or equals to zero the
 *            configured default timeout will be used. If the timeout
 *            expires, the method timeout() in command will be called.
 * @throws CommunicationException
 *             if any error/exception occurs. A CommnunicationException is
 *             also thrown if this communicator is not connected, e.g. run()
 *             was not called, or exceptions at creation time were ignored
 */
public void request(Message message, ICommand command, int timeout) throws CommunicationException {
    checkConnectionState("request()"); //$NON-NLS-1$
    // check parameter
    if (message == null) {
        log.debug("method request with null for parameter" //$NON-NLS-1$
                + "message called."); //$NON-NLS-1$
        throw new CommunicationException("no message to send as request", MessageIDs.E_MESSAGE_NOT_TO_REQUEST); //$NON-NLS-1$
    }
    if (command == null) {
        log.debug("method request with null for parameter " //$NON-NLS-1$
                + "command called"); //$NON-NLS-1$
        throw new CommunicationException("no command for receiving response", //$NON-NLS-1$
                MessageIDs.E_NO_RECEIVING_COMMAND);
    }
    int timeoutToUse = DEFAULT_REQUEST_TIMEOUT;
    if (timeout <= 0) {
        log.debug("invalid timeout given to request: " + //$NON-NLS-1$
                "using default timeout"); //$NON-NLS-1$
    } else {
        timeoutToUse = timeout;
    }
    MessageIdentifier messageIdentifier = new MessageIdentifier(m_connection.getNextSequenceNumber());
    try {
        message.setMessageId(messageIdentifier);
        // create string message
        String messageToSend = m_serializer.serialize(message);
        // put command into awaiting responses
        AwaitingCommand awaitingCommand = new AwaitingCommand(command, timeoutToUse);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.put(messageIdentifier, awaitingCommand);
        }
        // send message and start thread
        m_connection.send(new MessageHeader(MessageHeader.REQUEST, message), messageToSend);
        awaitingCommand.start();
    } catch (SerialisationException se) {
        log.error(se.getLocalizedMessage(), se);
        throw new CommunicationException("could not send message as request:" //$NON-NLS-1$
                + se.getMessage(), MessageIDs.E_MESSAGE_NOT_TO_REQUEST);
    } catch (IOException ioe) {
        log.error(ioe.getLocalizedMessage(), ioe);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.remove(messageIdentifier);
        }
        throw new CommunicationException("io error occured during requesting a message: "//$NON-NLS-1$
                + ioe.getMessage(), MessageIDs.E_MESSAGE_REQUEST);
    } catch (IllegalArgumentException iae) {
        log.error(iae.getLocalizedMessage(), iae);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.remove(messageIdentifier);
        }
        log.debug(iae.getLocalizedMessage(), iae);
        throw new CommunicationException("message could not send as a request", //$NON-NLS-1$
                MessageIDs.E_MESSAGE_NOT_TO_REQUEST);
    }
}

From source file:org.eclipse.jubula.communication.Communicator.java

/**
 * Send a message through this communicator and expect a response of type
 * command. ICommand.request will be called at the other site. If a response
 * was received the corresponding data will be set to the command object via
 * setData(). If the response was received during the given timeout,
 * command.response will be called. Otherwise command.timeout will be
 * called. This method will not block./*from   w w  w  .j  av a2 s.  c  o  m*/
 * 
 * @param message -
 *            the Message to send, must not be null otherwise an
 *            CommunicationException is thrown.
 * @param command -
 *            the expected command, must not be null or a
 *            CommunicationException is thrown. If the command arrives in
 *            good time, the method execute() of the given instance will be
 *            called. If the commands arrives to late timeout() will be
 *            called.
 * @param timeout -
 *            max milliseconds to wait for a response. Only values greater 
 *            than zero are valid. For values less or equals to zero the
 *            configured default timeout will be used. If the timeout
 *            expires, the method timeout() in command will be called.
 * @throws CommunicationException
 *             if any error/exception occurs. A CommnunicationException is
 *             also thrown if this communicator is not connected, e.g. run()
 *             was not called, or exceptions at creation time were ignored
 */
public void request(Message message, ICommand command, int timeout) throws CommunicationException {
    checkConnectionState("request()"); //$NON-NLS-1$
    // check parameter
    if (message == null) {
        log.debug("method request with null for parameter" //$NON-NLS-1$
                + "message called."); //$NON-NLS-1$
        throw new CommunicationException("no message to send as request", MessageIDs.E_MESSAGE_NOT_TO_REQUEST); //$NON-NLS-1$
    }
    if (command == null) {
        log.debug("method request with null for parameter " //$NON-NLS-1$
                + "command called"); //$NON-NLS-1$
        throw new CommunicationException("no command for receiving response", //$NON-NLS-1$
                MessageIDs.E_NO_RECEIVING_COMMAND);
    }
    int timeoutToUse = m_requestTimeout;
    if (timeout <= 0) {
        log.debug("invalid timeout given to request: " + //$NON-NLS-1$
                "using default timeout"); //$NON-NLS-1$
    } else {
        timeoutToUse = timeout;
    }
    MessageIdentifier messageIdentifier = new MessageIdentifier(m_connection.getNextSequenceNumber());
    try {
        message.setMessageId(messageIdentifier);
        // create string message
        String messageToSend = m_serializer.serialize(message);
        // put command into awaiting responses
        AwaitingCommand awaitingCommand = new AwaitingCommand(command, timeoutToUse);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.put(messageIdentifier, awaitingCommand);
        }
        // send message and start thread
        m_connection.send(new MessageHeader(MessageHeader.REQUEST, message), messageToSend);
        awaitingCommand.start();
    } catch (SerialisationException se) {
        log.error(se.getLocalizedMessage(), se);
        throw new CommunicationException("could not send message as request:" //$NON-NLS-1$
                + se.getMessage(), MessageIDs.E_MESSAGE_NOT_TO_REQUEST);
    } catch (IOException ioe) {
        log.error(ioe.getLocalizedMessage(), ioe);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.remove(messageIdentifier);
        }
        throw new CommunicationException("io error occured during requesting a message: "//$NON-NLS-1$
                + ioe.getMessage(), MessageIDs.E_MESSAGE_REQUEST);
    } catch (IllegalArgumentException iae) {
        log.error(iae.getLocalizedMessage(), iae);
        synchronized (m_awaitingCommands) {
            m_awaitingCommands.remove(messageIdentifier);
        }
        log.debug(iae.getLocalizedMessage(), iae);
        throw new CommunicationException("message could not send as a request", //$NON-NLS-1$
                MessageIDs.E_MESSAGE_NOT_TO_REQUEST);
    }
}