package org.argeo.app.api;
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
/** Constants used to name entity structures. */
public interface EntityNames {
// LDAP-LIKE ENTITIES
@Deprecated
- final String DISPLAY_NAME = LdapAttrs.displayName.property();
+ final String DISPLAY_NAME = LdapAttr.displayName.property();
// Persons
@Deprecated
- final String GIVEN_NAME = LdapAttrs.givenName.property();
+ final String GIVEN_NAME = LdapAttr.givenName.property();
@Deprecated
- final String SURNAME = LdapAttrs.sn.property();
+ final String SURNAME = LdapAttr.sn.property();
@Deprecated
- final String EMAIL = LdapAttrs.mail.property();
+ final String EMAIL = LdapAttr.mail.property();
@Deprecated
- final String OU = LdapAttrs.ou.property();
+ final String OU = LdapAttr.ou.property();
// WGS84
final String GEO_LAT = "geo:lat";
import org.argeo.api.acr.ArgeoNamespace;
import org.argeo.api.acr.ContentName;
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
import org.argeo.api.cms.CmsConstants;
import org.argeo.cms.SystemRole;
@Deprecated
public String dn() {
- return new StringBuilder(LdapAttrs.cn.name()).append("=").append(getRolePrefix()).append(".").append(name())
+ return new StringBuilder(LdapAttr.cn.name()).append("=").append(getRolePrefix()).append(".").append(name())
.append(",").append(CmsConstants.SYSTEM_ROLES_BASEDN).toString();
}
}
import javax.xml.namespace.QName;
import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.CmsConstants;
import org.argeo.api.cms.CmsSession;
import org.argeo.app.api.EntityType;
userNode = usersBase.addNode(uid, NodeType.NT_UNSTRUCTURED);
userNode.addMixin(EntityType.user.get());
userNode.addMixin(NodeType.MIX_CREATED);
- userNode.setProperty(LdapAttrs.distinguishedName.property(), userDn.toString());
- userNode.setProperty(LdapAttrs.uid.property(), uid);
+ userNode.setProperty(LdapAttr.distinguishedName.property(), userDn.toString());
+ userNode.setProperty(LdapAttr.uid.property(), uid);
adminSession.save();
// JackrabbitSecurityUtils.denyPrivilege(adminSession, userNode.getPath(), SuiteRole.coworker.dn(),
// Privilege.JCR_READ);
}
synchronized static public long findNextId(Content hierarchyUnit, QName cclass) {
- if (!hierarchyUnit.hasContentClass(LdapObjs.posixGroup.qName()))
+ if (!hierarchyUnit.hasContentClass(LdapObj.posixGroup.qName()))
throw new IllegalArgumentException(hierarchyUnit + " is not a POSIX group");
- long min = hierarchyUnit.get(LdapAttrs.gidNumber.qName(), Long.class).orElseThrow();
+ long min = hierarchyUnit.get(LdapAttr.gidNumber.qName(), Long.class).orElseThrow();
long currentMax = 0l;
for (Content childHu : hierarchyUnit) {
- if (!childHu.hasContentClass(LdapObjs.organizationalUnit.qName()))
+ if (!childHu.hasContentClass(LdapObj.organizationalUnit.qName()))
continue;
// FIXME filter out functional hierarchy unit
for (Content role : childHu) {
if (role.hasContentClass(cclass)) {
- if (LdapObjs.posixAccount.qName().equals(cclass)) {
- Long id = role.get(LdapAttrs.uidNumber.qName(), Long.class).orElseThrow();
+ if (LdapObj.posixAccount.qName().equals(cclass)) {
+ Long id = role.get(LdapAttr.uidNumber.qName(), Long.class).orElseThrow();
if (id > currentMax)
currentMax = id;
}
package org.argeo.app.ui.people;
import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.directory.CmsGroup;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.api.cms.directory.HierarchyUnit;
// TODO localise at content level
String title;
- if (context.hasContentClass(LdapObjs.organization))
- title = SuiteMsg.org.lead() + " " + context.attr(LdapAttrs.cn) + " ("
+ if (context.hasContentClass(LdapObj.organization))
+ title = SuiteMsg.org.lead() + " " + context.attr(LdapAttr.cn) + " ("
+ hierarchyUnit.getHierarchyUnitLabel(CurrentUser.locale()) + ")";
else
- title = SuiteMsg.group.lead() + " " + context.attr(LdapAttrs.cn) + " ("
+ title = SuiteMsg.group.lead() + " " + context.attr(LdapAttr.cn) + " ("
+ hierarchyUnit.getHierarchyUnitLabel(CurrentUser.locale()) + ")";
SuiteUiUtils.addFormLabel(parent, title);
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.directory.CmsDirectory;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.api.cms.directory.HierarchyUnit;
@Override
public CmsIcon getIcon(HierarchyUnit model) {
Content content = ContentUtils.hierarchyUnitToContent(contentSession, model);
- if (content.hasContentClass(LdapObjs.organization))
+ if (content.hasContentClass(LdapObj.organization))
return SuiteIcon.organisation;
- else if (content.hasContentClass(LdapObjs.posixGroup))
+ else if (content.hasContentClass(LdapObj.posixGroup))
return SuiteIcon.users;
else
return SuiteIcon.addressBook;
import java.util.UUID;
import org.argeo.api.acr.Content;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.api.cms.directory.HierarchyUnit;
import org.argeo.app.core.SuiteUtils;
public NewUserForm(CmsUserManager cmsUserManager, Content hierarchyUnit) {
this.hierarchyUnit = hierarchyUnit;
- if (!hierarchyUnit.hasContentClass(LdapObjs.posixGroup.qName()))
+ if (!hierarchyUnit.hasContentClass(LdapObj.posixGroup.qName()))
throw new IllegalArgumentException(hierarchyUnit + " is not a POSIX group");
this.cmsUserManager = cmsUserManager;
}
String username = "uid=" + uid + ",ou=People," + hu.getBase();
Map<String, Object> properties = new HashMap<>();
- properties.put(LdapAttrs.givenName.name(), firstName);
- properties.put(LdapAttrs.sn.name(), lastName);
- properties.put(LdapAttrs.mail.name(), email);
- properties.put(LdapAttrs.cn.name(), firstName + " " + lastName);
- properties.put(LdapAttrs.employeeNumber.name(), uuid.toString());
+ properties.put(LdapAttr.givenName.name(), firstName);
+ properties.put(LdapAttr.sn.name(), lastName);
+ properties.put(LdapAttr.mail.name(), email);
+ properties.put(LdapAttr.cn.name(), firstName + " " + lastName);
+ properties.put(LdapAttr.employeeNumber.name(), uuid.toString());
Map<String, Object> credentials = new HashMap<>();
User user = cmsUserManager.createUser(username, properties, credentials);
- Long huGidNumber = hierarchyUnit.get(LdapAttrs.gidNumber.qName(), Long.class).orElseThrow();
- Long nextUserId = SuiteUtils.findNextId(hierarchyUnit, LdapObjs.posixAccount.qName());
+ Long huGidNumber = hierarchyUnit.get(LdapAttr.gidNumber.qName(), Long.class).orElseThrow();
+ Long nextUserId = SuiteUtils.findNextId(hierarchyUnit, LdapObj.posixAccount.qName());
String homeDirectory = "/home/" + uid;
Map<String, Object> additionalProperties = new HashMap<>();
- additionalProperties.put(LdapAttrs.uidNumber.name(), nextUserId.toString());
- additionalProperties.put(LdapAttrs.gidNumber.name(), huGidNumber.toString());
- additionalProperties.put(LdapAttrs.homeDirectory.name(), homeDirectory);
+ additionalProperties.put(LdapAttr.uidNumber.name(), nextUserId.toString());
+ additionalProperties.put(LdapAttr.gidNumber.name(), huGidNumber.toString());
+ additionalProperties.put(LdapAttr.homeDirectory.name(), homeDirectory);
Set<String> objectClasses = new HashSet<>();
- objectClasses.add(LdapObjs.posixAccount.name());
+ objectClasses.add(LdapObj.posixAccount.name());
cmsUserManager.addObjectClasses(user, objectClasses, additionalProperties);
return true;
}
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentRepository;
import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapAttrs;
+import org.argeo.api.acr.ldap.LdapAttr;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.api.cms.directory.HierarchyUnit;
import org.argeo.api.cms.ux.CmsView;
@Override
public String getText(Content role) {
- return role.attr(LdapAttrs.mail);
+ return role.attr(LdapAttr.mail);
}
@Override
import org.argeo.api.acr.Content;
import org.argeo.api.acr.QNamed;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.directory.CmsUser;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.app.api.SuiteRole;
String roleContext = RoleNameUtils.getContext(user.getName());
- if (context.hasContentClass(LdapObjs.person.qName())) {
+ if (context.hasContentClass(LdapObj.person.qName())) {
- addFormLine(main, SuiteMsg.firstName, context, LdapAttrs.givenName);
- addFormLine(main, SuiteMsg.lastName, context, LdapAttrs.sn);
- addFormLine(main, SuiteMsg.email, context, LdapAttrs.mail);
+ addFormLine(main, SuiteMsg.firstName, context, LdapAttr.givenName);
+ addFormLine(main, SuiteMsg.lastName, context, LdapAttr.sn);
+ addFormLine(main, SuiteMsg.email, context, LdapAttr.mail);
}
- if (context.hasContentClass(LdapObjs.posixAccount.qName())) {
- if (hierarchyUnitContent.hasContentClass(LdapObjs.organization)) {
+ if (context.hasContentClass(LdapObj.posixAccount.qName())) {
+ if (hierarchyUnitContent.hasContentClass(LdapObj.organization)) {
SwtSection rolesSection = new SwtSection(main, SWT.NONE);
rolesSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
rolesSection.setLayout(new GridLayout(2, false));
import org.argeo.api.acr.Content;
import org.argeo.api.acr.ContentSession;
-import org.argeo.api.acr.ldap.LdapAttrs;
-import org.argeo.api.acr.ldap.LdapObjs;
+import org.argeo.api.acr.ldap.LdapAttr;
+import org.argeo.api.acr.ldap.LdapObj;
import org.argeo.api.cms.directory.CmsUserManager;
import org.argeo.api.cms.directory.HierarchyUnit;
import org.argeo.api.cms.directory.UserDirectory;
@Override
public String getText(Content role) {
- if (role.hasContentClass(LdapObjs.inetOrgPerson))
+ if (role.hasContentClass(LdapObj.inetOrgPerson))
return UserAdminUtils.getUserDisplayName(role.adapt(User.class));
- else if (role.hasContentClass(LdapObjs.organization))
- return role.attr(LdapAttrs.o);
- else if (role.hasContentClass(LdapObjs.groupOfNames))
- return role.attr(LdapAttrs.cn);
+ else if (role.hasContentClass(LdapObj.organization))
+ return role.attr(LdapAttr.o);
+ else if (role.hasContentClass(LdapObj.groupOfNames))
+ return role.attr(LdapAttr.cn);
else
return null;
}
@Override
public CmsIcon getIcon(Content role) {
- if (role.hasContentClass(LdapObjs.posixAccount))
+ if (role.hasContentClass(LdapObj.posixAccount))
return SuiteIcon.user;
- else if (role.hasContentClass(LdapObjs.inetOrgPerson))
+ else if (role.hasContentClass(LdapObj.inetOrgPerson))
return SuiteIcon.person;
- else if (role.hasContentClass(LdapObjs.organization))
+ else if (role.hasContentClass(LdapObj.organization))
return SuiteIcon.organisationContact;
- else if (role.hasContentClass(LdapObjs.groupOfNames))
+ else if (role.hasContentClass(LdapObj.groupOfNames))
return SuiteIcon.group;
else
return null;
if (ud.getRealm().isPresent()) {
for (Role r : ud.getHierarchyUnitRoles(ud, null, true)) {
Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r);
- if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization))
+ if (content.hasContentClass(LdapObj.inetOrgPerson, LdapObj.organization))
roles.add(content);
}
|| directChild.isType(HierarchyUnit.Type.ROLES))) {
for (Role r : ud.getHierarchyUnitRoles(directChild, null, false)) {
Content content = ContentUtils.roleToContent(cmsUserManager, contentSession, r);
- if (content.hasContentClass(LdapObjs.inetOrgPerson, LdapObjs.organization,
- LdapObjs.groupOfNames))
+ if (content.hasContentClass(LdapObj.inetOrgPerson, LdapObj.organization,
+ LdapObj.groupOfNames))
roles.add(content);
}
}