test_class.declarator: impl
test_class.modifier: private
test_class.original_string: private WebSocketHybi impl;
test_class.type: WebSocketHybi
test_class.var_name: impl
test_class.file: tigase-server 7.1.0/src/test/java/tigase/server/websocket/WebSocketHybiTest.java
test_class.identifier: WebSocketHybiTest
test_class.superclass: extends TestCase
test_case.body: @Test
  	public void testHandshakeOK() throws NoSuchAlgorithmException, IOException {
  		final ByteBuffer tmp = ByteBuffer.allocate(2048);
  		WebSocketXMPPIOService<Object> io = new WebSocketXMPPIOService<Object>(new WebSocketProtocolIfc[]{ new WebSocketHixie76() }) {
  
  			@Override
  			protected void writeBytes(ByteBuffer data) {
  				tmp.put(data);
  			}
  
  			@Override
  			public int getLocalPort() {
  				return 80;
  			}
  
  		};		
  		Map<String,String> params = new HashMap<String,String>();
  		params.put("Sec-WebSocket-Version", "13");
  		params.put("Sec-WebSocket-Key", "some random data as a key");
  		params.put("Sec-WebSocket-Protocol", "xmpp");
  		byte[] bytes = new byte[10];
  		bytes[0] = '\r';
  		bytes[1] = '\n';
  		Assert.assertTrue("Handshake failed", impl.handshake(io, params, bytes));
  	}
