@Override
protected int getItemCount() {
- data = new ArrayList<>(selected.getTypes());
+ data = new ArrayList<>(selected.getContentClasses());
return data.size();
}
};
Object data = getData(row);
item.setData(data);
String text = data != null ? column.getText(data) : "";
- item.setText(i, text);
+ if (text != null)
+ item.setText(i, text);
CmsIcon icon = column.getIcon(data);
if (icon != null) {
Image image = theme.getSmallIcon(icon);
* TYPING
*/
@Override
- public List<QName> getTypes() {
+ public List<QName> getContentClasses() {
try {
// Node node = getJcrNode();
// List<QName> res = new ArrayList<>();
/*
* TYPING
*/
- List<QName> getTypes();
+ List<QName> getContentClasses();
+
+ /** AND */
+ default boolean isContentClass(QName... contentClass) {
+ List<QName> contentClasses = getContentClasses();
+ for (QName cClass : contentClass) {
+ if (!contentClasses.contains(cClass))
+ return false;
+ }
+ return true;
+ }
+
+ /** OR */
+ default boolean hasContentClass(QName... contentClass) {
+ List<QName> contentClasses = getContentClasses();
+ for (QName cClass : contentClass) {
+ if (contentClasses.contains(cClass))
+ return true;
+ }
+ return false;
+ }
/*
* DEFAULT METHODS
/*
* CONVENIENCE METHODS
*/
-// default String attr(String key) {
-// return get(key, String.class);
-// }
+ default String attr(String key) {
+ Object obj = get(key);
+ if (obj == null)
+ return null;
+ return obj.toString();
+
+ }
+
+ default String attr(QName key) {
+ Object obj = get(key);
+ if (obj == null)
+ return null;
+ return obj.toString();
+
+ }
//
// default String attr(Object key) {
// return key != null ? attr(key.toString()) : attr(null);
@Override
public String toString() {
- return toPrefixedString();
+ return toQNameString();
}
@Override
//
;
- public final static String CR_NAMESPACE_URI = "http://argeo.org/ns/cr";
+ public final static String CR_NAMESPACE_URI = "http://www.argeo.org/ns/cr";
public final static String CR_DEFAULT_PREFIX = "cr";
- public final static String LDAP_NAMESPACE_URI = "http://argeo.org/ns/ldap";
+ public final static String LDAP_NAMESPACE_URI = "http://www.argeo.org/ns/ldap";
public final static String LDAP_DEFAULT_PREFIX = "ldap";
- public final static String ROLE_NAMESPACE_URI = "http://argeo.org/ns/role";
+ public final static String ROLE_NAMESPACE_URI = "http://www.argeo.org/ns/role";
public final static String ROLE_DEFAULT_PREFIX = "role";
private final ContentName value;
*/
@Override
- public List<QName> getTypes() {
+ public List<QName> getContentClasses() {
return new ArrayList<>();
}
import java.net.URL;
import java.util.Objects;
+import org.argeo.api.acr.CrName;
+
public enum CmsContentTypes {
- CR_2("cr", "http://argeo.org/ns/cr", "cr.xsd", null),
+ CR_2(CrName.CR_DEFAULT_PREFIX, CrName.CR_NAMESPACE_URI, "cr.xsd", null),
//
XSD_2001("xs", "http://www.w3.org/2001/XMLSchema", "XMLSchema.xsd", "http://www.w3.org/2001/XMLSchema.xsd"),
//
//
XLINK_1999("xlink", "http://www.w3.org/1999/xlink", "xlink.xsd", "http://www.w3.org/XML/2008/06/xlink.xsd"),
//
- XSLT_2_0("xsl", "http://www.w3.org/1999/XSL/Transform", "schema-for-xslt20.xsd", "https://www.w3.org/2007/schema-for-xslt20.xsd"),
+ XSLT_2_0("xsl", "http://www.w3.org/1999/XSL/Transform", "schema-for-xslt20.xsd",
+ "https://www.w3.org/2007/schema-for-xslt20.xsd"),
//
SVG_1_1("svg", "http://www.w3.org/2000/svg", "SVG.xsd",
"https://raw.githubusercontent.com/oreillymedia/HTMLBook/master/schema/svg/SVG.xsd"),
//
- DOCBOOK_5_0_1("dbk","http://docbook.org/ns/docbook","docbook.xsd","http://docbook.org/xml/5.0.1/xsd/docbook.xsd"),
+ DOCBOOK_5_0_1("dbk", "http://docbook.org/ns/docbook", "docbook.xsd",
+ "http://docbook.org/xml/5.0.1/xsd/docbook.xsd"),
//
XML_EVENTS_2001("ev", "http://www.w3.org/2001/xml-events", "xml-events-attribs-1.xsd",
"http://www.w3.org/MarkUp/SCHEMA/xml-events-attribs-1.xsd"),
}
@Override
- public List<QName> getTypes() {
+ public List<QName> getContentClasses() {
Dictionary<String, Object> properties = doGetProperties();
List<QName> contentClasses = new ArrayList<>();
String objectClass = properties.get(LdapAttrs.objectClass.name()).toString();
* TYPING
*/
@Override
- public List<QName> getTypes() {
- List<QName> contentClasses = super.getTypes();
+ public List<QName> getContentClasses() {
+ List<QName> contentClasses = super.getContentClasses();
contentClasses.add(CrName.COLLECTION.get());
return contentClasses;
}
*/
@Override
- public List<QName> getTypes() {
+ public List<QName> getContentClasses() {
List<QName> res = new ArrayList<>();
if (Files.isDirectory(path))
res.add(CrName.COLLECTION.get());
* TYPING
*/
@Override
- public List<QName> getTypes() {
+ public List<QName> getContentClasses() {
List<QName> res = new ArrayList<>();
res.add(getName());
return res;
import org.argeo.osgi.useradmin.TokenUtils;
import org.argeo.osgi.useradmin.UserDirectory;
import org.argeo.util.directory.DirectoryConf;
+import org.argeo.util.directory.ldap.SharedSecret;
import org.argeo.util.naming.LdapAttrs;
import org.argeo.util.naming.NamingUtils;
-import org.argeo.util.naming.SharedSecret;
import org.argeo.util.transaction.WorkTransaction;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.useradmin.Authorization;
import org.argeo.util.directory.DirectoryDigestUtils;
import org.argeo.util.naming.LdapAttrs;
import org.argeo.util.naming.LdapObjs;
-import org.argeo.util.naming.SharedSecret;
/** An entry in an LDAP (or LDIF) directory. */
public class DefaultLdapEntry implements LdapEntry {
--- /dev/null
+package org.argeo.util.directory.ldap;
+
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+
+import org.argeo.util.naming.NamingUtils;
+
+public class SharedSecret extends AuthPassword {
+ public final static String X_SHARED_SECRET = "X-SharedSecret";
+ private final Instant expiry;
+
+ public SharedSecret(String authInfo, String authValue) {
+ super(authInfo, authValue);
+ expiry = null;
+ }
+
+ public SharedSecret(AuthPassword authPassword) {
+ super(authPassword);
+ String authInfo = getAuthInfo();
+ if (authInfo.length() == 16) {
+ expiry = NamingUtils.ldapDateToInstant(authInfo);
+ } else {
+ expiry = null;
+ }
+ }
+
+ public SharedSecret(ZonedDateTime expiryTimestamp, String value) {
+ super(NamingUtils.instantToLdapDate(expiryTimestamp), value);
+ expiry = expiryTimestamp.withZoneSameInstant(ZoneOffset.UTC).toInstant();
+ }
+
+ public SharedSecret(int hours, String value) {
+ this(ZonedDateTime.now().plusHours(hours), value);
+ }
+
+ @Override
+ protected String getExpectedAuthScheme() {
+ return X_SHARED_SECRET;
+ }
+
+ public boolean isExpired() {
+ if (expiry == null)
+ return false;
+ return expiry.isBefore(Instant.now());
+ }
+
+}
* "https://github.com/krb5/krb5/blob/master/src/plugins/kdb/ldap/libkdb_ldap/kerberos.schema">Kerberos
* LDAP (partial)</a>
*/
-public enum LdapAttrs implements SpecifiedName, Supplier<String> {
+public enum LdapAttrs implements SpecifiedName, Supplier<String>, QNamed {
/** */
uid("0.9.2342.19200300.100.1.1", "RFC 4519"),
/** */
return spec;
}
- public String getPrefix() {
- return prefix();
- }
-
- public static String prefix() {
- return "ldap";
- }
-
@Deprecated
public String property() {
return get();
}
public String get() {
- String prefix = getPrefix();
+ String prefix = getDefaultPrefix();
return prefix != null ? prefix + ":" + name() : name();
}
- public String getNamespace() {
- return namespace();
+ @Override
+ public String getDefaultPrefix() {
+ return LdapObjs.LDAP_DEFAULT_PREFIX;
}
- public static String namespace() {
- return "http://www.argeo.org/ns/ldap";
+ @Override
+ public String getNamespace() {
+ return LdapObjs.LDAP_NAMESPACE_URI;
}
@Override
* <a href="https://www.ldap.com/ldap-oid-reference">https://www.ldap.com/ldap-
* oid-reference</a>
*/
-public enum LdapObjs implements SpecifiedName {
+public enum LdapObjs implements SpecifiedName, QNamed {
account("0.9.2342.19200300.100.4.5", "RFC 4524"),
/** */
document("0.9.2342.19200300.100.4.6", "RFC 4524"),
/** */
referral("2.16.840.1.113730.3.2.6", "RFC 3296");
- private final static String LDAP_ = "ldap:";
+ /** MUST be equal to ContentRepository LDAP namespace. */
+ final static String LDAP_NAMESPACE_URI = "http://www.argeo.org/ns/ldap";
+ /** MUST be equal to ContentRepository LDAP prefix. */
+ final static String LDAP_DEFAULT_PREFIX = "ldap";
+
+ private final static String LDAP_ = LDAP_DEFAULT_PREFIX + ":";
private final String oid, spec;
private LdapObjs(String oid, String spec) {
return new StringBuilder(LDAP_).append(name()).toString();
}
+ @Override
+ public String getDefaultPrefix() {
+ return LdapObjs.LDAP_DEFAULT_PREFIX;
+ }
+
+ @Override
+ public String getNamespace() {
+ return LdapObjs.LDAP_NAMESPACE_URI;
+ }
+
}
--- /dev/null
+package org.argeo.util.naming;
+
+import javax.xml.namespace.QName;
+
+/** A (possibly) qualified name. To be used in enums. */
+public interface QNamed {
+ String name();
+
+ default QName qName() {
+ return new DisplayQName(getNamespace(), name(), getDefaultPrefix());
+ }
+
+ String getNamespace();
+
+ String getDefaultPrefix();
+
+ static class DisplayQName extends QName {
+ private static final long serialVersionUID = 2376484886212253123L;
+
+ public DisplayQName(String namespaceURI, String localPart, String prefix) {
+ super(namespaceURI, localPart, prefix);
+ }
+
+ public DisplayQName(String localPart) {
+ super(localPart);
+ }
+
+ @Override
+ public String toString() {
+ String prefix = getPrefix();
+ assert prefix != null;
+ return "".equals(prefix) ? getLocalPart() : prefix + ":" + getLocalPart();
+ }
+
+ }
+}
+++ /dev/null
-package org.argeo.util.naming;
-
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-
-import org.argeo.util.directory.ldap.AuthPassword;
-
-public class SharedSecret extends AuthPassword {
- public final static String X_SHARED_SECRET = "X-SharedSecret";
- private final Instant expiry;
-
- public SharedSecret(String authInfo, String authValue) {
- super(authInfo, authValue);
- expiry = null;
- }
-
- public SharedSecret(AuthPassword authPassword) {
- super(authPassword);
- String authInfo = getAuthInfo();
- if (authInfo.length() == 16) {
- expiry = NamingUtils.ldapDateToInstant(authInfo);
- } else {
- expiry = null;
- }
- }
-
- public SharedSecret(ZonedDateTime expiryTimestamp, String value) {
- super(NamingUtils.instantToLdapDate(expiryTimestamp), value);
- expiry = expiryTimestamp.withZoneSameInstant(ZoneOffset.UTC).toInstant();
- }
-
- public SharedSecret(int hours, String value) {
- this(ZonedDateTime.now().plusHours(hours), value);
- }
-
- @Override
- protected String getExpectedAuthScheme() {
- return X_SHARED_SECRET;
- }
-
- public boolean isExpired() {
- if (expiry == null)
- return false;
- return expiry.isBefore(Instant.now());
- }
-
-}
package org.argeo.cms.web;
-import static org.argeo.util.naming.SharedSecret.X_SHARED_SECRET;
+import static org.argeo.util.directory.ldap.SharedSecret.X_SHARED_SECRET;
import java.io.IOException;
import java.security.PrivilegedAction;
import org.argeo.eclipse.ui.specific.UiContext;
import org.argeo.jcr.JcrUtils;
import org.argeo.util.directory.ldap.AuthPassword;
-import org.argeo.util.naming.SharedSecret;
+import org.argeo.util.directory.ldap.SharedSecret;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.application.AbstractEntryPoint;
import org.eclipse.rap.rwt.client.WebClient;