java.lang.Object
org.eclipse.milo.opcua.sdk.client.identity.UsernameProvider
All Implemented Interfaces:
IdentityProvider

public class UsernameProvider extends Object implements IdentityProvider
An IdentityProvider that chooses a UserTokenPolicy with UserTokenType.UserName.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UsernameProvider(String username, String password)
    Construct a UsernameProvider that does not validate the remote certificate and selects the first available UserTokenPolicy with UserTokenType.UserName.
    UsernameProvider(String username, String password, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator)
    Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects the first available UserTokenPolicy with UserTokenType.UserName.
    UsernameProvider(String username, String password, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator, Function<List<org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy>,org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy> policyChooser)
    Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects ta UserTokenPolicy using policyChooser.
    UsernameProvider(String username, Supplier<byte[]> passwordSupplier)
    Construct a UsernameProvider that does not validate the remote certificate and selects the first available UserTokenPolicy with UserTokenType.UserName.
    UsernameProvider(String username, Supplier<byte[]> passwordSupplier, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator)
    Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects the first available UserTokenPolicy with UserTokenType.UserName.
    UsernameProvider(String username, Supplier<byte[]> passwordSupplier, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator, Function<List<org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy>,org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy> policyChooser)
    Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects ta UserTokenPolicy using policyChooser.
  • Method Summary

    Modifier and Type
    Method
    Description
    getIdentityToken(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription endpoint, org.eclipse.milo.opcua.stack.core.types.builtin.ByteString serverNonce)
    Return the UserIdentityToken and SignatureData (if applicable for the token) to use when activating a session.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UsernameProvider

      public UsernameProvider(String username, String password)
      Construct a UsernameProvider that does not validate the remote certificate and selects the first available UserTokenPolicy with UserTokenType.UserName.
      Parameters:
      username - the username to authenticate with.
      password - the password to authenticate with.
    • UsernameProvider

      public UsernameProvider(String username, String password, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator)
      Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects the first available UserTokenPolicy with UserTokenType.UserName.
      Parameters:
      username - the username to authenticate with.
      password - the password to authenticate with.
      certificateValidator - the CertificateValidator used to validate the remote certificate.
    • UsernameProvider

      public UsernameProvider(String username, String password, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator, Function<List<org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy>,org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy> policyChooser)
      Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects ta UserTokenPolicy using policyChooser.

      Useful if the server might return more than one UserTokenPolicy with UserTokenType.UserName.

      Parameters:
      username - the username to authenticate with.
      password - the password to authenticate with.
      certificateValidator - the CertificateValidator used to validate the remote certificate.
      policyChooser - a function that selects a UserTokenPolicy to use. The policy list is guaranteed to be non-null and non-empty.
    • UsernameProvider

      public UsernameProvider(String username, Supplier<byte[]> passwordSupplier)
      Construct a UsernameProvider that does not validate the remote certificate and selects the first available UserTokenPolicy with UserTokenType.UserName.
      Parameters:
      username - the username to authenticate with.
      passwordSupplier - a supplier providing the password bytes. The supplied byte[] will be zeroed out after being retrieved and used.
    • UsernameProvider

      public UsernameProvider(String username, Supplier<byte[]> passwordSupplier, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator)
      Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects the first available UserTokenPolicy with UserTokenType.UserName.
      Parameters:
      username - the username to authenticate with.
      passwordSupplier - a supplier providing the password bytes. The supplied byte[] will be zeroed out after being retrieved and used.
      certificateValidator - the CertificateValidator used to validate the remote certificate.
    • UsernameProvider

      public UsernameProvider(String username, Supplier<byte[]> passwordSupplier, org.eclipse.milo.opcua.stack.core.security.CertificateValidator certificateValidator, Function<List<org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy>,org.eclipse.milo.opcua.stack.core.types.structured.UserTokenPolicy> policyChooser)
      Construct a UsernameProvider that validates the remote certificate using certificateValidator and selects ta UserTokenPolicy using policyChooser.

      Useful if the server might return more than one UserTokenPolicy with UserTokenType.UserName.

      Parameters:
      username - the username to authenticate with.
      passwordSupplier - a supplier providing the password bytes. The supplied byte[] will be zeroed out after being retrieved and used.
      certificateValidator - the CertificateValidator used to validate the remote certificate.
      policyChooser - a function that selects a UserTokenPolicy to use. The policy list is guaranteed to be non-null and non-empty.
  • Method Details

    • getIdentityToken

      public SignedIdentityToken getIdentityToken(org.eclipse.milo.opcua.stack.core.types.structured.EndpointDescription endpoint, org.eclipse.milo.opcua.stack.core.types.builtin.ByteString serverNonce) throws Exception
      Description copied from interface: IdentityProvider
      Return the UserIdentityToken and SignatureData (if applicable for the token) to use when activating a session.
      Specified by:
      getIdentityToken in interface IdentityProvider
      Parameters:
      endpoint - the EndpointDescription being connected to.
      Returns:
      a SignedIdentityToken containing the UserIdentityToken and SignatureData.
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class Object