Files
alfresco-community-repo/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationService.java
Raluca Munteanu 86dc6f3402 Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@125603 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-04-20 10:21:07 +00:00

63 lines
1.9 KiB
Java

package org.alfresco.repo.security.authentication;
import java.util.List;
import java.util.Set;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.service.cmr.security.AuthenticationService;
/**
* Common code for authentication services
*
* @author andyh
*/
public abstract class AbstractAuthenticationService implements AuthenticationService
{
public static final String GUEST_AUTHENTICATION_NOT_SUPPORTED = "Guest authentication not supported";
private SysAdminParams sysAdminParams;
public void setSysAdminParams(SysAdminParams sysAdminParams)
{
this.sysAdminParams = sysAdminParams;
}
public void preAuthenticationCheck(String userName) throws AuthenticationException
{
if (sysAdminParams != null)
{
List<String> allowedUsers = sysAdminParams.getAllowedUserList();
if ((allowedUsers != null) && (!allowedUsers.contains(userName)))
{
throw new AuthenticationDisallowedException("Username not allowed: " + userName);
}
Integer maxUsers = (Integer) sysAdminParams.getMaxUsers();
if ((maxUsers != null) && (maxUsers > -1) && (getUsersWithTickets(true).size() >= maxUsers))
{
throw new AuthenticationMaxUsersException("Max users exceeded: " + maxUsers);
}
}
}
public List<String> getAllowedUsers()
{
return sysAdminParams.getAllowedUserList();
}
public int getMaxUsers()
{
return sysAdminParams.getMaxUsers();
}
public abstract Set<String> getUsersWithTickets(boolean nonExpiredOnly);
public abstract int invalidateTickets(boolean nonExpiredOnly);
public abstract int countTickets(boolean nonExpiredOnly);
public abstract Set<TicketComponent> getTicketComponents();
}