text:
// Package server implements a configurable, general-purpose web server.
// It relies on configurations obtained from the adjacent config package
// and can execute middleware as defined by the adjacent middleware package.
package server

import (
	"crypto/tls"
	"crypto/x509"
	"fmt"
	"io/ioutil"
	"log"
	"net"
	"os"
	"runtime"
	"sync"
	"time"

	"github.com/miekg/coredns/middleware"
	"github.com/miekg/coredns/middleware/metrics"

	"github.com/miekg/dns"
	"golang.org/x/net/context"
)

// Server represents an instance of a server, which serves
// DNS requests at a particular address (host and port). A
// server is capable of serving numerous zones on
// the same address and the listener may be stopped for
// graceful termination (POSIX only).
type Server struct {
	Addr   string // Address we listen on
	mux    *dns.ServeMux
	server [2]*dns.Server // by convention 0 is tcp and 1 is udp

	tcp        net.Listener
	udp        net.PacketConn
	listenerMu sync.Mutex // protects listener and packetconn

	tls         bool // whether this server is serving all HTTPS hosts or not
	TLSConfig   *tls.Config
	OnDemandTLS bool             // whether this server supports on-demand TLS (load certs at handshake-time)
	zones       map[string]zone  // zones keyed by their address
	dnsWg       sync.WaitGroup   // used to wait on outstanding connections
	startChan   chan struct{}    // used to block until server is finished starting
	connTimeout time.Duration    // the maximum duration of a graceful shutdown
	ReqCallback OptionalCallback // if non-nil, is executed at the beginning of every request
	SNICallback func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
}

// OptionalCallback is a function that may or may not handle a request.
// It returns whether or not it handled the request. If it handled the
// request, it is presumed that no further request handling should occur.
type OptionalCallback func(dns.ResponseWriter, *dns.Msg) bool

// New creates a new Server which will bind to addr and serve
// the sites/hosts configured in configs. Its listener will
// gracefully close when the server is stopped which will take
// no longer than gracefulTimeout.
//
// This function does not start serving.
//
// Do not re-use a server (start, stop, then start again). We
// could probably add more locking to make this possible, but
// as it stands, you should dispose of a server after stopping it.
// The behavior of serving with a spent server is undefined.
func New(addr string, configs []Config, gracefulTimeout time.Duration) (*Server, error) {
	var useTLS, useOnDemandTLS bool
	if len(configs) > 0 {
		useTLS = configs[0].TLS.Enabled
		useOnDemandTLS = configs[0].TLS.OnDemand
	}

	s := &Server{
		Addr:      addr,
		TLSConfig: new(tls.Config),
		// TODO: Make these values configurable?
		// ReadTimeout:    2 * time.Minute,
		// WriteTimeout:   2 * time.Minute,
		// MaxHeaderBytes: 1 << 16,
		tls:         useTLS,
		OnDemandTLS: useOnDemandTLS,
		zones:       make(map[string]zone),
		startChan:   make(chan struct{}),
		connTimeout: gracefulTimeout,
	}
	mux := dns.NewServeMux()
	mux.Handle(".", s) // wildcard handler, everything will go through here
	s.mux = mux

	// We have to bound our wg with one increment
	// to prevent a "race condition" that is hard-coded
	// into sync.WaitGroup.Wait() - basically, an add
	// with a positive delta must be guaranteed to
	// occur before Wait() is called on the wg.
	// In a way, this kind of acts as a safety barrier.
	s.dnsWg.Add(1)

	// Set up each zone
	for _, conf := range configs {
		if _, exists := s.zones[conf.Host]; exists {
			return nil, fmt.Errorf("cannot serve %s - host already defined for address %s", conf.Address(), s.Addr)
		}

		z := zone{config: conf}

		// Build middleware stack
		err := z.buildStack()
		if err != nil {
			return nil, err
		}

		s.zones[conf.Host] = z
	}

	return s, nil
}

// LocalAddr return the addresses where the server is bound to. The TCP listener
// address is the first returned, the UDP conn address the second.
func (s *Server) LocalAddr() (net.Addr, net.Addr) {
	s.listenerMu.Lock()
	tcp := s.tcp.Addr()
	udp := s.udp.LocalAddr()
	s.listenerMu.Unlock()
	return tcp, udp
}

// Serve starts the server with an existing listener. It blocks until the server stops.
func (s *Server) Serve(ln net.Listener, pc net.PacketConn) error {
	err := s.setup()
	if err != nil {
		close(s.startChan) // MUST defer so error is properly reported, same with all cases in this file
		return err
	}
	s.listenerMu.Lock()
	s.server[0] = &dns.Server{Listener: ln, Net: "tcp", Handler: s.mux}
	s.tcp = ln
	s.server[1] = &dns.Server{PacketConn: pc, Net: "udp", Handler: s.mux}
	s.udp = pc
	s.listenerMu.Unlock()

	go func() {
		s.server[0].ActivateAndServe()
	}()
	close(s.startChan)
	return s.server[1].ActivateAndServe()
}

// ListenAndServe starts the server with a new listener. It blocks until the server stops.
func (s *Server) ListenAndServe() error {
	err := s.setup()
	// defer close(s.startChan) // Don't understand why defer wouldn't actually work in this method (prolly cause the last ActivateAndServe does not actually return?
	if err != nil {
		close(s.startChan)
		return err
	}

	l, err := net.Listen("tcp", s.Addr)
	if err != nil {
		close(s.startChan)
		return err
	}
	pc, err := net.ListenPacket("udp", s.Addr)
	if err != nil {
		close(s.startChan)
		return err
	}

	s.listenerMu.Lock()
	s.server[0] = &dns.Server{Listener: l, Net: "tcp", Handler: s.mux}
	s.tcp = l
	s.server[1] = &dns.Server{PacketConn: pc, Net: "udp", Handler: s.mux}
	s.udp = pc
	s.listenerMu.Unlock()

	go func() {
		s.server[0].ActivateAndServe()
	}()
	close(s.startChan)
	return s.server[1].ActivateAndServe()
}

// setup prepares the server s to begin listening; it should be
// called just before the listener announces itself on the network
// and should only be called when the server is just starting up.
func (s *Server) setup() error {
	// Execute startup functions now
	for _, z := range s.zones {
		for _, startupFunc := range z.config.Startup {
			err := startupFunc()
			if err != nil {
				return err
			}
		}
	}

	return nil
}

/*
TODO(miek): no such thing in the glorious Go DNS.
// serveTLS serves TLS with SNI and client auth support if s has them enabled. It
// blocks until s quits.
func serveTLS(s *Server, ln net.Listener, tlsConfigs []TLSConfig) error {
	// Customize our TLS configuration
	s.TLSConfig.MinVersion = tlsConfigs[0].ProtocolMinVersion
	s.TLSConfig.MaxVersion = tlsConfigs[0].ProtocolMaxVersion
	s.TLSConfig.CipherSuites = tlsConfigs[0].Ciphers
	s.TLSConfig.PreferServerCipherSuites = tlsConfigs[0].PreferServerCipherSuites

	// TLS client authentication, if user enabled it
	err := setupClientAuth(tlsConfigs, s.TLSConfig)
	if err != nil {
		defer close(s.startChan)
		return err
	}

	// Create TLS listener - note that we do not replace s.listener
	// with this TLS listener; tls.listener is unexported and does
	// not implement the File() method we need for graceful restarts
	// on POSIX systems.
	ln = tls.NewListener(ln, s.TLSConfig)

	close(s.startChan) // unblock anyone waiting for this to start listening
	return s.Serve(ln)
}
*/

// Stop stops the server. It blocks until the server is
// totally stopped. On POSIX systems, it will wait for
// connections to close (up to a max timeout of a few
// seconds); on Windows it will close the listener
// immediately.
func (s *Server) Stop() (err error) {

	if runtime.GOOS != "windows" {
		// force connections to close after timeout
		done := make(chan struct{})
		go func() {
			s.dnsWg.Done() // decrement our initial increment used as a barrier
			s.dnsWg.Wait()
			close(done)
		}()

		// Wait for remaining connections to finish or
		// force them all to close after timeout
		select {
		case <-time.After(s.connTimeout):
		case <-done:
		}
	}

	// Close the listener now; this stops the server without delay
	s.listenerMu.Lock()
	if s.tcp != nil {
		err = s.tcp.Close()
	}
	if s.udp != nil {
		err = s.udp.Close()
	}

	for _, s1 := range s.server {
		err = s1.Shutdown()
	}
	s.listenerMu.Unlock()

	return
}

// WaitUntilStarted blocks until the server s is started, meaning
// that practically the next instruction is to start the server loop.
// It also unblocks if the server encounters an error during startup.
func (s *Server) WaitUntilStarted() {
	<-s.startChan
}

// ListenerFd gets a dup'ed file of the listener. If there
// is no underlying file, the return value will be nil. It
// is the caller's responsibility to close the file.
func (s *Server) ListenerFd() *os.File {
	s.listenerMu.Lock()
	defer s.listenerMu.Unlock()
	if s.tcp != nil {
		file, _ := s.tcp.(*net.TCPListener).File()
		return file
	}
	return nil
}

// PacketConnFd gets a dup'ed file of the packetconn. If there
// is no underlying file, the return value will be nil. It
// is the caller's responsibility to close the file.
func (s *Server) PacketConnFd() *os.File {
	s.listenerMu.Lock()
	defer s.listenerMu.Unlock()
	if s.udp != nil {
		file, _ := s.udp.(*net.UDPConn).File()
		return file
	}
	return nil
}

// ServeDNS is the entry point for every request to the address that s
// is bound to. It acts as a multiplexer for the requests zonename as
// defined in the request so that the correct zone
// (configuration and middleware stack) will handle the request.
func (s *Server) ServeDNS(w dns.ResponseWriter, r *dns.Msg) {
	defer func() {
		// In case the user doesn't enable error middleware, we still
		// need to make sure that we stay alive up here
		if rec := recover(); rec != nil {
			DefaultErrorFunc(w, r, dns.RcodeServerFailure)
		}
	}()

	if m, err := middleware.Edns0Version(r); err != nil { // Wrong EDNS version, return at once.
		rc := middleware.RcodeToString(dns.RcodeBadVers)
		state := middleware.State{W: w, Req: r}

		metrics.Report(state, metrics.Dropped, rc, m.Len(), time.Now())
		w.WriteMsg(m)
		return
	}

	// Execute the optional request callback if it exists
	if s.ReqCallback != nil && s.ReqCallback(w, r) {
		return
	}

	q := r.Question[0].Name
	b := make([]byte, len(q))
	off, end := 0, false
	ctx := context.Background()

	for {
		l := len(q[off:])
		for i := 0; i < l; i++ {
			b[i] = q[off+i]
			// normalize the name for the lookup
			if b[i] >= 'A' && b[i] <= 'Z' {
				b[i] |= ('a' - 'A')
			}
		}

		if h, ok := s.zones[string(b[:l])]; ok {
			if r.Question[0].Qtype != dns.TypeDS {
				rcode, _ := h.stack.ServeDNS(ctx, w, r)
				if RcodeNoClientWrite(rcode) {
					DefaultErrorFunc(w, r, rcode)
				}
				return
			}
		}
		off, end = dns.NextLabel(q, off)
		if end {
			break
		}
	}
	// Wildcard match, if we have found nothing try the root zone as a last resort.
	if h, ok := s.zones["."]; ok {
		rcode, _ := h.stack.ServeDNS(ctx, w, r)
		if RcodeNoClientWrite(rcode) {
			DefaultErrorFunc(w, r, rcode)
		}
		return
	}

	// Still here? Error out with REFUSED and some logging
	remoteHost := w.RemoteAddr().String()
	DefaultErrorFunc(w, r, dns.RcodeRefused)
	log.Printf("[INFO] \"%s %s %s\" - No such zone at %s (Remote: %s)", dns.Type(r.Question[0].Qtype), dns.Class(r.Question[0].Qclass), q, s.Addr, remoteHost)
}

// DefaultErrorFunc responds to an DNS request with an error.
func DefaultErrorFunc(w dns.ResponseWriter, r *dns.Msg, rcode int) {
	state := middleware.State{W: w, Req: r}
	rc := middleware.RcodeToString(rcode)

	answer := new(dns.Msg)
	answer.SetRcode(r, rcode)
	state.SizeAndDo(answer)

	metrics.Report(state, metrics.Dropped, rc, answer.Len(), time.Now())
	w.WriteMsg(answer)
}