test_case.class_method_signature: WebSocketHybiTest.testHandshakeOK()
test_case.full_signature: @Test public void testHandshakeOK()
test_case.identifier: testHandshakeOK
test_case.invocations: allocate put put put put assertTrue handshake
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHandshakeOK()
focal_class.declarator: log = Logger.getLogger(WebSocketHybi.class.getCanonicalName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = Logger.getLogger(WebSocketHybi.class.getCanonicalName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: ID = "hybi"
focal_class.modifier: public static final
focal_class.original_string: public static final String ID = "hybi";
focal_class.type: String
focal_class.var_name: ID
focal_class.declarator: GUID           = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
focal_class.modifier: private static final
focal_class.original_string: private static final String GUID           = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
focal_class.type: String
focal_class.var_name: GUID
focal_class.declarator: RESPONSE_HEADER =
  		"HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" +
  		"Connection: Upgrade\r\n" + "Access-Control-Allow-Origin: *\r\n" +
  		// Removed header below as it creates issues with connectivity using IE11 
  //		"Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n" +
  		"Access-Control-Allow-Headers: Content-Type\r\n" +
  		"Access-Control-Max-Age: 86400\r\n"
focal_class.modifier: private static final
focal_class.original_string: private static final String RESPONSE_HEADER =
  		"HTTP/1.1 101 Switching Protocols\r\n" + "Upgrade: websocket\r\n" +
  		"Connection: Upgrade\r\n" + "Access-Control-Allow-Origin: *\r\n" +
  		// Removed header below as it creates issues with connectivity using IE11 
  //		"Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n" +
  		"Access-Control-Allow-Headers: Content-Type\r\n" +
  		"Access-Control-Max-Age: 86400\r\n";
focal_class.type: String
focal_class.var_name: RESPONSE_HEADER
focal_class.declarator: WS_ACCEPT_KEY   = "Sec-WebSocket-Accept"
focal_class.modifier: private static final
focal_class.original_string: private static final String WS_ACCEPT_KEY   = "Sec-WebSocket-Accept";
focal_class.type: String
focal_class.var_name: WS_ACCEPT_KEY
focal_class.declarator: WS_KEY_KEY      = "Sec-WebSocket-Key"
focal_class.modifier: private static final
focal_class.original_string: private static final String WS_KEY_KEY      = "Sec-WebSocket-Key";
focal_class.type: String
focal_class.var_name: WS_KEY_KEY
focal_class.declarator: CLOSE_CODE = "close-code"
focal_class.modifier: private static final
focal_class.original_string: private static final String CLOSE_CODE = "close-code";
focal_class.type: String
focal_class.var_name: CLOSE_CODE
focal_class.declarator: ALLOW_UNMASKED_FROM_CLIENT = Boolean.getBoolean("ws-allow-unmasked-frames")
focal_class.modifier: private static final
focal_class.original_string: private static final boolean ALLOW_UNMASKED_FROM_CLIENT = Boolean.getBoolean("ws-allow-unmasked-frames");
focal_class.type: boolean
focal_class.var_name: ALLOW_UNMASKED_FROM_CLIENT
focal_class.declarator: PROTOCOL_ERROR = 1003
focal_class.modifier: private static final
focal_class.original_string: private static final int PROTOCOL_ERROR = 1003;
focal_class.type: int
focal_class.var_name: PROTOCOL_ERROR
focal_class.file: tigase-server 7.1.0/src/main/java/tigase/server/websocket/WebSocketHybi.java
focal_class.identifier: WebSocketHybi
focal_class.interfaces: implements WebSocketProtocolIfc
focal_class.class_method_signature: WebSocketHybi.getId()
focal_class.full_signature: @Override public String getId()
focal_class.identifier: getId
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getId()
focal_class.class_method_signature: WebSocketHybi.handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_class.full_signature: @Override public boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_class.identifier: handshake
focal_class.modifiers: @Override public
focal_class.parameters: (WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_class.return: boolean
focal_class.signature: boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_class.class_method_signature: WebSocketHybi.decodeFrame(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.full_signature: @Override public ByteBuffer decodeFrame(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.identifier: decodeFrame
focal_class.modifiers: @Override public
focal_class.parameters: (WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.return: ByteBuffer
focal_class.signature: ByteBuffer decodeFrame(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.class_method_signature: WebSocketHybi.encodeFrameAndWrite(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.full_signature: @Override public void encodeFrameAndWrite(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.identifier: encodeFrameAndWrite
focal_class.modifiers: @Override public
focal_class.parameters: (WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.return: void
focal_class.signature: void encodeFrameAndWrite(WebSocketXMPPIOService service, ByteBuffer buf)
focal_class.class_method_signature: WebSocketHybi.closeConnection(WebSocketXMPPIOService service)
focal_class.full_signature: @Override public void closeConnection(WebSocketXMPPIOService service)
focal_class.identifier: closeConnection
focal_class.modifiers: @Override public
focal_class.parameters: (WebSocketXMPPIOService service)
focal_class.return: void
focal_class.signature: void closeConnection(WebSocketXMPPIOService service)
focal_class.class_method_signature: WebSocketHybi.closeConnection(WebSocketXMPPIOService service, Integer code)
focal_class.full_signature: private void closeConnection(WebSocketXMPPIOService service, Integer code)
focal_class.identifier: closeConnection
focal_class.modifiers: private
focal_class.parameters: (WebSocketXMPPIOService service, Integer code)
focal_class.return: void
focal_class.signature: void closeConnection(WebSocketXMPPIOService service, Integer code)
focal_class.class_method_signature: WebSocketHybi.createFrameHeader(byte type, int size)
focal_class.full_signature: private ByteBuffer createFrameHeader(byte type, int size)
focal_class.identifier: createFrameHeader
focal_class.modifiers: private
focal_class.parameters: (byte type, int size)
focal_class.return: ByteBuffer
focal_class.signature: ByteBuffer createFrameHeader(byte type, int size)
focal_method.body: @Override
  	public boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf) throws NoSuchAlgorithmException, IOException {
  		if (!headers.containsKey(WS_VERSION_KEY)) {
  			return false;
  		}
  		
  		StringBuilder response = new StringBuilder(RESPONSE_HEADER.length() * 2);
  		response.append(RESPONSE_HEADER);
  
  		int version = Integer.parseInt(headers.get(WS_VERSION_KEY));
  		String key = headers.get(WS_KEY_KEY) + GUID;
  
  		MessageDigest md = MessageDigest.getInstance("SHA1");
  		byte[] resp = md.digest(key.getBytes());
  
  		response.append(WS_PROTOCOL_KEY).append(": ");
  		if (headers.get(WS_PROTOCOL_KEY).contains("xmpp-framing")) {
  			response.append("xmpp-framing");
  		} else {
  			response.append("xmpp");
  		}
  		response.append("\r\n");
  		response.append(WS_ACCEPT_KEY + ": ");
  		response.append(Base64.encode(resp));
  		response.append("\r\n");
  		response.append("\r\n");
  		service.maskingKey = new byte[4];
  		service.writeRawData(response.toString());
  			
  		return true;
  	}
focal_method.class_method_signature: WebSocketHybi.handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_method.full_signature: @Override public boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_method.identifier: handshake
focal_method.invocations: containsKey length append parseInt get get getInstance digest getBytes append append contains get append append append append append encode append append writeRawData toString
focal_method.modifiers: @Override public
focal_method.parameters: (WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)
focal_method.return: boolean
focal_method.signature: boolean handshake(WebSocketXMPPIOService service, Map<String, String> headers, byte[] buf)