Package org.glassfish.grizzly

Examples of org.glassfish.grizzly.TransformationException


            if (expectedLength == -1 || originalMessage.remaining() < expectedLength) {
                return TransformationResult.createIncompletedResult(
                            originalMessage);
            }
        } catch (SSLException e) {
            throw new TransformationException(e);
        }
       
        final Buffer targetBuffer = memoryManager.allocate(
                    sslEngine.getSession().getApplicationBufferSize());

        TransformationResult<Buffer, Buffer> transformationResult = null;

        try {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "SSLDecoder engine: {0} input: {1} output: {2}",
                        new Object[]{sslEngine, originalMessage, targetBuffer});
            }

            final int pos = originalMessage.position();
            final SSLEngineResult sslEngineResult;
            if (!originalMessage.isComposite()) {
                sslEngineResult = sslEngine.unwrap(originalMessage.toByteBuffer(),
                        targetBuffer.toByteBuffer());
            } else {
                final ByteBuffer originalByteBuffer =
                        originalMessage.toByteBuffer(pos,
                        pos + expectedLength);

                sslEngineResult = sslEngine.unwrap(originalByteBuffer,
                        targetBuffer.toByteBuffer());
            }
           
            originalMessage.position(pos + sslEngineResult.bytesConsumed());
            targetBuffer.position(sslEngineResult.bytesProduced());


            final SSLEngineResult.Status status = sslEngineResult.getStatus();

            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "SSLDecoderr done engine: {0} result: {1} input: {2} output: {3}",
                        new Object[]{sslEngine, sslEngineResult, originalMessage, targetBuffer});
            }

            if (status == SSLEngineResult.Status.OK) {
                targetBuffer.trim();

                return TransformationResult.createCompletedResult(
                        targetBuffer, originalMessage);
            } else if (status == SSLEngineResult.Status.CLOSED) {
                targetBuffer.dispose();

                return TransformationResult.createCompletedResult(
                        Buffers.EMPTY_BUFFER, originalMessage);
            } else {
                targetBuffer.dispose();

                if (status == SSLEngineResult.Status.BUFFER_UNDERFLOW) {
                    transformationResult =
                            TransformationResult.createIncompletedResult(
                            originalMessage);
                } else if (status == SSLEngineResult.Status.BUFFER_OVERFLOW) {
                    transformationResult =
                            TransformationResult.createErrorResult(
                            BUFFER_OVERFLOW_ERROR,
                            "Buffer overflow during unwrap operation");
                }
            }
        } catch (SSLException e) {
            targetBuffer.dispose();
            throw new TransformationException(e);
        }

        return transformationResult;
    }
View Full Code Here


            } catch (SSLException e) {
                disposeBuffers(currentTargetBuffer, targetBuffer);

                originalByteBufferArray.restore();

                throw new TransformationException(e);
            }
           
            if (originalByteBuffer.hasRemaining()) { // Keep working with the current source ByteBuffer
                i--;
            }
View Full Code Here

    protected TransformationResult<Buffer, String> transformImpl(
            AttributeStorage storage, Buffer input)
            throws TransformationException {

        if (input == null) {
            throw new TransformationException("Input could not be null");
        }

        final TransformationResult<Buffer, String> result;

        if (stringTerminateBytes == null) {
View Full Code Here

        if (input != null && input.hasRemaining()) {
            try {
                state.setMemoryManager(memoryManager);
                encodedBuffer = encodeBuffer(input, state);
            } catch (IOException ioe) {
                throw new TransformationException(ioe);
            }
        }

        if (encodedBuffer == null) {
            return TransformationResult.createIncompletedResult(null);
View Full Code Here

    protected TransformationResult<String, Buffer> transformImpl(
            AttributeStorage storage, String input)
            throws TransformationException {

        if (input == null) {
            throw new TransformationException("Input could not be null");
        }

        byte[] byteRepresentation;
        try {
            if (stringTerminator != null) {
                input = input + stringTerminator;
            }
           
            byteRepresentation = input.getBytes(charset.name());
        } catch(UnsupportedEncodingException e) {
            throw new TransformationException("Charset " +
                    charset.name() + " is not supported", e);
        }

        final Buffer output =
                obtainMemoryManager(storage).allocate(byteRepresentation.length + 4);
View Full Code Here

  // Uses left-to-right evaluation order
        final long inCrc32Value = crc32.getValue();
  if ((getUInt(buffer, crc32) != inCrc32Value) ||
      // rfc1952; ISIZE is the input size modulo 2^32
      (getUInt(buffer, crc32) != (inflater.getBytesWritten() & 0xffffffffL)))
      throw new TransformationException("Corrupt GZIP trailer");

        return true;
    }
View Full Code Here

                    return ctx.getInvokeAction();
                }
            case INCOMPLETE:
                return ctx.getStopAction(message);
            case ERROR:
                throw new TransformationException(getClass().getName() +
                        " transformation error: (" + result.getErrorCode() + ") " +
                        result.getErrorDescription());
        }

        return ctx.getInvokeAction();
View Full Code Here

                    return ctx.getInvokeAction();
                }
            case INCOMPLETE:
                return ctx.getStopAction(message);
            case ERROR:
                throw new TransformationException(getClass().getName() +
                        " transformation error: (" + result.getErrorCode() + ") " +
                        result.getErrorDescription());
        }

        return ctx.getInvokeAction();
View Full Code Here

        } else if (status == Status.INCOMPLETE) {
            exception = new IllegalStateException("Encoder returned INCOMPLETE state");
        }

        if (exception == null) {
            exception = new TransformationException(result.getErrorCode() + ": " +
                result.getErrorDescription());
        }

        return ReadyFutureImpl.create(exception);
    }
View Full Code Here

            return true;
        } else if (status == Status.INCOMPLETE) {
            return false;
        }

        throw new TransformationException(result.getErrorCode() + ": " +
                result.getErrorDescription());
    }
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.TransformationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.