Example usage for io.netty.channel ChannelHandlerContext fireChannelRead

List of usage examples for io.netty.channel ChannelHandlerContext fireChannelRead

Introduction

In this page you can find the example usage for io.netty.channel ChannelHandlerContext fireChannelRead.

Prototype

@Override
    ChannelHandlerContext fireChannelRead(Object msg);

Source Link

Usage

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnWrite(ChannelHandlerContext ctx, WriteRequest msg) throws XrootdException {
    ctx.fireChannelRead(msg);
    return null;//from   www. jav  a2s  . com
}

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnSync(ChannelHandlerContext ctx, SyncRequest msg) throws XrootdException {
    ctx.fireChannelRead(msg);
    return null;/*  w w  w .j  a  va2s  .c  o m*/
}

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnClose(ChannelHandlerContext ctx, CloseRequest msg) throws XrootdException {
    ctx.fireChannelRead(msg);
    return null;/*from ww w . j av  a2 s.  c o m*/
}

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnProtocolRequest(ChannelHandlerContext ctx, ProtocolRequest msg) throws XrootdException {
    ctx.fireChannelRead(msg);
    return null;//w w  w .jav a2  s .  c  o  m
}

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnQuery(ChannelHandlerContext ctx, QueryRequest req) throws XrootdException {
    switch (req.getReqcode()) {
    case kXR_Qcksum:
    case kXR_Qxattr:
        String args = req.getArgs();
        int pos = args.indexOf(OPAQUE_DELIMITER);
        String path;//from  www. j  a  v  a 2s  .c om
        String opaque;
        if (pos > -1) {
            path = args.substring(0, pos);
            opaque = args.substring(pos + 1);
        } else {
            path = args;
            opaque = "";
        }
        req.setArgs(authorize(ctx, req, FilePerm.READ, path, opaque));
        break;
    }
    ctx.fireChannelRead(req);
    return null;
}

From source file:org.dcache.xrootd.core.XrootdAuthorizationHandler.java

License:Open Source License

@Override
protected Void doOnSet(ChannelHandlerContext ctx, SetRequest request) throws XrootdException {
    ctx.fireChannelRead(request);
    return null;/*w w w .  j av  a2  s . c  o m*/
}

From source file:org.dcache.xrootd.core.XrootdRequestHandler.java

License:Open Source License

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg instanceof XrootdRequest) {
        requestReceived(ctx, (XrootdRequest) msg);
    } else if (msg instanceof HAProxyMessage) {
        HAProxyMessage proxyMessage = (HAProxyMessage) msg;
        switch (proxyMessage.command()) {
        case LOCAL:
            _isHealthCheck = true;// w  ww.j a  va 2 s .c om
            break;
        case PROXY:
            String sourceAddress = proxyMessage.sourceAddress();
            String destinationAddress = proxyMessage.destinationAddress();
            InetSocketAddress localAddress = (InetSocketAddress) ctx.channel().localAddress();
            if (proxyMessage.proxiedProtocol() == HAProxyProxiedProtocol.TCP4
                    || proxyMessage.proxiedProtocol() == HAProxyProxiedProtocol.TCP6) {
                if (Objects.equals(destinationAddress, localAddress.getAddress().getHostAddress())) {
                    /* Workaround for what looks like a bug in HAProxy - health checks should
                     * generate a LOCAL command, but it appears they do actually use PROXY.
                     */
                    _isHealthCheck = true;
                } else {
                    _destinationAddress = new InetSocketAddress(InetAddresses.forString(destinationAddress),
                            proxyMessage.destinationPort());
                    _sourceAddress = new InetSocketAddress(InetAddresses.forString(sourceAddress),
                            proxyMessage.sourcePort());
                }
            }
            break;
        }
        ctx.fireChannelRead(msg);
    } else {
        ctx.fireChannelRead(msg);
    }
}

From source file:org.dcache.xrootd.plugins.authn.gsi.GSIClientAuthenticationHandler.java

License:Open Source License

protected void doOnAuthenticationResponse(ChannelHandlerContext ctx, InboundAuthenticationResponse response)
        throws XrootdException {
    /*//  www. j  a va  2 s  . c  o m
     *  handler will have been constructed on first
     *  sendAuthenticationRequest call
     */
    if (requestHandler.isRequestExpired()) {
        throw new XrootdException(kXR_InvalidRequest, "Authentication request response time expired.");
    }

    serverStep = response.getServerStep();
    ChannelId id = ctx.channel().id();
    int status = response.getStatus();
    int streamId = client.getStreamId();
    XrootdTpcInfo tpcInfo = client.getInfo();
    switch (status) {
    case kXR_ok:
        LOGGER.trace("Authentication to {}, channel {}, stream {}, " + "sessionId {} succeeded; "
                + "passing to next handler.", tpcInfo.getSrc(), id, streamId, client.getSessionId());
        ctx.fireChannelRead(response);
        break;
    case kXR_authmore:
        LOGGER.trace(
                "Authentication to {}, channel {}, stream {}, " + "sessionId {}, " + "proceeding to next step.",
                tpcInfo.getSrc(), id, streamId, client.getSessionId());
        client.setAuthResponse(response);
        sendAuthenticationRequest(ctx);
        break;
    default:
        throw new XrootdException(kXR_ServerError,
                "wrong status from GSI authentication " + "response: " + status);
    }
}

From source file:org.dcache.xrootd.plugins.authn.unix.UnixClientAuthenticationHandler.java

License:Open Source License

@Override
protected void doOnAuthenticationResponse(ChannelHandlerContext ctx, InboundAuthenticationResponse response)
        throws XrootdException {
    ChannelId id = ctx.channel().id();/* w  ww.  j  a  v a2  s  . com*/
    int status = response.getStatus();
    int streamId = client.getStreamId();
    XrootdTpcInfo tpcInfo = client.getInfo();
    switch (status) {
    case kXR_ok:
        LOGGER.trace("Authentication to {}, channel {}, stream {}, " + "sessionId {} succeeded; "
                + "passing to next handler.", tpcInfo.getSrc(), id, streamId, client.getSessionId());
        ctx.fireChannelRead(response);
        break;
    default:
        throw new XrootdException(kXR_error, "failed with status " + status);
    }
}

From source file:org.dcache.xrootd.tpc.AbstractClientRequestHandler.java

License:Open Source License

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
    if (msg instanceof XrootdInboundResponse) {
        responseReceived(ctx, (XrootdInboundResponse) msg);
        return;/* w ww .  ja va 2s . co m*/
    }
    ctx.fireChannelRead(msg);
}