/** Remove a member from this group. */
void removeMember(CmsGroup group, Role role);
-
+
void edit(Runnable action);
/* MISCELLANEOUS */
boolean isType(Type type);
+ /** A technical direct child. */
+ HierarchyUnit getDirectChild(Type type);
+
/**
* The base of this organisational unit within the hierarchy. This would
* typically be an LDAP base DN.
/** A programmatic role. */
public interface SystemRole {
- QName getName();
+ QName qName();
/** Whether this role is implied for this authenticated user. */
default boolean implied(Subject subject, String context) {
- return implied(getName(), subject, context);
+ return implied(qName(), subject, context);
}
/** Whether this role is implied for this distinguished name. */
default boolean implied(String dn, String context) {
String roleContext = RoleNameUtils.getContext(dn);
QName roleName = RoleNameUtils.getLastRdnAsName(dn);
- return roleContext.equalsIgnoreCase(context) && getName().equals(roleName);
+ return roleContext.equalsIgnoreCase(context) && qName().equals(roleName);
}
/**
@Override
public Object put(QName key, Object value) {
Object previous = get(key);
- // TODO deal with typing
- doGetProperties().put(key.getLocalPart(), value);
+ provider.getUserManager().edit(() -> doGetProperties().put(key.getLocalPart(), value));
return previous;
}
this.userManager = userManager;
}
+ public CmsUserManager getUserManager() {
+ return userManager;
+ }
+
UserManagerContent getRootContent(ProvidedSession session) {
return new UserManagerContent(session);
}
}
@Override
- public QName getName() {
+ public QName qName() {
return name;
}
return directoryDao.doGetDirectHierarchyUnits(baseDn, functionalOnly);
}
+ @Override
+ public HierarchyUnit getDirectChild(Type type) {
+ // TODO factorise with hierarchy unit?
+ return switch (type) {
+ case ROLES -> getDirectoryDao().doGetHierarchyUnit((LdapName) getBaseDn().add(getSystemRoleBaseRdn()));
+ case PEOPLE -> getDirectoryDao().doGetHierarchyUnit((LdapName) getBaseDn().add(getUserBaseRdn()));
+ case GROUPS -> getDirectoryDao().doGetHierarchyUnit((LdapName) getBaseDn().add(getGroupBaseRdn()));
+ case FUNCTIONAL -> throw new IllegalArgumentException("Type must be a technical type");
+ };
+ }
+
@Override
public String getHierarchyUnitName() {
return getName();
for (int i = 0; i < segments.length; i++) {
String segment = segments[i];
// TODO make attr names configurable ?
- String attr = getDirectory().getRealm().isPresent()/* IPA */ ? LdapAttr.cn.name()
- : LdapAttr.ou.name();
+ String attr = getDirectory().getRealm().isPresent()/* IPA */ ? LdapAttr.cn.name() : LdapAttr.ou.name();
if (parentRdn != null) {
if (getUserBaseRdn().equals(parentRdn))
attr = LdapAttr.uid.name();
return getDirectoryDao().doGetDirectHierarchyUnits(getDn(), functionalOnly);
}
+ @Override
+ public HierarchyUnit getDirectChild(Type type) {
+ return switch (type) {
+ case ROLES ->
+ getDirectoryDao().doGetHierarchyUnit((LdapName) getDn().add(getDirectory().getSystemRoleBaseRdn()));
+ case PEOPLE -> getDirectoryDao().doGetHierarchyUnit((LdapName) getDn().add(getDirectory().getUserBaseRdn()));
+ case GROUPS -> getDirectoryDao().doGetHierarchyUnit((LdapName) getDn().add(getDirectory().getGroupBaseRdn()));
+ case FUNCTIONAL -> throw new IllegalArgumentException("Type must be a technical type");
+ };
+ }
+
@Override
public boolean isType(Type type) {
return this.type.equals(type);