/** * Check if the connection can be closed when there are uncommitted * operations. * * @return if this connection can be closed when it has uncommitted * operations, {@code true}; otherwise, {@code false} */ protected boolean allowCloseInUOW_() { // We allow closing in unit of work in two cases: // // 1) if auto-commit is on, since then Connection.close() will cause // a commit so we won't leave uncommitted changes around // // 2) if we're not allowed to commit or roll back the transaction via // the connection object (because the it is part of an XA // transaction). In that case, commit and rollback are performed via // the XAResource, and it is therefore safe to close the connection. // // Otherwise, the transaction must be idle before a call to close() is // allowed. return autoCommit_ || !allowLocalCommitRollback_(); }
private void flowEUSRIDPWDconnect(String password) throws SqlException { flowServerAttributes(); checkSecmgrForSecmecSupport(NetConfiguration.SECMEC_EUSRIDPWD); initializePublicKeyForEncryption(); flowKeyExchange(NetConfiguration.SECMEC_EUSRIDPWD, publicKey_); flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism null, //user null, //password encryptedUseridForEUSRIDPWD(), encryptedPasswordForEUSRIDPWD(password)); }
/** * Close the connection and release its resources. * @exception SQLException if a database-access error occurs. */ synchronized public void close() throws SQLException { // Release resources owned by the prepared statement used by isValid if (isValidStmt != null) { isValidStmt.close(); isValidStmt = null; } super.close(); }
private void flowUSRENCPWDconnect(String password) throws SqlException { flowServerAttributes(); checkSecmgrForSecmecSupport(NetConfiguration.SECMEC_USRENCPWD); initializePublicKeyForEncryption(); flowKeyExchange(NetConfiguration.SECMEC_USRENCPWD, publicKey_); flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism user_, null, //password null, //encryptedUserid encryptedPasswordForUSRENCPWD(password)); }
private void initialize(String password, com.pivotal.gemfirexd.internal.jdbc.ClientBaseDataSource dataSource, int rmId, boolean isXAConn) throws SqlException { this.rmId_ = rmId; this.isXAConnection_ = isXAConn; /* (original code) securityMechanism_ = dataSource.getSecurityMechanism(password); setDeferredResetPassword(password); checkDatabaseName(); dataSource_ = dataSource; this.rmId_ = rmId; this.isXAConnection_ = isXAConn; */ // GemStone changes END flowConnect(password, securityMechanism_, true /* GemStone change */); completeConnect(); }
constructExtnam(); constructPrddta(); // construct product data setDeferredResetPassword(password); try { switch (securityMechanism) { case NetConfiguration.SECMEC_USRIDPWD: // Clear text user id and password checkUserPassword(user_, password); flowUSRIDPWDconnect(password); break; case NetConfiguration.SECMEC_USRIDONL: // Clear text user, no password sent to server checkUser(user_); flowUSRIDONLconnect(); break; case NetConfiguration.SECMEC_USRENCPWD: // Clear text user, encrypted password checkUserPassword(user_, password); flowUSRENCPWDconnect(password); break; case NetConfiguration.SECMEC_EUSRIDPWD: // Encrypted user, encrypted password checkUserPassword(user_, password); flowEUSRIDPWDconnect(password); break; case NetConfiguration.SECMEC_EUSRIDDTA: checkUserPassword(user_, password); flowEUSRIDDTAconnect(); break; case NetConfiguration.SECMEC_EUSRPWDDTA: checkUserPassword(user_, password);
final int isolation = getCachedIsolation(); final boolean autoCommit = autoCommit_; serverName = failover(thisUrl, failedUrls, status, port); SQLState.COMMUNICATION_ERROR), "Failed after trying all " + "available servers: " + allServers + ", for control host[port]: " + getLocatorUrl(thisUrl) + getAlternateNetServers(), failoverEx); thisUrl = getServerUrl(this.serverNameIP_, this.portNumber_); clearWarningsX(); final String failedServer = this.netAgent_.getServerLocation(); if (this.netAgent_.reconnectAgent(logWriter, this.loginTimeout_, final String password = getDeferredResetPassword(); flowConnect(password, this.securityMechanism_, false); setCurrentSchema(); setCurrentSchemaCalled = true; completeReset(false, true, false); if (isolation != getCachedIsolation()) { setTransactionIsolationX(isolation); setAutoCommitX(autoCommit);
SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, "Using control connection to host[port] '" + conn .getServerLocation() + "' with refresh=" + refreshServerList); alternates = getAlternateNetServers(alternates); serverUrl = getNextServer(serverIter, alternates, failedUrls, false); final Properties locateProps = getConnectionProperties( incomingProps); locateProps.setProperty(ClientAttribute.LOAD_BALANCE, "false"); if (conn.getTransactionIsolationX() != TRANSACTION_NONE) { conn.setTransactionIsolationX(TRANSACTION_NONE); conn.setAutoCommitX(false); cstmt = conn.prepareCall(qAllAndPreferredServer); cstmt = conn.prepareCall(qPreferredServer); rs = conn.createStatement().executeQuery(qAllServersOnly); if ((status = doFailoverOnException(ex.getSQLState(), ex.getErrorCode(), ex)) != FailoverStatus.NONE) { String failUrl = serverUrl; conn.close(); } catch (Throwable t) {
protected boolean flowReconnect(String password, int securityMechanism) throws SqlException { constructExtnam(); constructPrddta(); //modify this to not new up an array checkSecmgrForSecmecSupport(securityMechanism); try { switch (securityMechanism) { case NetConfiguration.SECMEC_USRIDPWD: // Clear text user id and password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_USRIDONL: // Clear text user, no password sent to server checkUser(user_); resetConnectionAtFirstSql_ = true; return true; case NetConfiguration.SECMEC_USRENCPWD: // Clear text user, encrypted password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_EUSRIDPWD: // Encrypted user, encrypted password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_EUSRIDDTA: checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true;
/** * The User ID and Strong Password Substitute mechanism (USRSSBPWD) * authenticates the user like the user ID and password mechanism, but * the password does not flow. A password substitute is generated instead * using the SHA-1 algorithm, and is sent to the application server. * * The application server generates a password substitute using the same * algorithm and compares it with the application requester's password * substitute. If equal, the user is authenticated. * * The SECTKN parameter is used to flow the client and server encryption * seeds on the ACCSEC and ACCSECRD commands. * * More information in DRDA, V3, Volume 3 standard - PWDSSB (page 650) */ private void flowUSRSSBPWDconnect(String password) throws SqlException { flowServerAttributes(); checkSecmgrForSecmecSupport(NetConfiguration.SECMEC_USRSSBPWD); // Generate a random client seed to send to the target server - in // response we will also get a generated seed from this last one. // Seeds are used on both sides to generate the password substitute. initializeClientSeed(); flowSeedExchange(NetConfiguration.SECMEC_USRSSBPWD, sourceSeed_); flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism user_, null, null, passwordSubstituteForUSRSSBPWD(password)); // PWD Substitute }
public NetConnection(NetLogWriter netLogWriter, int driverManagerLoginTimeout, String serverName, int portNumber, String databaseName, java.util.Properties properties) throws SqlException { super(netLogWriter, driverManagerLoginTimeout, serverName, portNumber, databaseName, properties); this.pooledConnection_ = null; this.closeStatementsOnClose = true; netAgent_ = (NetAgent) super.agent_; if (netAgent_.exceptionOpeningSocket_ != null) { throw netAgent_.exceptionOpeningSocket_; } checkDatabaseName(); String password = ClientBaseDataSource.getPassword(properties); securityMechanism_ = ClientBaseDataSource.getSecurityMechanism(properties); isODBCDriver = ClientBaseDataSource.getIsODBCDriver(properties); flowConnect(password, securityMechanism_, true /* GemStone change */); if(!isConnectionNull()) completeConnect(); if (isODBCDriver) { if (SanityManager.TraceClientHA) { SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, "ODBC: Adding odbc connection to the connections list"); } odbcConnectionList.add(this); } }
boolean toRouteQuery = isSnappyDRDAProtocol(); String routeQuery = properties.getProperty( ClientAttribute.ROUTE_QUERY); setDeferredResetPassword(password); checkDatabaseName(); dataSource_ = dataSource;
private void checkUserPassword(String user, String password) throws SqlException { checkUser(user); if (password == null) { throw new SqlException(netAgent_.logWriter_, new ClientMessageId(SQLState.CONNECT_PASSWORD_ISNULL)); } checkPasswordLength(password); }
public NetConnection(NetLogWriter netLogWriter, String ipaddr, int portNumber, com.pivotal.gemfirexd.internal.jdbc.ClientBaseDataSource dataSource, boolean isXAConn) throws SqlException { super(netLogWriter, isXAConn, dataSource); this.pooledConnection_ = null; this.closeStatementsOnClose = true; netAgent_ = (NetAgent) super.agent_; if (netAgent_.exceptionOpeningSocket_ != null) { throw netAgent_.exceptionOpeningSocket_; } checkDatabaseName(); this.isXAConnection_ = isXAConn; flowSimpleConnect(); productID_ = targetSrvrlslv_; super.completeConnect(); }
NetConnection conn = (NetConnection)e.getKey(); SqlException sqle = (SqlException)e.getValue(); if (conn.doFailoverOnException(sqle.getSQLState(), sqle.getErrorCode(), sqle) == FailoverStatus.NEW_SERVER) { conn.close(); } catch (SQLException se) {
private void checkUser(String user) throws SqlException { if (user == null) { throw new SqlException(netAgent_.logWriter_, new ClientMessageId(SQLState.CONNECT_USERID_ISNULL)); } checkUserLength(user); }
constructExtnam(); constructPrddta(); // construct product data setDeferredResetPassword(password); try { switch (securityMechanism) { case NetConfiguration.SECMEC_USRIDPWD: // Clear text user id and password checkUserPassword(user_, password); flowUSRIDPWDconnect(password); break; case NetConfiguration.SECMEC_USRIDONL: // Clear text user, no password sent to server checkUser(user_); flowUSRIDONLconnect(); break; case NetConfiguration.SECMEC_USRENCPWD: // Clear text user, encrypted password checkUserPassword(user_, password); flowUSRENCPWDconnect(password); break; case NetConfiguration.SECMEC_EUSRIDPWD: // Encrypted user, encrypted password checkUserPassword(user_, password); flowEUSRIDPWDconnect(password); break; case NetConfiguration.SECMEC_EUSRIDDTA: checkUserPassword(user_, password); flowEUSRIDDTAconnect(); break; case NetConfiguration.SECMEC_EUSRPWDDTA: checkUserPassword(user_, password);
final int isolation = getCachedIsolation(); final boolean autoCommit = autoCommit_; serverName = failover(thisUrl, failedUrls, status, port); SQLState.COMMUNICATION_ERROR), "Failed after trying all " + "available servers: " + allServers + ", for control host[port]: " + getLocatorUrl(thisUrl) + getAlternateNetServers(), failoverEx); thisUrl = getServerUrl(this.serverNameIP_, this.portNumber_); clearWarningsX(); final String failedServer = this.netAgent_.getServerLocation(); if (this.netAgent_.reconnectAgent(logWriter, this.loginTimeout_, final String password = getDeferredResetPassword(); flowConnect(password, this.securityMechanism_, false); completeReset(false, true, false); if (isolation != getCachedIsolation()) { setTransactionIsolationX(isolation); setAutoCommitX(autoCommit); "Agent now has local address[port] as '" + getServerUrl( String.valueOf(s.getLocalAddress()), s.getLocalPort()) + "', remote address[port] as '" + getAgentString(agent)
SanityManager.DEBUG_PRINT(SanityManager.TRACE_CLIENT_HA, "Using control connection to host[port] '" + conn .getServerLocation() + "' with refresh=" + refreshServerList); alternates = getAlternateNetServers(alternates); serverUrl = getNextServer(serverIter, alternates, failedUrls, false); final Properties locateProps = getConnectionProperties( incomingProps); locateProps.setProperty(ClientAttribute.LOAD_BALANCE, "false"); if (conn.getTransactionIsolationX() != TRANSACTION_NONE) { conn.setTransactionIsolationX(TRANSACTION_NONE); conn.setAutoCommitX(false); cstmt = conn.prepareCall(qAllAndPreferredServer); cstmt = conn.prepareCall(qPreferredServer); rs = conn.createStatement().executeQuery(qAllServersOnly); if ((status = doFailoverOnException(ex.getSQLState(), ex.getErrorCode(), ex)) != FailoverStatus.NONE) { String failUrl = serverUrl; conn.close(); } catch (Throwable t) {
protected boolean flowReconnect(String password, int securityMechanism) throws SqlException { constructExtnam(); constructPrddta(); //modify this to not new up an array checkSecmgrForSecmecSupport(securityMechanism); try { switch (securityMechanism) { case NetConfiguration.SECMEC_USRIDPWD: // Clear text user id and password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_USRIDONL: // Clear text user, no password sent to server checkUser(user_); resetConnectionAtFirstSql_ = true; return true; case NetConfiguration.SECMEC_USRENCPWD: // Clear text user, encrypted password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_EUSRIDPWD: // Encrypted user, encrypted password checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true; setDeferredResetPassword(password); return true; case NetConfiguration.SECMEC_EUSRIDDTA: checkUserPassword(user_, password); resetConnectionAtFirstSql_ = true;