Example usage for javax.naming ConfigurationException ConfigurationException

List of usage examples for javax.naming ConfigurationException ConfigurationException

Introduction

In this page you can find the example usage for javax.naming ConfigurationException ConfigurationException.

Prototype

public ConfigurationException(String explanation) 

Source Link

Document

Constructs a new instance of ConfigurationException using an explanation.

Usage

From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java

/**
 * @param remoteBgpIdentifier/*from w ww  .j av  a2s . c  om*/
 *          the remoteBgpIdentifier to set
 */
void setRemoteBgpIdentifier(final long remoteBgpIdentifier) throws ConfigurationException {
    if (remoteBgpIdentifier <= 0) {
        throw new ConfigurationException("Illegal remote BGP identifier: " + remoteBgpIdentifier);
    }
    this.remoteBgpIdentifier = remoteBgpIdentifier;
}

From source file:com.cloud.agent.AgentShell.java

protected boolean parseCommand(final String[] args) throws ConfigurationException {
    String host = null;/*from  w ww  .  jav a  2s  .  com*/
    String workers = null;
    String port = null;
    String zone = null;
    String pod = null;
    String guid = null;
    for (int i = 0; i < args.length; i++) {
        final String[] tokens = args[i].split("=");
        if (tokens.length != 2) {
            System.out.println("Invalid Parameter: " + args[i]);
            continue;
        }

        // save command line properties
        _cmdLineProperties.put(tokens[0], tokens[1]);

        if (tokens[0].equalsIgnoreCase("port")) {
            port = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("threads") || tokens[0].equalsIgnoreCase("workers")) {
            workers = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("host")) {
            host = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("zone")) {
            zone = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("pod")) {
            pod = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("guid")) {
            guid = tokens[1];
        } else if (tokens[0].equalsIgnoreCase("eth1ip")) {
            _privateIp = tokens[1];
        }
    }

    if (port == null) {
        port = getProperty(null, "port");
    }

    _port = NumbersUtil.parseInt(port, 8250);

    _proxyPort = NumbersUtil.parseInt(getProperty(null, "consoleproxy.httpListenPort"), 443);

    if (workers == null) {
        workers = getProperty(null, "workers");
    }

    _workers = NumbersUtil.parseInt(workers, 5);

    if (host == null) {
        host = getProperty(null, "host");
    }

    if (host == null) {
        host = "localhost";
    }
    _host = host;

    if (zone != null)
        _zone = zone;
    else
        _zone = getProperty(null, "zone");
    if (_zone == null || (_zone.startsWith("@") && _zone.endsWith("@"))) {
        _zone = "default";
    }

    if (pod != null)
        _pod = pod;
    else
        _pod = getProperty(null, "pod");
    if (_pod == null || (_pod.startsWith("@") && _pod.endsWith("@"))) {
        _pod = "default";
    }

    if (_host == null || (_host.startsWith("@") && _host.endsWith("@"))) {
        throw new ConfigurationException("Host is not configured correctly: " + _host);
    }

    final String retries = getProperty(null, "ping.retries");
    _pingRetries = NumbersUtil.parseInt(retries, 5);

    String value = getProperty(null, "developer");
    boolean developer = Boolean.parseBoolean(value);

    if (guid != null)
        _guid = guid;
    else
        _guid = getProperty(null, "guid");
    if (_guid == null) {
        if (!developer) {
            throw new ConfigurationException("Unable to find the guid");
        }
        _guid = UUID.randomUUID().toString();
    }

    return true;
}

From source file:com.wso2telco.proxy.util.DBUtils.java

/**
 * Get a map of parameters mapped to a scope
 *
 * @return map of scope vs parameters/*from w w w .  ja  v  a2 s . c  o m*/
 * @throws AuthenticatorException on errors
 */
