Major refactoring of Argeo CMS UI
[lgpl/argeo-commons.git] / org.argeo.api / src / org / argeo / api / cms / CmsSessionId.java
diff --git a/org.argeo.api/src/org/argeo/api/cms/CmsSessionId.java b/org.argeo.api/src/org/argeo/api/cms/CmsSessionId.java
new file mode 100644 (file)
index 0000000..0e47789
--- /dev/null
@@ -0,0 +1,39 @@
+package org.argeo.api.cms;
+
+import java.util.UUID;
+
+import javax.security.auth.Subject;
+
+/**
+ * The ID of a {@link CmsSession}, which must be available in the private
+ * credentials of an authenticated {@link Subject}.
+ */
+public class CmsSessionId {
+       private final UUID uuid;
+
+       public CmsSessionId(UUID value) {
+               if (value == null)
+                       throw new IllegalArgumentException("Value cannot be null");
+               this.uuid = value;
+       }
+
+       public UUID getUuid() {
+               return uuid;
+       }
+
+       @Override
+       public int hashCode() {
+               return uuid.hashCode();
+       }
+
+       @Override
+       public boolean equals(Object obj) {
+               return obj instanceof CmsSessionId && ((CmsSessionId) obj).getUuid().equals(uuid);
+       }
+
+       @Override
+       public String toString() {
+               return "Node Session " + uuid;
+       }
+
+}