You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by db...@apache.org on 2016/05/02 18:11:51 UTC
[12/60] incubator-trafodion git commit: TRAFODION-1933 JDBC TYpe4
driver build scripts migrated to use maven instead of ant
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
deleted file mode 100644
index 2c7599a..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareMessage.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class PrepareMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, int sqlAsyncEnable, int queryTimeout, short stmtType,
- int sqlStmtType, String stmtLabel, int stmtLabelCharset, String cursorName, int cursorNameCharset,
- String moduleName, int moduleNameCharset, long moduleTimestamp, String sqlString, int sqlStringCharset,
- String stmtOptions, String stmtExplainLabel, int maxRowsetSize, byte[] txId, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] stmtLabelBytes = ic.encodeString(stmtLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] cursorNameBytes = ic.encodeString(cursorName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] moduleNameBytes = ic.encodeString(moduleName, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] sqlStringBytes = ic.encodeString(sqlString, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtOptionsBytes = ic.encodeString(stmtOptions, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- byte[] stmtExplainLabelBytes = ic.encodeString(stmtExplainLabel, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_int; // sqlAsyncEnable
- wlength += TRANSPORT.size_int; // queryTimeout
- wlength += TRANSPORT.size_short; // stmtType
- wlength += TRANSPORT.size_int; // sqlStmtType
- wlength += TRANSPORT.size_bytesWithCharset(stmtLabelBytes); // +stmtCharset
- wlength += TRANSPORT.size_bytesWithCharset(cursorNameBytes); // +cursorCharset
- wlength += TRANSPORT.size_bytesWithCharset(moduleNameBytes);
- if (moduleName != null && moduleName.length() > 0) {
- wlength += TRANSPORT.size_long; // moduleTimestamp
- }
- wlength += TRANSPORT.size_bytesWithCharset(sqlStringBytes); // +sqlStringCharset
- wlength += TRANSPORT.size_bytes(stmtOptionsBytes);
- wlength += TRANSPORT.size_bytes(stmtExplainLabelBytes);
- wlength += TRANSPORT.size_int; // maxRowsetSize
- wlength += TRANSPORT.size_bytes(txId); // transId
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertInt(sqlAsyncEnable);
- buf.insertInt(queryTimeout);
- buf.insertShort(stmtType);
- buf.insertInt(sqlStmtType);
- buf.insertStringWithCharset(stmtLabelBytes, stmtLabelCharset);
- buf.insertStringWithCharset(cursorNameBytes, cursorNameCharset);
- buf.insertStringWithCharset(moduleNameBytes, moduleNameCharset);
- if (moduleName != null && moduleName.length() > 0) {
- buf.insertLong(moduleTimestamp);
- }
- buf.insertStringWithCharset(sqlStringBytes, sqlStringCharset);
- buf.insertString(stmtOptionsBytes);
- buf.insertString(stmtExplainLabelBytes);
- buf.insertInt(maxRowsetSize);
- buf.insertString(txId);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
deleted file mode 100644
index 82b0448..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PrepareReply.java
+++ /dev/null
@@ -1,103 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class PrepareReply {
- int returnCode;
- int totalErrorLength;
- SQLWarningOrError[] errorList;
- int sqlQueryType;
- int stmtHandle;
- int estimatedCost;
-
- int inputDescLength;
- int inputParamLength;
- int inputNumberParams;
- Descriptor2[] inputDesc;
-
- int outputDescLength;
- int outputParamLength;
- int outputNumberParams;
- Descriptor2[] outputDesc;
-
- // -------------------------------------------------------------
- PrepareReply(LogicalByteArray buf, InterfaceConnection ic) throws CharacterCodingException,
- UnsupportedCharsetException {
- buf.setLocation(Header.sizeOf());
-
- returnCode = buf.extractInt();
-
- // should check SQL_SUCCESS or SQL_SUCCESS_WITH_INFO
- // if(returnCode == TRANSPORT.SQL_SUCCESS)
- if (returnCode == TRANSPORT.SQL_SUCCESS || returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
- if (returnCode == TRANSPORT.SQL_SUCCESS_WITH_INFO) {
- totalErrorLength = buf.extractInt();
-
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, InterfaceUtilities.SQLCHARSETCODE_UTF8);
- }
- }
- }
- sqlQueryType = buf.extractInt();
- stmtHandle = buf.extractInt();
- estimatedCost = buf.extractInt();
-
- inputDescLength = buf.extractInt();
- if (inputDescLength > 0) {
- inputParamLength = buf.extractInt();
- inputNumberParams = buf.extractInt();
-
- inputDesc = new Descriptor2[inputNumberParams];
- for (int i = 0; i < inputNumberParams; i++) {
- inputDesc[i] = new Descriptor2(buf, ic);
- inputDesc[i].setRowLength(inputParamLength);
- }
- }
-
- outputDescLength = buf.extractInt();
- if (outputDescLength > 0) {
- outputParamLength = buf.extractInt();
- outputNumberParams = buf.extractInt();
-
- outputDesc = new Descriptor2[outputNumberParams];
- for (int i = 0; i < outputNumberParams; i++) {
- outputDesc[i] = new Descriptor2(buf, ic);
- outputDesc[i].setRowLength(outputParamLength);
- }
- }
- } else {
- totalErrorLength = buf.extractInt();
-
- if (totalErrorLength > 0) {
- errorList = new SQLWarningOrError[buf.extractInt()];
- for (int i = 0; i < errorList.length; i++) {
- errorList[i] = new SQLWarningOrError(buf, ic, ic.getISOMapping());
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
deleted file mode 100644
index 801a4b1..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/PreparedStatementManager.java
+++ /dev/null
@@ -1,242 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.PrintWriter;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.logging.Level;
-
-public abstract class PreparedStatementManager extends HPT4Handle {
-
- boolean isStatementCachingEnabled() {
- if (maxStatements_ < 1) {
- return false;
- } else {
- return true;
- }
- }
-
- boolean makeRoom() throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "makeRoom()");
- }
- }
-
- Iterator i;
- CachedPreparedStatement cs;
- long oldest;
- long stmtTime;
- String key;
-
- i = (prepStmtsInCache_.values()).iterator();
- if (!i.hasNext()) {
- return false;
- }
- cs = (CachedPreparedStatement) i.next();
- stmtTime = cs.getLastUsedTime();
- key = cs.getLookUpKey();
- oldest = stmtTime;
-
- for (; i.hasNext();) {
- cs = (CachedPreparedStatement) i.next();
- stmtTime = cs.getLastUsedTime();
- if (oldest > stmtTime) {
- oldest = stmtTime;
- key = cs.getLookUpKey();
- }
- }
- cs = (CachedPreparedStatement) prepStmtsInCache_.remove(key);
- if (cs != null) {
- if (cs.inUse_ == false) // if the user has already closed the
- // statement, hard close it
- cs.close(true);
-
- return true;
- } else {
- return false;
- }
- }
-
- void closePreparedStatementsAll() throws SQLException {
-
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "closePreparedStatementsAll()");
- }
- }
-
- Object[] csArray;
-
- CachedPreparedStatement cs;
- int i = 0;
-
- csArray = (prepStmtsInCache_.values()).toArray();
- for (i = 0; i < csArray.length; i++) {
- cs = (CachedPreparedStatement) csArray[i];
- if (cs != null) {
- cs.close(false);
- }
- }
- }
-
- private String createKey(TrafT4Connection connect, String sql, int resultSetHoldability) throws SQLException {
- String lookupKey = sql + connect.getCatalog() + connect.getSchema() + connect.getTransactionIsolation()
- + resultSetHoldability;
-
- return lookupKey;
- }
-
- boolean closePreparedStatement(TrafT4Connection connect, String sql, int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "closePreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
- + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- CachedPreparedStatement cs;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- cs = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cs != null) {
- cs.inUse_ = false;
- return true;
- }
-
- return false;
- }
-
- void clearPreparedStatementsAll() {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "clearPreparedStatementsAll()");
- }
- }
- if (prepStmtsInCache_ != null) {
- prepStmtsInCache_.clear();
- }
- count_ = 0;
- }
-
- void addPreparedStatement(TrafT4Connection connect, String sql, PreparedStatement pStmt, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "addPreparedStatement(" + connect + ",\"" + sql + "\"," + pStmt + ","
- + resultSetType + "," + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- CachedPreparedStatement cachedStmt;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cachedStmt != null) {
- // Update the last use time
- cachedStmt.setLastUsedInfo();
- } else {
- if (count_ < maxStatements_) {
- cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
- prepStmtsInCache_.put(lookupKey, cachedStmt);
- count_++;
- } else {
- if (makeRoom()) {
- cachedStmt = new CachedPreparedStatement(pStmt, lookupKey);
- prepStmtsInCache_.put(lookupKey, cachedStmt);
- }
- }
- }
- }
-
- PreparedStatement getPreparedStatement(TrafT4Connection connect, String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException {
- if (out_ != null) {
- if (traceLevel_ != Level.OFF) {
- out_.println(traceId_ + "getPreparedStatement(" + connect + ",\"" + sql + "\"," + resultSetType + ","
- + resultSetConcurrency + "," + resultSetHoldability + ")");
- }
- }
-
- PreparedStatement pStmt = null;
- CachedPreparedStatement cachedStmt;
-
- String lookupKey = createKey(connect, sql, resultSetHoldability);
-
- if (prepStmtsInCache_ != null) {
- cachedStmt = (CachedPreparedStatement) prepStmtsInCache_.get(lookupKey);
- if (cachedStmt != null) {
- if (!cachedStmt.inUse_) {
- pStmt = cachedStmt.getPreparedStatement();
- ((org.trafodion.jdbc.t4.TrafT4PreparedStatement) pStmt).reuse(connect, resultSetType, resultSetConcurrency,
- resultSetHoldability);
- } else {
- pStmt = null;
- }
- }
- }
- return pStmt;
- }
-
- void setLogInfo(Level traceLevel, PrintWriter out) {
- this.traceLevel_ = traceLevel;
- this.out_ = out;
-
- }
-
- PreparedStatementManager() {
- super();
- String className = getClass().getName();
- traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
- }
-
- PreparedStatementManager(T4Properties t4props) {
- super();
-
- String className = getClass().getName();
-
- String tmp;
-
- if (t4props != null) {
- maxStatements_ = t4props.getMaxStatements();
-
- }
- if (maxStatements_ > 0) {
- prepStmtsInCache_ = new Hashtable();
- }
- traceId_ = "jdbcTrace:[" + Thread.currentThread() + "]:[" + hashCode() + "]:" + className + ".";
- }
-
- private Hashtable prepStmtsInCache_;
- private int maxStatements_;
- private int count_;
-
- Level traceLevel_;
- PrintWriter out_;
- String traceId_;
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
deleted file mode 100644
index 21ee6f3..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Row.java
+++ /dev/null
@@ -1,233 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.io.Serializable;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.SQLException;
-import java.util.BitSet;
-import java.util.Locale;
-
-// Referenced classes of package sun.jdbc.rowset:
-// BaseRow
-
-class Row extends BaseRow implements Serializable, Cloneable {
-
- private Object currentVals[];
- private BitSet colsChanged;
- private boolean deleted;
- private boolean updated;
- private boolean inserted;
- private int numCols;
-
- Row(int i) {
- origVals = new Object[i];
- currentVals = new Object[i];
- colsChanged = new BitSet(i);
- numCols = i;
- }
-
- Row(int i, Object aobj[]) {
- origVals = new Object[i];
- for (int j = 0; j < i; j++) {
- origVals[j] = aobj[j];
-
- }
- currentVals = new Object[i];
- colsChanged = new BitSet(i);
- numCols = i;
- }
-
- protected void clearDeleted() {
- deleted = false;
- }
-
- protected void clearInserted() {
- inserted = false;
- }
-
- protected void clearUpdated() {
- updated = false;
- for (int i = 0; i < numCols; i++) {
- currentVals[i] = null;
- colsChanged.clear(i);
- }
-
- }
-
- protected boolean getColUpdated(int i) {
- return colsChanged.get(i);
- }
-
- protected Object getColumnObject(int i) throws SQLException {
- if (getColUpdated(i - 1)) {
- return currentVals[i - 1];
- } else {
- return origVals[i - 1];
- }
- }
-
- protected boolean getDeleted() {
- return deleted;
- }
-
- protected boolean getInserted() {
- return inserted;
- }
-
- protected boolean getUpdated() {
- return updated;
- }
-
- protected void initColumnObject(int i, Object obj) {
- origVals[i - 1] = obj;
- }
-
- protected void moveCurrentToOrig() {
- for (int i = 0; i < numCols; i++) {
- if (getColUpdated(i)) {
- origVals[i] = currentVals[i];
- currentVals[i] = null;
- colsChanged.clear(i);
- }
- }
- }
-
- private void setColUpdated(int i) {
- colsChanged.set(i);
- }
-
- protected void setColumnObject(int i, Object obj) {
- currentVals[i - 1] = obj;
- setColUpdated(i - 1);
- }
-
- protected void setLobObject(int i, Object obj) {
- currentVals[i - 1] = obj;
- origVals[i - 1] = obj;
- }
-
- protected void setDeleted() {
- deleted = true;
- }
-
- protected void setInserted() {
- inserted = true;
- }
-
- protected void setUpdated() {
- updated = true;
- }
-
- protected void deleteRow(Locale locale, PreparedStatement deleteStmt, BitSet paramCols) throws SQLException {
- int i;
- int j;
- int count;
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (paramCols.get(i)) {
- deleteStmt.setObject(j++, origVals[i]);
- }
- }
- count = deleteStmt.executeUpdate();
- if (count == 0) {
- throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
- }
- }
-
- protected void updateRow(Locale locale, PreparedStatement updateStmt, BitSet paramCols, BitSet keyCols)
- throws SQLException {
- int i;
- int j;
- int count;
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (keyCols.get(i)) {
- if (getColUpdated(i)) {
- throw HPT4Messages.createSQLException(null, locale, "primary_key_not_updateable", null);
- }
- } else {
- if (paramCols.get(i)) { // LOB Support SB 10/8/2004
- Object obj = getColumnObject((i + 1));
-
-
- updateStmt.setObject(j++, getColumnObject(i + 1));
- }
- }
- }
-
- for (i = 0; i < numCols; i++) {
- // if (paramCols.get(i))
- if (keyCols.get(i)) {
- Object obj = origVals[i];
-
-
- updateStmt.setObject(j++, origVals[i]);
- }
- }
-
- count = updateStmt.executeUpdate();
- if (count == 0) {
- throw HPT4Messages.createSQLException(null, locale, "row_modified", null);
- }
- moveCurrentToOrig();
- setUpdated();
- }
-
- protected void refreshRow(Locale locale, PreparedStatement selectStmt, BitSet selectCols, BitSet keyCols)
- throws SQLException {
- int i;
- int j;
- ResultSet rs;
- ResultSetMetaData rsmd;
- int columnCount;
-
- clearUpdated();
-
- for (i = 0, j = 1; i < numCols; i++) {
- if (keyCols.get(i)) {
- selectStmt.setObject(j++, origVals[i]);
- }
- }
- rs = selectStmt.executeQuery();
- if (rs != null) {
- try {
- rsmd = rs.getMetaData();
- columnCount = rsmd.getColumnCount();
- rs.next();
- for (i = 0, j = 1; i < numCols; i++) {
- if (selectCols.get(i)) {
- origVals[i] = rs.getObject(j++);
- }
- }
- } catch (SQLException ex) {
- throw ex;
- } finally {
- rs.close();
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
deleted file mode 100644
index 042772b..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescList_def.java
+++ /dev/null
@@ -1,46 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDescList_def {
- SQLItemDesc_def[] list;
-
- public SQLItemDescList_def(LogicalByteArray buf, boolean useOld, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException {
- int length = buf.extractInt();
-
- if (length > 0) {
- if (!useOld) {
- length = buf.extractInt();
- }
- list = new SQLItemDesc_def[length];
-
- for (int i = 0; i < length; i++) {
- list[i] = (useOld) ? new SQLItemDescOld_def() : new SQLItemDesc_def();
- list[i].extractFromByteArray(buf, ic);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
deleted file mode 100644
index 666f37c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDescOld_def.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDescOld_def extends SQLItemDesc_def {
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
- CharacterCodingException {
- version = buf.extractInt();
- dataType = buf.extractInt();
- datetimeCode = buf.extractInt();
- maxLen = buf.extractInt();
- precision = buf.extractShort();
- scale = buf.extractShort();
- nullInfo = buf.extractByte();
-
- colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- signType = buf.extractByte();
- ODBCDataType = buf.extractInt();
- ODBCPrecision = buf.extractShort();
- SQLCharset = buf.extractInt();
- ODBCCharset = buf.extractInt();
-
- TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- intLeadPrec = buf.extractInt();
- paramMode = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
deleted file mode 100644
index 24d0b04..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLItemDesc_def.java
+++ /dev/null
@@ -1,70 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SQLItemDesc_def {
- int version;
- int dataType;
- int datetimeCode;
- int maxLen;
- short precision;
- short scale;
- byte nullInfo;
- String colHeadingNm;
- byte signType;
- int ODBCDataType;
- short ODBCPrecision;
- int SQLCharset;
- int ODBCCharset;
- String TableName;
- String CatalogName;
- String SchemaName;
- String Heading;
- int intLeadPrec;
- int paramMode;
-
- void extractFromByteArray(LogicalByteArray buf, InterfaceConnection ic) throws UnsupportedCharsetException,
- CharacterCodingException {
- version = buf.extractInt();
- dataType = buf.extractInt();
- datetimeCode = buf.extractInt();
- maxLen = buf.extractInt();
- precision = buf.extractShort();
- scale = buf.extractShort();
- nullInfo = buf.extractByte();
- signType = buf.extractByte();
- ODBCDataType = buf.extractInt();
- ODBCPrecision = buf.extractShort();
- SQLCharset = buf.extractInt();
- ODBCCharset = buf.extractInt();
- colHeadingNm = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- TableName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- CatalogName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- SchemaName = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- Heading = ic.decodeBytes(buf.extractString(), InterfaceUtilities.SQLCHARSETCODE_UTF8);
- intLeadPrec = buf.extractInt();
- paramMode = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
deleted file mode 100644
index a56b1c5..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValueList_def.java
+++ /dev/null
@@ -1,64 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.sql.SQLException;
-
-class SQLValueList_def {
- SQLValue_def[] buffer;
-
- // ----------------------------------------------------------
- int sizeof() {
- int size = TRANSPORT.size_int;
-
- if (buffer != null) {
- for (int i = 0; i < buffer.length; i++) {
- size += buffer[i].sizeof();
- }
- }
- return size;
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- if (buffer != null) {
- buf.insertInt(buffer.length);
- for (int i = 0; i < buffer.length; i++) {
- buffer[i].insertIntoByteArray(buf);
- }
- } else {
- buf.insertInt(0);
- }
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) throws SQLException {
- int len = buf.extractInt();
-
- buffer = new SQLValue_def[len];
-
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = new SQLValue_def();
- buffer[i].extractFromByteArray(buf);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
deleted file mode 100644
index 5795e7c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLValue_def.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.sql.SQLException;
-
-class SQLValue_def {
- int dataType;
- short dataInd;
- SQL_DataValue_def dataValue;
- int dataCharSet;
-
- // ----------------------------------------------------------
- int sizeof() {
- return TRANSPORT.size_int * 2 + TRANSPORT.size_short + dataValue.sizeof();
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- buf.insertInt(dataType);
- buf.insertShort(dataInd);
- dataValue.insertIntoByteArray(buf);
- buf.insertInt(dataCharSet);
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) throws SQLException {
- dataType = buf.extractInt();
- dataInd = buf.extractShort();
-
- dataValue = new SQL_DataValue_def();
- dataValue.extractFromByteArray(buf);
-
- dataCharSet = buf.extractInt();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
deleted file mode 100644
index a95697e..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQLWarningOrError.java
+++ /dev/null
@@ -1,47 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-public class SQLWarningOrError {
- int rowId;
- int sqlCode;
- String text;
- String sqlState;
-
- public SQLWarningOrError(int rowId, int sqlCode, String text, String sqlState) {
- this.rowId = rowId;
- this.sqlCode = sqlCode;
- this.text = text;
- this.sqlState = sqlState;
- }
-
- public SQLWarningOrError(LogicalByteArray buf, InterfaceConnection ic, int charset)
- throws CharacterCodingException, UnsupportedCharsetException {
- rowId = buf.extractInt();
- sqlCode = buf.extractInt();
- text = ic.decodeBytes(buf.extractString(), charset);
- sqlState = new String(buf.extractByteArray(5));
- buf.extractByte(); // null terminator
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
deleted file mode 100644
index edaada8..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SQL_DataValue_def.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.ByteBuffer;
-
-class SQL_DataValue_def {
- int length;
- byte[] buffer;
- ByteBuffer userBuffer;
-
- // ----------------------------------------------------------
- int sizeof() {
- return (buffer != null) ? TRANSPORT.size_int + buffer.length + 1 : TRANSPORT.size_int;
- }
-
- // ----------------------------------------------------------
- void insertIntoByteArray(LogicalByteArray buf) {
- if (buffer != null) {
- buf.insertInt(length);
- buf.insertByteArray(buffer, length);
- } else {
- buf.insertInt(0);
- }
- }
-
- // ----------------------------------------------------------
- void extractFromByteArray(LogicalByteArray buf) {
- length = buf.extractInt();
-
- if (length > 0) {
- buffer = buf.extractByteArray(length);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
deleted file mode 100644
index a1e4d01..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecClientMsgKeys.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-*
-/**********************************************************************/
-
-package org.trafodion.jdbc.t4;
-
-public class SecClientMsgKeys
-{
- /**
- * Literal constants of java Security Client error messages.
- */
-
- public static final String ERR_RETRIEVE_KEY_FROM_FILE = "ERR_RETRIEVE_KEY_FROM_FILE";
- public static final String SESSION_KEY_GENERATION_FAILED = "SESSION_KEY_GENERATION_FAILED";
- public static final String INPUT_PARAMETER_IS_NULL = "INPUT_PARAMETER_IS_NULL";
- public static final String PWD_LENGTH_TOO_LONG = "PWD_LENGTH_TOO_LONG";
- public static final String ENCRYPTION_FAILED = "ENCRYPTION_FAILED";
- public static final String HMAC_FAILED = "HMAC_FAILED";
- public static final String PUBKEY_LENGTH_IS_ZERO = "PUBKEY_LENGTH_IS_ZERO";
- public static final String ERR_READ_CERT_FILE = "ERR_READ_CERT_FILE";
- public static final String FAILED_GENERATE_RANDOM_NUM = "FAILED_GENERATE_RANDOM_NUM";
- public static final String CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN = "CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN";
- public static final String BAD_MESSAGE_DIGEST_LEN = "BAD_MESSAGE_DIGEST_LEN";
- public static final String FILE_NOTFOUND = "FILE_NOTFOUND";
- public static final String DATA_ENCRYPTION_FAILED = "DATA_ENCRYPTION_FAILED";
- public static final String DECRYPTION_FAILED = "DECRYPTION_FAILED";
- public static final String ERR_WRITE_CERT_FILE = "ERR_WRITE_CERT_FILE";
- public static final String GET_LOCAL_HOST_NAME_FAILED = "GET_LOCAL_HOST_NAME_FAILED";
- public static final String BAD_TOKEN_LEN = "BAD_TOKEN_LEN";
- public static final String INCORRECT_TOKEN_FORMAT = "INCORRECT_TOKEN_FORMAT";
- public static final String HOME_ENVIRONMENT_VAR_IS_NULL = "HOME_ENVIRONMENT_VAR_IS_NULL";
- public static final String ERR_CREATE_SYMMETRIC_KEY = "ERR_CREATE_SYMMETRIC_KEY";
- public static final String FAILED_BUILDING_PWDKEY = "FAILED_BUILDING_PWDKEY";
- public static final String DIR_NOTFOUND = "DIR_NOTFOUND";
- public static final String ERR_OPEN_INPUT_FILE = "ERR_OPEN_INPUT_FILE";
- public static final String FILE_CORRUPTION = "FILE_CORRUPTION";
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
deleted file mode 100644
index 60da5da..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecPwd.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
- //
- **********************************************************************/
-
-/**
- * class SecPwd - builds the password key, encrypts password,
- * creates HMAC message based on password, rolename
- * process info and time stamp. It also gets expiration
- * date of a certificate.
- *
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.sql.Connection;
-
-
-public class SecPwd {
- /**
- *
- *
- * @return SecPwd
- */
- public static SecPwd getInstance(Connection con, String directory, String fileName,
- String serverName, boolean spjMode, byte[] procInfo) throws SecurityException
- {
- if (con == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
- SecPwd secpwd = new SecPwd(directory, fileName, serverName, spjMode, procInfo);
-
- SymCrypto.insert(con, secpwd);
-
-
- return secpwd;
- }
-
- public static void removeInstance(Connection con)
- {
- SymCrypto.remove(con);
- }
-
- /**
- * Ctor for the SecPwd. There are two possible certificates: active
- * certificate and certificate that is going to be active.
- *
- * If autodownload is true, certificate will always come from the
- * server. In this case, only active certificate is used.
- *
- * If autodownload is false, active certificate is used to encrypt the
- * password. When there is a new certificate, it will be stored in
- * "certificate". As soon as this new certificate is activated on the
- * server, the current active certificate will become stale, and the new
- * certificate will be copied over and becomes the active certificate.
- *
- * If spjMode is true, the OS name is NONSTOP_KERNEL and the host name
- * is the same as the server name then just setSpj mode to true
- * and does nothing.
- *
- * @param directory
- * specifies the directory to locate the certificate. The default
- * value is %HOME% if set else %HOMEDRIVE%%HOMEPATH%.
- * @param fileName
- * specifies the certificate that is in waiting. The default
- * value is the first 5 characters of server name.
- * @param activeFileName
- * specifies the current certificate in use. The default value is
- * the first 5 character of server name + Active
- * @param spjMode
- * true - and if os.name == NSK and the host name
- * matches the local host - token case. Certificate is not
- * handled in this case.
- * false - handles certificate
- * @param serverName
- * server name for this certificate.
- * @throws SecurityException
- */
- private SecPwd(String directory, String fileName,
- String serverName, boolean spjMode, byte[] procInfo) throws SecurityException {
- String hostName = null;
-
- try {
- hostName = java.net.InetAddress.getLocalHost().getHostName();
- } catch (java.net.UnknownHostException ex) {
- throw new SecurityException(
- SecClientMsgKeys.GET_LOCAL_HOST_NAME_FAILED, null);
- }
-
- // check USERID env variable for MXCI testing of SPJs. If set use normal password
- // encryption
- if ((spjMode == true) &&
- // ((hostName.substring(0, 5)).compareToIgnoreCase(serverName.substring(0, 5)) == 0) &&
- (System.getenv("USERID") == null))// token
- {
- m_spjMode = spjMode;
- }
- else // password
- {
- if (procInfo == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"procInfo"});
- // Stores procInfo with the time stamp for data message encryption used
- m_procInfo = new byte [SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE];
- System.arraycopy(procInfo, 0, m_procInfo, 0, (SecdefsCommon.PROCINFO_SIZE + SecdefsCommon.TIMESTAMP_SIZE));
- directory = (directory != null) ? directory : System.getenv("HOME");
- if (directory == null)
- {
- String hmdrive = System.getenv("HOMEDRIVE");
- String hmpath = System.getenv("HOMEPATH");
- if (hmdrive != null && hmpath != null)
- {
- directory = hmdrive + File.separator + hmpath;
- }
- else
- {
- directory = System.getProperty("user.home");
- if (directory == null)
- throw new SecurityException (SecClientMsgKeys.HOME_ENVIRONMENT_VAR_IS_NULL, null);
- }
- }
- fileName = (fileName != null) ? fileName : serverName + ".cer";
-
- File dir = new File(directory);
- if (dir.isDirectory() == false)
- throw new SecurityException(SecClientMsgKeys.DIR_NOTFOUND, new Object[]{dir.getPath()});
-
- certFile = new File(directory, fileName);
- }
- }
-
- /**
- * Processes the active certificate when spjMode is false
- * else does nothing. The certificate is processed by calling
- * the Security ctor to creates the password key and initializes it
- * with password id. Gets public key and the length of the public
- * key from the certificate file. Generates nonce and session key.
- * @throws SecurityException
- */
- public void openCertificate() throws SecurityException {
- if (m_spjMode == false) // do nothing for the token case
- m_sec = new Security(certFile);
- }
-
- /** This method builds the password key which consists 4 bytes of password id,
- * 128 bytes of role name which would be 128 spaces when role name is null,
- * 32 bytes of the digest message calculated using the session key on the data made up of
- * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
- * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
- * on the plain text made up of the session key, the nonce and the password.
- * The password key is generated only when the spjMode is false. When
- * the spjMode is true, 26 bytes of the token is returned instead.
- * Builds password key
- * @param pwd
- * password to be encrypted
- * @param rolename
- * role name to build password key
- * @param procInfo
- * process information (PIN, CPU, segment name and time stamp)
- * @return pwdkey
- * returns the password key if spjMode is false
- * returns the token when spjMode is true
- * @throws SecurityException
- */
-
- public void encryptPwd(byte[] pwd, byte[] rolename, byte[] pwdkey) throws SecurityException {
- // rolename is optional so can be NULL
- if (pwd == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password"});
- if (pwdkey == null)
- throw new SecurityException(SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"password key"});
- if (m_spjMode == true) // token
- {
- if (pwd.length != SecdefsCommon.TOKENSIZE)
- throw new SecurityException(SecClientMsgKeys.BAD_TOKEN_LEN, null);
- if ((pwd[0] != SecdefsCommon.USERTOKEN_ID_1)
- || (pwd[1] != SecdefsCommon.USERTOKEN_ID_2))
- throw new SecurityException(
- SecClientMsgKeys.INCORRECT_TOKEN_FORMAT, null);
- ByteBuffer.wrap(pwd).get(pwdkey, 0, SecdefsCommon.TOKENSIZE);
- }
- else
- {
- m_sec.encryptPwd(pwd, rolename, m_procInfo, pwdkey);
- }
- }
-
- /** Gets length of buffer for password encryption (public)
- * or the length of the token if it is the SPJ mode
- * @returns
- * If the spjMode is false
- * the length of the password key is returnd if success
- * 0 if failed
- * If spjMode is true
- * the length of the token is returned
- * @throws SecurityException
- */
- public int getPwdEBufferLen() throws SecurityException {
- if (m_spjMode == true)
- return SecdefsCommon.TOKENSIZE;
- else
- return m_sec.getPwdEBufferLen();
- }
-
- /** Gets the expiration date of the certificate
- * @return an array of bytes
- * presents the certificate's
- * expiration day in the format YYMMDDHHMMSS
- * or a zero length byte array if the it is in the SPJ mode
- */
- public byte[] getCertExpDate() {
- if (m_spjMode == false)
- return m_sec.getCertExpDate();
- else
- return new byte[0];
- }
-
- /**
- * When autodownload is on, client will download the certificate from server
- * when there is no certificate or certificate is stale.
- *
- * @param buf
- * content of the certificate pushed from server.
- */
- public void switchCertificate(byte[] buf) throws SecurityException {
- FileChannel outChannel = null;
- try {
- outChannel = new FileOutputStream(certFile).getChannel();
- outChannel.write(ByteBuffer.wrap(buf));
- } catch (Exception e) {
- throw new SecurityException(SecClientMsgKeys.ERR_WRITE_CERT_FILE, new Object[]{certFile});
- } finally {
- try {
- if (outChannel != null)
- outChannel.close();
- } catch (Exception e) {
- }
- }
- m_sec = new Security(certFile);
- }
-
- public byte[] getProcInfo()
- {
- return m_procInfo;
- }
-
- private Security m_sec;
- private File certFile;
- private boolean m_spjMode;
- private byte[] m_procInfo; //stores only 4 bytes pid + 4 bytes nid
-
-
-};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
deleted file mode 100644
index 5400d55..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecResourceBundle.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
-**********************************************************************/
-
-package org.trafodion.jdbc.t4;
-
-import java.util.ResourceBundle;
-import java.text.MessageFormat;
-
-public class SecResourceBundle
-{
-
- private static ResourceBundle rb = ResourceBundle.getBundle("secClient");
-
- /**
- * This method is used to obtain parameterized message text
- *
- */
- static String obtainMessageText (String key, Object[] params) {
- String pattern;
- try {
- pattern = rb.getString(key);
- } catch (Exception e) {
- return key;
- }
- if(pattern == null) {
- return key;
- }
- String message;
- try {
- message = MessageFormat.format(pattern, params);
- } catch (Exception e) {
- return pattern;
- }
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
deleted file mode 100644
index f003588..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecdefsCommon.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
-**********************************************************************/
-
-package org.trafodion.jdbc.t4;
-
-/**
- * This class contains defines
- *
- */
-
-public class SecdefsCommon {
-
- public static final int NONCE_RANDOM = 24;
- public static final int NONCE_SEQNUM = 8;
- public static final int NONCE_SIZE = (NONCE_RANDOM+NONCE_SEQNUM);
- public static final int SESSION_KEYLEN = 32;
- public static final int DIGEST_LENGTH = 32;
- // AES block size used in data encryption
- public static final int AES_BLOCKSIZE = 16;
- public static final int KEY_REFRESH = 30;
- public static final int TIMESTAMP_SIZE = 8;
- public static final int ROLENAME_SIZE = 128;
- public static final int PROCINFO_SIZE = 8;
- public static final int PWDID_SIZE = 4;
- public static final int EXPDATESIZE = 12;
- public static final int PWDKEY_SIZE_LESS_LOGINDATA = (PWDID_SIZE + ROLENAME_SIZE + DIGEST_LENGTH + TIMESTAMP_SIZE);
- // For public key encryption, the number of bytes
- // to be encrypted is 11 bytes less than the public key length
- public static final int UNUSEDBYTES = 11;
- public static final int TOKENSIZE = 68;
- // User tokens begin with byte values 3,4.
- public static final byte USERTOKEN_ID_1 = '\3'; // User token identifier, must be a sequence
- public static final byte USERTOKEN_ID_2 = '\4'; // not allowed in password
- public static final int DATA_BLOCK_BIT_SIZE = 128; // data encryption block size in bits. Java
- // supports block size of 128 bits for AES
- // algorithm using cryptographic key of 256 bits only.
-
-
- // Structure used to describe layout of Encrypted data
- // in login message
- public static class LoginData {
- //000 Session key
- byte[] session_key = new byte[SecdefsCommon.SESSION_KEYLEN];
- //032 Nonce
- byte[] nonce = new byte[SecdefsCommon.NONCE_SIZE];
- Byte password; // 064 User's password
- } // 128 for 1024 or 256 for 2048
-
-// Structure used to describe layout of password key
-
- public static class PwdKey {
- //000 Key identifier, binary values 1,2,3,4
- //or 1,2,2,4 keys, optional mode only
- byte[] id= new byte[SecdefsCommon.PWDID_SIZE];
- //004 RolenameA
- byte[] rolename = new byte[SecdefsCommon.ROLENAME_SIZE];
- //132 Digest of server id and encrypted data
- byte[] digest = new byte[SecdefsCommon.DIGEST_LENGTH];
- // 164 time stamp
- byte[] ts = new byte[SecdefsCommon.TIMESTAMP_SIZE];
- LoginData data; //172 Encrypted data
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
deleted file mode 100644
index 1a02021..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/Security.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
-**********************************************************************/
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.ByteBuffer;
-import java.security.SecureRandom;
-import java.util.Date;
-import java.security.NoSuchAlgorithmException;
-import java.io.File;
-import javax.crypto.SecretKey;
-
-
-
-class Security
-{
- public static final Cipher cipher = org.trafodion.jdbc.t4.Cipher.getInstance();
- public static final MessageDigest msgDigest = MessageDigest.getInstance();
-
- /** Ctor - Creates the password key and initializes it with
- * password id. Gets public key and the length of the public key
- * from the certificate file. Generates nonce and session key.
- * @param cert_file - fully qualified name of certificate file
- * @throw SecurityException
- */
- public Security(File certFile) throws SecurityException
- {
- // m_encrypted = 0;
- m_pwdkey = new SecdefsCommon.PwdKey();
- m_pwdkey.data = new SecdefsCommon.LoginData();
- m_pwdkey.id[0] = '\1';
- m_pwdkey.id[1] = '\2';
- m_pwdkey.id[2] = '\3';
- m_pwdkey.id[3] = '\4';
-
- try {
- m_keyObj = new Key();
- m_cert = new Certificate(certFile);
- m_keyObj.getPubKeyFromFile(m_cert.getCert());
- generateSessionKey();
- }catch (SecurityException se) {
- throw se;
- }
- }
-
- /** This method builds the password key which consists 4 bytes of password id,
- * 128 bytes of role name which would be 128 spaces when role name is null,
- * 32 bytes of the digest message calculated using the session key on the data made up of
- * the procInfo and the encrypted data and 256 bytes (if the 2048 public key is used) or
- * 128 bytes (if the1024 public key is used) encrypted data calculated using the public key
- * on the plain text made up of the session key, the nonce and the password.
- * Builds password key
- * @param pwd
- * password to be encrypted
- * @param rolename
- * role name to build password key
- * @param procInfo
- * process information (PIN, CPU, segment name and time stamp)
- * @return pwdkey
- * returned password key
- * @throws SecurityException
- */
- public void encryptPwd(byte[] pwd, byte[] rolename, byte[] procInfo,
- byte[] pwdkey)
- throws SecurityException
- {
- // Get public key length
- int pubKeyLen = m_keyObj.getPubKeyLen();
- int maxPlainTextLen = pubKeyLen - SecdefsCommon.UNUSEDBYTES;
-
- // Password + nonce + session key can't be longer than the public
- // key's length
- if ((SecdefsCommon.NONCE_SIZE + SecdefsCommon.SESSION_KEYLEN
- + pwd.length) > maxPlainTextLen)
- throw new SecurityException(SecClientMsgKeys.
- PWD_LENGTH_TOO_LONG, null);
-
- byte[] to_encrypt = new byte[SecdefsCommon.SESSION_KEYLEN +
- SecdefsCommon.NONCE_SIZE + pwd.length];
- byte[] cipherText = new byte[pubKeyLen];
- byte[] to_digest = new byte[SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE + pubKeyLen];
- byte[] digestedMsg = new byte[SecdefsCommon.DIGEST_LENGTH];
-
- try {
- // Build password key
- // Copy 4 bytes of id
- System.arraycopy(m_pwdkey.id, 0, pwdkey, 0, SecdefsCommon.PWDID_SIZE);
- // Copy rolename
- if (rolename != null)
- System.arraycopy(rolename, 0, pwdkey, SecdefsCommon.PWDID_SIZE,
- rolename.length);
- // Copy 12 bytes of procInfo and 8 bytes of timestamp to
- // password key store procInfo in the digest starting from
- // digest[20]
- System.arraycopy(procInfo, 0, pwdkey, (SecdefsCommon.PWDID_SIZE +
- SecdefsCommon.ROLENAME_SIZE + SecdefsCommon.DIGEST_LENGTH -
- SecdefsCommon.PROCINFO_SIZE), (SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE));
-
- // Build plain text to encrypt
- System.arraycopy(m_pwdkey.data.session_key, 0, to_encrypt, 0,
- SecdefsCommon.SESSION_KEYLEN);
- System.arraycopy(m_pwdkey.data.nonce, 0, to_encrypt,
- SecdefsCommon.SESSION_KEYLEN, SecdefsCommon.NONCE_SIZE);
- System.arraycopy(pwd, 0, to_encrypt,
- (SecdefsCommon.SESSION_KEYLEN + SecdefsCommon.NONCE_SIZE), pwd.length);
-
- // Encrypt the data
- int cipherTextLen = cipher.encrypt(to_encrypt, cipherText,
- (java.security.Key)(m_keyObj.getPubKey()));
-
- if(cipherTextLen != pubKeyLen)
- throw new SecurityException(SecClientMsgKeys.
- CIPHER_TEXT_LEN_NOT_EQUAL_KEY_LEN, null);
-
- // Copy cipherText to pwdkey
- System.arraycopy(cipherText, 0, pwdkey,
- SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA, cipherTextLen);
-
- // Create digest
- // Get bytes from digest[20] on
- System.arraycopy(pwdkey, (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA -
- SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.PROCINFO_SIZE),
- to_digest, 0, (SecdefsCommon.PROCINFO_SIZE +
- SecdefsCommon.TIMESTAMP_SIZE + cipherTextLen));
-
- int mdLen = msgDigest.digest(m_pwdkey.data.session_key,
- to_digest, digestedMsg);
-
- if (mdLen != SecdefsCommon.DIGEST_LENGTH)
- throw new SecurityException(SecClientMsgKeys.
- BAD_MESSAGE_DIGEST_LEN, null);
-
- // copy digestedMsg into pwdkey
- System.arraycopy(digestedMsg, 0, pwdkey,
- (SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA
- - SecdefsCommon.TIMESTAMP_SIZE - SecdefsCommon.DIGEST_LENGTH), mdLen );
-
- }catch (SecurityException se) {
- throw se;
- }catch (Exception e) {
- throw new SecurityException(SecClientMsgKeys.FAILED_BUILDING_PWDKEY, null);
- }finally {
- if (to_digest != null)
- to_digest = null;
- if (digestedMsg != null)
- digestedMsg = null;
- if (to_encrypt != null)
- to_encrypt = null;
- }
- }
-
- /** Encrypts the data using AES256 algorithm.
- *
- * @param data - data to be encrypted
- * @return array of bytes of 2 bytes PIN,
- * 2 bytes of CPU, 8 bytes of seg_name
- * and the encrypted data
- * @throw SecurityException
- */
-
- public byte[] encryptData(byte[] data) throws SecurityException
- {
- //Creates a secret key from the session key
- byte[] skey = new byte[SecdefsCommon.AES_BLOCKSIZE];
- System.arraycopy(m_pwdkey.data.session_key, SecdefsCommon.AES_BLOCKSIZE,
- skey, 0, SecdefsCommon.AES_BLOCKSIZE);
- SecretKey seckey = Key.generateSymmetricKey(skey);
- byte [] iv = new byte [SecdefsCommon.AES_BLOCKSIZE];
- System.arraycopy(m_pwdkey.data.nonce, SecdefsCommon.AES_BLOCKSIZE,
- iv, 0, SecdefsCommon.AES_BLOCKSIZE);
- m_cipher = Cipher.getEASInstance("AES/CBC/PKCS5Padding");
- return Cipher.encryptData(data, seckey, iv, m_cipher);
- }
-
- // Currently not implemented
- // Generate message digest
- // str - message to digest
- // hmacMsg - Hashed message in bytes
- // hmacMsgLen - Length of hashed message
- public void HMAC_Message_Generate(byte[] str, byte[] hmacMsg,
- int hmacMsgLen) throws SecurityException
- {
- // Not implemented yet
- }
-
- // Currently not implemented
- // Verify message digest
- // str - message digest
- // length - message digest length
- public boolean HMAC_Message_Verify(byte[] str) throws SecurityException
- {
- // Not implemented yet
- return false;
- }
-
- /** increment the nonce sequence
- *
- */
- public void incrementNonceSeq ()
- {
- m_nonceSeq++;
- }
-
- /** Gets length of buffer for password encryption (public)
- * @Return pass word key length if success and 0 if failed
- * @throw SecurityException
- */
- public int getPwdEBufferLen() throws SecurityException
- {
- int pubKLen = m_keyObj.getPubKeyLen();
- if(pubKLen <= 0)
- throw new SecurityException(SecClientMsgKeys.
- PUBKEY_LENGTH_IS_ZERO, null);
- else
- return (pubKLen + SecdefsCommon.PWDKEY_SIZE_LESS_LOGINDATA);
- }
-
- /** Gets certificate's expiration date
- * @Return an array of bytes represents the certificate's
- * expiration day in the string format YYMMDDHHMMSS
- */
- public byte[] getCertExpDate()
- {
- return m_cert.getCertExpDate();
- }
-
- // Generates session key and nonce
- private void generateSessionKey() throws SecurityException
- {
- //try {
- SecureRandom random = new SecureRandom();
- try {
- random.setSeed(System.currentTimeMillis());
-
- random.setSeed(Runtime.getRuntime().freeMemory());
- random.setSeed(Runtime.getRuntime().totalMemory());
- random.setSeed(Runtime.getRuntime().maxMemory());
-
- String p = null;
-
- p = System.getProperty("java.version", "unknown java version");
- random.setSeed(p.getBytes());
- p = System.getProperty("java.vendor", "unknown vendor");
- random.setSeed(p.getBytes());
- p = System.getProperty("os.name", "unknown os");
- random.setSeed(p.getBytes());
- p = System.getProperty("os.version", "unknown os version");
- random.setSeed(p.getBytes());
-
- // Add current time again
-
- random.setSeed(System.currentTimeMillis());
- }
- catch(Exception e ) {
- // Ignore
- }
- byte bytes[] = new byte[SecdefsCommon.SESSION_KEYLEN +
- SecdefsCommon.NONCE_SIZE];
- synchronized(random) {
- random.nextBytes(bytes);
- }
-
- // Assign bytes to members m_pwdkey.data.session_key
- // and m_pwdkey.data.nonce
-
- System.arraycopy(bytes, 0, m_pwdkey.data.session_key, 0, SecdefsCommon.SESSION_KEYLEN);
- System.arraycopy(bytes, SecdefsCommon.SESSION_KEYLEN, m_pwdkey.data.nonce, 0, SecdefsCommon.NONCE_SIZE);
-
- m_nonceSeq = (ByteBuffer.wrap(m_pwdkey.data.nonce)).getLong(
- SecdefsCommon.SESSION_KEYLEN -
- SecdefsCommon.NONCE_SEQNUM);
-
- // Set time when session key is generated
- m_keyTime = (new Date()).getTime();
- /*}catch (NoSuchAlgorithmException nae) {
- throw new SecurityException(SecClientMsgKeys.SESSION_KEY_GENERATION_FAILED, null);
- }*/
- }
-
- // encryption is required or not for replied message 0-yes, 1-no
- //int m_encrypted;
- // security option - mandatory - 1 or undocumented option - 0
- // Time when session key is generated
- private long m_keyTime;
- // sequence nonce used in nonce increment
- // Need to use 64 bit number type here
- private long m_nonceSeq;
- // certificate
- private Certificate m_cert;
- // key
- private Key m_keyObj;
- // password key
- private SecdefsCommon.PwdKey m_pwdkey;
- private javax.crypto.Cipher m_cipher;
-
-};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
deleted file mode 100644
index 64d1a3d..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SecurityException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
- **********************************************************************/
-package org.trafodion.jdbc.t4;
-
-import java.lang.String;
-import java.lang.Integer;
-import java.sql.SQLException;
-
-public class SecurityException extends SQLException
-{
- private static final String SQLState = "38001";
-
- public SecurityException(String key, Object[] params)
- {
- // Get the text message from the file secClient.properties.
- // Parse the message for the error message and error number.
- this((SecResourceBundle.obtainMessageText(key, params)).substring(6),
- Integer.parseInt((SecResourceBundle.obtainMessageText(key, params)).substring(0, 5)));
- }
-
- public SecurityException(String errMsg, int errNum)
- {
- super(errMsg, SQLState, errNum);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
deleted file mode 100644
index 8ee7c6c..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionMessage.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-
-class SetConnectionOptionMessage {
- // ----------------------------------------------------------
- static LogicalByteArray marshal(int dialogueId, short connectionOption, int optionValueNum, String optionValueStr,
- InterfaceConnection ic) throws CharacterCodingException, UnsupportedCharsetException {
- int wlength = Header.sizeOf();
- LogicalByteArray buf;
-
- byte[] optionValueBytes = ic.encodeString(optionValueStr, InterfaceUtilities.SQLCHARSETCODE_UTF8);
-
- wlength += TRANSPORT.size_int; // dialogueId
- wlength += TRANSPORT.size_short; // connectionOption
- wlength += TRANSPORT.size_int; // optionValueNum
- wlength += TRANSPORT.size_bytes(optionValueBytes); // optionValueStr
-
- buf = new LogicalByteArray(wlength, Header.sizeOf(), ic.getByteSwap());
-
- buf.insertInt(dialogueId);
- buf.insertShort(connectionOption);
- buf.insertInt(optionValueNum);
- buf.insertString(optionValueBytes);
-
- return buf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
deleted file mode 100644
index fa3ecc0..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SetConnectionOptionReply.java
+++ /dev/null
@@ -1,45 +0,0 @@
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-
-package org.trafodion.jdbc.t4;
-
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.sql.SQLException;
-
-class SetConnectionOptionReply {
- odbc_SQLSvc_SetConnectionOption_exc_ m_p1;
- ERROR_DESC_LIST_def m_p2;
-
- // -------------------------------------------------------------
- SetConnectionOptionReply(LogicalByteArray buf, String addr, InterfaceConnection ic)
- throws CharacterCodingException, UnsupportedCharsetException, SQLException {
- buf.setLocation(Header.sizeOf());
-
- m_p1 = new odbc_SQLSvc_SetConnectionOption_exc_();
- m_p1.extractFromByteArray(buf, addr, ic);
-
- if (m_p1.exception_nr == TRANSPORT.CEE_SUCCESS) {
- m_p2 = new ERROR_DESC_LIST_def();
- m_p2.extractFromByteArray(buf, ic);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/72e17019/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java b/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
deleted file mode 100644
index a0e10ad..0000000
--- a/core/conn/jdbc_type4/src/org/trafodion/jdbc/t4/SymCrypto.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements. See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
- //
- **********************************************************************/
-
-/**
- * class SymCrypto - Stores connections and correspondence SecPwd
- * objects.
- */
-
-package org.trafodion.jdbc.t4;
-
-import java.util.HashMap;
-import java.sql.Connection;
-
-public class SymCrypto
-{
- static HashMap<Connection, SymCrypto> storage = new HashMap<Connection, SymCrypto> ();
-
- /**
- * Ctor -
- * @param secpwd
- */
- private SymCrypto(SecPwd secpwd)
- {
- m_secPwd = secpwd;
- }
-
- /**
- * Returns the SymCrypto object correspondence to the connection passed in
- * @param con
- * @return the value to which the SymCrypto object maps the connection passed in or
- * null if the map contains no mapping for the connection.
- * @throws SecurityException
- */
- public static SymCrypto getInstance(Connection con) throws SecurityException
- {
- if (con == null)
- throw new SecurityException (SecClientMsgKeys.INPUT_PARAMETER_IS_NULL, new Object[]{"connection"});
- return storage.get(con);
- }
-
- /**
- * Creates and SymCrypto object from the SecPwd object and inserts the connection
- * and the equivalent SymCRypto object into the hash table storage. If the table previously
- * contained a mapping for the connection, the old value is replaced.
- * @param con - the JDBC connection
- * @param secpwd - the SecPwd object associated with the JDBC connection
- */
- public static void insert(Connection con, SecPwd secpwd)
- {
- SymCrypto symcrypto = new SymCrypto(secpwd);
- storage.put(con, symcrypto);
- }
-
- /**
- * Removed the mapping of this JDBC connection from the hash table if present
- * @param con - JDBC connection whose entry is to be removed from the hash table storage
- */
- public static void remove(Connection con)
- {
- if (con != null)
- storage.remove(con);
- }
-
- private SecPwd m_secPwd;
-
-}