public static Map<String, ScopeParam> getScopeParams(String scope) throws AuthenticatorException {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet results = null;
    String[] scopeValues = scope.split("\\s+|\\+");
    StringBuilder params = new StringBuilder("?");
    for (int i = 1; i < scopeValues.length; i++) {
        params.append(",?");
    }
    String sql = "SELECT * FROM `scope_parameter` WHERE scope in (" + params + ")";

    if (log.isDebugEnabled()) {
        log.debug("Executing the query " + sql);
    }

    Map scopeParamsMap = new HashMap();
    try {
        conn = getConnectDBConnection();
        ps = conn.prepareStatement(sql);
        for (int i = 0; i < scopeValues.length; i++) {
            ps.setString(i + 1, scopeValues[i]);
        }
        results = ps.executeQuery();

        Boolean mainScopeFound = false;
        List<String> scopeValuesFromDatabase = new ArrayList<>();

        while (results.next()) {
            Boolean isMultiscope = results.getBoolean("is_multiscope");
            scopeValuesFromDatabase.add(results.getString("scope"));

            if (!isMultiscope) {
                //throw error if multiple main scopes found
                if (mainScopeFound) {
                    throw new ConfigurationException("Multiple main scopes found");
                }

                //mark as main scope found
                mainScopeFound = true;

                scopeParamsMap.put("scope", results.getString("scope"));

                ScopeParam parameters = new ScopeParam();
                parameters.setScope(results.getString("scope"));
                parameters.setLoginHintMandatory(results.getBoolean("is_login_hint_mandatory"));
                parameters.setHeaderMsisdnMandatory(results.getBoolean("is_header_msisdn_mandatory"));
                parameters.setMsisdnMismatchResult(ScopeParam.msisdnMismatchResultTypes
                        .valueOf(results.getString("msisdn_mismatch_result")));
                parameters.setHeFailureResult(
                        ScopeParam.heFailureResults.valueOf(results.getString("he_failure_result")));
                parameters.setTncVisible(results.getBoolean("is_tnc_visible"));
                parameters.setLoginHintFormat(getLoginHintFormatTypeDetails(results.getInt("param_id"), conn));

                scopeParamsMap.put("params", parameters);
            }
        }

        //validate all scopes and compare with scopes fetched from database
        for (String scopeToValidate : scopeValues) {
            if (!scopeValuesFromDatabase.contains(scopeToValidate)) {
                throw new ConfigurationException("One or more scopes are not valid");
            }
        }
    } catch (SQLException e) {
        handleException("Error occurred while getting scope parameters from the database", e);
    } catch (ConfigurationException e) {
        handleException(e.getMessage(), e);
    } catch (NamingException e) {
        log.error("Naming exception ", e);
    } finally {
        closeAllConnections(ps, conn, results);
    }
    return scopeParamsMap;
}

From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java

/**
 * @param holdTime//  w  w  w. j a v  a 2  s  . c  o  m
 *          the holdTime to set
 */
void setHoldTime(final int holdTime) throws ConfigurationException {
    if (holdTime < 0) {
        throw new ConfigurationException("Illegal hold time given: " + holdTime);
    }

    this.holdTime = holdTime;
}

From source file:com.cloud.network.vpn.RemoteAccessVpnManagerImpl.java

private void validateRemoteAccessVpnConfiguration() throws ConfigurationException {
    String ipRange = RemoteAccessVpnClientIpRange.value();
    if (ipRange == null) {
        s_logger.warn("Remote Access VPN global configuration missing client ip range -- ignoring");
        return;//from ww w  . j a v a2 s  . c o m
    }
    Integer pskLength = _pskLength;
    if (pskLength != null && (pskLength < 8 || pskLength > 256)) {
        throw new ConfigurationException(
                "Remote Access VPN: IPSec preshared key length should be between 8 and 256");
    }

    String[] range = ipRange.split("-");
    if (range.length != 2) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip range " + ipRange);
    }
    if (!NetUtils.isValidIp(range[0]) || !NetUtils.isValidIp(range[1])) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip in range specification " + ipRange);
    }
    if (!NetUtils.validIpRange(range[0], range[1])) {
        throw new ConfigurationException("Remote Access VPN: Invalid ip range " + ipRange);
    }
}

From source file:io.netlibs.bgp.config.nodes.impl.PeerConfigurationImpl.java

