Author: anil.saldhana(a)jboss.com
Date: 2008-08-30 06:50:54 -0400 (Sat, 30 Aug 2008)
New Revision: 42
Added:
trunk/identity-impl/src/main/java/org/
trunk/identity-impl/src/main/java/org/jboss/
trunk/identity-impl/src/main/java/org/jboss/identity/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleGroup.java
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentity.java
Log:
impl
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java
===================================================================
---
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/store/FileBasedIdentityStore.java 2008-08-30
10:50:54 UTC (rev 42)
@@ -0,0 +1,208 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.impl.store;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.identity.api.exception.IdentityException;
+import org.jboss.identity.api.store.FeaturesDescription;
+import org.jboss.identity.api.store.IdentityStore;
+import org.jboss.identity.impl.types.SimpleGroup;
+import org.jboss.identity.impl.types.SimpleIdentity;
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.IdentityType;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.relation.RelationshipType;
+
+/**
+ * File Based Identity Store
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Aug 1, 2008
+ */
+public class FileBasedIdentityStore implements IdentityStore
+{
+ //TODO: Handle file semantics
+
+ private List<Identity> identities = new ArrayList<Identity>();
+
+ private List<Group> groups = new ArrayList<Group>();
+
+ public void addAttributes(Identity identity, Map<String, String[]> attributes)
+ throws IdentityException
+ {
+ }
+
+ public void bootstrap() throws IOException
+ {
+ }
+
+ public Identity createIdentity(String name) throws IdentityException
+ {
+ //Is there one already available?
+ Identity identity = this.findIdentity(name);
+ if(identity == null)
+ {
+ identity = new SimpleIdentity(name);
+ identities.add(identity);
+ }
+ return identity;
+ }
+
+ public <R extends RelationshipType> void createRelationship(Identity
fromIdentity,
+ Identity toIdentity,
+ R relationshipType)
+ throws IdentityException
+ {
+ }
+
+ public Group createGroup(String groupName) throws IdentityException
+ {
+ Group group = findGroup(groupName);
+ if(group == null)
+ {
+ group = new SimpleGroup(groupName);
+ groups.add(group);
+ }
+ return group;
+ }
+
+
+ public Group findGroup(String groupName)
+ {
+ for(Group group: groups)
+ {
+ if(group.getName().equals(groupName))
+ return group;
+ }
+ return null;
+ }
+
+ public void removeGroup(Group group) throws IdentityException
+ {
+ groups.remove(group);
+ }
+
+ public <T extends IdentityType> Collection<Identity> findIdentities(T
identityType,
+ int offset,
+ int limit,
+ String orderedByAttributeName, boolean ascending) throws IdentityException
+ {
+ return null;
+ }
+
+ public <T extends IdentityType> Collection<Identity> findIdentities(T
identityType,
+ Map<String, String[]> attributes, int offset,
+ int limit, String orderedByAttributeName, boolean ascending)
+ throws IdentityException
+ {
+ return null;
+ }
+
+ public Collection<Identity> findIdentities(Identity identity,
+ RelationshipType relationshipType, boolean parent,
+ int offset, int limit, String orderedByAttributeName,
+ boolean ascending) throws IdentityException
+ {
+ return null;
+ }
+
+ public Identity findIdentity(String name) throws IdentityException
+ {
+ for(Identity identity: identities)
+ {
+ if(name.equals(identity.getName()))
+ return identity;
+ }
+ return null;
+ }
+
+ public Identity findIdentity(Object id) throws IdentityException
+ {
+ return null;
+ }
+
+ public Map<String, String[]> getAttributes(Identity identity)
+ throws IdentityException
+ {
+ return null;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public int getIdentitiesCount(IdentityType identityType)
+ throws IdentityException
+ {
+ return 0;
+ }
+
+ public Set<String> getSupportedAttributeNames(IdentityType identityType)
+ throws IdentityException
+ {
+ return null;
+ }
+
+ public FeaturesDescription getSupportedFeatures()
+ {
+ return null;
+ }
+
+ public void removeAttributes(Identity identity, Set<String> attributes)
+ throws IdentityException
+ {
+ }
+
+ public void removeIdentity(Identity identity) throws IdentityException
+ {
+ }
+
+ public <R extends RelationshipType> void removeRelationship(Identity
fromIdentity,
+ Identity toIdentity,
+ R relationshipType)
+ throws IdentityException
+ {
+ }
+
+ public void removeRelationships(Identity identity1, Identity identity2)
+ throws IdentityException
+ {
+ }
+
+ public Set<RelationshipType> resolveRelationships(Identity fromIdentity,
+ Identity toIdentity)
+ throws IdentityException
+ {
+ return null;
+ }
+
+ public void updateAttributes(Identity identity, Map<String, String[]>
attributes)
+ throws IdentityException
+ {
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleGroup.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleGroup.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleGroup.java 2008-08-30
10:50:54 UTC (rev 42)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.impl.types;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.identity.model.IdentityAttribute;
+import org.jboss.identity.model.Role;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.policy.PolicyValidationException;
+import org.jboss.identity.model.policy.RelationshipPolicy;
+
+/**
+ * A simple implementation of group
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Aug 6, 2008
+ */
+public class SimpleGroup implements Group
+{
+ private String name;
+
+ public SimpleGroup(String name)
+ {
+ this.name = name;
+ }
+
+ public void add(RelationshipPolicy<Group, Group> relationPolicy)
+ {
+ }
+
+ public void addAll(Collection<RelationshipPolicy<Group, Group>>
relationList)
+ {
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public Group getParent()
+ {
+ return null;
+ }
+
+ public List<RelationshipPolicy<Group, Group>> getRelationshipPolicies()
+ {
+ return null;
+ }
+
+ public List<Role> getRoles()
+ {
+ return null;
+ }
+
+ public List<Group> getSubGroups()
+ {
+ return null;
+ }
+
+ public List<IdentityAttribute> getAttributes()
+ {
+ return null;
+ }
+
+ public void validatePolicy() throws PolicyValidationException
+ {
+ }
+}
\ No newline at end of file
Added:
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentity.java
===================================================================
--- trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentity.java
(rev 0)
+++
trunk/identity-impl/src/main/java/org/jboss/identity/impl/types/SimpleIdentity.java 2008-08-30
10:50:54 UTC (rev 42)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.impl.types;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.IdentityAttribute;
+import org.jboss.identity.model.Role;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.policy.PolicyValidationException;
+
+/**
+ * Very simple identity
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Aug 6, 2008
+ */
+public class SimpleIdentity implements Identity
+{
+ protected String name;
+ protected List<IdentityAttribute> attributes = Collections.emptyList();
+ protected List<Group> groups = Collections.emptyList();
+ protected List<Role> roles = Collections.emptyList();
+
+ public SimpleIdentity(String n)
+ {
+ this.name = n;
+ }
+
+ public List<IdentityAttribute> getAttributes()
+ {
+ return Collections.unmodifiableList(attributes);
+ }
+
+ public List<Group> getGroups()
+ {
+ return Collections.unmodifiableList(groups);
+ }
+
+ public List<Role> getRoles()
+ {
+ return Collections.unmodifiableList(roles);
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void validatePolicy() throws PolicyValidationException
+ {
+ }
+}
\ No newline at end of file