As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
you can create some cind of group for "admin" users and checking this in the class adminAuthfilter if they are in this group then give them access.
You can do this by editing : web.xml Admin Authentication Filter ( you can remove the usage of admin filter , this would be wrong idea, but you can do this)class rg.alfresco.web.app.servlet.AdminAuthenticationFilter , this class checks if current user is admin or not .
if (isAdmin) { //add hire : //get all users from that group authorities = this.getAuthorityService() .getContainedAuthorities(AuthorityType.USER, "GROUP_NAME_GROUP", immediate); //get current user String currentUserName=Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName(); //check if current user is in this group for (String authority : authorities) { NodeRef ref = this.getPersonService().getPerson(authority); String userName= this.getNodeService().getProperty(ref, ContentModel.PROP_USERNAME); if(userName.equals(currentUserName))//current user is in this group { chain.doFilter(req, res); } } this sould do it, you would have acces to admin parts, also you can create multiple filters, and define some kind of security for your self. So have funn coding this out, but I think this is more or less what you need to make it nice and net . PS: change classs of filter admin authentification filter according to what you jave coded out. chain.doFilter(req, res); //if is admin go to the page like /jsp/admin/…. } else { httpResponse.sendError(HttpServletResponse.SC_FORBIDDEN); //return 403 } }
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); } } }
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; } }
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"); }
<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>
<%@ page import="org.alfresco.web.bean.repository.tenant.TenantAdminConsoleBean" %> <%@ page import="org.alfresco.web.bean.NavigationBean" %> <%@ page import="org.alfresco.repo.security.authority.AuthorityServiceImpl" %> <%@ page import="org.alfresco.service.cmr.security.AuthorityType" %> <%@ page import="java.util.Set" %> <% TenantAdminConsoleBean tac = new TenantAdminConsoleBean(); String myUserName= tac.getCurrentUserName(); AuthorityServiceImpl asi = new AuthorityServiceImpl(); Set<String> myGroups = asi.getContainingAuthorities(AuthorityType.GROUP, myUserName, false); boolean isContained = myGroups.contains("myAdmins"); //person.getPerson(teste3); %>