| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.extensions; |
| | |
| | | private RedirectingByteChannel channel; |
| | | |
| | | // The number of bytes in the length buffer. |
| | | private final int lengthSize = 4; |
| | | private static final int lengthSize = 4; |
| | | |
| | | //Length of the buffer. |
| | | private int bufLength; |
| | |
| | | */ |
| | | private int readAll(ByteBuffer byteBuf, int total) throws IOException |
| | | { |
| | | int count = 0; |
| | | while (channel.isOpen() && total > 0) { |
| | | count = channel.read(byteBuf); |
| | | int count = channel.read(byteBuf); |
| | | if (count == -1) return -1; |
| | | if (count == 0) return 0; |
| | | total -= count; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public synchronized int read(ByteBuffer clearDst) throws IOException { |
| | | int bytesToRead = lengthSize; |
| | | if(reading) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public synchronized int write(ByteBuffer clearSrc) throws IOException { |
| | | int sendBufSize = getAppBufSize(); |
| | | int srcLen = clearSrc.remaining(); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public synchronized void close() throws IOException { |
| | | saslContext.dispose(); |
| | | saslContext=null; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isOpen() { |
| | | return saslContext != null; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int getAppBufSize() { |
| | | return saslContext.getBufSize(Sasl.MAX_BUFFER); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public Certificate[] getClientCertificateChain() { |
| | | return new Certificate[0]; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public int getSSF() { |
| | | return saslContext.getSSF(); |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public ByteChannel wrapChannel(ByteChannel channel) { |
| | | return this; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public String getName() { |
| | | return name; |
| | | } |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public boolean isSecure() { |
| | | return true; |
| | | } |