diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java index 159e66cf2..6bf4101da 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java @@ -125,7 +125,7 @@ final class TDS { // Data Classification constants static final byte TDS_FEATURE_EXT_DATACLASSIFICATION = 0x09; static final byte DATA_CLASSIFICATION_NOT_ENABLED = 0x00; - static final byte MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION = 0x01; + static final byte MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION = 0x02; static final int AES_256_CBC = 1; static final int AEAD_AES_256_CBC_HMAC_SHA256 = 2; @@ -6434,6 +6434,8 @@ final SQLServerConnection getConnection() { private boolean useColumnEncryption = false; private boolean serverSupportsColumnEncryption = false; private boolean serverSupportsDataClassification = false; + private byte serverSupportedDataClassificationVersion = TDS.DATA_CLASSIFICATION_NOT_ENABLED; + private ColumnEncryptionVersion columnEncryptionVersion; private final byte valueBytes[] = new byte[256]; @@ -6461,6 +6463,7 @@ private static int nextReaderID() { serverSupportsColumnEncryption = con.getServerSupportsColumnEncryption(); columnEncryptionVersion = con.getServerColumnEncryptionVersion(); serverSupportsDataClassification = con.getServerSupportsDataClassification(); + serverSupportedDataClassificationVersion = con.getServerSupportedDataClassificationVersion(); } final boolean isColumnEncryptionSettingEnabled() { @@ -6475,6 +6478,10 @@ final boolean getServerSupportsDataClassification() { return serverSupportsDataClassification; } + final byte getServerSupportedDataClassificationVersion() { + return serverSupportedDataClassificationVersion; + } + final void throwInvalidTDS() throws SQLServerException { if (logger.isLoggable(Level.SEVERE)) logger.severe(toString() + " got unexpected value in TDS response at offset:" + payloadOffset); diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java index ec76e281b..a7d5d3da2 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java @@ -680,11 +680,16 @@ ColumnEncryptionVersion getServerColumnEncryptionVersion() { } private boolean serverSupportsDataClassification = false; + private byte serverSupportedDataClassificationVersion = TDS.DATA_CLASSIFICATION_NOT_ENABLED; boolean getServerSupportsDataClassification() { return serverSupportsDataClassification; } + byte getServerSupportedDataClassificationVersion() { + return serverSupportedDataClassificationVersion; + } + // Boolean that indicates whether LOB objects created by this connection should be loaded into memory private boolean delayLoadingLobs = SQLServerDriverBooleanProperty.DELAY_LOADING_LOBS.getDefaultValue(); @@ -4669,9 +4674,9 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept throw new SQLServerException(SQLServerException.getErrString("R_UnknownDataClsTokenNumber"), null); } - byte supportedDataClassificationVersion = data[0]; - if ((0 == supportedDataClassificationVersion) - || (supportedDataClassificationVersion > TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) { + serverSupportedDataClassificationVersion = data[0]; + if ((0 == serverSupportedDataClassificationVersion) + || (serverSupportedDataClassificationVersion > TDS.MAX_SUPPORTED_DATA_CLASSIFICATION_VERSION)) { throw new SQLServerException(SQLServerException.getErrString("R_InvalidDataClsVersionNumber"), null); } diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index d9f41510a..c780b2c36 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -455,6 +455,36 @@ public String toString() { } +enum SensitivityRank { + NOT_DEFINED(-1), + NONE(0), + LOW(10), + MEDIUM(20), + HIGH(30), + CRITICAL(40); + + private static final SensitivityRank[] VALUES = values(); + private int rank; + + private SensitivityRank(int rank) { + this.rank = rank; + } + + public int getValue() { + return rank; + } + + static boolean isValid(int rank) throws SQLServerException { + for (SensitivityRank r : VALUES) { + if (r.getValue() == rank) { + return true; + } + } + return false; + } +} + + /** * Provides methods to connect to a SQL Server database and to obtain information about the JDBC driver. */ diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java index df8b031fd..7d0aac977 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/StreamColumns.java @@ -259,42 +259,50 @@ private SensitivityClassification processDataClassification(TDSReader tdsReader) SensitivityClassification sensitivityClassification = null; // get the label count - int numLabels = tdsReader.readUnsignedShort(); - List