Package org.zeromq

Class ZAuth

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class ZAuth
    extends java.lang.Object
    implements java.io.Closeable
    A ZAuth actor takes over authentication for all incoming connections in its context. You can whitelist or blacklist peers based on IP address, and define policies for securing PLAIN, CURVE, and GSSAPI connections.
    Note that libzmq provides four levels of security: default NULL (which ZAuth does not see), and authenticated NULL, PLAIN, and CURVE, which ZAuth can see.
    Based on zauth.c in czmq
    • Constructor Detail

      • ZAuth

        public ZAuth​(ZContext ctx)
        Install authentication for the specified context. Note that until you add policies, all incoming NULL connections are allowed (classic ZeroMQ behavior), and all PLAIN and CURVE connections are denied.
        Parameters:
        ctx -
      • ZAuth

        public ZAuth​(ZContext ctx,
                     java.lang.String actorName)
      • ZAuth

        public ZAuth​(ZContext ctx,
                     java.lang.String actorName,
                     java.util.Map<java.lang.String,​ZAuth.Auth> auths)
    • Method Detail

      • makeSimpleAuths

        private static java.util.Map<java.lang.String,​ZAuth.Auth> makeSimpleAuths()
      • setVerbose

        public ZAuth setVerbose​(boolean verbose)
        Enable verbose tracing of commands and activity
        Parameters:
        verbose -
      • verbose

        public ZAuth verbose​(boolean verbose)
      • allow

        public ZAuth allow​(java.lang.String address)
        Allow (whitelist) a single IP address. For NULL, all clients from this address will be accepted. For PLAIN and CURVE, they will be allowed to continue with authentication. You can call this method multiple times to whitelist multiple IP addresses. If you whitelist a single address, any non-whitelisted addresses are treated as blacklisted.
        Parameters:
        address -
      • deny

        public ZAuth deny​(java.lang.String address)
        Deny (blacklist) a single IP address. For all security mechanisms, this rejects the connection without any further authentication. Use either a whitelist, or a blacklist, not not both. If you define both a whitelist and a blacklist, only the whitelist takes effect.
        Parameters:
        address -
      • configurePlain

        public ZAuth configurePlain​(java.lang.String domain,
                                    java.lang.String filename)
        Configure PLAIN authentication for a given domain. PLAIN authentication uses a plain-text password file. To cover all domains, use "*". You can modify the password file at any time; it is reloaded automatically.
        Parameters:
        domain -
        filename -
      • configureCurve

        public ZAuth configureCurve​(java.lang.String location)
        Configure CURVE authentication
        Parameters:
        location - Can be ZAuth.CURVE_ALLOW_ANY or a directory with public-keys that will be accepted
      • replies

        public ZAuth replies​(boolean enable)
      • nextReply

        public ZAuth.ZapReply nextReply()
        Retrieves the next ZAP reply.
        Returns:
        the next reply or null if the actor is closed.
      • nextReply

        public ZAuth.ZapReply nextReply​(boolean wait)
        Retrieves the next ZAP reply.
        Parameters:
        wait - true to wait for the next reply, false to immediately return if there is no next reply.
        Returns:
        the next reply or null if the actor is closed or if there is no next reply yet.
      • nextReply

        public ZAuth.ZapReply nextReply​(int timeout)
        Retrieves the next ZAP reply.
        Parameters:
        timeout - the timeout in milliseconds to wait for a reply before giving up and returning null.
        Returns:
        the next reply or null if the actor is closed or if there is no next reply after the elapsed timeout.
      • close

        public void close()
                   throws java.io.IOException
        Destructor.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • destroy

        public void destroy()
        Destructor.
      • send

        protected ZAuth send​(java.lang.String command,
                             java.lang.String... datas)