/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is used by clients of Java SASL that need to create an input stream
* that uses SaslClient's unwrap() method to decode the SASL buffers
* sent by the SASL server.
*
* Extend from InputStream instead of FilterInputStream because
* we need to override less methods in InputStream. That is, the
* behavior of the default implementations in InputStream matches
* more closely with the behavior we want in SaslInputStream.
*
* @author Rosanna Lee
*/
private static final boolean debug = false;
// Initialized to empty buffer
super();
try {
} catch (NumberFormatException e) {
" property must be numeric string: " + str);
}
}
saslBuffer = new byte[recvMaxBufSize];
}
byte[] inBuf = new byte[1];
if (count > 0) {
return inBuf[0];
} else {
return -1;
}
}
}
if (actual == -1) {
return -1; // EOF
}
}
// Requesting more that we have stored
// Return all that we have; next invocation of read() will
// trigger fill()
return avail;
} else {
// Requesting less than we have stored
// Return all that was requested
return count;
}
}
/**
* Fills the buf with more data by reading a SASL buffer, unwrapping it,
* and leaving the bytes in buf for read() to return.
* @return The number of unwrapped bytes available
*/
// Read in length of buffer
if (actual != 4) {
return -1;
}
if (len > recvMaxBufSize) {
throw new IOException(
len + "exceeds the negotiated receive buffer size limit:" +
}
if (debug) {
}
// Read SASL buffer
}
// Unwrap
bufPos = 0;
}
/**
* Read requested number of bytes before returning.
* @return The number of bytes actually read; -1 if none read
*/
if (debug) {
}
while (total > 0) {
if (debug) {
}
if (count == -1 ) {
}
}
return pos;
}
}
try {
} catch (SaslException e) {
// Save exception for throwing after closing 'in'
save = e;
}
throw save;
}
}
/**
* Returns the integer represented by 4 bytes in network byte order.
*/
// Copied from com.sun.security.sasl.util.SaslImpl.
if (count > 4) {
throw new IllegalArgumentException("Cannot handle more than 4 bytes");
}
int answer = 0;
for (int i = 0; i < count; i++) {
answer <<= 8;
}
return answer;
}
}