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 localAS/*  w w  w  .ja  va 2  s .  c  om*/
 *          the localAS to set
 */
void setLocalAS(final int localAS) throws ConfigurationException {
    if (localAS <= 0) {
        throw new ConfigurationException("negative AS number not allowed");
    }

    this.localAS = localAS;
}

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

/**
 * @param remoteAS//  w  ww .jav  a  2s.  c  o  m
 *          the remoteAS to set
 * @throws ConfigurationException
 */
void setRemoteAS(final int remoteAS) throws ConfigurationException {
    if (remoteAS <= 0) {
        throw new ConfigurationException("negative AS number not allowed");
    }

    this.remoteAS = remoteAS;
}

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

/**
 * Get MSISDN properties by operator Id.
 *
 * @param operatorId   operator Id./*from   ww  w.j ava  2s .  c o  m*/
 * @param operatorName operator Name.
 * @return MSISDN properties of given operator.
 * @throws SQLException    on errors
 * @throws NamingException on errors
 */
public static List<MSISDNHeader> getMSISDNPropertiesByOperatorId(int operatorId, String operatorName)
        throws SQLException, NamingException {
    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;
    List<MSISDNHeader> msisdnHeaderList = new ArrayList<MSISDNHeader>();
    String queryToGetOperatorProperty = "SELECT  msisdnHeaderName, isHeaderEncrypted, encryptionImplementation, "
            + "msisdnEncryptionKey, priority FROM operators_msisdn_headers_properties WHERE operatorId = ? ORDER BY"
            + " priority ASC";
    try {
        connection = getConnectDBConnection();
        preparedStatement = connection.prepareStatement(queryToGetOperatorProperty);
        preparedStatement.setInt(1, operatorId);
        resultSet = preparedStatement.executeQuery();
        while (resultSet.next()) {
            MSISDNHeader msisdnHeader = new MSISDNHeader();
            msisdnHeader.setMsisdnHeaderName(resultSet.getString(AuthProxyConstants.MSISDN_HEADER_NAME));
            msisdnHeader.setHeaderEncrypted(resultSet.getBoolean(AuthProxyConstants.IS_HEADER_ENCRYPTED));
            msisdnHeader.setHeaderEncryptionMethod(
                    resultSet.getString(AuthProxyConstants.ENCRYPTION_IMPLEMENTATION));
            msisdnHeader.setHeaderEncryptionKey(resultSet.getString(AuthProxyConstants.MSISDN_ENCRYPTION_KEY));
            msisdnHeader.setPriority(resultSet.getInt(AuthProxyConstants.PRIORITY));
            msisdnHeaderList.add(msisdnHeader);
        }
    } catch (SQLException e) {
        throw new SQLException(
                "Error occurred while retrieving operator MSISDN properties of operator : " + operatorName, e);
    } catch (NamingException e) {
        throw new ConfigurationException("DataSource could not be found in mobile-connect.xml");
    } finally {
        closeAllConnections(preparedStatement, connection, resultSet);
    }
    return msisdnHeaderList;
}

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

private synchronized String login() throws ExecutionException {
    String result = null;/*from   ww  w  . ja  v a2s.  c o  m*/
    JSONObject jsonResponse = null;
    try {
        URI agentUri = null;
        agentUri = new URI("https", null, _ip, DEFAULT_PORT, "/nitro/v2/config/" + "login", null, null);
        org.json.JSONObject jsonBody = new JSONObject();
        org.json.JSONObject jsonCredentials = new JSONObject();
        jsonCredentials.put("username", _username);
        jsonCredentials.put("password", _password);
        jsonBody.put("login", jsonCredentials);

        result = postHttpRequest(jsonBody.toString(), agentUri, _sessionid);
        if (result == null) {
            throw new ConfigurationException("No Response Received from the NetScalerControlCenter Device");
        } else {
            jsonResponse = new JSONObject(result);
            org.json.JSONArray loginResponse = jsonResponse.getJSONArray("login");
            _sessionid = jsonResponse.getJSONArray("login").getJSONObject(0).getString("sessionid");
            s_logger.debug("New Session id from NCC :" + _sessionid);
            set_nccsession(_sessionid);
            s_logger.debug("session on Static Session variable" + get_nccsession());
        }
        s_logger.debug("Login to NCC Device response :: " + result);
        return result;
    } catch (URISyntaxException e) {
        String errMsg = "Could not generate URI for Hyper-V agent";
        s_logger.error(errMsg, e);

    } catch (JSONException e) {
        s_logger.debug("JSON Exception :" + e.getMessage());
        throw new ExecutionException("Failed to log in to NCC device at " + _ip + " due to " + e.getMessage());
    } catch (Exception e) {
        throw new ExecutionException("Failed to log in to NCC device at " + _ip + " due to " + e.getMessage());
    }
    return result;
}

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

