Examples of RexProRequest


Examples of com.tinkerpop.rexster.protocol.server.RexProRequest

    /**
     * RexPro authentication
     */
    public NextAction handleRead(final FilterChainContext ctx) throws IOException {
        final RexProRequest request = ctx.getMessage();
        request.process();

        final RexProMessage message = request.getRequestMessage();
        if (message instanceof SessionRequestMessage && !message.hasSession()) {
            final SessionRequestMessage specificMessage = (SessionRequestMessage) message;

            if (!specificMessage.metaGetKillSession()) {
                final String username = specificMessage.Username;
                final String password = specificMessage.Password;
                if (!authenticate(username, password)) {
                    // there is no session to this message...that's a problem
                    final ErrorResponseMessage errorMessage = new ErrorResponseMessage();
                    errorMessage.setSessionAsUUID(RexProMessage.EMPTY_SESSION);
                    errorMessage.Request = specificMessage.Request;
                    errorMessage.ErrorMessage = "Invalid username or password.";
                    errorMessage.metaSetFlag(ErrorResponseMessage.AUTH_FAILURE_ERROR);

                    request.writeResponseMessage(errorMessage);
                    ctx.write(request);

                    return ctx.getStopAction();
                }
            }
        } else if (message instanceof ScriptRequestMessage && !message.hasSession()) {
      // sessionless script requests don't support secure requests atm - requires a changes to the
      // rexpro protocol to do so
      // there is no session to this message...that's a problem
      final ErrorResponseMessage errorMessage = new ErrorResponseMessage();
      errorMessage.setSessionAsUUID(RexProMessage.EMPTY_SESSION);
      errorMessage.Request = message.Request;
      errorMessage.ErrorMessage = "Cannot make sessionless requests with <security> turned on.";
      errorMessage.metaSetFlag(ErrorResponseMessage.AUTH_FAILURE_ERROR);

      request.writeResponseMessage(errorMessage);
      ctx.write(request);

      return ctx.getStopAction();
    }

View Full Code Here

Examples of com.tinkerpop.rexster.protocol.server.RexProRequest

/**
* @author Blake Eggleston (bdeggleston.github.com)
*/
public class RexProProcessorFilter extends BaseFilter {
    public NextAction handleRead(final FilterChainContext ctx) throws IOException {
        final RexProRequest request = ctx.getMessage();
        request.process();
        ctx.write(request);
        return ctx.getStopAction();
    }
View Full Code Here

Examples of com.tinkerpop.rexster.protocol.server.RexProRequest

            // stop the filterchain processing and store sourceBuffer to be
            // used next time
            return ctx.getStopAction(sourceBuffer);
        }

        RexProRequest request = null;
        final byte messageVersion = sourceBuffer.get(0);
        try {
            switch (messageVersion) {
                case 1:
                    request = new RexProRequest(sourceBuffer.toByteBuffer(), sourceBufferLength, rexsterApplication);
                    break;
                default:
                    //unexpected rexpro version
                    logger.warn("unsupported rexpro version: " + messageVersion);
                    return ctx.getStopAction();
            }
        } catch (IncompleteRexProRequestException ex) {
            // If the source message doesn't contain entire body
            // stop the filterchain processing and store sourceBuffer to be
            // used next time
            logger.debug(ex);
            return ctx.getStopAction(sourceBuffer);
        }

        // Check if the source buffer has more than 1 complete message
        // If yes - split up the first message and the remainder
        final Buffer remainder = sourceBufferLength > request.getCompleteRequestMessageLength() ?
                sourceBuffer.split(request.getCompleteRequestMessageLength()) : null;

        if (logger.isDebugEnabled()) {
            final StringBuilder sb = new StringBuilder();
            for (byte b : request.getRequestMessageBytes()) {
                sb.append(StringUtils.rightPad(Byte.toString(b), 4));
                sb.append(" ");
            }

            logger.debug(String.format("Received message [version:%s][message type:%s][body length:%s][body:%s]",
                    messageVersion, request.getRequestMessageType(), request.getRequestBodyLength(), sb.toString().trim()));
        }

        ctx.setMessage(request);
        sourceBuffer.tryDispose();
        return ctx.getInvokeAction(remainder);
View Full Code Here

Examples of com.tinkerpop.rexster.protocol.server.RexProRequest

        sourceBuffer.tryDispose();
        return ctx.getInvokeAction(remainder);
    }

    public NextAction handleWrite(final FilterChainContext ctx) throws IOException {
        RexProRequest request = ctx.getMessage();

        // Retrieve the memory manager
        final MemoryManager memoryManager =
                ctx.getConnection().getTransport().getMemoryManager();

        // Write the response to the buffer
        final Buffer bb = memoryManager.allocate(request.getResponseSize());
        request.writeToBuffer(bb);

        // Allow Grizzly core to dispose the buffer, once it's written
        bb.allowBufferDispose(true);

        // Set the Buffer as a context message
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.