Mercurial > hg > Applications > tvnjviewer
changeset 15:e28c17afa0e9
add SecurityType.REQUIRE_AUTHENTICATION
author | one |
---|---|
date | Sun, 28 Sep 2014 11:59:14 +0900 (2014-09-28) |
parents | 6d8b59301b95 |
children | cc9fdda7d22e |
files | src/main/java/com/glavsoft/rfb/RfbCapabilityInfo.java src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java src/main/java/com/glavsoft/rfb/protocol/auth/RequireAuthentication.java src/main/java/com/glavsoft/rfb/protocol/auth/SecurityType.java src/main/java/com/glavsoft/transport/Reader.java |
diffstat | 5 files changed, 50 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/RfbCapabilityInfo.java Sun Sep 28 11:53:26 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/RfbCapabilityInfo.java Sun Sep 28 11:59:14 2014 +0900 @@ -51,6 +51,8 @@ public static final String AUTHENTICATION_NO_AUTH = "NOAUTH__"; public static final String AUTHENTICATION_VNC_AUTH ="VNCAUTH_"; + + public static final String AUTHENTICATION_REQ_AUTH ="REQAUTH_"; public static final String ENCODING_COPYRECT = "COPYRECT"; public static final String ENCODING_HEXTILE = "HEXTILE_";
--- a/src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java Sun Sep 28 11:53:26 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/ProtocolSettings.java Sun Sep 28 11:59:14 2014 +0900 @@ -158,6 +158,8 @@ RfbCapabilityInfo.VENDOR_STANDARD, RfbCapabilityInfo.AUTHENTICATION_NO_AUTH); cc.addEnabled(SecurityType.VNC_AUTHENTICATION.getId(), RfbCapabilityInfo.VENDOR_STANDARD, RfbCapabilityInfo.AUTHENTICATION_VNC_AUTH); + cc.addEnabled(SecurityType.REQUIRE_AUTHENTICATION.getId() + , RfbCapabilityInfo.VENDOR_STANDARD, RfbCapabilityInfo.AUTHENTICATION_REQ_AUTH); //cc.addEnabled( 19, "VENC", "VENCRYPT"); //cc.addEnabled( 20, "GTKV", "SASL____"); //cc.addEnabled(129, RfbCapabilityInfo.TIGHT_VNC_VENDOR, "ULGNAUTH");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/com/glavsoft/rfb/protocol/auth/RequireAuthentication.java Sun Sep 28 11:59:14 2014 +0900 @@ -0,0 +1,38 @@ +package com.glavsoft.rfb.protocol.auth; + +import com.glavsoft.exceptions.TransportException; +import com.glavsoft.rfb.CapabilityContainer; +import com.glavsoft.rfb.IPasswordRetriever; +import com.glavsoft.transport.Reader; +import com.glavsoft.transport.Writer; + +public class RequireAuthentication extends AuthHandler { + + @Override + public boolean authenticate(Reader reader, Writer writer, + CapabilityContainer authCaps, IPasswordRetriever passwordRetriever) throws TransportException { + byte[] headBuf = new byte[2]; + reader.readBytes(headBuf); + if (headBuf[1] == 2) { + byte[] b = new byte[258]; + reader.readBytes(b); + byte[] outBuf = new byte[256]; + writer.write(outBuf); + writer.flush(); + } else if (headBuf[1] == 23) { + byte[] b = new byte[130]; + reader.readBytes(b); + byte[] outBuf = new byte[192]; + writer.write(outBuf); + writer.flush(); + } + + return false; + } + + @Override + public SecurityType getType() { + return SecurityType.REQUIRE_AUTHENTICATION; + } +} +
--- a/src/main/java/com/glavsoft/rfb/protocol/auth/SecurityType.java Sun Sep 28 11:53:26 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/protocol/auth/SecurityType.java Sun Sep 28 11:59:14 2014 +0900 @@ -37,7 +37,8 @@ VNC_AUTHENTICATION(2), // int RA2_AUTHENTICATION = 5; // int RA2NE_AUTHENTICATION = 6; - TIGHT_AUTHENTICATION(16); + TIGHT_AUTHENTICATION(16), + REQUIRE_AUTHENTICATION(32); // int ULTRA_AUTHENTICATION = 17; // int TLS_AUTHENTICATION = 18; // int VENCRYPT_AUTHENTICATION = 19; @@ -58,6 +59,7 @@ put(TIGHT_AUTHENTICATION.getId(), new TightAuthentication()); put(VNC_AUTHENTICATION.getId(), new VncAuthentication()); put(NONE_AUTHENTICATION.getId(), new NoneAuthentication()); + put(REQUIRE_AUTHENTICATION.getId(), new RequireAuthentication()); }}; public static AuthHandler getAuthHandlerById(int id) throws UnsupportedSecurityTypeException {
--- a/src/main/java/com/glavsoft/transport/Reader.java Sun Sep 28 11:53:26 2014 +0900 +++ b/src/main/java/com/glavsoft/transport/Reader.java Sun Sep 28 11:59:14 2014 +0900 @@ -142,6 +142,11 @@ byte b[] = new byte[length]; return readBytes(b, 0, length); } + + public byte[] readBytes(byte[] b) throws TransportException { + byte[] result = readBytes(b, 0, b.length); + return result; + } public byte[] readBytes(byte[] b, int offset, int length) throws TransportException { try {