/**
 * @param name//from   w  ww.j a v a2s.  c o m
 *          the name to set
 * @throws ConfigurationException
 */
void setPeerName(final String name) throws ConfigurationException {
    if (StringUtils.isBlank(name)) {
        throw new ConfigurationException("blank name not allowed");
    }

    this.peerName = name;
}

From source file:com.cloud.user.AccountManagerImpl.java

@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {
    _name = name;//from ww  w  . j  a  v  a  2s.  c  o  m

    _systemAccount = _accountDao.findById(AccountVO.ACCOUNT_ID_SYSTEM);
    if (_systemAccount == null) {
        throw new ConfigurationException(
                "Unable to find the system account using " + Account.ACCOUNT_ID_SYSTEM);
    }

    _systemUser = _userDao.findById(UserVO.UID_SYSTEM);
    if (_systemUser == null) {
        throw new ConfigurationException("Unable to find the system user using " + User.UID_SYSTEM);
    }

    ComponentLocator locator = ComponentLocator.getCurrentLocator();
    ConfigurationDao configDao = locator.getDao(ConfigurationDao.class);
    Map<String, String> configs = configDao.getConfiguration(params);

    String loginAttempts = configs.get(Config.IncorrectLoginAttemptsAllowed.key());
    _allowedLoginAttempts = NumbersUtil.parseInt(loginAttempts, 5);

    String value = configs.get(Config.AccountCleanupInterval.key());
    _cleanupInterval = NumbersUtil.parseInt(value, 60 * 60 * 24); // 1 day.

    _userAuthenticators = locator.getAdapters(UserAuthenticator.class);
    if (_userAuthenticators == null || !_userAuthenticators.isSet()) {
        s_logger.error("Unable to find an user authenticator.");
    }

    return true;
}

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

/**
 * setupServer://from  w  w  w  . ja v a 2s .c  o  m
 * Add the cloudstack plugin and setup the agent.
 * Add the ssh keys to the host.
 *
 * @param c
 * @throws IOException
 */
public Boolean setupServer(String key) throws IOException {
    LOGGER.debug("Setup all bits on agent: " + config.getAgentHostname());
    /* version dependent patching ? */
    try {
        com.trilead.ssh2.Connection sshConnection = SSHCmdHelper.acquireAuthorizedConnection(
                config.getAgentIp(), config.getAgentSshUserName(), config.getAgentSshPassword());
        if (sshConnection == null) {
            throw new ConfigurationException(
                    String.format("Unable to " + "connect to server(IP=%1$s, username=%2$s, " + "password=%3$s",
                            config.getAgentIp(), config.getAgentSshUserName(), config.getAgentSshPassword()));
        }
        SCPClient scp = new SCPClient(sshConnection);
        String userDataScriptDir = "scripts/vm/hypervisor/ovm3/";
        String userDataScriptPath = Script.findScript("", userDataScriptDir);
        if (userDataScriptPath == null) {
            throw new ConfigurationException("Can not find " + userDataScriptDir);
        }
        String mkdir = "mkdir -p " + config.getAgentScriptsDir();
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, mkdir)) {
            throw new ConfigurationException("Failed " + mkdir + " on " + config.getAgentHostname());
        }
        for (String script : config.getAgentScripts()) {
            script = userDataScriptPath + "/" + script;
            scp.put(script, config.getAgentScriptsDir(), "0755");
        }
        String prepareCmd = String.format(config.getAgentScriptsDir() + "/" + config.getAgentScript()
                + " --ssl=" + c.getUseSsl() + " " + "--port=" + c.getPort());
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
            throw new ConfigurationException("Failed to insert module on " + config.getAgentHostname());
        } else {
            /* because of OVM 3.3.1 (might be 2000) */
            Thread.sleep(5000);
        }
        CloudstackPlugin cSp = new CloudstackPlugin(c);
        cSp.ovsUploadSshKey(config.getAgentSshKeyFileName(),
                FileUtils.readFileToString(getSystemVMKeyFile(key)));
        cSp.dom0CheckStorageHealthCheck(config.getAgentScriptsDir(), config.getAgentCheckStorageScript(),
                config.getCsHostGuid(), config.getAgentStorageCheckTimeout(),
                config.getAgentStorageCheckInterval());
    } catch (Exception es) {
        LOGGER.error("Unexpected exception ", es);
        String msg = "Unable to install module in agent";
        throw new CloudRuntimeException(msg);
    }
    return true;
}

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

