public class UsernamePasswordAuthenticatorBuilder extends AbstractParent<JavaMailBuilder> implements Builder<javax.mail.Authenticator>
You can define direct values for username and password:
.username("foo") .password("bar")Or you can specify one or several property keys:
.username("${ogham.email.javamail.authenticator.username}") .password("${ogham.email.javamail.authenticator.password}")The evaluation of the properties will be evaluated when
build()
is
called (by default).
If updatable(Boolean)
is set to true, it means that properties are
not evaluated when calling build()
. Instead, the property keys are
kept for later evaluation. The evaluation will then be done each time an
authentication to the mail server is started.
parent
Constructor and Description |
---|
UsernamePasswordAuthenticatorBuilder(JavaMailBuilder parent,
BuildContext buildContext)
Initializes the parent instance for fluent chaining (when method
AbstractParent.and() is called). |
Modifier and Type | Method and Description |
---|---|
javax.mail.Authenticator |
build()
Instantiate and configures the instance.
|
ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,String> |
password()
Set the password to use for the authentication.
|
UsernamePasswordAuthenticatorBuilder |
password(String password)
Set the password to use for the authentication.
|
ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,Boolean> |
updatable()
If set to true, it means that properties are not evaluated when calling
build() . |
UsernamePasswordAuthenticatorBuilder |
updatable(Boolean updatable)
If set to true, it means that properties are not evaluated when calling
build() . |
ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,String> |
username()
Set the username to use for the authentication.
|
UsernamePasswordAuthenticatorBuilder |
username(String username)
Set the username to use for the authentication.
|
and
public UsernamePasswordAuthenticatorBuilder(JavaMailBuilder parent, BuildContext buildContext)
AbstractParent.and()
is called).parent
- the parent builderbuildContext
- for registering instances and property evaluationpublic UsernamePasswordAuthenticatorBuilder username(String username)
The value set using this method takes precedence over any property and
default value configured using username()
.
.username("my-username") .username() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-username")
.username("my-username") .username() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-username")In both cases,
username("my-username")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
username
- the usernamepublic ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,String> username()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.username() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-username")
Non-null value set using username(String)
takes precedence over
property values and default value.
.username("my-username") .username() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-username")The value
"my-username"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public UsernamePasswordAuthenticatorBuilder password(String password)
The value set using this method takes precedence over any property and
default value configured using password()
.
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")In both cases,
password("my-password")
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
password
- the passowrdpublic ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,String> password()
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")
Non-null value set using password(String)
takes precedence over
property values and default value.
.password("my-password") .password() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue("default-password")The value
"my-password"
is used regardless of the value of the
properties and default value.
See ConfigurationValueBuilder
for more information.
public UsernamePasswordAuthenticatorBuilder updatable(Boolean updatable)
build()
. Instead, the property keys are kept for later
evaluation. The evaluation will then be done each time an authentication
to the mail server is started.
The value set using this method takes precedence over any property and
default value configured using updatable()
.
.updatable(true) .updatable() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(false)
.updatable(true) .updatable() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(false)In both cases,
updatable(true)
is used.
If this method is called several times, only the last value is used.
If null
value is set, it is like not setting a value at all. The
property/default value configuration is applied.
updatable
- true to evaluate expression when connecting to serverpublic ConfigurationValueBuilder<UsernamePasswordAuthenticatorBuilder,Boolean> updatable()
build()
. Instead, the property keys are kept for later
evaluation. The evaluation will then be done each time an authentication
to the mail server is started.
This method is mainly used by Configurer
s to register some
property keys and/or a default value. The aim is to let developer be able
to externalize its configuration (using system properties, configuration
file or anything else). If the developer doesn't configure any value for
the registered properties, the default value is used (if set).
.updatable() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(false)
Non-null value set using updatable(Boolean)
takes precedence
over property values and default value.
.updatable(true) .updatable() .properties("${custom.property.high-priority}", "${custom.property.low-priority}") .defaultValue(false)The value
true
is used regardless of the value of the properties
and default value.
See ConfigurationValueBuilder
for more information.
Copyright © 2021. All rights reserved.