Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.infinispan.client.hotrod.configuration;
  
  import java.util.HashMap;
  import java.util.Map;
  
 
AuthenticationConfigurationBuilder.

Author(s):
Tristan Tarrant
Since:
7.0
 
    private static final Log log = LogFactory.getLog(AuthenticationConfigurationBuilder.class);
    private boolean enabled = false;
    private String serverName;
    private Map<StringStringsaslProperties = new HashMap<StringString>();
    private String saslMechanism;
    private Subject clientSubject;
 
       super(builder);
    }

   
Specifies a javax.security.auth.callback.CallbackHandler to be used during the authentication handshake. The javax.security.auth.callback.Callbacks that need to be handled are specific to the chosen SASL mechanism.
 
       this. = callbackHandler;
       return this;
    }

   
Configures whether authentication should be enabled or not
 
    public AuthenticationConfigurationBuilder enabled(boolean enabled) {
       this. = enabled;
       return this;
    }

   
Enables authentication
 
       this. = true;
       return this;
    }

   
Disables authentication
 
       this. = false;
       return this;
    }

   
Selects the SASL mechanism to use for the connection to the server
 
    public AuthenticationConfigurationBuilder saslMechanism(String saslMechanism) {
       this. = saslMechanism;
       return this;
    }

   
Sets the SASL properties
 
    public AuthenticationConfigurationBuilder saslProperties(Map<StringStringsaslProperties) {
       this. = saslProperties;
       return this;
    }

   
Sets the SASL QOP property. If multiple values are specified they will determine preference order
 
       StringBuilder s = new StringBuilder();
       for(int i=0; i < qop.lengthi++) {
          if (i > 0) {
             s.append(",");
          }
          s.append(qop[i].toString());
       }
       this..put(.s.toString());
       return this;
    }

   
Sets the SASL strength property. If multiple values are specified they will determine preference order
      StringBuilder s = new StringBuilder();
      for(int i=0; i < strength.lengthi++) {
         if (i > 0) {
            s.append(",");
         }
         s.append(strength[i].toString());
      }
      this..put(.s.toString());
      return this;
   }

   
Sets the name of the server as expected by the SASL protocol
      this. = serverName;
      return this;
   }

   
Sets the client subject, necessary for those SASL mechanisms which require it to access client credentials (i.e. GSSAPI)
      this. = clientSubject;
      return this;
   }
   }
   public Builder<?> read(AuthenticationConfiguration template) {
      this. = template.callbackHandler();
      this. = template.clientSubject();
      this. = template.enabled();
      this. = template.saslMechanism();
      this. = template.saslProperties();
      this. = template.serverName();
      return this;
   }
   public void validate() {
      if () {
         if ( == null &&  == null) {
            throw .invalidCallbackHandler();
         }
         if ( == null) {
            throw .invalidSaslMechanism();
         }
      }
   }
New to GrepCode? Check out our FAQ X