org.bouncycastle.crypto.tls.DTLSTransport Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-jdk15on Show documentation
Show all versions of bcprov-ext-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7. Note: this package includes the IDEA and NTRU encryption algorithms.
package org.bouncycastle.crypto.tls;
import java.io.IOException;
public class DTLSTransport
implements DatagramTransport
{
private final DTLSRecordLayer recordLayer;
DTLSTransport(DTLSRecordLayer recordLayer)
{
this.recordLayer = recordLayer;
}
public int getReceiveLimit()
throws IOException
{
return recordLayer.getReceiveLimit();
}
public int getSendLimit()
throws IOException
{
return recordLayer.getSendLimit();
}
public int receive(byte[] buf, int off, int len, int waitMillis)
throws IOException
{
try
{
return recordLayer.receive(buf, off, len, waitMillis);
}
catch (TlsFatalAlert fatalAlert)
{
recordLayer.fail(fatalAlert.getAlertDescription());
throw fatalAlert;
}
catch (IOException e)
{
recordLayer.fail(AlertDescription.internal_error);
throw e;
}
catch (RuntimeException e)
{
recordLayer.fail(AlertDescription.internal_error);
throw new TlsFatalAlert(AlertDescription.internal_error, e);
}
}
public void send(byte[] buf, int off, int len)
throws IOException
{
try
{
recordLayer.send(buf, off, len);
}
catch (TlsFatalAlert fatalAlert)
{
recordLayer.fail(fatalAlert.getAlertDescription());
throw fatalAlert;
}
catch (IOException e)
{
recordLayer.fail(AlertDescription.internal_error);
throw e;
}
catch (RuntimeException e)
{
recordLayer.fail(AlertDescription.internal_error);
throw new TlsFatalAlert(AlertDescription.internal_error, e);
}
}
public void close()
throws IOException
{
recordLayer.close();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy