Package com.hazelcast.config.security
Class SimpleAuthenticationConfig
- java.lang.Object
-
- com.hazelcast.config.security.AbstractClusterLoginConfig<SimpleAuthenticationConfig>
-
- com.hazelcast.config.security.SimpleAuthenticationConfig
-
- All Implemented Interfaces:
AuthenticationConfig
public class SimpleAuthenticationConfig extends AbstractClusterLoginConfig<SimpleAuthenticationConfig>
Typed authentication configuration forSimplePropertiesLoginModule
. The user configuration (username, password, and assigned roles) is directly part of the configuration object.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimpleAuthenticationConfig.UserDto
Helper immutable object representing user attributes (i.e.
-
Constructor Summary
Constructors Constructor Description SimpleAuthenticationConfig()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleAuthenticationConfig
addUser(java.lang.String username, SimpleAuthenticationConfig.UserDto userDto)
Adds one user to the configuration.SimpleAuthenticationConfig
addUser(java.lang.String username, java.lang.String password, java.lang.String... roles)
Adds one user to the configuration.LoginModuleConfig[]
asLoginModuleConfigs()
Converts current configuration to stack of login modules.boolean
equals(java.lang.Object obj)
java.lang.String
getPassword(java.lang.String username)
Return the configured password for given username.java.util.Set<java.lang.String>
getRoles(java.lang.String username)
Returns role names assigned to the given user.java.lang.String
getRoleSeparator()
Returns the custom role separator (when set).java.util.Set<java.lang.String>
getUsernames()
Returns names of users registered in the configuration.int
hashCode()
protected java.util.Properties
initLoginModuleProperties()
protected static java.lang.String
requireNonEmpty(java.lang.String str, java.lang.String message)
protected SimpleAuthenticationConfig
self()
SimpleAuthenticationConfig
setRoleSeparator(java.lang.String roleSeparator)
Allows to use a custom role separator in the configuration.SimpleAuthenticationConfig
setUserMap(java.util.Map<java.lang.String,SimpleAuthenticationConfig.UserDto> map)
Replaces the users with ones from the given map.java.lang.String
toString()
-
Methods inherited from class com.hazelcast.config.security.AbstractClusterLoginConfig
getSkipEndpoint, getSkipIdentity, getSkipRole, setIfConfigured, setIfConfigured, setIfConfigured, setSkipEndpoint, setSkipIdentity, setSkipRole
-
-
-
-
Method Detail
-
addUser
public SimpleAuthenticationConfig addUser(@Nonnull java.lang.String username, @Nonnull java.lang.String password, java.lang.String... roles)
Adds one user to the configuration.- Parameters:
username
- usernamepassword
- user's passwordroles
- roles assigned to the user- Returns:
- this object
-
addUser
public SimpleAuthenticationConfig addUser(@Nonnull java.lang.String username, @Nonnull SimpleAuthenticationConfig.UserDto userDto)
Adds one user to the configuration.- Parameters:
username
- usernameuserDto
- user's attributes- Returns:
- this object
-
setRoleSeparator
public SimpleAuthenticationConfig setRoleSeparator(@Nullable java.lang.String roleSeparator)
Allows to use a custom role separator in the configuration. It's important in case when a role name contains the default separator "," (comma).- Parameters:
roleSeparator
- new separator- Returns:
- this object
-
getRoleSeparator
@Nullable public java.lang.String getRoleSeparator()
Returns the custom role separator (when set). If no custom one is used,null
is returned and default separator is used ("," - comma).- Returns:
- the separator
-
getUsernames
@Nonnull public java.util.Set<java.lang.String> getUsernames()
Returns names of users registered in the configuration.- Returns:
- set of usernames
-
getPassword
public java.lang.String getPassword(@Nonnull java.lang.String username)
Return the configured password for given username.- Parameters:
username
- username- Returns:
- user's password or null if such user doesn't exist
-
getRoles
public java.util.Set<java.lang.String> getRoles(@Nonnull java.lang.String username)
Returns role names assigned to the given user.- Parameters:
username
- username- Returns:
- configured roles or null if the user doesn't exist
-
setUserMap
public SimpleAuthenticationConfig setUserMap(@Nullable java.util.Map<java.lang.String,SimpleAuthenticationConfig.UserDto> map)
Replaces the users with ones from the given map.- Parameters:
map
- map of new users- Returns:
- this object
-
initLoginModuleProperties
protected java.util.Properties initLoginModuleProperties()
- Overrides:
initLoginModuleProperties
in classAbstractClusterLoginConfig<SimpleAuthenticationConfig>
-
asLoginModuleConfigs
public LoginModuleConfig[] asLoginModuleConfigs()
Description copied from interface:AuthenticationConfig
Converts current configuration to stack of login modules.- Returns:
- login modules stack
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractClusterLoginConfig<SimpleAuthenticationConfig>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classAbstractClusterLoginConfig<SimpleAuthenticationConfig>
-
self
protected SimpleAuthenticationConfig self()
- Specified by:
self
in classAbstractClusterLoginConfig<SimpleAuthenticationConfig>
-
requireNonEmpty
protected static java.lang.String requireNonEmpty(java.lang.String str, java.lang.String message)
-
-