public class OwnerDynamicAuthority implements DynamicAuthority, InitializingBean
{
private OwnableService ownableService;
public OwnerDynamicAuthority()
{
super();
}
public void setOwnableService(OwnableService ownableService)
{
this.ownableService = ownableService;
}
public void afterPropertiesSet() throws Exception
{
if (ownableService == null)
{
throw new IllegalArgumentException("There must be an ownable service");
}
}
public boolean hasAuthority(final NodeRef nodeRef, final String userName)
{
return AuthenticationUtil.runAs(new RunAsWork<Boolean>(){
public Boolean doWork() throws Exception
{
// TODO Auto-generated method stub
return EqualsHelper.nullSafeEquals(ownableService.getOwner(nodeRef), userName);
}}, AuthenticationUtil.getSystemUserName());
}
public String getAuthority()
{
return PermissionService.OWNER_AUTHORITY;
}
}
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.