Merged V2.1 to HEAD

6466: Xml metadata.  Support for pulling collections of values from XML
   6470: Fix for AWC-1321 - Using zero as items per page gives error for Alfresco repos in OpenSearch
   6471: Fix for AWC-1496 - OpenSearch dashlet can get in a state where search queries are not executed
   6472: Fix for AWC-1495. Searching additional attributes now working correctly for folders.
   6473: Fix for AR-1251 (Version error when saving new content via CIFS)
   6474: Updated bundles and installers - added missing files back into Linux bundle
   6475: LDAP and chainging authentication
          Resolved conflicted state of 'root\projects\repository\source\java\org\alfresco\repo\security\authentication\AuthenticationUtil.java'
   6477: XForms WCM-696.
   6478: Fix for WCM-567 (IndexOutOfBoundsException when stepping through wizard rapidly)
   6480: Fix to issue when removing locks on directories.
   6481: Updated installer and config wizard to fix download option and config behaviour when called from installer.
   6482: Fix for WCM-1229 (properties sheet does not refresh)
   6483: Fix for AR-1511
   6484: Fix for AR-1351
   6485: Missed a unit test update


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6737 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-10 22:57:18 +00:00
parent 1f3aabc6a0
commit bcfd0ae519
31 changed files with 1179 additions and 487 deletions

View File

@@ -28,10 +28,6 @@ import net.sf.acegisecurity.Authentication;
import net.sf.acegisecurity.GrantedAuthority;
import net.sf.acegisecurity.GrantedAuthorityImpl;
import net.sf.acegisecurity.UserDetails;
import net.sf.acegisecurity.context.Context;
import net.sf.acegisecurity.context.ContextHolder;
import net.sf.acegisecurity.context.security.SecureContext;
import net.sf.acegisecurity.context.security.SecureContextImpl;
import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import net.sf.acegisecurity.providers.dao.User;
@@ -46,11 +42,9 @@ import org.alfresco.service.cmr.security.PermissionService;
*/
public abstract class AbstractAuthenticationComponent implements AuthenticationComponent
{
// Name of the system user
static final String SYSTEM_USER_NAME = "System";
/**
* The abstract class keeps track of support for guest login
*/
private Boolean allowGuestLogin = null;
public AbstractAuthenticationComponent()
@@ -58,6 +52,11 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
super();
}
/**
* Set if guest login is supported.
*
* @param allowGuestLogin
*/
public void setAllowGuestLogin(Boolean allowGuestLogin)
{
this.allowGuestLogin = allowGuestLogin;
@@ -65,6 +64,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
public void authenticate(String userName, char[] password) throws AuthenticationException
{
// Support guest login from the login screen
if ((userName != null) && (userName.equalsIgnoreCase(PermissionService.GUEST_AUTHORITY)))
{
setGuestUserAsCurrentUser();
@@ -75,6 +75,14 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
}
}
/**
* Default unsupported authentication implementation
* - as of 2.1 this is the best way to implement your own authentication component as it will support guest login
* - prior to this direct over ride for authenticate(String , char[]) was used. This will still work.
*
* @param userName
* @param password
*/
protected void authenticateImpl(String userName, char[] password)
{
throw new UnsupportedOperationException();
@@ -97,11 +105,11 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
try
{
UserDetails ud = null;
if (userName.equals(SYSTEM_USER_NAME))
if (userName.equals(AuthenticationUtil.SYSTEM_USER_NAME))
{
GrantedAuthority[] gas = new GrantedAuthority[1];
gas[0] = new GrantedAuthorityImpl("ROLE_SYSTEM");
ud = new User(SYSTEM_USER_NAME, "", true, true, true, true, gas);
ud = new User(AuthenticationUtil.SYSTEM_USER_NAME, "", true, true, true, true, gas);
}
else if (userName.equalsIgnoreCase(PermissionService.GUEST_AUTHORITY))
{
@@ -173,28 +181,6 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
return AuthenticationUtil.getCurrentUserName();
}
/**
* Get the current user name
*
* @param authentication
* Authentication
* @return String
*/
private String getUserName(Authentication authentication)
{
String username;
if (authentication.getPrincipal() instanceof UserDetails)
{
username = ((UserDetails) authentication.getPrincipal()).getUsername();
}
else
{
username = authentication.getPrincipal().toString();
}
return username;
}
/**
* Set the system user as the current user.
*
@@ -202,7 +188,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
*/
public Authentication setSystemUserAsCurrentUser()
{
return setCurrentUser(SYSTEM_USER_NAME);
return setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME);
}
/**
@@ -212,7 +198,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC
*/
public String getSystemUserName()
{
return SYSTEM_USER_NAME;
return AuthenticationUtil.SYSTEM_USER_NAME;
}
/**