// setupClientAuth sets up TLS client authentication only if
// any of the TLS configs specified at least one cert file.
func setupClientAuth(tlsConfigs []TLSConfig, config *tls.Config) error {
	var clientAuth bool
	for _, cfg := range tlsConfigs {
		if len(cfg.ClientCerts) > 0 {
			clientAuth = true
			break
		}
	}

	if clientAuth {
		pool := x509.NewCertPool()
		for _, cfg := range tlsConfigs {
			for _, caFile := range cfg.ClientCerts {
				caCrt, err := ioutil.ReadFile(caFile) // Anyone that gets a cert from this CA can connect
				if err != nil {
					return err
				}
				if !pool.AppendCertsFromPEM(caCrt) {
					return fmt.Errorf("error loading client certificate '%s': no certificates were successfully parsed", caFile)
				}
			}
		}
		config.ClientCAs = pool
		config.ClientAuth = tls.RequireAndVerifyClientCert
	}

	return nil
}

// RunFirstStartupFuncs runs all of the server's FirstStartup
// callback functions unless one of them returns an error first.
// It is the caller's responsibility to call this only once and
// at the correct time. The functions here should not be executed
// at restarts or where the user does not explicitly start a new
// instance of the server.
func (s *Server) RunFirstStartupFuncs() error {
	for _, z := range s.zones {
		for _, f := range z.config.FirstStartup {
			if err := f(); err != nil {
				return err
			}
		}
	}
	return nil
}

// ShutdownCallbacks executes all the shutdown callbacks
// for all the virtualhosts in servers, and returns all the
// errors generated during their execution. In other words,
// an error executing one shutdown callback does not stop
// execution of others. Only one shutdown callback is executed
// at a time. You must protect the servers that are passed in
// if they are shared across threads.
func ShutdownCallbacks(servers []*Server) []error {
	var errs []error
	for _, s := range servers {
		for _, zone := range s.zones {
			for _, shutdownFunc := range zone.config.Shutdown {
				err := shutdownFunc()
				if err != nil {
					errs = append(errs, err)
				}
			}
		}
	}
	return errs
}

func StartupCallbacks(servers []*Server) []error {
	var errs []error
	for _, s := range servers {
		for _, zone := range s.zones {
			for _, startupFunc := range zone.config.Startup {
				err := startupFunc()
				if err != nil {
					errs = append(errs, err)
				}
			}
		}
	}
	return errs
}

func RcodeNoClientWrite(rcode int) bool {
	switch rcode {
	case dns.RcodeServerFailure:
		fallthrough
	case dns.RcodeRefused:
		fallthrough
	case dns.RcodeFormatError:
		fallthrough
	case dns.RcodeNotImplemented:
		return true
	}
	return false
}


text:
/* tslint:disable:no-string-literal */
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var dom_1 = require("./dom");
var IS_FOCUSABLE_ATTRIBUTE = 'data-is-focusable';
var IS_VISIBLE_ATTRIBUTE = 'data-is-visible';
var FOCUSZONE_ID_ATTRIBUTE = 'data-focuszone-id';
function getFirstFocusable(rootElement, currentElement, includeElementsInFocusZones) {
    return getNextElement(rootElement, currentElement, true, false, false, includeElementsInFocusZones);
}
exports.getFirstFocusable = getFirstFocusable;
function getLastFocusable(rootElement, currentElement, includeElementsInFocusZones) {
    return getPreviousElement(rootElement, currentElement, true, false, true, includeElementsInFocusZones);
}
exports.getLastFocusable = getLastFocusable;
/**
 * Attempts to focus the first focusable element that is a child or child's child of the rootElement.
 * @return True if focus was set, false if it was not.
 * @param {HTMLElement} rootElement - element to start the search for a focusable child.
 */
function focusFirstChild(rootElement) {
    var element = getNextElement(rootElement, rootElement, true, false, false, true);
    if (element) {
        element.focus();
        return true;
    }
    return false;
}
exports.focusFirstChild = focusFirstChild;
/** Traverse to find the previous element. */
function getPreviousElement(rootElement, currentElement, checkNode, suppressParentTraversal, traverseChildren, includeElementsInFocusZones) {
    if (!currentElement ||
        currentElement === rootElement) {
        return null;
    }
    var isCurrentElementVisible = isElementVisible(currentElement);
    // Check its children.
    if (traverseChildren && (includeElementsInFocusZones || !isElementFocusZone(currentElement)) && isCurrentElementVisible) {
        var childMatch = getPreviousElement(rootElement, currentElement.lastElementChild, true, true, true, includeElementsInFocusZones);
        if (childMatch) {
            return childMatch;
        }
    }
    // Check the current node, if it's not the first traversal.
    if (checkNode && isCurrentElementVisible && isElementTabbable(currentElement)) {
        return currentElement;
    }
    // Check its previous sibling.
    var siblingMatch = getPreviousElement(rootElement, currentElement.previousElementSibling, true, true, true, includeElementsInFocusZones);
    if (siblingMatch) {
        return siblingMatch;
    }
    // Check its parent.
    if (!suppressParentTraversal) {
        return getPreviousElement(rootElement, currentElement.parentElement, true, false, false, includeElementsInFocusZones);
    }
    return null;
}
exports.getPreviousElement = getPreviousElement;
/** Traverse to find the next focusable element. */
function getNextElement(rootElement, currentElement, checkNode, suppressParentTraversal, suppressChildTraversal, includeElementsInFocusZones) {
    if (!currentElement ||
        (currentElement === rootElement && suppressChildTraversal)) {
        return null;
    }
    var isCurrentElementVisible = isElementVisible(currentElement);
    // Check the current node, if it's not the first traversal.
    if (checkNode && isCurrentElementVisible && isElementTabbable(currentElement)) {
        return currentElement;
    }
    // Check its children.
    if (!suppressChildTraversal && isCurrentElementVisible && (includeElementsInFocusZones || !isElementFocusZone(currentElement))) {
        var childMatch = getNextElement(rootElement, currentElement.firstElementChild, true, true, false, includeElementsInFocusZones);
        if (childMatch) {
            return childMatch;
        }
    }
    if (currentElement === rootElement) {
        return null;
    }
    // Check its sibling.
    var siblingMatch = getNextElement(rootElement, currentElement.nextElementSibling, true, true, false, includeElementsInFocusZones);
    if (siblingMatch) {
        return siblingMatch;
    }
    if (!suppressParentTraversal) {
        return getNextElement(rootElement, currentElement.parentElement, false, false, true, includeElementsInFocusZones);
    }
    return null;
}
exports.getNextElement = getNextElement;
function isElementVisible(element) {
    // If the element is not valid, return false.
    if (!element || !element.getAttribute) {
        return false;
    }
    var visibilityAttribute = element.getAttribute(IS_VISIBLE_ATTRIBUTE);
    // If the element is explicitly marked with the visibility attribute, return that value as boolean.
    if (visibilityAttribute !== null && visibilityAttribute !== undefined) {
        return visibilityAttribute === 'true';
    }
    // Fallback to other methods of determining actual visibility.
    return (element.offsetHeight !== 0 ||
        element.offsetParent !== null ||
        element.isVisible === true); // used as a workaround for testing.
}
exports.isElementVisible = isElementVisible;
function isElementTabbable(element) {
    // If this element is null or is disabled, it is not considered tabbable.
    if (!element || element.disabled) {
        return false;
    }
    // In IE, element.tabIndex is default to 0. We need to use element get tabIndex attribute to get the correct tabIndex
    var tabIndex = -1;
    if (element && element.getAttribute) {
        tabIndex = parseInt(element.getAttribute('tabIndex'), 10);
    }
    var isFocusableAttribute = element.getAttribute ? element.getAttribute(IS_FOCUSABLE_ATTRIBUTE) : null;
    return (!!element && isFocusableAttribute !== 'false' &&
        (element.tagName === 'A' ||
            (element.tagName === 'BUTTON') ||
            (element.tagName === 'INPUT') ||
            (element.tagName === 'TEXTAREA') ||
            (tabIndex >= 0) ||
            (element.getAttribute && (isFocusableAttribute === 'true' ||
                element.getAttribute('role') === 'button'))));
}
exports.isElementTabbable = isElementTabbable;
function isElementFocusZone(element) {
    return element && !!element.getAttribute(FOCUSZONE_ID_ATTRIBUTE);
}
exports.isElementFocusZone = isElementFocusZone;
function doesElementContainFocus(element) {
    var currentActiveElement = dom_1.getDocument(element).activeElement;
    if (currentActiveElement && dom_1.elementContains(element, currentActiveElement)) {
        return true;
    }
    return false;
}
exports.doesElementContainFocus = doesElementContainFocus;

//# sourceMappingURL=focus.js.map

redpajama_set_name: RedPajamaGithub


text:
package org.apache.tinkerpop.gremlin.driver;

import io.netty.channel.Channel;
import io.netty.handler.codec.http.EmptyHttpHeaders;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PingWebSocketFrame;
import org.apache.tinkerpop.gremlin.driver.exception.ConnectionException;
import org.apache.tinkerpop.gremlin.driver.handler.NioGremlinRequestEncoder;
import org.apache.tinkerpop.gremlin.driver.handler.NioGremlinResponseDecoder;
import org.apache.tinkerpop.gremlin.driver.handler.WebSocketClientHandler;
import org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinRequestEncoder;
import org.apache.tinkerpop.gremlin.driver.handler.WebSocketGremlinResponseDecoder;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.handler.ssl.SslContext;

import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeUnit;

/**
 * Client-side channel initializer interface.  It is responsible for constructing the Netty {@code ChannelPipeline}
 * used by the client to connect and send message to Gremlin Server.
 *
 * @author Stephen Mallette (http://stephen.genoprime.com)
 */
public interface Channelizer extends ChannelHandler {

    /**
     * Initializes the {@code Channelizer}. Called just after construction.
     */
    public void init(final Connection connection);

    /**
     * Called on {@link Connection#close()} to perform an {@code Channelizer} specific functions.  Note that the
     * {@link Connection} already calls {@code Channel.close()} so there is no need to call that method here.
     * An implementation will typically use this method to send a {@code Channelizer} specific message to the
     * server to notify of shutdown coming from the client side (e.g. a "close" websocket frame).
     */
    public void close(final Channel channel);

    /**
     * Create a message for the driver to use as a "keep-alive" for the connection. This method will only be used if
     * {@link #supportsKeepAlive()} is {@code true}.
     */
    public default Object createKeepAliveMessage() {
        return null;
    }

    /**
     * Determines if the channelizer supports a method for keeping the connection to the server alive.
     */
    public default boolean supportsKeepAlive() {
        return false;
    }

    /**
     * Called after the channel connects. The {@code Channelizer} may need to perform some functions, such as a
     * handshake.
     */
    public default void connected() {
    }

    /**
     * Base implementation of the client side {@link Channelizer}.
     */
    abstract class AbstractChannelizer extends ChannelInitializer<SocketChannel> implements Channelizer {
        protected Connection connection;
        protected Cluster cluster;
        private ConcurrentMap<UUID, ResultQueue> pending;

        protected static final String PIPELINE_GREMLIN_SASL_HANDLER = "gremlin-sasl-handler";
        protected static final String PIPELINE_GREMLIN_HANDLER = "gremlin-handler";

        public boolean supportsSsl() {
            return cluster.connectionPoolSettings().enableSsl;
        }

        public abstract void configure(final ChannelPipeline pipeline);

        public void finalize(final ChannelPipeline pipeline) {
            // do nothing
        }

        @Override
        public void close(final Channel channel) {
            // do nothing
        }

        @Override
        public void init(final Connection connection) {
            this.connection = connection;
            this.cluster = connection.getCluster();
            this.pending = connection.getPending();
        }

        @Override
        protected void initChannel(final SocketChannel socketChannel) throws Exception {
            final ChannelPipeline pipeline = socketChannel.pipeline();
            final Optional<SslContext> sslCtx;
            if (supportsSsl()) {
                try {
                    sslCtx = Optional.of(cluster.createSSLContext());
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            } else {
                sslCtx = Optional.empty();
            }

            if (sslCtx.isPresent()) {
                pipeline.addLast(sslCtx.get().newHandler(socketChannel.alloc(), connection.getUri().getHost(), connection.getUri().getPort()));
            }

            configure(pipeline);
            pipeline.addLast(PIPELINE_GREMLIN_SASL_HANDLER, new Handler.GremlinSaslAuthenticationHandler(cluster.authProperties()));
            pipeline.addLast(PIPELINE_GREMLIN_HANDLER, new Handler.GremlinResponseHandler(pending));
        }
    }

