⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netconnection.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            // do not reset managers on a connection reset.  this information shouldn't            // change and can be used to check secmec support.            targetExtnam_ = null;            targetSrvclsnm_ = null;            targetSrvnam_ = null;            targetSrvrlslv_ = null;            publicKey_ = null;            targetPublicKey_ = null;            targetSecmec_ = 0;            if (ds != null && securityMechanism_ == 0) {                securityMechanism_ = ds.getSecurityMechanism();            }            resetConnectionAtFirstSql_ = false;        }        // properties prddta_ and crrtkn_ will be initialized by        // calls to constructPrddta() and constructCrrtkn()        //----------------------------------------------------------        boolean isDeferredReset = flowReconnect(null, securityMechanism_);        completeReset(isDeferredReset, recomputeFromDataSource);    }    protected void checkResetPreconditions(org.apache.derby.client.am.LogWriter logWriter,                                           String user,                                           String password,                                           ClientDataSource ds) throws SqlException {        if (inUnitOfWork_) {            throw new SqlException(logWriter, "Connection reset is not allowed when inside a unit of work.");        }    }    java.util.List getSpecialRegisters() {        if (xares_ != null) {            return xares_.getSpecialRegisters();        } else {            return null;        }    }    public void addSpecialRegisters(String s) {        if (xares_ != null) {            xares_.addSpecialRegisters(s);        }    }    public void completeConnect() throws SqlException {        super.completeConnect();    }    protected void completeReset(boolean isDeferredReset, boolean recomputeFromDataSource) throws SqlException {        super.completeReset(isDeferredReset, recomputeFromDataSource);    }    public void flowConnect(String password,                            int securityMechanism) throws SqlException {        netAgent_ = (NetAgent) super.agent_;        constructExtnam();        // these calls need to be after newing up the agent        // because they require the ccsid manager        constructPrddta();  // construct product data        netAgent_.typdef_ = new Typdef(netAgent_, 1208, NetConfiguration.SYSTEM_ASC, 1200, 1208);        netAgent_.targetTypdef_ = new Typdef(netAgent_);        netAgent_.originalTargetTypdef_ = netAgent_.targetTypdef_;        setDeferredResetPassword(password);        // If password is not null, change security mechanism from        // SECMEC_USRIDONL to SECMEC_USRIDPWD        securityMechanism = ClientBaseDataSource.getUpgradedSecurityMechanism((short) securityMechanism, 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);                flowEUSRPWDDTAconnect(password);                break;            default:                throw new SqlException(agent_.logWriter_, "security mechanism '" + securityMechanism + "' not supported");            }        } catch (java.lang.Throwable e) { // if *anything* goes wrong, make sure the connection is destroyed            // always mark the connection closed in case of an error.            // This prevents attempts to use this closed connection            // to retrieve error message text if an error SQLCA            // is returned in one of the connect flows.            open_ = false;            // logWriter may be closed in agent_.close(),            // so SqlException needs to be created before that            // but to be thrown after.            SqlException exceptionToBeThrown;            if (e instanceof SqlException) // rethrow original exception if it's an SqlException            {                exceptionToBeThrown = (SqlException) e;            } else // any other exceptions will be wrapped by an SqlException first            {                exceptionToBeThrown = new SqlException(agent_.logWriter_, e, "Unexpected throwable caught " + e.toString());            }            try {                if (agent_ != null) {                    agent_.close();                }            } catch (SqlException ignoreMe) {            }            throw exceptionToBeThrown;        }    }    protected void flowSimpleConnect() throws SqlException {        netAgent_ = (NetAgent) super.agent_;        constructExtnam();        // these calls need to be after newing up the agent        // because they require the ccsid manager        constructPrddta();  // construct product data        netAgent_.typdef_ = new Typdef(netAgent_, 1208, NetConfiguration.SYSTEM_ASC, 1200, 1208);        netAgent_.targetTypdef_ = new Typdef(netAgent_);        netAgent_.originalTargetTypdef_ = netAgent_.targetTypdef_;        try {            flowServerAttributes();        } catch (java.lang.Throwable e) { // if *anything* goes wrong, make sure the connection is destroyed            // always mark the connection closed in case of an error.            // This prevents attempts to use this closed connection            // to retrieve error message text if an error SQLCA            // is returned in one of the connect flows.            open_ = false;            // logWriter may be closed in agent_.close(),            // so SqlException needs to be created before that            // but to be thrown after.            SqlException exceptionToBeThrown;            if (e instanceof SqlException) // rethrow original exception if it's an SqlException            {                exceptionToBeThrown = (SqlException) e;            } else // any other exceptions will be wrapped by an SqlException first            {                exceptionToBeThrown = new SqlException(agent_.logWriter_, e, "Unexpected throwable caught " + e.toString());            }            try {                if (agent_ != null) {                    agent_.close();                }            } catch (SqlException ignoreMe) {            }            throw exceptionToBeThrown;        }    }    protected boolean flowReconnect(String password, int securityMechanism) throws SqlException {        constructExtnam();        // these calls need to be after newing up the agent        // because they require the ccsid manager        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;                setDeferredResetPassword(password);                return true;            case NetConfiguration.SECMEC_EUSRPWDDTA:                checkUserPassword(user_, password);                resetConnectionAtFirstSql_ = true;                setDeferredResetPassword(password);                return true;            default:                throw new SqlException(agent_.logWriter_, "security mechanism '" + securityMechanism + "' not supported");            }        } catch (SqlException sqle) {            // this may not be needed because on method up the stack            open_ = false;                       // all reset exceptions are caught and wrapped in disconnect exceptions            try {                if (agent_ != null) {                    agent_.close();                }            } catch (SqlException ignoreMe) {            }            throw sqle;        }    }    protected void finalize() throws java.lang.Throwable {        super.finalize();    }    protected byte[] getCnnToken() {        return cnntkn_;    }    protected short getSequenceNumber() {        return ++seqNo_;    }    //--------------------------------flow methods--------------------------------    private void flowUSRIDPWDconnect(String password) throws SqlException {        flowServerAttributesAndKeyExchange(NetConfiguration.SECMEC_USRIDPWD,                null); // publicKey        flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism                user_,                password,                null, //encryptedUserid                null); //encryptedPassword    }    private void flowUSRIDONLconnect() throws SqlException {        flowServerAttributesAndKeyExchange(NetConfiguration.SECMEC_USRIDONL,                null); //publicKey        flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism                user_,                null, //password                null, //encryptedUserid                null); //encryptedPassword    }    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 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));    }    private void flowEUSRIDDTAconnect() throws SqlException {        flowServerAttributes();        checkSecmgrForSecmecSupport(NetConfiguration.SECMEC_EUSRIDPWD);        initializePublicKeyForEncryption();        flowKeyExchange(NetConfiguration.SECMEC_EUSRIDDTA, publicKey_);        flowSecurityCheckAndAccessRdb(targetSecmec_, //securityMechanism                null, //user                null, //password                encryptedUseridForEUSRIDPWD(),                null);//encryptedPasswordForEUSRIDPWD (password),    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -