Package org.zeromq

Class ZAuth

java.lang.Object
org.zeromq.ZAuth
All Implemented Interfaces:
Closeable, AutoCloseable

public class ZAuth extends Object implements 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
  • Field Details

  • Constructor Details

    • 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, ZCertStore.Fingerprinter fingerprinter)
    • ZAuth

      public ZAuth(ZContext ctx, String actorName)
    • ZAuth

      public ZAuth(ZContext ctx, String actorName, Map<String,ZAuth.Auth> auths)
  • Method Details

    • makeSimpleAuths

      private static Map<String,ZAuth.Auth> makeSimpleAuths()
    • curveVariant

      private static Map<String,ZAuth.Auth> curveVariant(ZCertStore.Fingerprinter fingerprinter)
    • 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(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(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(String domain, 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(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 IOException
      Destructor.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • destroy

      public void destroy()
      Destructor.
    • send

      protected ZAuth send(String command, String... datas)