    /**
     * WebSocket {@link Channelizer} implementation.
     */
    public final class WebSocketChannelizer extends AbstractChannelizer {
        private WebSocketClientHandler handler;

        private WebSocketGremlinRequestEncoder webSocketGremlinRequestEncoder;
        private WebSocketGremlinResponseDecoder webSocketGremlinResponseDecoder;

        @Override
        public void init(final Connection connection) {
            super.init(connection);
            webSocketGremlinRequestEncoder = new WebSocketGremlinRequestEncoder(true, cluster.getSerializer());
            webSocketGremlinResponseDecoder = new WebSocketGremlinResponseDecoder(cluster.getSerializer());
        }

        /**
         * Keep-alive is supported through the ping/pong websocket protocol.
         *
         * @see IETF RFC 6455
         */
        @Override
        public boolean supportsKeepAlive() {
            return true;
        }

        @Override
        public Object createKeepAliveMessage() {
            return new PingWebSocketFrame();
        }

        /**
         * Sends a {@code CloseWebSocketFrame} to the server for the specified channel.
         */
        @Override
        public void close(final Channel channel) {
            if (channel.isOpen()) channel.writeAndFlush(new CloseWebSocketFrame());
        }

        @Override
        public boolean supportsSsl() {
            final String scheme = connection.getUri().getScheme();
            return "wss".equalsIgnoreCase(scheme);
        }

        @Override
        public void configure(final ChannelPipeline pipeline) {
            final String scheme = connection.getUri().getScheme();
            if (!"ws".equalsIgnoreCase(scheme) && !"wss".equalsIgnoreCase(scheme))
                throw new IllegalStateException("Unsupported scheme (only ws: or wss: supported): " + scheme);

            if (!supportsSsl() && "wss".equalsIgnoreCase(scheme))
                throw new IllegalStateException("To use wss scheme ensure that enableSsl is set to true in configuration");

            final int maxContentLength = cluster.connectionPoolSettings().maxContentLength;
            handler = new WebSocketClientHandler(
                    WebSocketClientHandshakerFactory.newHandshaker(
                            connection.getUri(), WebSocketVersion.V13, null, false, EmptyHttpHeaders.INSTANCE, maxContentLength));

            pipeline.addLast("http-codec", new HttpClientCodec());
            pipeline.addLast("aggregator", new HttpObjectAggregator(maxContentLength));
            pipeline.addLast("ws-handler", handler);
            pipeline.addLast("gremlin-encoder", webSocketGremlinRequestEncoder);
            pipeline.addLast("gremlin-decoder", webSocketGremlinResponseDecoder);
        }

        @Override
        public void connected() {
            try {
                // block for a few seconds - if the handshake takes longer than there's gotta be issues with that
                // server. more than likely, SSL is enabled on the server, but the client forgot to enable it or
                // perhaps the server is not configured for websockets.
                handler.handshakeFuture().get(15000, TimeUnit.MILLISECONDS);
            } catch (Exception ex) {
                throw new RuntimeException(new ConnectionException(connection.getUri(),
                        "Could not complete websocket handshake - ensure that client protocol matches server", ex));
            }
        }
    }

    /**
     * NIO {@link Channelizer} implementation.
     */
    public final class NioChannelizer extends AbstractChannelizer {
        @Override
        public void init(final Connection connection) {
            super.init(connection);
        }

        @Override
        public void configure(ChannelPipeline pipeline) {
            pipeline.addLast("gremlin-decoder", new NioGremlinResponseDecoder(cluster.getSerializer()));
            pipeline.addLast("gremlin-encoder", new NioGremlinRequestEncoder(true, cluster.getSerializer()));
        }
    }
}


text:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration name="asyncwait-global1" >
  <!--  packages="org.apache.logging.log4j.core.async" -->

  <AsyncWaitStrategyFactory
      class="org.apache.logging.log4j.core.async.AsyncWaitStrategyFactoryConfigTest$YieldingWaitStrategyFactory" />

  <Appenders>
    <List name="WaitStrategyAppenderList" />
  </Appenders>

  <Loggers>
    <Root level="info">
      <AppenderRef ref="WaitStrategyAppenderList"/>
    </Root>
  </Loggers>
</Configuration>


text:
public class DataTerceiraEra{
    private int dia, mes, ano;

    DataTerceiraEra(int dia, int mes, int ano){
        this.dia = dia;
        this.mes = mes;
        this.ano = ano;
    }

    public boolean ehBissexto(){
       /* um ano solar tem aprox 365 dias e 6 hrs e a cada 4 anos nos acrescentamos
        * 1 dia para nao "sobrar" 24hrs e "dessincronizar" do sol
        *
        * sem `(ano % 400 == 0)` apos 400 anos precisa acrescentar
        * 1 dia no calendario para nao sobrar mais dias pois a cada 100 anos
        * vai sobrando mais 6 hrs
        *
        * esse site deixa claro caso voce nao entendeu minha explicacao:
        * http://www.megacurioso.com.br/historia-e-geografia/20049-como-funciona-o-ano-bissexto-.htm
        */
       return (ano % 4 == 0 && ano % 100 != 0) || (ano % 400 == 0);
    }

    public int getDia() {
        return dia;
    }

    public int getMes() {
        return mes;
    }

    public int getAno() {
        return ano;
    }

    public boolean equals(Object obj){
        DataTerceiraEra novaData = (DataTerceiraEra) obj;
        return novaData.ano == this.ano &&
        novaData.mes == this.mes &&
        novaData.dia == this.dia;
    }
}


text:
package storm.contrib.spring.topology.component.grouping;

import backtype.storm.grouping.CustomStreamGrouping;
import backtype.storm.topology.BoltDeclarer;

/**
 * [Class Description]
 *
 * @author Grant Henke
 * @since 12/4/12
 */
public class CustomBoltGrouping extends GenericBoltGrouping implements IBoltGrouping {

    public CustomStreamGrouping customStreamGrouping;

    public CustomBoltGrouping(final String componentId, final String streamId, final CustomStreamGrouping customStreamGrouping) {
        super(componentId, streamId);
        this.customStreamGrouping = customStreamGrouping;
    }

    public CustomBoltGrouping(final String componentId, final CustomStreamGrouping customStreamGrouping) {
        super(componentId);
        this.customStreamGrouping = customStreamGrouping;
    }

    public void addToBolt(final BoltDeclarer boltDeclarer) {
        if (streamId == null) {
            boltDeclarer.customGrouping(componentId, customStreamGrouping);
        } else {
            boltDeclarer.customGrouping(componentId, streamId, customStreamGrouping);
        }
    }
}


text:
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

//parts of this were inspired by https://github.com/prime31/UIToolkit/blob/master/Assets/Plugins/UIToolkit/UIElements/UIText.cs

public class FLabel : FFacetElementNode
{
	public static float defaultAnchorX = 0.5f;
	public static float defaultAnchorY = 0.5f;

	protected FFont _font;
	protected string _fontName;
	protected string _text;

	protected Color _color = Futile.white;
	protected Color _alphaColor = Futile.white;

	protected FLetterQuadLine[] _letterQuadLines;

	protected bool _isMeshDirty = false;

	protected float _anchorX = defaultAnchorX;
	protected float _anchorY = defaultAnchorY;

	protected bool _doesTextNeedUpdate = false;
	protected bool _doesLocalPositionNeedUpdate = false;
	protected bool _doQuadsNeedUpdate = false;

	protected Rect _textRect;

	protected FTextParams _textParams;

	public FLabel (string fontName, string text) : this(fontName, text, new FTextParams())
	{
	}

	public FLabel (string fontName, string text, FTextParams textParams) : base()
	{
		_fontName = fontName;
		_text = text;
		_font = Futile.atlasManager.GetFontWithName(_fontName);
		_textParams = textParams;

		Init(FFacetType.Quad, _font.element, 0);

		CreateTextQuads();
	}

	public void CreateTextQuads()
	{
		_doesTextNeedUpdate = false;

		int oldFacetsNeeded = _numberOfFacetsNeeded;

		_letterQuadLines = _font.GetQuadInfoForText(_text,_textParams);

		_numberOfFacetsNeeded = 0;

		int lineCount = _letterQuadLines.Length;
		for(int i = 0; i< lineCount; i++)
		{
			_numberOfFacetsNeeded += _letterQuadLines[i].quads.Length;
		}

		if(_isOnStage)
		{
			int delta = _numberOfFacetsNeeded - oldFacetsNeeded;

			if(delta != 0) //if the number of letter quads has changed, tell the stage
			{
				_stage.HandleFacetsChanged();
			}
		}

		UpdateLocalPosition(); //figures out the bounds and alignment, and sets the mesh dirty
	}

	public void UpdateLocalPosition()
	{
		_doesLocalPositionNeedUpdate = false;

		float minY = float.MaxValue;
		float maxY = float.MinValue;

		float minX = float.MaxValue;
		float maxX = float.MinValue;

		int lineCount = _letterQuadLines.Length;
		for(int i = 0; i<lineCount; i++)
		{
			FLetterQuadLine line = _letterQuadLines[i];
			minY = Math.Min (line.bounds.yMin,minY);
			maxY = Math.Max (line.bounds.yMax,maxY);
		}

		float offsetY = -(minY + ((maxY-minY)*_anchorY));

		for(int i = 0; i<lineCount; i++)
		{
			FLetterQuadLine line = _letterQuadLines[i];
			float offsetX = -line.bounds.width*_anchorX;

			minX = Math.Min (offsetX,minX);
			maxX = Math.Max (offsetX+line.bounds.width,maxX);

			int quadCount = line.quads.Length;
			for(int q = 0; q< quadCount; q++)
			{
				line.quads[q].CalculateVectors(offsetX+_font.offsetX, offsetY+_font.offsetY);
			}

		}

		_textRect.x = minX;
		_textRect.y = minY+offsetY;
		_textRect.width = maxX-minX;
		_textRect.height = maxY-minY;

		_isMeshDirty = true;
	}

	override public void Redraw(bool shouldForceDirty, bool shouldUpdateDepth)
	{
		bool wasMatrixDirty = _isMatrixDirty;
		bool wasAlphaDirty = _isAlphaDirty;

		UpdateDepthMatrixAlpha(shouldForceDirty, shouldUpdateDepth);

		if(shouldUpdateDepth)
		{
			UpdateFacets();
		}

		if(wasMatrixDirty || shouldForceDirty || shouldUpdateDepth)
		{
			_isMeshDirty = true;
		}

		if(wasAlphaDirty || shouldForceDirty)
		{
			_isMeshDirty = true;
			_alphaColor = _color.CloneWithMultipliedAlpha(_concatenatedAlpha);
		}

		if(_doesLocalPositionNeedUpdate)
		{
			UpdateLocalPosition();
		}

		if(_isMeshDirty)
		{
			PopulateRenderLayer();
		}
	}

	override public void PopulateRenderLayer()
	{
		if(_isOnStage && _firstFacetIndex != -1)
		{
			_isMeshDirty = false;

			Vector3[] vertices = _renderLayer.vertices;
			Vector2[] uvs = _renderLayer.uvs;
			Color[] colors = _renderLayer.colors;

			int vertexIndex0 = _firstFacetIndex*4;
			int vertexIndex1 = vertexIndex0 + 1;
			int vertexIndex2 = vertexIndex0 + 2;
			int vertexIndex3 = vertexIndex0 + 3;

			int lineCount = _letterQuadLines.Length;
			for(int i = 0; i<lineCount; i++)
			{
				FLetterQuad[] quads = _letterQuadLines[i].quads;

				int quadCount = quads.Length;

				for(int q = 0; q<quadCount; q++)
				{
					FLetterQuad quad = quads[q];
					FCharInfo charInfo = quad.charInfo;

					_concatenatedMatrix.ApplyVector3FromLocalVector2(ref vertices[vertexIndex0], quad.topLeft,0);
					_concatenatedMatrix.ApplyVector3FromLocalVector2(ref vertices[vertexIndex1], quad.topRight,0);
					_concatenatedMatrix.ApplyVector3FromLocalVector2(ref vertices[vertexIndex2], quad.bottomRight,0);
					_concatenatedMatrix.ApplyVector3FromLocalVector2(ref vertices[vertexIndex3], quad.bottomLeft,0);

					uvs[vertexIndex0] = charInfo.uvTopLeft;
					uvs[vertexIndex1] = charInfo.uvTopRight;
					uvs[vertexIndex2] = charInfo.uvBottomRight;
					uvs[vertexIndex3] = charInfo.uvBottomLeft;

					colors[vertexIndex0] = _alphaColor;
					colors[vertexIndex1] = _alphaColor;
					colors[vertexIndex2] = _alphaColor;
					colors[vertexIndex3] = _alphaColor;

					vertexIndex0 += 4;
					vertexIndex1 += 4;
					vertexIndex2 += 4;
					vertexIndex3 += 4;
				}
			}

			_renderLayer.HandleVertsChange();
		}
	}

