Skip to content

Commit

Permalink
Partial revert of 9fb51ae
Browse files Browse the repository at this point in the history
* The AuthenticationType CLEARTEXT was not a fully different option but a
  simple name change for USERPASSWORD and was never included in a final
  release.

* Reverts both AuthenticationType and Handshake to reflect 8.7 teiid client
  • Loading branch information
Paul Richardson committed Aug 6, 2014
1 parent 33bde2d commit 0513845
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,7 @@

package org.teiid.net.socket;

import org.teiid.designer.annotation.Removed;
import org.teiid.designer.annotation.Since;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion.Version;

public enum AuthenticationType {
@Since(Version.TEIID_8_7)
USERPASSWORD,

GSS,

@Removed(Version.TEIID_8_7)
CLEARTEXT;

private static boolean lessThan87(ITeiidServerVersion teiidVersion) {
return teiidVersion.isLessThan(Version.TEIID_8_7.get());
}

/**
* @param teiidVersion
* @param readByte
*
* @return enum value
*/
public static AuthenticationType value(ITeiidServerVersion teiidVersion, byte readByte) {
switch (readByte) {
case 0:
if (lessThan87(teiidVersion))
return CLEARTEXT;
else
return USERPASSWORD;
case 1:
return GSS;
default:
throw new IllegalStateException();
}
}

/**
* @param teiidVersion
* @return Same as ordinal but handle deprecated inclusion of CLEARTEXT
*/
public int index(ITeiidServerVersion teiidVersion) {
if (lessThan87(teiidVersion) && this == CLEARTEXT)
return 0;

return this.ordinal();
}
USERPASSWORD, GSS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.teiid.core.util.StringUtil;
import org.teiid.designer.runtime.version.spi.ITeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion;
import org.teiid.designer.runtime.version.spi.TeiidServerVersion.Version;


/**
Expand All @@ -59,18 +58,6 @@ private ITeiidServerVersion getTeiidVersion() {
return version;
}

private AuthenticationType getAuthenticationType() {
if (authType == null) {
ITeiidServerVersion version = getTeiidVersion();
if (version.isGreaterThanOrEqualTo(Version.TEIID_8_7.get()))
authType = AuthenticationType.USERPASSWORD;

authType = AuthenticationType.CLEARTEXT;
}

return authType;
}

/**
* @return Returns the version.
*/
Expand Down Expand Up @@ -116,16 +103,20 @@ public void setPublicKey(byte[] key) {
}

public AuthenticationType getAuthType() {
return getAuthenticationType();
return authType;
}

public void setAuthType(AuthenticationType authType) {
this.authType = authType;
}

@Override
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
version = (String)in.readObject();
publicKey = (byte[])in.readObject();
try {
authType = AuthenticationType.value(getTeiidVersion(), in.readByte());
authType = AuthenticationType.values()[in.readByte()];
} catch (EOFException e) {

}
Expand All @@ -135,7 +126,7 @@ public void readExternal(ObjectInput in) throws IOException,
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(version);
out.writeObject(publicKey);
out.writeByte(authType.index(getTeiidVersion()));
out.writeByte(authType.ordinal());
}

}

0 comments on commit 0513845

Please sign in to comment.