@Test public void testGetInitialResponseWithNullUserAndPassword() { XOauth2Mechanism mech = new XOauth2Mechanism(); byte[] response = mech.getInitialResponse(); assertNotNull(response); assertTrue(response.length > 0); }
@Override public byte[] getInitialResponse() { String username = getUsername(); String password = getPassword(); if (username == null) { username = ""; } if (password == null) { password = ""; } byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8); byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); byte[] data = new byte[usernameBytes.length + passwordBytes.length + 20]; System.arraycopy("user=".getBytes(StandardCharsets.US_ASCII), 0, data, 0, 5); System.arraycopy(usernameBytes, 0, data, 5, usernameBytes.length); data[5+usernameBytes.length] = 1; System.arraycopy("auth=Bearer ".getBytes(StandardCharsets.US_ASCII), 0, data, 6+usernameBytes.length, 12); System.arraycopy(passwordBytes, 0, data, 18 + usernameBytes.length, passwordBytes.length); data[data.length-2] = 1; data[data.length-1] = 1; return data; }
XOauth2Mechanism extends AbstractMechanism { @Override public byte[] getInitialResponse() { String username = getUsername(); String password = getPassword(); if (username == null) { username = ""; } if (password == null) { password = ""; } byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8); byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); byte[] data = new byte[usernameBytes.length + passwordBytes.length + 20]; System.arraycopy("user=".getBytes(StandardCharsets.US_ASCII), 0, data, 0, 5); System.arraycopy(usernameBytes, 0, data, 5, usernameBytes.length); data[5+usernameBytes.length] = 1; System.arraycopy("auth=Bearer ".getBytes(StandardCharsets.US_ASCII), 0, data, 6+usernameBytes.length, 12); System.arraycopy(passwordBytes, 0, data, 18 + usernameBytes.length, passwordBytes.length); data[data.length-2] = 1; data[data.length-1] = 1; return data; } }
XOauth2Mechanism extends AbstractMechanism { @Override public byte[] getInitialResponse() { String username = getUsername(); String password = getPassword(); if (username == null) { username = ""; } if (password == null) { password = ""; } byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8); byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); byte[] data = new byte[usernameBytes.length + passwordBytes.length + 20]; System.arraycopy("user=".getBytes(StandardCharsets.US_ASCII), 0, data, 0, 5); System.arraycopy(usernameBytes, 0, data, 5, usernameBytes.length); data[5+usernameBytes.length] = 1; System.arraycopy("auth=Bearer ".getBytes(StandardCharsets.US_ASCII), 0, data, 6+usernameBytes.length, 12); System.arraycopy(passwordBytes, 0, data, 18 + usernameBytes.length, passwordBytes.length); data[data.length-2] = 1; data[data.length-1] = 1; return data; }  }
XOauth2Mechanism extends AbstractMechanism { @Override public byte[] getInitialResponse() { String username = getUsername(); String password = getPassword(); if (username == null) { username = ""; } if (password == null) { password = ""; } byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8); byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); byte[] data = new byte[usernameBytes.length + passwordBytes.length + 20]; System.arraycopy("user=".getBytes(StandardCharsets.US_ASCII), 0, data, 0, 5); System.arraycopy(usernameBytes, 0, data, 5, usernameBytes.length); data[5+usernameBytes.length] = 1; System.arraycopy("auth=Bearer ".getBytes(StandardCharsets.US_ASCII), 0, data, 6+usernameBytes.length, 12); System.arraycopy(passwordBytes, 0, data, 18 + usernameBytes.length, passwordBytes.length); data[data.length-2] = 1; data[data.length-1] = 1; return data; }  @Override int getPriority(); @Override String getName(); @Override byte[] getInitialResponse(); @Override byte[] getChallengeResponse(byte[] challenge); @Override boolean isApplicable(String username, String password, Principal localPrincipal); @Override String getAdditionalFailureInformation(); }
XOauth2Mechanism extends AbstractMechanism { @Override public byte[] getInitialResponse() { String username = getUsername(); String password = getPassword(); if (username == null) { username = ""; } if (password == null) { password = ""; } byte[] usernameBytes = username.getBytes(StandardCharsets.UTF_8); byte[] passwordBytes = password.getBytes(StandardCharsets.UTF_8); byte[] data = new byte[usernameBytes.length + passwordBytes.length + 20]; System.arraycopy("user=".getBytes(StandardCharsets.US_ASCII), 0, data, 0, 5); System.arraycopy(usernameBytes, 0, data, 5, usernameBytes.length); data[5+usernameBytes.length] = 1; System.arraycopy("auth=Bearer ".getBytes(StandardCharsets.US_ASCII), 0, data, 6+usernameBytes.length, 12); System.arraycopy(passwordBytes, 0, data, 18 + usernameBytes.length, passwordBytes.length); data[data.length-2] = 1; data[data.length-1] = 1; return data; }  @Override int getPriority(); @Override String getName(); @Override byte[] getInitialResponse(); @Override byte[] getChallengeResponse(byte[] challenge); @Override boolean isApplicable(String username, String password, Principal localPrincipal); @Override String getAdditionalFailureInformation();  }