    public FLabelAlignment alignment
    {
        get
        {
            if (_anchorX == 0.5f) return FLabelAlignment.Center;
            if (_anchorX == 0.0f) return FLabelAlignment.Left;
            if (_anchorX == 1.0f) return FLabelAlignment.Right;

            return FLabelAlignment.Custom;
        }
        set
        {
            if (value == FLabelAlignment.Center) this.anchorX = 0.5f;
            else if (value == FLabelAlignment.Left) this.anchorX = 0.0f;
            else if (value == FLabelAlignment.Right) this.anchorX = 1.0f;
        }
    }

	public string text
	{
		get {return _text;}
		set
		{
			if(_text != value)
			{
				_text = value;
				_doesTextNeedUpdate = true;
				CreateTextQuads(); //lazily creating the quads was causing too many issues, so just create them when .text is set
			}
		}
	}

	public float anchorX
	{
		get {return _anchorX;}
		set
		{
			if(_anchorX != value)
			{
				_anchorX = value;
				_doesLocalPositionNeedUpdate = true;
			}
		}
	}

	public float anchorY
	{
		get {return _anchorY;}
		set
		{
			if(_anchorY != value)
			{
				_anchorY = value;
				_doesLocalPositionNeedUpdate = true;
			}
		}
	}

	virtual public Color color
	{
		get { return _color; }
		set
		{
			if(_color != value)
			{
				_color = value;
				_isAlphaDirty = true;
			}
		}
	}

	virtual public Rect textRect
	{
		get
		{
			if(_doesTextNeedUpdate) CreateTextQuads();
			if(_doesLocalPositionNeedUpdate) UpdateLocalPosition();
			return _textRect;
		}
	}

	[Obsolete("FLabel's boundsRect is obsolete, use textRect instead")]
	public Rect boundsRect
	{
		get {throw new NotSupportedException("boundsRect is obsolete! Use textRect instead");}
	}

	//for convenience
	public void SetAnchor(float newX, float newY)
	{
		this.anchorX = newX;
		this.anchorY = newY;
	}

	public void SetAnchor(Vector2 newAnchor)
	{
		this.anchorX = newAnchor.x;
		this.anchorY = newAnchor.y;
	}

	public Vector2 GetAnchor()
	{
		return new Vector2(_anchorX,_anchorY);
	}
}

public enum FLabelAlignment
{
    Center,
    Left,
    Right,
    Custom
}


text:
class Demo
  module Web
    class Error < Core::Error
      SanitizationError = Class.new(self)
    end
  end
end


text:
int
initAndClearProcLog();
int
initProcLog();
int
logAgentProc( rsComm_t* );
int
readProcLog( int pid, procLog_t *procLog );
int
rmProcLog( int pid );

#endif //PROC_LOG_H


text:
{% extends 'OctaHomeCore/baseWithNavBar.html' %}

{% block title %} Settings - Account {% endblock %}

{% block AccountNavBarActive %} active {% endblock %}

{% load my_filters %}

{% block PageArea %}

Add Action

		<form action="{% url 'SettingsCommand' command='addActionComplete' %}" method="POST" onsubmit="return validateForm()" name="CreateActionForm">
			<fieldset>
				<input type="hidden" name="csrfmiddlewaretoken" value="{{csrfmiddlewaretoken}}">
				Name:
				<input type="text" name="name" class="form-control" style="width: 200px;" placeholder="Event Name..." maxlength="30" required pattern="[^]{3,30}">

				Action Type:
				<select name="type" class="form-control" style="max-width: 200px;" id="type">
					{% for type in types %}
						{% if type.UserCreatable %}
							<option value="{{ type|getClassName }}">{{ type.getTypeName }}</option>
						{% endif %}
					{% endfor %}
				</select>
				{% for type in types %}

						{% for template in type.AdditionPartials %}
							{% if type.UserCreatable %}
								{% include template %}
							{% endif %}
						{% endfor %}

				{% endfor %}