/**
 * @param connectRetryInterval/*from w  w w  . j  a  v a  2 s.  c om*/
 *          the connectRetryInterval to set
 */
void setIdleHoldTime(final int connectRetryInterval) throws ConfigurationException {
    if (connectRetryInterval < 0) {
        throw new ConfigurationException("Illegal connect retry interval given: " + connectRetryInterval);
    }

    this.idleHoldTime = connectRetryInterval;
}

From source file:com.cloud.network.resource.NitroError.java

@Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
    try {/* w ww .  j a v  a 2s  . c om*/
        _name = (String) params.get("name");
        if (_name == null) {
            throw new ConfigurationException("Unable to find name in the configuration parameters");
        }

        _zoneId = (String) params.get("zoneId");
        if (_zoneId == null) {
            throw new ConfigurationException("Unable to find zone Id  in the configuration parameters");
        }

        _physicalNetworkId = (String) params.get("physicalNetworkId");
        if (_physicalNetworkId == null) {
            throw new ConfigurationException(
                    "Unable to find physical network id in the configuration parameters");
        }

        _ip = (String) params.get("ip");
        if (_ip == null) {
            throw new ConfigurationException("Unable to find IP address in the configuration parameters");
        }

        _username = (String) params.get("username");
        if (_username == null) {
            throw new ConfigurationException("Unable to find username in the configuration parameters");
        }

        _password = (String) params.get("password");
        if (_password == null) {
            throw new ConfigurationException("Unable to find password in the configuration parameters");
        }

        _publicInterface = (String) params.get("publicinterface");
        if (_publicInterface == null) {
            throw new ConfigurationException("Unable to find public interface in the configuration parameters");
        }

        _privateInterface = (String) params.get("privateinterface");
        if (_privateInterface == null) {
            throw new ConfigurationException(
                    "Unable to find private interface in the configuration parameters");
        }

        _numRetries = NumbersUtil.parseInt((String) params.get("numretries"), 2);

        _guid = (String) params.get("guid");
        if (_guid == null) {
            throw new ConfigurationException("Unable to find the guid in the configuration parameters");
        }

        _deviceName = (String) params.get("deviceName");
        if (_deviceName == null) {
            throw new ConfigurationException("Unable to find the device name in the configuration parameters");
        }

        _isSdx = _deviceName.equalsIgnoreCase("NetscalerSDXLoadBalancer");

        _inline = Boolean.parseBoolean((String) params.get("inline"));

        if (((String) params.get("cloudmanaged")) != null) {
            _cloudManaged = Boolean.parseBoolean((String) params.get("cloudmanaged"));
        }

        // validate device configuration parameters
        login();
        validateDeviceType(_deviceName);
        validateInterfaces(_publicInterface, _privateInterface);

        //enable load balancing feature
        enableLoadBalancingFeature();
        SSL.enableSslFeature(_netscalerService, _isSdx);

        //if the the device is cloud stack provisioned then make it part of the public network
        if (_cloudManaged) {
            _publicIP = (String) params.get("publicip");
            _publicIPGateway = (String) params.get("publicipgateway");
            _publicIPNetmask = (String) params.get("publicipnetmask");
            _publicIPVlan = (String) params.get("publicipvlan");
            if ("untagged".equalsIgnoreCase(_publicIPVlan)) {
                // if public network is un-tagged just add subnet IP
                addSubnetIP(_publicIP, _publicIPNetmask);
            } else {
                // if public network is tagged then add vlan and bind subnet IP to the vlan
                addGuestVlanAndSubnet(Long.parseLong(_publicIPVlan), _publicIP, _publicIPNetmask, false);
            }
        }

        return true;
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
}

From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java

/**
 * Get SP related configurations// ww  w .  j a  v  a 2s  . c  o  m
 *
 * @param correlationId
 * @return
 * @throws ConfigurationException
 * @throws CommonAuthenticatorException
 */
