summaryrefslogtreecommitdiff
path: root/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl')
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java31
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java16
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java22
3 files changed, 39 insertions, 30 deletions
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
index 7964239e31..625e1a77c2 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLEncryptor.java
@@ -21,21 +21,19 @@ package org.apache.qpid.transport.network.security.sasl;
*/
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.sasl.Sasl;
-import javax.security.sasl.SaslClient;
-
import org.apache.qpid.transport.Connection;
import org.apache.qpid.transport.ConnectionException;
import org.apache.qpid.transport.ConnectionListener;
+import javax.security.sasl.Sasl;
+import javax.security.sasl.SaslClient;
+
public abstract class SASLEncryptor implements ConnectionListener
{
- protected SaslClient saslClient;
- protected boolean securityLayerEstablished = false;
- protected int sendBuffSize;
- protected int recvBuffSize;
+ private SaslClient saslClient;
+ private boolean securityLayerEstablished = false;
+ private int sendBuffSize;
+ private int recvBuffSize;
public boolean isSecurityLayerEstablished()
{
@@ -63,4 +61,19 @@ public abstract class SASLEncryptor implements ConnectionListener
public void closed(Connection conn) {}
public abstract void securityLayerEstablished();
+
+ public SaslClient getSaslClient()
+ {
+ return saslClient;
+ }
+
+ public int getSendBuffSize()
+ {
+ return sendBuffSize;
+ }
+
+ public int getRecvBuffSize()
+ {
+ return recvBuffSize;
+ }
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
index 86106318ef..a100b96412 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLReceiver.java
@@ -21,18 +21,16 @@ package org.apache.qpid.transport.network.security.sasl;
*/
-import java.nio.ByteBuffer;
-
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
import org.apache.qpid.transport.Receiver;
import org.apache.qpid.transport.SenderException;
import org.apache.qpid.transport.util.Logger;
+import javax.security.sasl.SaslException;
+import java.nio.ByteBuffer;
+
public class SASLReceiver extends SASLEncryptor implements Receiver<ByteBuffer> {
- Receiver<ByteBuffer> delegate;
+ private Receiver<ByteBuffer> delegate;
private byte[] netData;
private static final Logger log = Logger.get(SASLReceiver.class);
@@ -58,11 +56,11 @@ public class SASLReceiver extends SASLEncryptor implements Receiver<ByteBuffer>
{
while (buf.hasRemaining())
{
- int length = Math.min(buf.remaining(),recvBuffSize);
+ int length = Math.min(buf.remaining(), getRecvBuffSize());
buf.get(netData, 0, length);
try
{
- byte[] out = saslClient.unwrap(netData, 0, length);
+ byte[] out = getSaslClient().unwrap(netData, 0, length);
delegate.received(ByteBuffer.wrap(out));
}
catch (SaslException e)
@@ -79,7 +77,7 @@ public class SASLReceiver extends SASLEncryptor implements Receiver<ByteBuffer>
public void securityLayerEstablished()
{
- netData = new byte[recvBuffSize];
+ netData = new byte[getRecvBuffSize()];
log.debug("SASL Security Layer Established");
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
index 2d9e4e9a7e..61d54a8386 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/sasl/SASLSender.java
@@ -21,19 +21,17 @@ package org.apache.qpid.transport.network.security.sasl;
*/
-import java.nio.ByteBuffer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.security.sasl.SaslClient;
-import javax.security.sasl.SaslException;
-
import org.apache.qpid.transport.Sender;
import org.apache.qpid.transport.SenderException;
import org.apache.qpid.transport.util.Logger;
+import javax.security.sasl.SaslException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.atomic.AtomicBoolean;
+
public class SASLSender extends SASLEncryptor implements Sender<ByteBuffer> {
- protected Sender<ByteBuffer> delegate;
+ private Sender<ByteBuffer> delegate;
private byte[] appData;
private final AtomicBoolean closed = new AtomicBoolean(false);
private static final Logger log = Logger.get(SASLSender.class);
@@ -54,7 +52,7 @@ public class SASLSender extends SASLEncryptor implements Sender<ByteBuffer> {
{
try
{
- saslClient.dispose();
+ getSaslClient().dispose();
}
catch (SaslException e)
{
@@ -80,14 +78,14 @@ public class SASLSender extends SASLEncryptor implements Sender<ByteBuffer> {
{
while (buf.hasRemaining())
{
- int length = Math.min(buf.remaining(),sendBuffSize);
- log.debug("sendBuffSize %s", sendBuffSize);
+ int length = Math.min(buf.remaining(), getSendBuffSize());
+ log.debug("sendBuffSize %s", getSendBuffSize());
log.debug("buf.remaining() %s", buf.remaining());
buf.get(appData, 0, length);
try
{
- byte[] out = saslClient.wrap(appData, 0, length);
+ byte[] out = getSaslClient().wrap(appData, 0, length);
log.debug("out.length %s", out.length);
delegate.send(ByteBuffer.wrap(out));
@@ -112,7 +110,7 @@ public class SASLSender extends SASLEncryptor implements Sender<ByteBuffer> {
public void securityLayerEstablished()
{
- appData = new byte[sendBuffSize];
+ appData = new byte[getSendBuffSize()];
log.debug("SASL Security Layer Established");
}