4613N/A * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A multi-purpose class which handles all of the SSLEngine arguments. 0N/A * It validates arguments, checks for RO conditions, does space 0N/A * @author Brad R. Wetmore 0N/A * Keep track of the input parameters. 0N/A * The initial pos/limit conditions. This is useful because we can 0N/A * operations, or easily return the buffers to their pre-error 0N/A * Sum total of the space remaining in all of the appData buffers 0N/A * Called by the SSLEngine.wrap() method. 0N/A * Called by the SSLEngine.unwrap() method. 0N/A * The main initialization method for the arguments. Most 0N/A * of them are pretty obvious as to what they do. 0N/A * Since we're already iterating over appData array for validity 0N/A * checking, we also keep track of how much remainging space is 0N/A * available. Info is used in both unwrap (to see if there is 0N/A * enough space available in the destination), and in wrap (to 0N/A * determine how much more we can copy into the outgoing data 0N/A "appData[" + i +
"] == null");
0N/A * If we're unwrapping, then check to make sure our 0N/A * destination bufffers are writable. 0N/A * Ok, looks like we have a good set of args, let's 0N/A * store the rest of this stuff. 0N/A * Given spaceLeft bytes to transfer, gather up that much data 0N/A * from the appData buffers (starting at offset in the array), 0N/A * and transfer it into the netData buffer. 0N/A * The user has already ensured there is enough room. 0N/A * Using the supplied buffer, scatter the data into the appData buffers 0N/A * (starting at offset in the array). 0N/A * The user has already ensured there is enough room. 0N/A * we saved this off earlier? 0N/A * we saved this off earlier? 0N/A int sum =
0;
// Only calculating 2^14 here, don't need a long. 0N/A * In the case of Exception, we want to reset the positions 0N/A * to appear as though no data has been consumed or produced. 4613N/A * Currently, this method is only called as we are preparing to 4613N/A * fail out, and thus we don't need to actually recalculate 4613N/A * appRemaining. If that assumption changes, that variable should 4613N/A // See comment above about recalculating appRemaining. 0N/A * We are doing lots of ByteBuffer manipulations, in which case 0N/A * we need to make sure that the limits get set back correctly. 0N/A * This is one of the last things to get done before returning to