/**
* Find an entity descriptor by its unique identifier.
*
+ * @param id The unique identifier of the site of interest
+ * @param strict Honor metadata validity information?
+ *
+ * @return The corresponding entity
+ */
+ EntityDescriptor lookup(String id, boolean strict);
+
+ /**
+ * Find an entity descriptor that issued a SAML artifact.
+ *
+ * @param artifact The artifact whose source site is of interest
+ * @param strict Honor metadata validity information?
+
+ * @return The issuing entity
+ */
+ EntityDescriptor lookup(Artifact artifact, boolean strict);
+
+ /**
+ * Find an entity descriptor by its unique identifier.
+ *
* @param id
* The unique identifier of the site of interest
* @return The corresponding entity
* @return The issuing entity
*/
EntityDescriptor lookup(Artifact artifact);
+
+ /**
+ * Get access to the root entity in the metadata instance,
+ * or null if the root is a group.
+ *
+ * @return The root entity, if any
+ */
+ EntityDescriptor getRootEntity();
+
+ /**
+ * Get access to the root entity group in the metadata instance,
+ * or null if the root is a single entity.
+ *
+ * @return The root group, if any
+ */
+ EntitiesDescriptor getRootEntities();
}
import edu.internet2.middleware.shibboleth.common.ResourceWatchdogExecutionException;
import edu.internet2.middleware.shibboleth.common.ShibResource;
import edu.internet2.middleware.shibboleth.common.ShibResource.ResourceNotAvailableException;
+import edu.internet2.middleware.shibboleth.metadata.EntitiesDescriptor;
import edu.internet2.middleware.shibboleth.metadata.EntityDescriptor;
import edu.internet2.middleware.shibboleth.metadata.Metadata;
import edu.internet2.middleware.shibboleth.metadata.MetadataException;
}
public EntityDescriptor lookup(String providerId) {
+ return lookup(providerId, true);
+ }
+
+ public EntityDescriptor lookup(Artifact artifact) {
+ return lookup(artifact, true);
+ }
+ public EntityDescriptor lookup(String id, boolean strict) {
synchronized (currentMeta) {
- return currentMeta.lookup(providerId);
+ return currentMeta.lookup(id, strict);
}
}
- public EntityDescriptor lookup(Artifact artifact) {
+ public EntityDescriptor lookup(Artifact artifact, boolean strict) {
+ synchronized (currentMeta) {
+ return currentMeta.lookup(artifact, strict);
+ }
+ }
+
+ public EntityDescriptor getRootEntity() {
+ synchronized (currentMeta) {
+ return currentMeta.getRootEntity();
+ }
+ }
+ public EntitiesDescriptor getRootEntities() {
synchronized (currentMeta) {
- return currentMeta.lookup(artifact);
+ return currentMeta.getRootEntities();
}
}
protected void doOnChange() throws ResourceWatchdogExecutionException {
Metadata newMeta = null;
- Document newDoc = null;
try {
log.info("Detected a change in the metadata. Reloading from (" + resource.getURL().toString() + ").");
}
}
- public EntityDescriptor lookup(String id) {
+ public EntityDescriptor lookup(String id, boolean strict) {
ArrayList list = (ArrayList)sites.get(id);
if (list != null) {
long now = System.currentTimeMillis();
if (now < ((XMLEntityDescriptor)list.get(i)).getValidUntil())
return (EntityDescriptor)list.get(i);
}
+ if (!strict && list.size() > 0)
+ return (EntityDescriptor)list.get(0);
}
return null;
}
- public EntityDescriptor lookup(Artifact artifact) {
+ public EntityDescriptor lookup(Artifact artifact, boolean strict) {
ArrayList list = null;
if (artifact instanceof SAMLArtifactType0001) {
if (now < ((XMLEntityDescriptor)list.get(i)).getValidUntil())
return (EntityDescriptor)list.get(i);
}
+ if (!strict && list.size() > 0)
+ return (EntityDescriptor)list.get(0);
}
return null;
}
+ public EntityDescriptor lookup(String id) {
+ return lookup(id, true);
+ }
+
+ public EntityDescriptor lookup(Artifact artifact) {
+ return lookup(artifact, true);
+ }
+
+ public EntityDescriptor getRootEntity() {
+ return rootProvider;
+ }
+
+ public EntitiesDescriptor getRootEntities() {
+ return rootGroup;
+ }
+
class XMLEndpoint implements Endpoint {
private Element root = null;
private String binding = null;