Skip to content

Commit

Permalink
Added casting for ByteBuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcw committed Jan 29, 2024
1 parent 7cd1364 commit 1d05f82
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ public byte[] rangeOf(int start, int end)
}

int p = buffer.position();
buffer.position(start);
((java.nio.Buffer)buffer).position(start);
byte[] data = new byte[end - start];
buffer.get(data);
buffer.position(p);
((java.nio.Buffer)buffer).position(p);
return data;
}

Expand All @@ -105,7 +105,7 @@ public int position()

public void position(int p)
{
buffer.position(p);
((java.nio.Buffer)buffer).position(p);
}

public int u16()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ public void testRSA()

priv = keyFact.generatePrivate(new RSAPrivateKeySpec(((RSAPrivateKey)priv).getModulus(), ((RSAPrivateKey)priv).getPrivateExponent()));

assertEquals(priv, priv);
assertFalse(priv.equals(pub));
assertTrue(priv.equals(priv));
assertFalse(priv.equals(pub));// priv.equals(pub));

doSerialisationCheck(priv);

Expand Down Expand Up @@ -365,8 +365,8 @@ private void doBasicTest(String algorithm, KeyPair kp)
assertEquals(algorithm, pub.getAlgorithm());
assertEquals(algorithm, priv.getAlgorithm());

assertEquals(pub, pub);
assertEquals(priv, priv);
assertTrue(pub.equals(pub));
assertTrue(priv.equals(priv));

assertFalse(pub.equals(priv));
assertFalse(priv.equals(pub));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,8 @@ public boolean isTrusted()
}
catch (Exception ex)
{
Assert.assertEquals("Must be EST Exception", ESTException.class, ex.getClass());
Assert.assertEquals("Cause is IO Exception.", IOException.class, IOException.class);
Assert.assertTrue("Must be EST Exception", ex.getClass().equals(ESTException.class));
Assert.assertTrue("Cause is IO Exception.", ex.getCause().getClass().equals(IOException.class));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ private RecordPreview getRecordPreview(ByteBuffer src)

int position = src.position();
src.get(recordHeader);
src.position(position);
((java.nio.Buffer)src).position(position);

return protocol.previewInputRecord(recordHeader);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private void runTestConnection() throws Throwable
serverResult = serverEngine.wrap(serverOut, serverToClient);
runDelegatedTasks(serverEngine, serverResult);

clientToServer.flip();
serverToClient.flip();
((java.nio.Buffer)clientToServer).flip();
((java.nio.Buffer)serverToClient).flip();

clientResult = clientEngine.unwrap(serverToClient, clientIn);
runDelegatedTasks(clientEngine, clientResult);
Expand Down Expand Up @@ -152,15 +152,15 @@ private void runTestConnection() throws Throwable

private static void checkData(ByteBuffer a, ByteBuffer b) throws Exception
{
a.flip();
b.flip();
((java.nio.Buffer)a).flip();
((java.nio.Buffer)b).flip();

assertEquals(a, b);

a.position(a.limit());
b.position(b.limit());
a.limit(a.capacity());
b.limit(b.capacity());
((java.nio.Buffer)a).position(a.limit());
((java.nio.Buffer)b).position(b.limit());
((java.nio.Buffer)a).limit(a.capacity());
((java.nio.Buffer)b).limit(b.capacity());
}

private SSLContext createSSLContextClient() throws GeneralSecurityException
Expand Down

0 comments on commit 1d05f82

Please sign in to comment.