Class LoginConfigurationImpl
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.auth.LoginConfigurationImpl
-
- All Implemented Interfaces:
LoginConfiguration,LoginConfigurationEx,LoginConfigurationUpdate,XmlExternalizable
public class LoginConfigurationImpl extends Object implements LoginConfigurationEx
- Author:
- Pavel.Sher Date: 22.03.2006
-
-
Field Summary
Fields Modifier and Type Field Description static StringALLOWEDstatic StringAUTH_MODULEstatic StringAUTH_MODULESstatic StringBUILD_AUTHstatic StringBUILD_AUTH_MODEstatic StringGRACE_PERIOD_EXPIRATION_TIMEstatic StringGUEST_LOGINstatic StringGUEST_USERNAMEstatic StringJAAS_NAMEstatic StringKEYstatic StringLOGIN_DESCRIPTIONstatic StringLOGIN_FORMstatic StringLOGIN_FORM_COLLAPSEDstatic StringPROPERTYstatic StringTWO_FACTOR_AUTHstatic StringTYPE-
Fields inherited from interface jetbrains.buildServer.serverSide.auth.LoginConfiguration
DEFAULT_GUEST_USERNAME
-
-
Constructor Summary
Constructors Constructor Description LoginConfigurationImpl(UserModelEx userModel, CriticalErrors criticalErrors, ConfigHistoryManager configHistoryManager, AuditLogFactory auditLogFactory, ServerPaths serverPaths, SecurityContextEx securityContext)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends AuthModuleType>
AuthModule<T>addAuthModule(T authModuleType, Map<String,String> properties)Adds specified auth module with properties to list of configured auth modules.AuthModule<LoginModuleDescriptor>addDefaultLoginModule()Adds default login module to list of configured auth modules.voidaddListener(LoginConfigurationListener listener)voidclearConfiguredAuthModules()public for tests onlyConfigurationcreateJAASConfiguration()Creates JAAS login configuration for first configured login module.ConfigurationcreateJAASConfiguration(AuthModule<LoginModuleDescriptor> loginModuleWithProperties)Creates JAAS login configuration for specified login module with properties.AuthModuleTypefindAuthModuleTypeByName(String authModuleTypeName)Returns registered authentication module type with the specified name.StringgetAuthType()Always returns "mixed" string.BuildAuthenticationModegetBuildAuthenticationMode()Detemines which mode should be used for build authentication.<T extends AuthModuleType>
List<AuthModule<T>>getConfiguredAuthModules(Class<T> baseClass)Returns authentication modules configured in config file.List<AuthModule<LoginModuleDescriptor>>getConfiguredLoginModules()Returns enabled login modules in the order they are specified in config file.<T extends AuthModuleType>
AuthModule<T>getDefaultLoginModule(List<AuthModule<T>> loginModules)booleangetDefaultLoginModuleBooleanPropertyValue(String propertyKey)StringgetGuestUsername()Returns username of the guest userCollection<AuthModuleType>getRegisteredAuthModuleTypes()Returns collection of registered authentication module types.Collection<LoginModuleDescriptor>getRegisteredLoginModules()Returns collection of registered login module descriptors.LoginModuleDescriptorgetSelectedLoginModuleDescriptor()Returns descriptor of the first configured login module.StringgetTextForLoginPage()Returns text to show on the login page.TwoFactorAuthenticationTypegetTwoFactorAuthType()Returns currentTwoFactorAuthenticationTypelonggetTwoFactorGracePeriod()Returns duration of grace period for two-factor authentication.DategetTwoFactorSetupDeadline()Returns deadline for setup of two-factor authentication.booleanisAtLeastOneAuthModuleConfigured(Collection<Class<? extends AuthModuleType>> classes)Returns true if at least one authentication module with one of the specified type classes is configured.<T extends AuthModuleType>
booleanisAuthModuleConfigured(Class<T> clazz)Returns true if authentication module with the specified type class is configured.booleanisDefaultLoginConfigured()Returns true if default login module is configured (authorization via own server database).booleanisFreeRegistrationAllowed()Returns true if free user account registration is allowed.booleanisGuestLoginAllowed()Returns true if guest login is allowed.booleanisLoginFormCollapsed()booleanisOnlyDefaultLoginConfigured()Returns true if default login module is configured (authorization via own server database) and no other login modules are configured.booleanisRootLoginAllowed()Returns true if root login is allowed.booleanisUsersCanChangeOwnPasswords()Returns true if users are allowed to change own passwords for built-in authentication module.voidperformBatchChange(Runnable updateAction)Invokes the specified login configuration update action and firesLoginConfigurationListener.loginConfigurationChanged()event only once at the end.voidreadExternal(org.jdom.Element authConfig)Reads login configuration from "auth-config.xml".static Map<String,String>readProperties(org.jdom.Element element)voidregisterAuthModuleType(AuthModuleType authModuleType)Registers new authentication modulevoidregisterLoginModule(LoginModuleDescriptor moduleDescriptor)Registers new login modulevoidremoveListener(LoginConfigurationListener listener)voidsetBuildAuthenticationMode(BuildAuthenticationMode buildAuthenticationMode)Set build authentication mode.voidsetFreeRegistrationAllowed(boolean freeRegistrationAllowed)Enables free user account registration.voidsetGuestLoginAllowed(boolean guestLoginAllowed)Enables guest login.voidsetGuestUsername(String username)Sets username to be used by guest uservoidsetLoginFormCollapsed(boolean collapsed)Sets whether the login form should be collapsed on the login pagevoidsetRootLoginAllowed(boolean rootLoginAllowed)Enables root login.voidsetSelectedLoginModule(LoginModuleDescriptor loginModuleDescriptor)Sets current login module.voidsetTextForLoginPage(String textForLoginPage)Sets text to show on the login page.voidsetTwoFactorAuthType(TwoFactorAuthenticationType twoFactorAuthType)Sets type of two-factor authenticationvoidsetTwoFactorSetupDeadline(Date date)Set deadline for setup of two-factor authentication.voidunregisterAuthModuleType(AuthModuleType authModuleType)Unregisters authentication module which was registered byLoginConfiguration.registerAuthModuleType(jetbrains.buildServer.serverSide.auth.AuthModuleType)voidwriteTo(org.jdom.Element authConfig)Write data to the JDOM element
-
-
-
Field Detail
-
JAAS_NAME
@NotNull public static final String JAAS_NAME
- See Also:
- Constant Field Values
-
AUTH_MODULES
@NotNull public static final String AUTH_MODULES
- See Also:
- Constant Field Values
-
AUTH_MODULE
@NotNull public static final String AUTH_MODULE
- See Also:
- Constant Field Values
-
TYPE
@NotNull public static final String TYPE
- See Also:
- Constant Field Values
-
PROPERTY
@NotNull public static final String PROPERTY
- See Also:
- Constant Field Values
-
KEY
@NotNull public static final String KEY
- See Also:
- Constant Field Values
-
LOGIN_DESCRIPTION
@NotNull public static final String LOGIN_DESCRIPTION
- See Also:
- Constant Field Values
-
LOGIN_FORM
@NotNull public static final String LOGIN_FORM
- See Also:
- Constant Field Values
-
LOGIN_FORM_COLLAPSED
@NotNull public static final String LOGIN_FORM_COLLAPSED
- See Also:
- Constant Field Values
-
GUEST_LOGIN
@NotNull public static final String GUEST_LOGIN
- See Also:
- Constant Field Values
-
GUEST_USERNAME
@NotNull public static final String GUEST_USERNAME
- See Also:
- Constant Field Values
-
ALLOWED
@NotNull public static final String ALLOWED
- See Also:
- Constant Field Values
-
TWO_FACTOR_AUTH
@NotNull public static final String TWO_FACTOR_AUTH
- See Also:
- Constant Field Values
-
GRACE_PERIOD_EXPIRATION_TIME
@NotNull public static final String GRACE_PERIOD_EXPIRATION_TIME
- See Also:
- Constant Field Values
-
BUILD_AUTH
@NotNull public static final String BUILD_AUTH
- See Also:
- Constant Field Values
-
BUILD_AUTH_MODE
@NotNull public static final String BUILD_AUTH_MODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LoginConfigurationImpl
public LoginConfigurationImpl(@NotNull UserModelEx userModel, @NotNull CriticalErrors criticalErrors, @NotNull ConfigHistoryManager configHistoryManager, @NotNull AuditLogFactory auditLogFactory, @NotNull ServerPaths serverPaths, @NotNull SecurityContextEx securityContext)
-
-
Method Detail
-
clearConfiguredAuthModules
public void clearConfiguredAuthModules()
public for tests only- Specified by:
clearConfiguredAuthModulesin interfaceLoginConfigurationUpdate
-
addAuthModule
@NotNull public <T extends AuthModuleType> AuthModule<T> addAuthModule(@NotNull T authModuleType, @NotNull Map<String,String> properties)
Description copied from interface:LoginConfigurationUpdateAdds specified auth module with properties to list of configured auth modules. CallAuthConfigManager.persistConfiguration()to persist the change.- Specified by:
addAuthModulein interfaceLoginConfigurationUpdate- Parameters:
authModuleType- auth module typeproperties- auth module properties- Returns:
- created auth module
-
getConfiguredAuthModules
@NotNull public <T extends AuthModuleType> List<AuthModule<T>> getConfiguredAuthModules(@Nullable Class<T> baseClass)
Description copied from interface:LoginConfigurationReturns authentication modules configured in config file.- Specified by:
getConfiguredAuthModulesin interfaceLoginConfiguration- Parameters:
baseClass- auth module descriptor base class to filter auth modules or null to return all- Returns:
- see above
-
createJAASConfiguration
public Configuration createJAASConfiguration()
Description copied from interface:LoginConfigurationCreates JAAS login configuration for first configured login module.- Specified by:
createJAASConfigurationin interfaceLoginConfiguration- Returns:
- JAAS login configuration
-
createJAASConfiguration
@NotNull public Configuration createJAASConfiguration(@NotNull AuthModule<LoginModuleDescriptor> loginModuleWithProperties)
Description copied from interface:LoginConfigurationCreates JAAS login configuration for specified login module with properties.- Specified by:
createJAASConfigurationin interfaceLoginConfiguration- Returns:
- JAAS login configuration
-
getTextForLoginPage
@Nullable public String getTextForLoginPage()
Description copied from interface:LoginConfigurationReturns text to show on the login page.- Specified by:
getTextForLoginPagein interfaceLoginConfiguration- Returns:
- text to show on the login page.
-
setTextForLoginPage
public void setTextForLoginPage(String textForLoginPage)
Description copied from interface:LoginConfigurationUpdateSets text to show on the login page.- Specified by:
setTextForLoginPagein interfaceLoginConfigurationUpdate
-
isLoginFormCollapsed
public boolean isLoginFormCollapsed()
- Specified by:
isLoginFormCollapsedin interfaceLoginConfigurationEx
-
getTwoFactorAuthType
public TwoFactorAuthenticationType getTwoFactorAuthType()
Description copied from interface:LoginConfigurationExReturns currentTwoFactorAuthenticationType- Specified by:
getTwoFactorAuthTypein interfaceLoginConfigurationEx- Returns:
- two-factor authentication type
-
getTwoFactorSetupDeadline
@Nullable public Date getTwoFactorSetupDeadline()
Description copied from interface:LoginConfigurationExReturns deadline for setup of two-factor authentication. Applicable in mandatory mode only. After the deadline, users without grace period would not be able to log in.- Specified by:
getTwoFactorSetupDeadlinein interfaceLoginConfigurationEx- Returns:
- global deadline for setup of 2FA
-
getTwoFactorGracePeriod
public long getTwoFactorGracePeriod()
Description copied from interface:LoginConfigurationExReturns duration of grace period for two-factor authentication. This duration is used for grace period refreshes, both for single user and for all server users- Specified by:
getTwoFactorGracePeriodin interfaceLoginConfigurationEx- Returns:
- grace period duration, in milliseconds
-
getBuildAuthenticationMode
@NotNull public BuildAuthenticationMode getBuildAuthenticationMode()
Description copied from interface:LoginConfigurationExDetemines which mode should be used for build authentication.- Specified by:
getBuildAuthenticationModein interfaceLoginConfigurationEx
-
setLoginFormCollapsed
public void setLoginFormCollapsed(boolean collapsed)
Description copied from interface:LoginConfigurationUpdateSets whether the login form should be collapsed on the login page- Specified by:
setLoginFormCollapsedin interfaceLoginConfigurationUpdate
-
getSelectedLoginModuleDescriptor
@NotNull public LoginModuleDescriptor getSelectedLoginModuleDescriptor()
Description copied from interface:LoginConfigurationReturns descriptor of the first configured login module.- Specified by:
getSelectedLoginModuleDescriptorin interfaceLoginConfiguration- Returns:
- descriptor of the first configured login module
-
getConfiguredLoginModules
@NotNull public List<AuthModule<LoginModuleDescriptor>> getConfiguredLoginModules()
Description copied from interface:LoginConfigurationReturns enabled login modules in the order they are specified in config file. Never returns empty list: if no login modules are configured, returns the list that contains only default login module.- Specified by:
getConfiguredLoginModulesin interfaceLoginConfiguration- Returns:
- see above
-
isDefaultLoginConfigured
public boolean isDefaultLoginConfigured()
Description copied from interface:LoginConfigurationReturns true if default login module is configured (authorization via own server database).- Specified by:
isDefaultLoginConfiguredin interfaceLoginConfiguration- Returns:
- true if default login module is configured (authorization via own server database).
-
isOnlyDefaultLoginConfigured
public boolean isOnlyDefaultLoginConfigured()
Description copied from interface:LoginConfigurationReturns true if default login module is configured (authorization via own server database) and no other login modules are configured.- Specified by:
isOnlyDefaultLoginConfiguredin interfaceLoginConfiguration- Returns:
- true if default login module is configured
-
isAuthModuleConfigured
public <T extends AuthModuleType> boolean isAuthModuleConfigured(@NotNull Class<T> clazz)
Description copied from interface:LoginConfigurationReturns true if authentication module with the specified type class is configured.- Specified by:
isAuthModuleConfiguredin interfaceLoginConfiguration- Returns:
- true if authentication module with the specified type class is configured
-
isAtLeastOneAuthModuleConfigured
public boolean isAtLeastOneAuthModuleConfigured(@NotNull Collection<Class<? extends AuthModuleType>> classes)Description copied from interface:LoginConfigurationReturns true if at least one authentication module with one of the specified type classes is configured.- Specified by:
isAtLeastOneAuthModuleConfiguredin interfaceLoginConfiguration- Returns:
- true if at least one authentication module with one of the specified type classes is configured
-
addDefaultLoginModule
@TestOnly public AuthModule<LoginModuleDescriptor> addDefaultLoginModule()
Description copied from interface:LoginConfigurationUpdateAdds default login module to list of configured auth modules.- Specified by:
addDefaultLoginModulein interfaceLoginConfigurationUpdate
-
setSelectedLoginModule
@TestOnly public void setSelectedLoginModule(@NotNull LoginModuleDescriptor loginModuleDescriptor)Description copied from interface:LoginConfigurationUpdateSets current login module.- Specified by:
setSelectedLoginModulein interfaceLoginConfigurationUpdate
-
readExternal
public void readExternal(@NotNull org.jdom.Element authConfig)Description copied from interface:LoginConfigurationUpdateReads login configuration from "auth-config.xml".- Specified by:
readExternalin interfaceLoginConfigurationUpdate- Parameters:
authConfig- root element from "auth-config.xml"
-
performBatchChange
public void performBatchChange(@NotNull Runnable updateAction)Description copied from interface:LoginConfigurationUpdateInvokes the specified login configuration update action and firesLoginConfigurationListener.loginConfigurationChanged()event only once at the end.- Specified by:
performBatchChangein interfaceLoginConfigurationUpdate- Parameters:
updateAction- action to invoke
-
writeTo
public void writeTo(@NotNull org.jdom.Element authConfig)Description copied from interface:XmlExternalizableWrite data to the JDOM element- Specified by:
writeToin interfaceXmlExternalizable- Parameters:
authConfig- - parent element to write data to
-
readProperties
@NotNull public static Map<String,String> readProperties(@NotNull org.jdom.Element element)
-
isFreeRegistrationAllowed
public boolean isFreeRegistrationAllowed()
Description copied from interface:LoginConfigurationReturns true if free user account registration is allowed. Free registration can be enabled only if default login module selected.- Specified by:
isFreeRegistrationAllowedin interfaceLoginConfiguration- Returns:
- true if free user account registration is allowed
-
isUsersCanChangeOwnPasswords
public boolean isUsersCanChangeOwnPasswords()
Description copied from interface:LoginConfigurationReturns true if users are allowed to change own passwords for built-in authentication module.- Specified by:
isUsersCanChangeOwnPasswordsin interfaceLoginConfiguration- Returns:
- see above
-
getDefaultLoginModuleBooleanPropertyValue
public boolean getDefaultLoginModuleBooleanPropertyValue(@NotNull String propertyKey)- Specified by:
getDefaultLoginModuleBooleanPropertyValuein interfaceLoginConfigurationEx
-
getDefaultLoginModule
@Nullable public <T extends AuthModuleType> AuthModule<T> getDefaultLoginModule(@NotNull List<AuthModule<T>> loginModules)
- Specified by:
getDefaultLoginModulein interfaceLoginConfigurationEx
-
getRegisteredLoginModules
@NotNull public Collection<LoginModuleDescriptor> getRegisteredLoginModules()
Description copied from interface:LoginConfigurationReturns collection of registered login module descriptors.- Specified by:
getRegisteredLoginModulesin interfaceLoginConfiguration- Returns:
- collection of registered login module descriptors
-
getRegisteredAuthModuleTypes
@NotNull public Collection<AuthModuleType> getRegisteredAuthModuleTypes()
Description copied from interface:LoginConfigurationReturns collection of registered authentication module types.- Specified by:
getRegisteredAuthModuleTypesin interfaceLoginConfiguration- Returns:
- collection of registered authentication module types
-
findAuthModuleTypeByName
@Nullable public AuthModuleType findAuthModuleTypeByName(@NotNull String authModuleTypeName)
Description copied from interface:LoginConfigurationReturns registered authentication module type with the specified name.- Specified by:
findAuthModuleTypeByNamein interfaceLoginConfiguration- Returns:
- type or null if not found
-
setFreeRegistrationAllowed
@TestOnly public void setFreeRegistrationAllowed(boolean freeRegistrationAllowed)
Description copied from interface:LoginConfigurationUpdateEnables free user account registration. Free registration can be enabled only if default login module selected.- Specified by:
setFreeRegistrationAllowedin interfaceLoginConfigurationUpdate
-
isGuestLoginAllowed
public boolean isGuestLoginAllowed()
Description copied from interface:LoginConfigurationReturns true if guest login is allowed.- Specified by:
isGuestLoginAllowedin interfaceLoginConfiguration- Returns:
- true if guest login is allowed
-
isRootLoginAllowed
public boolean isRootLoginAllowed()
Description copied from interface:LoginConfigurationReturns true if root login is allowed.- Specified by:
isRootLoginAllowedin interfaceLoginConfiguration- Returns:
- true if root login is allowed
-
getGuestUsername
@NotNull public String getGuestUsername()
Description copied from interface:LoginConfigurationReturns username of the guest user- Specified by:
getGuestUsernamein interfaceLoginConfiguration- Returns:
- username of the guest user
-
setGuestUsername
public void setGuestUsername(@NotNull String username)Description copied from interface:LoginConfigurationUpdateSets username to be used by guest user- Specified by:
setGuestUsernamein interfaceLoginConfigurationUpdate
-
setGuestLoginAllowed
public void setGuestLoginAllowed(boolean guestLoginAllowed)
Description copied from interface:LoginConfigurationUpdateEnables guest login.- Specified by:
setGuestLoginAllowedin interfaceLoginConfigurationUpdate
-
setTwoFactorAuthType
public void setTwoFactorAuthType(@NotNull TwoFactorAuthenticationType twoFactorAuthType)Description copied from interface:LoginConfigurationUpdateSets type of two-factor authentication- Specified by:
setTwoFactorAuthTypein interfaceLoginConfigurationUpdate
-
setTwoFactorSetupDeadline
public void setTwoFactorSetupDeadline(@NotNull Date date)Description copied from interface:LoginConfigurationUpdateSet deadline for setup of two-factor authentication. Applicable only in mandatory mode.- Specified by:
setTwoFactorSetupDeadlinein interfaceLoginConfigurationUpdate
-
setBuildAuthenticationMode
public void setBuildAuthenticationMode(@NotNull BuildAuthenticationMode buildAuthenticationMode)Description copied from interface:LoginConfigurationUpdateSet build authentication mode.- Specified by:
setBuildAuthenticationModein interfaceLoginConfigurationUpdate
-
setRootLoginAllowed
@TestOnly public void setRootLoginAllowed(boolean rootLoginAllowed)
Description copied from interface:LoginConfigurationUpdateEnables root login.- Specified by:
setRootLoginAllowedin interfaceLoginConfigurationUpdate
-
registerLoginModule
public void registerLoginModule(@NotNull LoginModuleDescriptor moduleDescriptor)Description copied from interface:LoginConfigurationRegisters new login module- Specified by:
registerLoginModulein interfaceLoginConfiguration- Parameters:
moduleDescriptor- descriptor of the login module
-
registerAuthModuleType
public void registerAuthModuleType(@NotNull AuthModuleType authModuleType)Description copied from interface:LoginConfigurationRegisters new authentication module- Specified by:
registerAuthModuleTypein interfaceLoginConfiguration- Parameters:
authModuleType- type of the authentication module
-
unregisterAuthModuleType
public void unregisterAuthModuleType(@NotNull AuthModuleType authModuleType)Description copied from interface:LoginConfigurationExUnregisters authentication module which was registered byLoginConfiguration.registerAuthModuleType(jetbrains.buildServer.serverSide.auth.AuthModuleType)- Specified by:
unregisterAuthModuleTypein interfaceLoginConfigurationEx- Parameters:
authModuleType- type of the authentication module
-
getAuthType
public final String getAuthType()
Description copied from interface:LoginConfigurationAlways returns "mixed" string.- Specified by:
getAuthTypein interfaceLoginConfiguration- Returns:
- see above
-
addListener
public void addListener(@NotNull LoginConfigurationListener listener)- Specified by:
addListenerin interfaceLoginConfigurationEx
-
removeListener
public void removeListener(@NotNull LoginConfigurationListener listener)- Specified by:
removeListenerin interfaceLoginConfigurationEx
-
-