/**
 * @param localBgpIdentifier//from  w w  w. ja  va  2 s. c  o m
 *          the localBgpIdentifier to set
 */
void setLocalBgpIdentifier(final long localBgpIdentifier) throws ConfigurationException {
    if (localBgpIdentifier <= 0) {
        throw new ConfigurationException("Illegal local BGP identifier: " + localBgpIdentifier);
    }
    this.localBgpIdentifier = localBgpIdentifier;
}

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

/**
 * Get user details in Back Channeling Scenario using sessionID
 *
 * @param sessionId Id of the session/*from ww  w.  j  av a  2  s  .c  om*/
 */
public static BackChannelRequestDetails getBackChannelUserDetails(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.setCorrelationId(resultSet.getString("correlation_id"));
            backChannelRequestDetails.setSessionId(resultSet.getString("session_id"));
            backChannelRequestDetails.setNotificationUrl(resultSet.getString("notification_url"));
            backChannelRequestDetails
                    .setNotificationBearerToken(resultSet.getString("notification_bearer_token"));
            backChannelRequestDetails.setAuthCode(resultSet.getString("auth_code"));
            backChannelRequestDetails.setMsisdn(resultSet.getString("msisdn"));
            backChannelRequestDetails.setRequestIniticatedTime(resultSet.getString("request_initiated_time"));
            backChannelRequestDetails.setClientId(resultSet.getString("client_id"));
            backChannelRequestDetails.setRedirectUrl(resultSet.getString("redirect_url"));
        }
    } catch (SQLException e) {
        handleException("Error occurred while getting user related details for session: " + sessionId
                + "in BackChannel " + "Scenario.", 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.baremetal.networkservice.BaremetalPingPxeResource.java

private Answer execute(VmDataCommand cmd) {
    com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(_ip, 22);
    try {/*from  ww  w.j  a v a  2s. c  om*/
        List<String[]> vmData = cmd.getVmData();
        StringBuilder sb = new StringBuilder();
        for (String[] data : vmData) {
            String folder = data[0];
            String file = data[1];
            String contents = (data[2] == null) ? "none" : data[2];
            sb.append(cmd.getVmIpAddress());
            sb.append(",");
            sb.append(folder);
            sb.append(",");
            sb.append(file);
            sb.append(",");
            sb.append(contents);
            sb.append(";");
        }
        String arg = org.apache.commons.lang.StringUtils.stripEnd(sb.toString(), ";");

        sshConnection.connect(null, 60000, 60000);
        if (!sshConnection.authenticateWithPassword(_username, _password)) {
            s_logger.debug("SSH Failed to authenticate");
            throw new ConfigurationException(
                    String.format("Cannot connect to PING PXE server(IP=%1$s, username=%2$s, password=%3$s",
                            _ip, _username, _password));
        }

        String script = String.format("python /usr/bin/baremetal_user_data.py '%s'", arg);
        if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) {
            return new Answer(cmd, false, "Failed to add user data, command:" + script);
        }

        return new Answer(cmd, true, "Success");
    } catch (Exception e) {
        s_logger.debug("Prepare for creating baremetal template failed", e);
        return new Answer(cmd, false, e.getMessage());
    } finally {
        if (sshConnection != null) {
            sshConnection.close();
        }
    }
}