use of org.alfresco.repo.security.authentication.external.RemoteUserMapper in project acs-community-packaging by Alfresco.
the class AuthenticationHelper method getRemoteUserMapper.
/**
* Gets the remote user mapper if one is configured and active (i.e. external authentication is in use).
* @param sc
* the servlet context
* @return the remote user mapper if one is configured and active; otherwise <code>null</code>
*/
public static RemoteUserMapper getRemoteUserMapper(final ServletContext sc) {
final WebApplicationContext wc = WebApplicationContextUtils.getRequiredWebApplicationContext(sc);
RemoteUserMapper remoteUserMapper = (RemoteUserMapper) wc.getBean(REMOTE_USER_MAPPER);
if (remoteUserMapper != null && !(remoteUserMapper instanceof ActivateableBean) || ((ActivateableBean) remoteUserMapper).isActive()) {
if (logger.isDebugEnabled()) {
logger.debug("Remote user mapper configured and active.");
}
return remoteUserMapper;
}
if (logger.isDebugEnabled()) {
logger.debug("No active remote user mapper.");
}
return null;
}
use of org.alfresco.repo.security.authentication.external.RemoteUserMapper in project acs-community-packaging by Alfresco.
the class AuthenticationHelper method getRemoteUser.
/**
* Uses the remote user mapper, if one is configured, to extract a user ID from the request
*
* @param sc
* the servlet context
* @param httpRequest
* The HTTP request
* @return the user ID if a user has been externally authenticated or <code>null</code> otherwise.
*/
public static String getRemoteUser(final ServletContext sc, final HttpServletRequest httpRequest) {
String userId = null;
// If the remote user mapper is configured, we may be able to map in an externally authenticated user
RemoteUserMapper remoteUserMapper = getRemoteUserMapper(sc);
if (remoteUserMapper != null) {
userId = remoteUserMapper.getRemoteUser(httpRequest);
}
if (logger.isDebugEnabled()) {
if (userId == null) {
logger.debug("No external user ID in request.");
} else {
logger.debug("Extracted external user ID from request: " + userId);
}
}
return userId;
}
Aggregations