05-07-2010 05:14 AM
05-11-2010 07:27 AM
05-11-2010 09:19 AM
05-11-2010 11:16 AM
05-11-2010 02:45 PM
package org.alfresco.docassistent.filter;
import java.io.IOException;
import java.util.Set;
import javax.faces.context.FacesContext;
import javax.servlet.FilterChain;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.AuthorityService;
import org.alfresco.service.cmr.security.AuthorityType;
import org.alfresco.service.cmr.security.PersonService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.AdminAuthenticationFilter;
import org.alfresco.web.app.servlet.AuthenticationHelper;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.repository.User;
public class CustomAdminAuthenticationFilter extends AdminAuthenticationFilter {
@Override
public void doFilter(ServletRequest httpRequest,
ServletResponse httpResponse, FilterChain chain)
throws IOException, ServletException {
User user = AuthenticationHelper.getUser(
(HttpServletRequest) httpRequest,
(HttpServletResponse) httpResponse);
boolean isAdmin = (user != null && user.isAdmin());
if (!isAdmin) {
ServletContext context = ((HttpServletRequest) httpRequest)
.getSession().getServletContext();
AuthorityService authorityService = Repository.getServiceRegistry(
context).getAuthorityService();
PersonService personService = Repository
.getServiceRegistry(context).getPersonService();
NodeService nodeService = Repository.getServiceRegistry(context)
.getNodeService();
// Set<String> test = authorityService
// .getAllAuthorities(AuthorityType.GROUP);
// for (String authority : test) {
// System.out.println(authority);
// }
Set<String> authorities = authorityService.getContainedAuthorities(
AuthorityType.USER, "GROUP_NAME_GROUP", true);
// get current user
String currentUserName = Application.getCurrentUser(
FacesContext.getCurrentInstance()).getUserName();
// check if current user is in this group
for (String authority : authorities) {
NodeRef ref = personService.getPerson(authority);
String userName = (String) nodeService.getProperty(ref,
org.alfresco.model.ContentModel.PROP_USERNAME);
if (userName.equals(currentUserName))// current user is in this
// group
{
chain.doFilter(httpRequest, httpResponse);
}
}
super.doFilter(httpRequest, httpResponse, chain);
} else {
super.doFilter(httpRequest, httpResponse, chain);
}
}
}
05-12-2010 05:53 AM
05-12-2010 07:09 AM
05-13-2010 11:41 AM
package org.alfresco.sample;
import javax.faces.context.FacesContext;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.web.app.Application;
public class MyClass extends org.alfresco.web.bean.users.CreateUserWizard
{
private static final long serialVersionUID = 1L;
@Override
protected String finishImpl(FacesContext arg0, String arg1) throws Exception
{
//GetSuccessItemsTable getSuccessItemsTable = new GetSuccessItemsTable(this, arg0, arg1);
String tenant = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName().split("@")[1];
AuthenticationUtil.setRunAsUser("admin@" + tenant);
try {
return super.finishImpl(arg0, arg1);
} catch (Throwable e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
05-13-2010 11:46 AM
05-13-2010 11:46 AM
String username = Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName();
if(username.contans("@"))
{
String tenant= Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName().split("@")[1];
AuthenticationUtil.setRunAsUser("admin@" + tenant);
}else {
AuthenticationUtil.setRunAsUser("admin");
}
05-13-2010 12:00 PM
<a:stringEqualsEvaluator value="#{NavigationBean.currentUser.userName}" condition="user1@ecm.alfresco.com">
<a:actionLink value="#{msg.admin_console}"
image="/images/icons/admin_console.gif"
showLink="false"
action="dialog:adminConsole"
id="alf_admin_console" />
</a:stringEqualsEvaluator>
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.