mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
improve authentication system
This commit is contained in:
@@ -59,7 +59,7 @@ import javax.xml.bind.annotation.XmlType;
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(propOrder =
|
||||
{
|
||||
"name", "displayName", "mail", "password", "admin", "type"
|
||||
"name", "displayName", "mail", "password", "admin", "type", "lastLogin"
|
||||
})
|
||||
public class User
|
||||
implements TypedObject, Principal, Cloneable, Validateable, Serializable
|
||||
@@ -237,6 +237,17 @@ public class User
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getLastLogin()
|
||||
{
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -332,6 +343,17 @@ public class User
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param lastLogin
|
||||
*/
|
||||
public void setLastLogin(long lastLogin)
|
||||
{
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -385,6 +407,9 @@ public class User
|
||||
/** Field description */
|
||||
private String displayName;
|
||||
|
||||
/** Field description */
|
||||
private long lastLogin;
|
||||
|
||||
/** Field description */
|
||||
private String mail;
|
||||
|
||||
|
||||
@@ -43,4 +43,16 @@ import sonia.scm.Manager;
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface UserManager
|
||||
extends Manager<User, UserException>, ListenerSupport<UserListener> {}
|
||||
extends Manager<User, UserException>, ListenerSupport<UserListener>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param username
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(String username);
|
||||
}
|
||||
|
||||
@@ -115,6 +115,20 @@ public class XmlUserManager extends AbstractUserManager
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param username
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(String username)
|
||||
{
|
||||
return userDB.contains(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -46,8 +46,9 @@ import sonia.scm.plugin.ext.Extension;
|
||||
import sonia.scm.plugin.ext.ExtensionProcessor;
|
||||
import sonia.scm.repository.RepositoryHandler;
|
||||
import sonia.scm.security.EncryptionHandler;
|
||||
import sonia.scm.web.security.AuthenticationHandler;
|
||||
import sonia.scm.web.security.AuthenticationManager;
|
||||
import sonia.scm.web.security.XmlAuthenticationManager;
|
||||
import sonia.scm.web.security.XmlAuthenticationHandler;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -91,10 +92,10 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
||||
{
|
||||
Multibinder<RepositoryHandler> repositoryHandlers =
|
||||
Multibinder.newSetBinder(binder, RepositoryHandler.class);
|
||||
Multibinder<AuthenticationManager> authenticators =
|
||||
Multibinder.newSetBinder(binder, AuthenticationManager.class);
|
||||
Multibinder<AuthenticationHandler> authenticators =
|
||||
Multibinder.newSetBinder(binder, AuthenticationHandler.class);
|
||||
|
||||
authenticators.addBinding().to(XmlAuthenticationManager.class);
|
||||
authenticators.addBinding().to(XmlAuthenticationHandler.class);
|
||||
|
||||
for (Class extensionClass : extensions)
|
||||
{
|
||||
@@ -114,11 +115,11 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
||||
{
|
||||
bind(binder, EncryptionHandler.class, extensionClass);
|
||||
}
|
||||
else if (AuthenticationManager.class.isAssignableFrom(extensionClass))
|
||||
else if (AuthenticationHandler.class.isAssignableFrom(extensionClass))
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info("bind Authenticator {}", extensionClass.getName());
|
||||
logger.info("bind AuthenticationHandler {}", extensionClass.getName());
|
||||
}
|
||||
|
||||
binder.bind(extensionClass);
|
||||
|
||||
Reference in New Issue
Block a user