Search in sources :

Example 1 with NetLoggerBuilder

use of org.dcache.util.NetLoggerBuilder in project dcache by dCache.

the class AccessLogHandler method userEventTriggered.

@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
    if (evt instanceof LoginEvent) {
        LoginReply loginReply = ((LoginEvent) evt).getLoginReply();
        Subject subject = loginReply.getSubject();
        NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.login").omitNullValues();
        log.add("session", CDC.getSession());
        log.add("user.dn", Subjects.getDn(subject));
        log.add("user.sub", Subjects.getPrincipalNames(subject, OidcSubjectPrincipal.class));
        log.add("user.jti", Subjects.getPrincipalNames(subject, JwtJtiPrincipal.class));
        log.add("user.mapped", subject);
        log.toLogger(logger);
    }
    ctx.fireUserEventTriggered(evt);
}
Also used : OidcSubjectPrincipal(org.dcache.auth.OidcSubjectPrincipal) LoginEvent(org.dcache.xrootd.door.LoginEvent) LoginReply(org.dcache.auth.LoginReply) JwtJtiPrincipal(org.dcache.auth.JwtJtiPrincipal) Subject(javax.security.auth.Subject) NetLoggerBuilder(org.dcache.util.NetLoggerBuilder)

Example 2 with NetLoggerBuilder

use of org.dcache.util.NetLoggerBuilder in project dcache by dCache.

the class AccessLogHandler method channelInactive.

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.connection.end").omitNullValues();
    log.add("session", CDC.getSession());
    log.toLogger(logger);
    ctx.fireChannelInactive();
}
Also used : NetLoggerBuilder(org.dcache.util.NetLoggerBuilder)

Example 3 with NetLoggerBuilder

use of org.dcache.util.NetLoggerBuilder in project dcache by dCache.

the class ProxyAccessLogHandler method channelRead.

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg instanceof HAProxyMessage) {
        HAProxyMessage proxyMessage = (HAProxyMessage) msg;
        if (proxyMessage.command() == HAProxyCommand.PROXY) {
            InetSocketAddress remoteAddress = (InetSocketAddress) ctx.channel().remoteAddress();
            InetSocketAddress localAddress = (InetSocketAddress) ctx.channel().localAddress();
            String sourceAddress = proxyMessage.sourceAddress();
            String destinationAddress = proxyMessage.destinationAddress();
            if (proxyMessage.proxiedProtocol() == HAProxyProxiedProtocol.UNKNOWN) {
                NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.connection.start").omitNullValues();
                log.add("session", CDC.getSession());
                log.add("socket.remote", remoteAddress);
                log.add("socket.local", localAddress);
                log.toLogger(logger);
                replaceWith(ctx, handler);
            } else if (!Objects.equals(destinationAddress, localAddress.getAddress().getHostAddress())) {
                /* The above check is a workaround for what looks like a bug in HAProxy - health checks
                     * should generate a LOCAL command, but it appears they do actually use PROXY.
                     */
                NetLoggerBuilder log = new NetLoggerBuilder(INFO, "org.dcache.xrootd.connection.start").omitNullValues();
                log.add("session", CDC.getSession());
                log.add("socket.remote", HostAndPort.fromParts(sourceAddress, proxyMessage.sourcePort()));
                log.add("socket.proxy", HostAndPort.fromParts(destinationAddress, proxyMessage.destinationPort()));
                log.add("socket.local", localAddress);
                log.toLogger(logger);
                replaceWith(ctx, handler);
            }
        }
    }
    super.channelRead(ctx, msg);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) HAProxyMessage(io.netty.handler.codec.haproxy.HAProxyMessage) NetLoggerBuilder(org.dcache.util.NetLoggerBuilder)

Example 4 with NetLoggerBuilder

use of org.dcache.util.NetLoggerBuilder in project dcache by dCache.

the class HttpdRequestLog method log.

public void log(Request request, Response response) {
    NetLoggerBuilder log = new NetLoggerBuilder(logLevel(response), "org.dcache.httpd.request");
    log.add("request.method", request.getMethod());
    log.add("request.scheme", request.getScheme());
    log.add("request.url", request.getRequestURL());
    log.add("request.hostname", request.getLocalName());
    log.add("request.remoteIP", request.getRemoteAddr());
    log.add("response.code", response.getStatus());
    log.toLogger(ACCESS_LOGGER);
}
Also used : NetLoggerBuilder(org.dcache.util.NetLoggerBuilder)

Example 5 with NetLoggerBuilder

use of org.dcache.util.NetLoggerBuilder in project dcache by dCache.

the class EventLogger method sendEnd.

public static void sendEnd(CellMessage envelope) {
    if (send.isInfoEnabled() && !envelope.isStreamMode()) {
        NetLoggerBuilder log = new NetLoggerBuilder(SEND_END);
        log.add("uoid", envelope.getUOID());
        log.add("session", envelope.getSession());
        send.info(log.toString());
    }
}
Also used : NetLoggerBuilder(org.dcache.util.NetLoggerBuilder)

Aggregations

NetLoggerBuilder (org.dcache.util.NetLoggerBuilder)35 Stopwatch (com.google.common.base.Stopwatch)1 CharStreams (com.google.common.io.CharStreams)1 CellPath (dmg.cells.nucleus.CellPath)1 AuthorizedString (dmg.util.AuthorizedString)1 CertificateUtils (eu.emi.security.authn.x509.impl.CertificateUtils)1 PEM (eu.emi.security.authn.x509.impl.CertificateUtils.Encoding.PEM)1 OpensslNameUtils (eu.emi.security.authn.x509.impl.OpensslNameUtils)1 HAProxyMessage (io.netty.handler.codec.haproxy.HAProxyMessage)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 InetSocketAddress (java.net.InetSocketAddress)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 RemoteException (java.rmi.RemoteException)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1