Examples of IoBuffer


Examples of org.apache.mina.core.buffer.IoBuffer

   */
  @Test
  public void testFragmented() throws CharacterCodingException {
    final int maxLen = 100;

    IoBuffer savedBuf = IoBuffer.allocate(maxLen);

    String origMsg = "<1>- - blah blam foo\n";
    IoBuffer buf1 = IoBuffer.wrap(
        origMsg.substring(0, 11).getBytes(Charsets.UTF_8));
    IoBuffer buf2 = IoBuffer.wrap(
        origMsg.substring(11, 16).getBytes(Charsets.UTF_8));
    IoBuffer buf3 = IoBuffer.wrap(
        origMsg.substring(16, 21).getBytes(Charsets.UTF_8));

    LineSplitter lineSplitter = new LineSplitter(maxLen);
    ParsedBuffer parsedLine = new ParsedBuffer();

View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    String dangerousChars = "þÿÀÁ";

    ///////////////////////////////////////////////////////
    // encode and send them through the message handler
    String msg;
    IoBuffer buf;
    Event evt;

    // valid ISO-8859-1 on the right (ISO-8859-1) port
    msg = header + dangerousChars + "\n";
    buf = IoBuffer.wrap(msg.getBytes(Charsets.ISO_8859_1));
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    }

    @Override
    public void messageReceived(IoSession session, Object message) {

      IoBuffer buf = (IoBuffer) message;
      IoBuffer savedBuf = (IoBuffer) session.getAttribute(SAVED_BUF);

      ParsedBuffer parsedLine = new ParsedBuffer();
      List<Event> events = Lists.newArrayList();

      // the character set can be specified per-port
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

            throw new IllegalArgumentException("The message to encode is not a supported type: "
                                               + message.getClass().getCanonicalName());
        }

        // put the data into the byte buffer
        IoBuffer buf = IoBuffer.allocate(body.length + 3).setAutoExpand(true);
        buf.put((byte)config.getStartByte());
        buf.put(body);
        buf.put((byte)config.getEndByte1());
        buf.put((byte)config.getEndByte2());

        // flip the buffer so we can use it to write to the out stream
        buf.flip();
        LOG.debug("Encoded HL7 from {} to byte stream", message.getClass().getCanonicalName());
        out.write(buf);
    }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    {
        boolean isTcp = !session.getTransportMetadata().isConnectionless();
       
        ByteBuffer encodedByteBuf = ChangePasswordEncoder.encode( ( AbstractPasswordMessage ) message, isTcp );
       
        IoBuffer buf = IoBuffer.allocate( encodedByteBuf.remaining() );
        buf.put( encodedByteBuf.array() );
        buf.flip();
        out.write( buf );
    }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

        if ( hasSecurityLayer )
        {
            /*
             * Get the buffer as bytes.  First 4 bytes are length as int.
             */
            IoBuffer buf = ( IoBuffer ) message;
            int bufferLength = buf.getInt();
            byte[] bufferBytes = new byte[bufferLength];
            buf.get( bufferBytes );

            log.debug( "Will use SASL to unwrap received message of length:  {}", bufferLength );
            byte[] token = saslServer.unwrap( bufferBytes, 0, bufferBytes.length );
            nextFilter.messageReceived( session, IoBuffer.wrap( token ) );
        }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

         */
        String qop = ( String ) saslServer.getNegotiatedProperty( Sasl.QOP );
        boolean hasSecurityLayer = ( qop != null && ( qop.equals( SaslQoP.AUTH_INT.getValue() ) || qop
            .equals( SaslQoP.AUTH_CONF.getValue() ) ) );

        IoBuffer saslLayerBuffer = null;

        if ( hasSecurityLayer )
        {
            /*
             * Get the buffer as bytes.
             */
            IoBuffer buf = ( IoBuffer ) writeRequest.getMessage();
            int bufferLength = buf.remaining();
            byte[] bufferBytes = new byte[bufferLength];
            buf.get( bufferBytes );

            log.debug( "Will use SASL to wrap message of length:  {}", bufferLength );

            byte[] saslLayer = saslServer.wrap( bufferBytes, 0, bufferBytes.length );

View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    public long getId() {
        return session.getId();
    }

    public WriteFuture write(byte[] data, int offset, int len) {
        IoBuffer buffer = IoBuffer.wrap(data, offset, len);
        return session.write(buffer);
    }
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

        NioSocketAcceptor acceptor = new NioSocketAcceptor();
        acceptor.setHandler(new IoHandlerAdapter() {
            @Override
            public void messageReceived(IoSession session, Object message) throws Exception {
                IoBuffer recv = (IoBuffer) message;
                IoBuffer sent = IoBuffer.allocate(recv.remaining());
                sent.put(recv);
                sent.flip();
                session.write(sent);
            }
        });
        acceptor.setReuseAddress(true);
        acceptor.bind(new InetSocketAddress(echoPort));
View Full Code Here

Examples of org.apache.mina.core.buffer.IoBuffer

    {
        Asn1Object asn1Obj = ( Asn1Object ) message;
        boolean isTcp = !session.getTransportMetadata().isConnectionless();

        ByteBuffer encodedByteBuf = KerberosEncoder.encode( asn1Obj, isTcp );
        IoBuffer buf = IoBuffer.allocate( encodedByteBuf.remaining() );
        buf.put( encodedByteBuf.array() );
        buf.flip();
        out.write( buf );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.