public static BackChannelRequestDetails getRequestDetailsById(String correlationId)
        throws ConfigurationException, CommonAuthenticatorException {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    BackChannelRequestDetails backchannelRequestDetails = null;
    ResultSet resultSet = null;

    String getUserDetailsQuery = "select * FROM backchannel_request_details where correlation_id=?";

    try {
        connection = getConnectDBConnection();

        if (log.isDebugEnabled()) {
            log.debug("Executing the query " + getUserDetailsQuery);
        }

        preparedStatement = connection.prepareStatement(getUserDetailsQuery);
        preparedStatement.setString(1, correlationId);
        resultSet = preparedStatement.executeQuery();

        if (resultSet.next()) {
            backchannelRequestDetails = new BackChannelRequestDetails();
            backchannelRequestDetails.setSessionId(resultSet.getString("session_id"));
            backchannelRequestDetails.setAuthCode(resultSet.getString("auth_code"));
            backchannelRequestDetails.setCorrelationId(resultSet.getString("correlation_id"));
            backchannelRequestDetails.setMsisdn(resultSet.getString("msisdn"));
            backchannelRequestDetails
                    .setNotificationBearerToken(resultSet.getString("notification_bearer_token"));
            backchannelRequestDetails.setNotificationUrl(resultSet.getString("notification_url"));
            backchannelRequestDetails.setClientId(resultSet.getString("client_id"));
        }
    } catch (SQLException e) {
        handleException(
                "Error occurred while fetching SP related data for the Correlation Id: " + correlationId, e);
    } catch (NamingException e) {
        throw new ConfigurationException("DataSource could not be found in mobile-connect.xml");
    } finally {
        closeAllConnections(preparedStatement, connection, resultSet);
    }

    return backchannelRequestDetails;
}

From source file:com.cloud.hypervisor.ovm3.resources.helpers.Ovm3Configuration.java

/**
 * ValidateParam: Validate the input for configure
 * @param name/*w w w.jav a  2s .c  om*/
 * @param param
 * @return param
 * @throws ConfigurationException
 */
private String validateParam(String name, String param) throws ConfigurationException {
    if (param == null) {
        String msg = "Unable to get " + name + " params are null";
        LOGGER.debug(msg);
        throw new ConfigurationException(msg);
    }
    return param;
}

From source file:com.wso2telco.dbUtil.DataBaseConnectUtils.java

/**
 * Get SP related configurations/*from   ww w .j  a  va  2  s  .  c  o m*/
 *
 * @param sessionId
 * @return
 * @throws ConfigurationException
 * @throws CommonAuthenticatorException
 */
public static BackChannelRequestDetails getRequestDetailsBySessionId(String sessionId)
        throws ConfigurationException, CommonAuthenticatorException {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    BackChannelRequestDetails backchannelRequestDetails = null;
    ResultSet resultSet = null;

    String getUserDetailsQuery = "select * FROM backchannel_request_details where session_id=?";

    try {
        connection = getConnectDBConnection();

        if (log.isDebugEnabled()) {
            log.debug("Executing the query " + getUserDetailsQuery);
        }

        preparedStatement = connection.prepareStatement(getUserDetailsQuery);
        preparedStatement.setString(1, sessionId);
        resultSet = preparedStatement.executeQuery();

        if (resultSet.next()) {
            backchannelRequestDetails = new BackChannelRequestDetails();
            backchannelRequestDetails.setSessionId(resultSet.getString("session_id"));
            backchannelRequestDetails.setAuthCode(resultSet.getString("auth_code"));
            backchannelRequestDetails.setCorrelationId(resultSet.getString("correlation_id"));
            backchannelRequestDetails.setMsisdn(resultSet.getString("msisdn"));
            backchannelRequestDetails
                    .setNotificationBearerToken(resultSet.getString("notification_bearer_token"));
            backchannelRequestDetails.setNotificationUrl(resultSet.getString("notification_url"));
            backchannelRequestDetails.setClientId(resultSet.getString("client_id"));
        }
    } catch (SQLException e) {
        handleException("Error occurred while fetching SP related data for the Session Id: " + sessionId, e);
    } catch (NamingException e) {
        throw new ConfigurationException("DataSource could not be found in mobile-connect.xml");
    } finally {
        closeAllConnections(preparedStatement, connection, resultSet);
    }

    return backchannelRequestDetails;
}