				<button type="submit" class="btn btn-default">Add Action</button>
			</fieldset>
		</form>

{% endblock %}

{% block ExtraJavaScript %}
{% endblock %}


text:
*Detect sensitive data in Hadoop*

The chlorine-hadoop library defines a mapreduce program which can be used to detect and mask sensitive elements in HDFS directoires. It is Java based.

Chlorine-hadoop can detect different types of Credit card numbers, SSN, Phone Numbers, email adddresses, Ip Addresses, Street Addresses in HDFS datasets. It works with compressed text files. Optionally, it can mask the sensitive elements detected.

###To Download source code

*git clone https://github.com/dataApps/chlorine-hadoop.git*

###To build chlorine-hadoop

*mvn install*

###To develop chlorine-hadoop in eclipse

*mvn eclipse:clean eclipse:eclipse*

Then import the projects into the eclipse workspace.

###To use Chlorine-hadoop

```
usage: Scan [-help] [-i <path>] [-inc <file>] [-m <path>] [-o <path>] [-q
       <name>] [-s <timeinms>] [-sm <path>]
 -help                       print this message
 -i,--input_path <path>      input path to scan
 -inc,--incremental <file>   specify scan as incremental and use the
                             timestemp in the file to determine the files
                             to scan. If the file is present, the
                             timestamp will be read from the file. If file
                             is not present, file is automatically
                             geneated and updated with a timestamp for
                             subsequent scans. If both incremental and
                             scanfrom are specified, then incremental is
                             ignored.
 -m,--mask <path>            Copy the input to the specified path with
                             sensitive values masked. The directory
                             structure is retained.
 -o,--output_path <path>     Output path
 -q,--queue <name>           job queue
 -s,--scanfrom <timeinms>    Scan only files modified on or after the
                             specific time. The time is specified in
                             milliseconds after the epoch.
 -sm,--save_match <path>     path to save matches
```

## A sample script to run chlorine-hadoop job on an HDFS directory

The script template is available under  [/scripts/chlorine-hadoop.sh](https://github.com/dataApps/chlorine-hadoop/scripts/chlorine-hadoop.sh)

```
CHLORINE_JAR=/home/benoy/work/chlorine-hadoop/target/chlorine-hadoop-1.1.5-SNAPSHOT.jar
HADOOP_HOME=/apache/hadoop-2.7.1
HADOOP_CONF=$HADOOP_HOME/etc/hadoop
HADOOP_JAR_BASE=$HADOOP_HOME/share/hadoop
HADOOP_JARS=$HADOOP_JAR_BASE/common/*:$HADOOP_JAR_BASE/common/lib/*:$HADOOP_JAR_BASE/hdfs/*:$HADOOP_JAR_BASE/hdfs/lib/*:$HADOOP_JAR_BASE/yarn/*:$HADOOP_JAR_BASE/yarn/lib/*:$HADOOP_JAR_BASE/mapreduce/*:$HADOOP_JAR_BASE/mapeduce/lib/*

java -Xmx1000m -XX:MaxPermSize=128M  -cp $HADOOP_CONF:$CHLORINE_JAR:$HADOOP_JARS io.dataapps.chlorine.hadoop.Scan $*

```

###A sample run

```
./scripts/chlorine-hadoop.sh -i /data/csv_nohive -o /user/benoy/23 -sm /user/benoy/matches -q regular -m /user/benoy/data

Creating a DeepScan with the following inputs
input-path=/data/csv_nohive
output-path=/user/benoy/23
queue=regular
save Matches at=/user/benoy/matches
Mask and save masked files at=/user/benoy/data
16/04/22 10:50:04 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
16/04/22 10:50:05 INFO Configuration.deprecation: mapred.output.compress is deprecated. Instead, use mapreduce.output.fileoutputformat.compress
16/04/22 10:50:05 INFO Configuration.deprecation: mapred.job.queue.name is deprecated. Instead, use mapreduce.job.queuename
16/04/22 10:50:05 INFO hadoop.AbstractPipeline: ***********Run job: Chlorine Scan and Mask
16/04/22 10:50:05 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
16/04/22 10:50:05 WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
16/04/22 10:50:05 INFO input.FileInputFormat: Total input paths to process : 2
16/04/22 10:50:05 INFO mapreduce.JobSubmitter: number of splits:2
16/04/22 10:50:06 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1461174733991_0029
16/04/22 10:50:06 INFO impl.YarnClientImpl: Submitted application application_1461174733991_0029
16/04/22 10:50:06 INFO mapreduce.Job: The url to track the job: http://benoy-Satellite-C55-C:8088/proxy/application_1461174733991_0029/
16/04/22 10:50:21 INFO hadoop.AbstractPipeline: Job Chlorine Scan and Mask successful.
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: Total bytes scanned = 448
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: Total records scanned = 4
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: Total Matched records = 4
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: Total matches = 16
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: Email = 16
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: IPV4 = 16
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: StreetAddress = 16
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: SSN-dashes = 16
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: The matches detected are stored in /user/benoy/matches/scan_result_-996967296_-1
16/04/22 10:50:21 INFO hadoop.DeepScanPipeline: The matches in the input are masked and a copy is kept under /user/benoy/data

```

### Sample results

```
hadoop fs -cat /user/benoy/1/scan_result0

/data/csv_nohive/2015/08/31/user1.csv	Email	1	tests@tetts.com
/data/csv_nohive/2015/08/31/user1.csv	SSN-dashes	1	608-34-2345
/data/csv_nohive/2015/08/31/user1.csv	IPV4	1	123.34.456.23
/data/csv_nohive/2015/08/31/user1.csv	StreetAddress	1	1234 sdsfd dr
/data/csv_nohive/2015/08/31/user1.csv	Email	1	teret@dfdfd.com
/data/csv_nohive/2015/08/31/user1.csv	SSN-dashes	1	604-13-4345
/data/csv_nohive/2015/08/31/user1.csv	IPV4	1	123.33.234.13
/data/csv_nohive/2015/08/31/user1.csv	StreetAddress	1	1234 gsfsffs pl
/data/csv_nohive/2015/09/01/user2.csv	Email	1	three@three.com
/data/csv_nohive/2015/09/01/user2.csv	SSN-dashes	1	609-34-2345
/data/csv_nohive/2015/09/01/user2.csv	IPV4	1	131.34.456.23
/data/csv_nohive/2015/09/01/user2.csv	StreetAddress	1	1234 sdsfd dr
/data/csv_nohive/2015/09/01/user2.csv	Email	1	four@four.com
/data/csv_nohive/2015/09/01/user2.csv	SSN-dashes	1	607-13-4345
/data/csv_nohive/2015/09/01/user2.csv	IPV4	1	153.33.234.13
/data/csv_nohive/2015/09/01/user2.csv	StreetAddress	1	1234 gs pl

```

### Explanation of the output

One row will be emitted for each line containing a sensitive element. If multiple types of sensitive elements are found in a column value, then a row is emitted per type per column.
The out schema is as follows:

| column position | name | description |
| --- | --- |--- |
|1|Source File Path| Path to the file which contains the sensitive data|
|2|Type| sensitive data type. eg: email, credit card. This will be the name of the finder|
|3|count| number of sensitive elements found in a specific column of a specific sensitive element type|
|4|values| comma spearated list of sensitive data values found|

### Download library jar

The latest chlorine-finder and chlorine-hadoop libraries can be downloaded [here](https://dataapps.io/chlorine.html#Opensource).

###Further Documentation
[chlorine-hive wiki](https://github.com/dataApps/chlorine-hadoop/wiki)

###Related projects

###Java Docs
The java docs for chlorine-finder are available [here](https://dataApps.io/files/chlorine-hadoop/javadoc/index.html).

We welcome all contributions. You can contribute features, enhancements, bug fixes or new Finders.

##Want to contribute features, bug fixes, enhancements?

    Fork it
    Create your feature branch (git checkout -b my-new-feature)
    Take a look at the issues
    Commit your changes (git commit -am 'Add some feature')
    Push to the branch (git push origin my-new-feature)
    Create new Pull Request


text:
<?php

/**
 * @file
 * Contains class \BartFeenstra\Currency\Currency.
 */

namespace BartFeenstra\Currency;

use Symfony\Component\Yaml\Yaml;

/**
 * Describes a currency.
 */
class Currency {

  /**
   * Alternative (non-official) currency signs.
   *
   * @var array
   *   An array of strings that are similar to Currency::sign.
   */
  public $alternativeSigns = array();

  /**
   * Exchange rates to other currencies.
   *
   * @var array
   *   Keys are ISO 4217 codes, values are numeric strings.
   */
  public $exchangeRates = array();

  /**
   * ISO 4217 currency code.
   *
   * @var string
   */
  public $ISO4217Code = NULL;

  /**
   * ISO 4217 currency number.
   *
   * @var string
   */
  public $ISO4217Number = NULL;

  /**
   * The currency's official sign, such as '€' or '$'.
   *
   * @var string
   */
  public $sign = '¤';

  /**
   * The number of subunits this currency has.
   *
   * @var integer|null
   */
  public $subunits = NULL;

  /**
   * Human-readable title in US English.
   *
   * @var string
   */
  public $title = NULL;

  /**
   * This currency's usage.
   *
   * @var array
   *   An array of \BartFeenstra\Currency\Usage objects.
   */
  public $usage = array();

  /**
   * The path to the resources directory.
   */
  public static $resourcePath = '/../../../resources/';

  /**
   * A list of the ISO 4217 codes of all known currency resources.
   */
  public static $resourceISO4217Codes = array();

  /**
   * Returns the directory that contains the currency resources.
   *
   * @return string
   */
  public static function resourceDir() {
    return __DIR__ . self::$resourcePath;
  }

  /**
   * Lists all currency resources in the library.
   *
   * @return array
   *   An array with ISO 4217 currency codes.
   */
  public static function resourceListAll() {
    if (!self::$resourceISO4217Codes) {
      $directory = new \RecursiveDirectoryIterator(self::resourceDir());
      foreach ($directory as $item) {
        if (preg_match('#^...\.yml$#', $item->getFilename())) {
          self::$resourceISO4217Codes[] = substr($item->getFilename(), 0, 3);
        }
      }
    }

    return self::$resourceISO4217Codes;
  }

  /**
   * Loads a currency resource into this object.
   *
   * @param string $iso_4217_code
   */
  public function resourceLoad($iso_4217_code) {
    $filepath = self::resourceDir() . "$iso_4217_code.yml";
    if (is_readable($filepath)) {
      $this->resourceParse(file_get_contents($filepath));
    }
    else {
      throw new \RuntimeException(sprintf('The currency resource file %s does not exist or is not readable.', $filepath));
    }
  }

  /**
   * Parses a YAML file into this object.
   *
   * @param string $yaml
   */
  public function resourceParse($yaml) {
    $currency_data = Yaml::parse($yaml);
    $usages_data = $currency_data['usage'];
    $currency_data['usage'] = array();
    foreach ($currency_data as $property => $value) {
      $this->$property = $value;
    }
    foreach ($usages_data as $usage_data) {
      $usage = new Usage;
      foreach ($usage_data as $property => $value) {
        $usage->$property = $value;
      }
      $this->usage[] = $usage;
    }
    unset($currency_data);
  }

  /**
   * Dumps this object to YAML code.
   *
   * @return string
   */
  public function resourceDump() {
    $currency_data = get_object_vars($this);
    $currency_data['usage'] = array();
    foreach ($this->usage as $usage) {
      $currency_data['usage'][] = get_object_vars($usage);
    }

    return Yaml::dump($currency_data);
  }

  /**
   * Returns the number of decimals.
   *
   * @return int
   */
  function getDecimals() {
    $decimals = 0;
    if ($this->subunits > 0) {
      $decimals = 1;
      while (pow(10, $decimals) < $this->subunits) {
        $decimals++;
      }
    }

    return $decimals;
  }
}


text:
#import <Foundation/NSPlatform.h>

#define FOUNDATION_FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
#define FOUNDATION_DIR_MODE S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH

@interface NSPlatform_posix : NSPlatform {
}

@end

extern char **NSPlatform_environ();


text:
using System;
using System.Web.UI;
using System.Reflection;
using Nucleo.Web.Mappings.Configuration;

namespace Nucleo.Web.Mappings
{
	public class ControlMappingsManager
	{
		private ControlMappingCollection _mappings = null;

		#region " Properties "

		/// <summary>
		/// Gets the mappings setup by the manager.
		/// </summary>
		public ControlMappingCollection Mappings
		{
			get
			{
				if (_mappings == null)
					_mappings = new ControlMappingCollection();
				return _mappings;
			}
		}

		#endregion

		#region " Constructors "

		public ControlMappingsManager() { }

		#endregion

		#region " Methods "

		private Control GetControl(string controlID)
		{
			return null;
		}

		private object GetControlValue(Control control)
		{
			return null;
		}

		public void ReadFromControls(ref object parentObject)
		{
			foreach (ControlMapping mapping in this.Mappings)
			{
				Control control = this.GetControl(mapping.ControlID);
				if (control == null)
					throw new ArgumentException("No control was found with the ID: " + mapping.ControlID);

				object value = this.GetControlValue(control);
				PropertyInfo property = parentObject.GetType().GetProperty(mapping.ObjectPropertyName);
				if (property == null)
					throw new Exception("The object does not have a property: " + mapping.ObjectPropertyName);

				property.SetValue(parentObject, value, null);
			}
		}

		/// <summary>
		/// Registers a single mapping, mapping the control ID to the object name.
		/// </summary>
		/// <param name="controlID">The ID of the control.</param>
		/// <param name="objectPropertyName">The name of the property.</param>
		public void RegisterMapping(string controlID, string objectPropertyName)
		{
			this.Mappings.Add(new ControlMapping(
			                  	controlID, objectPropertyName));
		}

		/// <summary>
		/// Register the mapping for a group specified in the configuration file.
		/// </summary>
		/// <param name="group">The group to register.</param>
		public void RegisterMappingFromConfiguration(string group)
		{
			ControlMappingsSection section = ControlMappingsSection.Instance;
			if (section == null)
				throw new System.Configuration.ConfigurationErrorsException(
					"The controlMappings section hasn't been created in the config file");

			ControlMappingGroupElement groupElement = section.Groups[group];
			if (groupElement == null)
				throw new NullReferenceException(String.Format("The group '{0}' was not found in the configuration file", group));

			foreach (ControlMappingElement element in groupElement.Mappings)
				this.Mappings.Add(new ControlMapping(
				                  	element.ControlID, element.ObjectPropertyName));
		}

		private void SetControlValue(Control control, object value)
		{

		}

		public void WriteToControls(object parentObject)
		{
			foreach (ControlMapping mapping in this.Mappings)
			{
				Control control = this.GetControl(mapping.ControlID);
				PropertyInfo property = parentObject.GetType().GetProperty(mapping.ObjectPropertyName);
				if (property == null)
					throw new Exception("The object doesn't have the property " + parentObject);

				this.SetControlValue(control, property.GetValue(parentObject, null));
			}
		}

		#endregion
	}
}


text:
from .orm.utils import get_num_of_tables
from .lineup import Lineup
from .completer import Completer

class Console(object):

    def __init__(self, round, segment, table=None):
        self.round = round
        self.segment = segment
        self.start_from_table = table if table is not None else 1

    @property
    def tables(self):
        return [ i for i in range(self.start_from_table, get_num_of_tables() + 1) ]

    def run(self):
        for table in self.tables:
            try:
                self.process_table(table)
            except (EOFError, KeyboardInterrupt):
                break

    def process_table(self, table):
        lineup = self.get_lineup(table)
        print(lineup.info)
        print('')
        # Python 2.x workaround
        global input
        try:
            input = raw_input
        except NameError:
            pass # if raw_input is not defined (Python 3.x), ignore it
        for team in lineup.teams:
            Completer.install_new_completer(team.player_names)
            for pair in team.pairs:
                while True:
                    print(pair.info)
                    value = input("Player: ")
                    if not value:
                        print()
                        break
                    pair.set_player(value)

    def get_lineup(self, table):
        return Lineup(self.round, self.segment, table)


text:
<?php

namespace yii\payment\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;

class UnionpayController extends Controller{

	public $enableCsrfValidation = false;

	private $mode = 'unionpay';

	public function behaviors(){
		return [
			'verbs' => [
				'class' => VerbFilter::className(),
				'actions' => [
					'async' => ['post'],
					'sync' => ['post'],
				],
			],
		];
	}

	public function actionAsync(){
		if(empty($_POST) || !isset($_POST['orderId']) || !isset($_POST['queryId']) || !isset($_POST['respCode']) || !isset($_POST['respMsg'])){
			return false;
		}

		$id = $_POST['orderId'];
		$trade_id = $_POST['queryId'];
		$status = $this->checkTradeStatus($_POST['respCode'], $_POST['respMsg']) ? 1 : 0;
		$manager = $this->module->manager;
		$verified = $manager->verifySign($this->mode, true);
		$manager->saveNotify($this->mode, $id, $trade_id, $status, $verified, $_POST);

		if(!$verified){
			return false;
		}

		if($status && $manager->complete($id, $trade_id) && $asyncClass = $this->module->asyncClass){
			$asyncClass::paied($id);
		}

		return '验签成功';
	}

	public function actionSync(){
		if(!$this->module->manager->verifySign($this->mode)){
			return false;
		}

		$request = \Yii::$app->request;
		if($this->checkTradeStatus($request->post('respCode'), $request->post('respMsg'))){
			return $this->module->syncRoute ? $this->redirect([$this->module->syncRoute, 'id' => $request->post('orderId')]) : '付款成功';
		}

		return true;
	}

	private function checkTradeStatus($respCode, $respMsg){
		return $respCode == '00' && ($respMsg == 'Success!' || $respMsg == 'success');
	}

}


text:
This is a minimal Rails app to test the rails-autoscale-delayed_job gem.

## Prerequisites

- Ruby
- Node
- [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli)
- Redis

## Set up the app

Run `./bin/setup` install necessary dependencies. This will...

- Run `bundle install` to install gems

## Run the app

Run `./bin/dev` to run the app in development mode. This will...

- Use `heroku local` and a `Procfile` to start the following processes:
  - A [tiny proxy server](https://github.com/judoscale/judoscale-adapter-proxy-server) that adds the `X-Request-Start` request header so we can test request queue time reporting.
  - The Rails server.
  - The DelayedJob server to process jobs.

## How to use this sample app

Open https://rails-autoscale-adapter-mock.requestcatcher.com in a browser. The sample app is configured to use this endpoint as a mock for the Rails Autoscale Adapter API. This page will monitor all API requests sent from the adapter.

Run the app. Both the Rails and DelayedJob processes will send an initial request to the API once the app boots up. These can be inspected via request catcher.

Open http://localhost:5000 to see how many jobs are waiting on each of the available queues, and to enqueue sample jobs on those queues that will be processed by the DelayedJob server slowly.

## Deploy this app to Heroku

From this directory, run the following to create a new git repo and push it to Heroku:

```sh
git init
git add .
git commit -m "prep for Heroku"
heroku create
git push heroku main
```

To install Rails Autoscale:

```sh
# scale up a worker dyno before doing this so Rails Autoscale picks it up
heroku ps:scale dj=1
heroku addons:create rails-autoscale
```


text:
namespace AgileObjects.AgileMapper.UnitTests.Orms
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Common;
    using Infrastructure;
    using TestClasses;
    using Xunit;

    public abstract class WhenProjectingToEnumerableMembers<TOrmContext> : OrmTestClassBase<TOrmContext>
        where TOrmContext : ITestDbContext, new()
    {
        protected WhenProjectingToEnumerableMembers(ITestContext<TOrmContext> context)
            : base(context)
        {
        }

        #region Project -> Collection

        protected Task RunShouldProjectToAComplexTypeCollectionMember()
            => RunTest(ProjectToComplexTypeCollectionMember);

        protected Task RunShouldErrorProjectingToAComplexTypeCollectionMember()
            => RunTestAndExpectThrow(ProjectToComplexTypeCollectionMember);

        private static async Task ProjectToComplexTypeCollectionMember(TOrmContext context)
        {
            var rotaEntry1 = new RotaEntry
            {
                DayOfWeek = DayOfWeek.Monday,
                PersonId = 10,
                StartHour = 8,
                StartMinute = 45,
                EndHour = 5,
                EndMinute = 15
            };

            var rotaEntry2 = new RotaEntry
            {
                DayOfWeek = DayOfWeek.Tuesday,
                PersonId = 8,
                StartHour = 9,
                StartMinute = 00,
                EndHour = 4,
                EndMinute = 30
            };

            var rotaEntry3 = new RotaEntry
            {
                DayOfWeek = DayOfWeek.Friday,
                PersonId = 51,
                StartHour = 10,
                StartMinute = 30,
                EndHour = 10,
                EndMinute = 31
            };

            var rota = new Rota
            {
                StartDate = DateTime.Today,
                EndDate = DateTime.Today.AddDays(7),
                Entries = new List<RotaEntry> { rotaEntry1, rotaEntry2, rotaEntry3 }
            };

            await context.Rotas.Add(rota);
            await context.SaveChanges();

            var rotaDto = context.Rotas.Where(r => r.Id > 0).Project().To<RotaDto>().First();

            rotaDto.Id.ShouldBe(rota.Id);
            rotaDto.StartDate.ShouldBe(rota.StartDate);
            rotaDto.EndDate.ShouldBe(rota.EndDate);
            rotaDto.Entries.Count.ShouldBe(rota.Entries.Count);

            var i = 0;
            var rotaEntryDtos = rotaDto.Entries.OrderBy(re => re.Id).ToArray();

            foreach (var rotaEntry in rota.Entries.OrderBy(re => re.Id))
            {
                var rotaEntryDto = rotaEntryDtos.ElementAt(i);

                rotaEntryDto.Id.ShouldBe(rotaEntry.Id);
                rotaEntryDto.DayOfWeek.ShouldBe(rotaEntry.DayOfWeek);
                rotaEntryDto.PersonId.ShouldBe(rotaEntry.PersonId);
                rotaEntryDto.StartHour.ShouldBe(rotaEntry.StartHour);
                rotaEntryDto.StartMinute.ShouldBe(rotaEntry.StartMinute);
                rotaEntryDto.EndHour.ShouldBe(rotaEntry.EndHour);
                rotaEntryDto.EndMinute.ShouldBe(rotaEntry.EndMinute);

                ++i;
            }
        }

        #endregion

        [Fact]
        public Task ShouldProjectToComplexTypeEnumerableMember()
        {
            return RunTest(async context =>
            {
                var item1 = new OrderItem();
                var item2 = new OrderItem();

                var order = new OrderUk
                {
                    DatePlaced = DateTime.Now,
                    Items = new List<OrderItem> { item1, item2 }
                };

                await context.Orders.Add(order);
                await context.SaveChanges();

                var orderDto = context
                    .Orders
                    .Project()
                    .To<OrderDto>()
                    .ShouldHaveSingleItem();

                orderDto.Id.ShouldBe(order.Id);
                orderDto.DatePlaced.ShouldBe(order.DatePlaced);
                orderDto.Items.Count().ShouldBe(2);

                var i = 0;

                foreach (var orderItem in order.Items)
                {
                    var orderItemDto = order.Items.ElementAt(i);

                    orderItemDto.Id.ShouldBe(orderItem.Id);

                    ++i;
                }
            });
        }

        [Fact]
        public Task ShouldProjectViaLinkingType()
        {
            return RunTest(async context =>
            {
                var account = new Account
                {
                    User = new Person
                    {
                        Name = "Mario",
                        Address = new Address { Line1 = "Here", Postcode = "HS93HS" }
                    }
                };

                account.AddDeliveryAddress(new Address { Line1 = "There", Postcode = "JS95TH" });
                account.AddDeliveryAddress(new Address { Line1 = "Somewhere", Postcode = "KA02ID" });

                await context.Accounts.Add(account);
                await context.SaveChanges();

                var accountDto = context
                    .Accounts
                    .Project()
                    .To<AccountDto>()
                    .ShouldHaveSingleItem();

                accountDto.Id.ShouldBe(account.Id);

                accountDto.User.Id.ShouldBe(account.User.PersonId);
                accountDto.User.Name.ShouldBe(account.User.Name);
                accountDto.User.Address.Id.ShouldBe(account.User.Address.AddressId);
                accountDto.User.Address.Line1.ShouldBe(account.User.Address.Line1);
                accountDto.User.Address.Postcode.ShouldBe(account.User.Address.Postcode);

                accountDto.DeliveryAddresses.Count().ShouldBe(2);

                var addressDto1 = accountDto.DeliveryAddresses.First();
                var address1 = account.DeliveryAddresses.First().Address;
                addressDto1.Id.ShouldBe(address1.AddressId);
                addressDto1.Line1.ShouldBe(address1.Line1);
                addressDto1.Postcode.ShouldBe(address1.Postcode);

                var addressDto2 = accountDto.DeliveryAddresses.Second();
                var address2 = account.DeliveryAddresses.Second().Address;
                addressDto2.Id.ShouldBe(address2.AddressId);
                addressDto2.Line1.ShouldBe(address2.Line1);
                addressDto2.Postcode.ShouldBe(address2.Postcode);
            });
        }
    }
}


text:
/*!
 * @file MotionHistory.h
 * @author a_hasimoto
 * @date Date Created: 2012/Jan/06
 * @date Last Change:2012/Jul/25.
 */
#ifndef __SKL_MOTION_HISTORY_H__
#define __SKL_MOTION_HISTORY_H__

#include "FilterMat2Mat.h"

namespace skl{

/*!
 * @brief MotionHistoryImageを作る
 */
 class MotionHistory: public FilterMat2Mat<void>{

	public:
		MotionHistory(int history_length=8);
		virtual ~MotionHistory();
		void clear();
		void compute(const cv::Mat& mask);
		void compute(const cv::Mat& mask, cv::Mat& dest);

		inline const cv::Mat& motion_history_image()const{return prev;}
		inline int history_length()const{return (offset+1) / step;}
		inline void history_length(int __history_length){
			offset = 255 - 256 % __history_length;
			step = 256 / __history_length;
		}
	protected:
		int step;
		unsigned char offset;
		cv::Mat prev;
		cv::Size size;
	private:
		void compute(const cv::Mat& src, const cv::Mat& mask, cv::Mat& dest);

};

} // skl

#endif // __SKL_MOTION_HISTORY_H__


text:
@implementation ArtUIStyleManager (UIStyleModule2)

- (NSString *)getStyleName_Module2 {
    return @"Module2Style.plist";
}

- (NSString *)getHotReloaderStylePath_Module2 {
    return @"/App/Module2/UIStyle/Module2Style.plist";
}

@end

@implementation UIColor (UIStyleModule2)

+ (UIColor *)artModule2ForKey:(NSString *)aColorKey {
    return [self artModule:@"Module2" colorForKey:aColorKey];
}

+ (void)artModule2ForKey:(NSString *)aColorKey strongSelf:(id)strongSelf block:(void(^)(UIColor *color, id weakSelf))aBlock {
    [self artModule:@"Module2" colorForKey:aColorKey strongSelf:strongSelf block:aBlock];
}

@end

@implementation UIFont (UIStyleModule2)

+ (UIFont *)artModule2ForKey:(NSString *)aFontKey {
    return [self artModule:@"Module2" fontForKey:aFontKey];
}

+ (void)artModule2ForKey:(NSString *)aFontKey strongSelf:(id)strongSelf block:(void(^)(UIFont *color, id weakSelf))aBlock {
    [self artModule:@"Module2" fontForKey:aFontKey strongSelf:strongSelf block:aBlock];
}

@end


text:
package smile.validation;

/**
 * The precision or positive predictive value (PPV) is ratio of true positives
 * to combined true and false positives, which is different from sensitivity.
 * <p>
 * PPV = TP / (TP + FP)
 *
 * @author Haifeng Li
 */
public class Precision implements ClassificationMeasure {

    @Override
    public double measure(int[] truth, int[] prediction) {
        if (truth.length != prediction.length) {
            throw new IllegalArgumentException(String.format("The vector sizes don't match: %d != %d.", truth.length, prediction.length));
        }

        int tp = 0;
        int p = 0;
        for (int i = 0; i < truth.length; i++) {
            if (prediction[i] == 1) {
                p++;

                if (truth[i] == 1) {
                    tp++;
                }
            }
        }

        return (double) tp / p;
    }

    @Override
    public String toString() {
        return "Precision";
    }
}


text:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.enihsyou.shane.packagetracker.activity.TrackDetailActivity">
    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:title="@string/action_settings"
        app:showAsAction="never" />
</menu>


text:
package com.bearprogrammer.resource;

import java.util.Comparator;

/**
 *

 * A resource processor can be used to process a specified resource type. Any
 * kind of processing can be done, including: compressing and obfuscation.
 *

 *
 *

 * Each {@link Type} can have one or more processors that can be invoked in a
 * specified order. The order to execute the processors will be determined by
 * the implementation of the {@link Comparator#compare(Object, Object) compare}
 * method.
 *

 *
 * @author Vinicius Isola
 */
public interface Processor extends Comparable<Processor> {

	/**
	 * Do the processing.
	 *
	 * @param content
	 *            The content to be processed.
	 * @return The processed content.
	 * @throws ProcessingException
	 *             If any error occur while processing the content.
	 */
	public String process(String content) throws ProcessingException;

	/**
	 * Check if this processor supports the specified type.
	 *
	 * @param typeName
	 *            Name of the type to check for.
	 * @return True if this processor can be used to process resources of this
	 *         type.
	 */
	public boolean supportType(String typeName);

}


text:
#ifndef _RTE_CRYPTO_SYM_H_
#define _RTE_CRYPTO_SYM_H_

/**
 * @file rte_crypto_sym.h
 *
 * RTE Definitions for Symmetric Cryptography
 *
 * Defines symmetric cipher and authentication algorithms and modes, as well
 * as supported symmetric crypto operation combinations.
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <string.h>

#include <rte_mbuf.h>
#include <rte_memory.h>
#include <rte_mempool.h>

/** Symmetric Cipher Algorithms */
enum rte_crypto_cipher_algorithm {
	RTE_CRYPTO_CIPHER_NULL = 1,
	/**< NULL cipher algorithm. No mode applies to the NULL algorithm. */

	RTE_CRYPTO_CIPHER_3DES_CBC,
	/**< Triple DES algorithm in CBC mode */
	RTE_CRYPTO_CIPHER_3DES_CTR,
	/**< Triple DES algorithm in CTR mode */
	RTE_CRYPTO_CIPHER_3DES_ECB,
	/**< Triple DES algorithm in ECB mode */

	RTE_CRYPTO_CIPHER_AES_CBC,
	/**< AES algorithm in CBC mode */
	RTE_CRYPTO_CIPHER_AES_CCM,
	/**< AES algorithm in CCM mode. When this cipher algorithm is used the
	 * *RTE_CRYPTO_AUTH_AES_CCM* element of the
	 * *rte_crypto_hash_algorithm* enum MUST be used to set up the related
	 * *rte_crypto_auth_xform* structure in the session context or in
	 * the op_params of the crypto operation structure in the case of a
	 * session-less crypto operation
	 */
	RTE_CRYPTO_CIPHER_AES_CTR,
	/**< AES algorithm in Counter mode */
	RTE_CRYPTO_CIPHER_AES_ECB,
	/**< AES algorithm in ECB mode */
	RTE_CRYPTO_CIPHER_AES_F8,
	/**< AES algorithm in F8 mode */
	RTE_CRYPTO_CIPHER_AES_GCM,
	/**< AES algorithm in GCM mode. When this cipher algorithm is used the
	 * *RTE_CRYPTO_AUTH_AES_GCM* element of the
	 * *rte_crypto_auth_algorithm* enum MUST be used to set up the related
	 * *rte_crypto_auth_setup_data* structure in the session context or in
	 * the op_params of the crypto operation structure in the case of a
	 * session-less crypto operation.
	 */
	RTE_CRYPTO_CIPHER_AES_XTS,
	/**< AES algorithm in XTS mode */

	RTE_CRYPTO_CIPHER_ARC4,
	/**< (A)RC4 cipher algorithm */

	RTE_CRYPTO_CIPHER_KASUMI_F8,
	/**< Kasumi algorithm in F8 mode */

	RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
	/**< SNOW3G algorithm in UEA2 mode */

	RTE_CRYPTO_CIPHER_ZUC_EEA3,
	/**< ZUC algorithm in EEA3 mode */

	RTE_CRYPTO_CIPHER_LIST_END
};

/** Symmetric Cipher Direction */
enum rte_crypto_cipher_operation {
	RTE_CRYPTO_CIPHER_OP_ENCRYPT,
	/**< Encrypt cipher operation */
	RTE_CRYPTO_CIPHER_OP_DECRYPT
	/**< Decrypt cipher operation */
};

/**
 * Symmetric Cipher Setup Data.
 *
 * This structure contains data relating to Cipher (Encryption and Decryption)
 *  use to create a session.
 */
struct rte_crypto_cipher_xform {
	enum rte_crypto_cipher_operation op;
	/**< This parameter determines if the cipher operation is an encrypt or
	 * a decrypt operation. For the RC4 algorithm and the F8/CTR modes,
	 * only encrypt operations are valid.
	 */
	enum rte_crypto_cipher_algorithm algo;
	/**< Cipher algorithm */

	struct {
		uint8_t *data;	/**< pointer to key data */
		size_t length;	/**< key length in bytes */
	} key;
	/**< Cipher key
	 *
	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.data will
	 * point to a concatenation of the AES encryption key followed by a
	 * keymask. As per RFC3711, the keymask should be padded with trailing
	 * bytes to match the length of the encryption key used.
	 *
	 * For AES-XTS mode of operation, two keys must be provided and
	 * key.data must point to the two keys concatenated together (Key1 ||
	 * Key2). The cipher key length will contain the total size of both
	 * keys.
	 *
	 * Cipher key length is in bytes. For AES it can be 128 bits (16 bytes),
	 * 192 bits (24 bytes) or 256 bits (32 bytes).
	 *
	 * For the CCM mode of operation, the only supported key length is 128
	 * bits (16 bytes).
	 *
	 * For the RTE_CRYPTO_CIPHER_AES_F8 mode of operation, key.length
	 * should be set to the combined length of the encryption key and the
	 * keymask. Since the keymask and the encryption key are the same size,
	 * key.length should be set to 2 x the AES encryption key length.
	 *
	 * For the AES-XTS mode of operation:
	 *  - Two keys must be provided and key.length refers to total length of
	 *    the two keys.
	 *  - Each key can be either 128 bits (16 bytes) or 256 bits (32 bytes).
	 *  - Both keys must have the same size.
	 **/
};

/** Symmetric Authentication / Hash Algorithms */
enum rte_crypto_auth_algorithm {
	RTE_CRYPTO_AUTH_NULL = 1,
	/**< NULL hash algorithm. */

	RTE_CRYPTO_AUTH_AES_CBC_MAC,
	/**< AES-CBC-MAC algorithm. Only 128-bit keys are supported. */
	RTE_CRYPTO_AUTH_AES_CCM,
	/**< AES algorithm in CCM mode. This is an authenticated cipher. When
	 * this hash algorithm is used, the *RTE_CRYPTO_CIPHER_AES_CCM*
	 * element of the *rte_crypto_cipher_algorithm* enum MUST be used to
	 * set up the related rte_crypto_cipher_setup_data structure in the
	 * session context or the corresponding parameter in the crypto
	 * operation data structures op_params parameter MUST be set for a
	 * session-less crypto operation.
	 */
	RTE_CRYPTO_AUTH_AES_CMAC,
	/**< AES CMAC algorithm. */
	RTE_CRYPTO_AUTH_AES_GCM,
	/**< AES algorithm in GCM mode. When this hash algorithm
	 * is used, the RTE_CRYPTO_CIPHER_AES_GCM element of the
	 * rte_crypto_cipher_algorithm enum MUST be used to set up the related
	 * rte_crypto_cipher_setup_data structure in the session context, or
	 * the corresponding parameter in the crypto operation data structures
	 * op_params parameter MUST be set for a session-less crypto operation.
	 */
	RTE_CRYPTO_AUTH_AES_GMAC,
	/**< AES GMAC algorithm. When this hash algorithm
	* is used, the RTE_CRYPTO_CIPHER_AES_GCM element of the
	* rte_crypto_cipher_algorithm enum MUST be used to set up the related
	* rte_crypto_cipher_setup_data structure in the session context,  or
	* the corresponding parameter in the crypto operation data structures
	* op_params parameter MUST be set for a session-less crypto operation.
	*/
	RTE_CRYPTO_AUTH_AES_XCBC_MAC,
	/**< AES XCBC algorithm. */

	RTE_CRYPTO_AUTH_KASUMI_F9,
	/**< Kasumi algorithm in F9 mode. */

	RTE_CRYPTO_AUTH_MD5,
	/**< MD5 algorithm */
	RTE_CRYPTO_AUTH_MD5_HMAC,
	/**< HMAC using MD5 algorithm */

	RTE_CRYPTO_AUTH_SHA1,
	/**< 128 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA1_HMAC,
	/**< HMAC using 128 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA224,
	/**< 224 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA224_HMAC,
	/**< HMAC using 224 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA256,
	/**< 256 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA256_HMAC,
	/**< HMAC using 256 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA384,
	/**< 384 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA384_HMAC,
	/**< HMAC using 384 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA512,
	/**< 512 bit SHA algorithm. */
	RTE_CRYPTO_AUTH_SHA512_HMAC,
	/**< HMAC using 512 bit SHA algorithm. */

	RTE_CRYPTO_AUTH_SNOW3G_UIA2,
	/**< SNOW3G algorithm in UIA2 mode. */

	RTE_CRYPTO_AUTH_ZUC_EIA3,
	/**< ZUC algorithm in EIA3 mode */

	RTE_CRYPTO_AUTH_LIST_END
};

/** Symmetric Authentication / Hash Operations */
enum rte_crypto_auth_operation {
	RTE_CRYPTO_AUTH_OP_VERIFY,	/**< Verify authentication digest */
	RTE_CRYPTO_AUTH_OP_GENERATE	/**< Generate authentication digest */
};

/**
 * Authentication / Hash transform data.
 *
 * This structure contains data relating to an authentication/hash crypto
 * transforms. The fields op, algo and digest_length are common to all
 * authentication transforms and MUST be set.
 */
struct rte_crypto_auth_xform {
	enum rte_crypto_auth_operation op;
	/**< Authentication operation type */
	enum rte_crypto_auth_algorithm algo;
	/**< Authentication algorithm selection */

	struct {
		uint8_t *data;	/**< pointer to key data */
		size_t length;	/**< key length in bytes */
	} key;
	/**< Authentication key data.
	 * The authentication key length MUST be less than or equal to the
	 * block size of the algorithm. It is the callers responsibility to
	 * ensure that the key length is compliant with the standard being used
	 * (for example RFC 2104, FIPS 198a).
	 */

	uint32_t digest_length;
	/**< Length of the digest to be returned. If the verify option is set,
	 * this specifies the length of the digest to be compared for the
	 * session.
	 *
	 * If the value is less than the maximum length allowed by the hash,
	 * the result shall be truncated.  If the value is greater than the
	 * maximum length allowed by the hash then an error will be generated
	 * by *rte_cryptodev_sym_session_create* or by the
	 * *rte_cryptodev_sym_enqueue_burst* if using session-less APIs.
	 */

	uint32_t add_auth_data_length;
	/**< The length of the additional authenticated data (AAD) in bytes.
	 * The maximum permitted value is 240 bytes, unless otherwise specified
	 * below.
	 *
	 * This field must be specified when the hash algorithm is one of the
	 * following:
	 *
	 * - For SNOW3G (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2), this is the
	 *   length of the IV (which should be 16).
	 *
	 * - For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM).  In this case, this is
	 *   the length of the Additional Authenticated Data (called A, in NIST
	 *   SP800-38D).
	 *
	 * - For CCM (@ref RTE_CRYPTO_AUTH_AES_CCM).  In this case, this is
	 *   the length of the associated data (called A, in NIST SP800-38C).
	 *   Note that this does NOT include the length of any padding, or the
	 *   18 bytes reserved at the start of the above field to store the
	 *   block B0 and the encoded length.  The maximum permitted value in
	 *   this case is 222 bytes.
	 *
	 * @note
	 *  For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC) mode of operation
	 *  this field is not used and should be set to 0. Instead the length
	 *  of the AAD data is specified in the message length to hash field of
	 *  the rte_crypto_sym_op_data structure.
	 */
};

/** Crypto transformation types */
enum rte_crypto_sym_xform_type {
	RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED = 0,	/**< No xform specified */
	RTE_CRYPTO_SYM_XFORM_AUTH,		/**< Authentication xform */
	RTE_CRYPTO_SYM_XFORM_CIPHER		/**< Cipher xform  */
};

/**
 * Symmetric crypto transform structure.
 *
 * This is used to specify the crypto transforms required, multiple transforms
 * can be chained together to specify a chain transforms such as authentication
 * then cipher, or cipher then authentication. Each transform structure can
 * hold a single transform, the type field is used to specify which transform
 * is contained within the union
 */
struct rte_crypto_sym_xform {
	struct rte_crypto_sym_xform *next;
	/**< next xform in chain */
	enum rte_crypto_sym_xform_type type
	; /**< xform type */
	union {
		struct rte_crypto_auth_xform auth;
		/**< Authentication / hash xform */
		struct rte_crypto_cipher_xform cipher;
		/**< Cipher xform */
	};
};

/**
 * Crypto operation session type. This is used to specify whether a crypto
 * operation has session structure attached for immutable parameters or if all
 * operation information is included in the operation data structure.
 */
enum rte_crypto_sym_op_sess_type {
	RTE_CRYPTO_SYM_OP_WITH_SESSION,	/**< Session based crypto operation */
	RTE_CRYPTO_SYM_OP_SESSIONLESS	/**< Session-less crypto operation */
};

struct rte_cryptodev_sym_session;

/**
 * Symmetric Cryptographic Operation.
 *
 * This structure contains data relating to performing symmetric cryptographic
 * processing on a referenced mbuf data buffer.
 *
 * When a symmetric crypto operation is enqueued with the device for processing
 * it must have a valid *rte_mbuf* structure attached, via m_src parameter,
 * which contains the source data which the crypto operation is to be performed
 * on.
 */
struct rte_crypto_sym_op {
	struct rte_mbuf *m_src;	/**< source mbuf */
	struct rte_mbuf *m_dst;	/**< destination mbuf */

	enum rte_crypto_sym_op_sess_type sess_type;

	union {
		struct rte_cryptodev_sym_session *session;
		/**< Handle for the initialised session context */
		struct rte_crypto_sym_xform *xform;
		/**< Session-less API crypto operation parameters */
	};

	struct {
		struct {
			uint32_t offset;
			 /**< Starting point for cipher processing, specified
			  * as number of bytes from start of data in the source
			  * buffer. The result of the cipher operation will be
			  * written back into the output buffer starting at
			  * this location.
			  *
			  * @note
			  * For Snow3G @ RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
			  * this field should be in bits.
			  */

			uint32_t length;
			 /**< The message length, in bytes, of the source buffer
			  * on which the cryptographic operation will be
			  * computed. This must be a multiple of the block size
			  * if a block cipher is being used. This is also the
			  * same as the result length.
			  *
			  * @note
			  * In the case of CCM @ref RTE_CRYPTO_AUTH_AES_CCM,
			  * this value should not include the length of the
			  * padding or the length of the MAC; the driver will
			  * compute the actual number of bytes over which the
			  * encryption will occur, which will include these
			  * values.
			  *
			  * @note
			  * For AES-GMAC @ref RTE_CRYPTO_AUTH_AES_GMAC, this
			  * field should be set to 0.
			  *
			  * @note
			  * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UEA2
			  * this field should be in bits.
			  */
		} data; /**< Data offsets and length for ciphering */

		struct {
			uint8_t *data;
			/**< Initialisation Vector or Counter.
			 *
			 * - For block ciphers in CBC or F8 mode, or for Kasumi
			 * in F8 mode, or for SNOW3G in UEA2 mode, this is the
			 * Initialisation Vector (IV) value.
			 *
			 * - For block ciphers in CTR mode, this is the counter.
			 *
			 * - For GCM mode, this is either the IV (if the length
			 * is 96 bits) or J0 (for other sizes), where J0 is as
			 * defined by NIST SP800-38D. Regardless of the IV
			 * length, a full 16 bytes needs to be allocated.
			 *
			 * - For CCM mode, the first byte is reserved, and the
			 * nonce should be written starting at &iv[1] (to allow
			 * space for the implementation to write in the flags
			 * in the first byte). Note that a full 16 bytes should
			 * be allocated, even though the length field will
			 * have a value less than this.
			 *
			 * - For AES-XTS, this is the 128bit tweak, i, from
			 * IEEE Std 1619-2007.
			 *
			 * For optimum performance, the data pointed to SHOULD
			 * be 8-byte aligned.
			 */
			phys_addr_t phys_addr;
			uint16_t length;
			/**< Length of valid IV data.
			 *
			 * - For block ciphers in CBC or F8 mode, or for Kasumi
			 * in F8 mode, or for SNOW3G in UEA2 mode, this is the
			 * length of the IV (which must be the same as the
			 * block length of the cipher).
			 *
			 * - For block ciphers in CTR mode, this is the length
			 * of the counter (which must be the same as the block
			 * length of the cipher).
			 *
			 * - For GCM mode, this is either 12 (for 96-bit IVs)
			 * or 16, in which case data points to J0.
			 *
			 * - For CCM mode, this is the length of the nonce,
			 * which can be in the range 7 to 13 inclusive.
			 */
		} iv;	/**< Initialisation vector parameters */
	} cipher;

	struct {
		struct {
			uint32_t offset;
			 /**< Starting point for hash processing, specified as
			  * number of bytes from start of packet in source
			  * buffer.
			  *
			  * @note
			  * For CCM and GCM modes of operation, this field is
			  * ignored. The field @ref aad field
			  * should be set instead.
			  *
			  * @note For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC)
			  * mode of operation, this field specifies the start
			  * of the AAD data in the source buffer.
			  *
			  * @note
			  * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UIA2
			  * this field should be in bits.
			  */

			uint32_t length;
			 /**< The message length, in bytes, of the source
			  * buffer that the hash will be computed on.
			  *
			  * @note
			  * For CCM and GCM modes of operation, this field is
			  * ignored. The field @ref aad field should be set
			  * instead.
			  *
			  * @note
			  * For AES-GMAC @ref RTE_CRYPTO_AUTH_AES_GMAC mode
			  * of operation, this field specifies the length of
			  * the AAD data in the source buffer.
			  *
			  * @note
			  * For Snow3G @ RTE_CRYPTO_AUTH_SNOW3G_UIA2
			  * this field should be in bits.
			  */
		} data; /**< Data offsets and length for authentication */

		struct {
			uint8_t *data;
			/**< If this member of this structure is set this is a
			 * pointer to the location where the digest result
			 * should be inserted (in the case of digest generation)
			 * or where the purported digest exists (in the case of
			 * digest verification).
			 *
			 * At session creation time, the client specified the
			 * digest result length with the digest_length member
			 * of the @ref rte_crypto_auth_xform structure. For
			 * physical crypto devices the caller must allocate at
			 * least digest_length of physically contiguous memory
			 * at this location.
			 *
			 * For digest generation, the digest result will
			 * overwrite any data at this location.
			 *
			 * @note
			 * For GCM (@ref RTE_CRYPTO_AUTH_AES_GCM), for
			 * "digest result" read "authentication tag T".
			 *
			 * If this member is not set the digest result is
			 * understood to be in the destination buffer for
			 * digest generation, and in the source buffer for
			 * digest verification. The location of the digest
			 * result in this case is immediately following the
			 * region over which the digest is computed.
			 */
			phys_addr_t phys_addr;
			/**< Physical address of digest */
			uint16_t length;
			/**< Length of digest */
		} digest; /**< Digest parameters */

		struct {
			uint8_t *data;
			/**< Pointer to Additional Authenticated Data (AAD)
			 * needed for authenticated cipher mechanisms (CCM and
			 * GCM), and to the IV for SNOW3G authentication
			 * (@ref RTE_CRYPTO_AUTH_SNOW3G_UIA2). For other
			 * authentication mechanisms this pointer is ignored.
			 *
			 * The length of the data pointed to by this field is
			 * set up for the session in the @ref
			 * rte_crypto_auth_xform structure as part of the @ref
			 * rte_cryptodev_sym_session_create function call.
			 * This length must not exceed 240 bytes.
			 *
			 * Specifically for CCM (@ref RTE_CRYPTO_AUTH_AES_CCM),
			 * the caller should setup this field as follows:
			 *
			 * - the nonce should be written starting at an offset
			 * of one byte into the array, leaving room for the
			 * implementation to write in the flags to the first
			 *  byte.
			 *
			 * - the additional  authentication data itself should
			 * be written starting at an offset of 18 bytes into
			 * the array, leaving room for the length encoding in
			 * the first two bytes of the second block.
			 *
			 * - the array should be big enough to hold the above
			 *  fields, plus any padding to round this up to the
			 *  nearest multiple of the block size (16 bytes).
			 *  Padding will be added by the implementation.
			 *
			 * Finally, for GCM (@ref RTE_CRYPTO_AUTH_AES_GCM), the
			 * caller should setup this field as follows:
			 *
			 * - the AAD is written in starting at byte 0
			 * - the array must be big enough to hold the AAD, plus
			 * any space to round this up to the nearest multiple
			 * of the block size (16 bytes).
			 *
			 * @note
			 * For AES-GMAC (@ref RTE_CRYPTO_AUTH_AES_GMAC) mode of
			 * operation, this field is not used and should be set
			 * to 0. Instead the AAD data should be placed in the
			 * source buffer.
			 */
			phys_addr_t phys_addr;	/**< physical address */
			uint16_t length;	/**< Length of digest */
		} aad;
		/**< Additional authentication parameters */
	} auth;
} __rte_cache_aligned;

/**
 * Reset the fields of a symmetric operation to their default values.
 *
 * @param	op	The crypto operation to be reset.
 */
static inline void
__rte_crypto_sym_op_reset(struct rte_crypto_sym_op *op)
{
	memset(op, 0, sizeof(*op));

	op->sess_type = RTE_CRYPTO_SYM_OP_SESSIONLESS;
}

/**
 * Allocate space for symmetric crypto xforms in the private data space of the
 * crypto operation. This also defaults the crypto xform type to
 * RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED and configures the chaining of the xforms
 * in the crypto operation
 *
 * @return
 * - On success returns pointer to first crypto xform in crypto operations chain
 * - On failure returns NULL
 */
static inline struct rte_crypto_sym_xform *
__rte_crypto_sym_op_sym_xforms_alloc(struct rte_crypto_sym_op *sym_op,
		void *priv_data, uint8_t nb_xforms)
{
	struct rte_crypto_sym_xform *xform;

	sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;

	do {
		xform->type = RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED;
		xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
	} while (xform);

	return sym_op->xform;
}

/**
 * Attach a session to a symmetric crypto operation
 *
 * @param	sym_op	crypto operation
 * @param	sess	cryptodev session
 */
static inline int
__rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op,
		struct rte_cryptodev_sym_session *sess)
{
	sym_op->session = sess;
	sym_op->sess_type = RTE_CRYPTO_SYM_OP_WITH_SESSION;

	return 0;
}

#ifdef __cplusplus
}
#endif

#endif /* _RTE_CRYPTO_SYM_H_ */


text:
Android Intents
===============

A small library which will save you from writing the same intent creation code again and again for the most simple tasks. I found myself writing my own
library to create some common intents I was using across projects, so we decided to push that code to a project everyone could contribute to.

You can find a comprehensive list of all intents that can be used in the sample application. Here are some sample methods to show you how to do some
simple things:

- Send emails:

    `startActivity( EmailIntents.newEmailIntent( "me@example.com", "My subject", "Hey there!" ) );`

- Use the phone:

    `startActivity( PhoneIntents.newCallNumberIntent( "123456789" ) );`

    `startActivity( PhoneIntents.newSmsIntent( "123456789", "Hi!" ) );`

- Display an address on a map:

    `startActivity( GeoIntents.newMapsIntent( "Musée du Louvre 75058 Paris", "Le Louvre" ) );`

- Open the navigation app for a destination:

    `startActivity( GeoIntents.newNavigationIntent( "1 rue du Louvre 75058 Paris, France" ) );`

- Open your application on the available market application (be it Google Play, Amazon, ...):

    `startActivity( SystemIntents.newMarketForAppIntent( getApplicationContext() );`

This project has now been initiated with a few intents but we are looking forward to integrating your own intents to ease each developer's life.

Some rules for contributors:

- If the intent you are creating does not fit into any of the provided utility classes (EmailIntents, GeoIntents, ...), do not hesitate to create your own.
Those classes are meant to be simple factories with only static methods.
- If the intent you are creating is specific to an application (like a particular Twitter client), please put the utility class in a sub-package named after
that application.

## Usage

The easiest way to get the library included in your project is by using Gradle. Simply add the following line to your dependencies block:

    dependencies {
        compile 'com.marvinlabs:android-intents:1.3.+@aar'
    }

Of course, you can replace the version number by whichever version you need (you can have a look at this repository's tags to know which is the latest).

## About Vincent & MarvinLabs

I am a freelance developer located in Biarritz, France. You can [have a look at my website](http://vincentprat.info) to get to know me a little better. If you want to follow me, here are some links:

* [Follow me on Twitter](http://twitter.com/vpratfr)
* [Follow me on Google+](https://plus.google.com/+VincentPrat)
* [Follow me on Facebook](http://www.facebook.com/vpratfr)

MarvinLabs is my digital studio specialised in native mobile applications and web sites. You can [browse our website](http://www.marvinlabs.com) to get to know us a little better. If you want to get updates about our work, you can also:

* [Follow us on Twitter](http://twitter.com/marvinlabs)
* [Follow us on Google+](https://plus.google.com/+Marvinlabs)
* [Follow us on Facebook](http://www.facebook.com/studio.marvinlabs)

## Change log

### 1.3.0 (2013-06-23)

- [New] "map" intent on coordinates
- [New] "navigate to" intents

### 1.2.0 (2013-06-19)

- [New] a demo
- [New] Android Studio support
- [New] maven repository support

### 1.1 (2013-06-19)

- [New] intents to open the app markets


text:
namespace net {

namespace ct {

struct SignedEntryData;

// Extracts a SignedCertificateTimestampList that has been embedded within a
// leaf cert as an X.509v3 extension with the OID 1.3.6.1.4.1.11129.2.4.2.
// If the extension is present, returns true, updating |*sct_list| to contain
// the encoded list, minus the DER encoding necessary for the extension.
// |*sct_list| can then be further decoded with ct::DecodeSCTList
NET_EXPORT_PRIVATE bool ExtractEmbeddedSCTList(const CRYPTO_BUFFER* cert,
                                               std::string* sct_list);

// Obtains a PrecertChain log entry for |leaf|, an X.509v3 certificate that
// contains an X.509v3 extension with the OID 1.3.6.1.4.1.11129.2.4.2. On
// success, fills |*result| with the data for a PrecertChain log entry and
// returns true.
// The filled |*result| should be verified using ct::CTLogVerifier::Verify
// Note: If |leaf| does not contain the required extension, it is treated as
// a failure.
NET_EXPORT_PRIVATE bool GetPrecertSignedEntry(const CRYPTO_BUFFER* leaf,
                                              const CRYPTO_BUFFER* issuer,
                                              SignedEntryData* result);

// Obtains an X509Chain log entry for |leaf|, an X.509v3 certificate that
// is not expected to contain an X.509v3 extension with the OID
// 1.3.6.1.4.1.11129.2.4.2 (meaning a certificate without an embedded SCT).
// On success, fills |result| with the data for an X509Chain log entry and
// returns true.
// The filled |*result| should be verified using ct::CTLogVerifier::Verify
NET_EXPORT_PRIVATE bool GetX509SignedEntry(const CRYPTO_BUFFER* leaf,
                                           SignedEntryData* result);

// Extracts a SignedCertificateTimestampList that has been embedded within
// an OCSP response as an extension with the OID 1.3.6.1.4.1.11129.2.4.5.
// If the extension is present, and the response matches the issuer and
// serial number, returns true, updating |*sct_list| to contain
// the encoded list, minus the DER encoding necessary for the extension.
// |*sct_list| can then be further decoded with ct::DecodeSCTList.
NET_EXPORT_PRIVATE bool ExtractSCTListFromOCSPResponse(
    const CRYPTO_BUFFER* issuer,
    const std::string& cert_serial_number,
    base::StringPiece ocsp_response,
    std::string* sct_list);

}  // namespace ct

}  // namespace net

#endif  // NET_CERT_CT_OBJECTS_EXTRACTOR_H_