JBoss Identity SVN: r34 - in trunk/identity-impl/src/main/test/java: org and 7 other directories.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2008-07-22 19:16:09 -0400 (Tue, 22 Jul 2008)
New Revision: 34
Added:
trunk/identity-impl/src/main/test/java/org/
trunk/identity-impl/src/main/test/java/org/jboss/
trunk/identity-impl/src/main/test/java/org/jboss/test/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityManager.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityStore.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalPersistenceManager.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRealm.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRelationshipManager.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalSession.java
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/portal/
trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java
Log:
JBID-21: portal requirements mapping (Work in Progress)
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityManager.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityManager.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityManager.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,84 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import java.io.InputStream;
+
+import org.jboss.identity.api.managers.IdentityManager;
+import org.jboss.identity.api.session.Session;
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.Role;
+import org.jboss.identity.model.RoleType;
+import org.jboss.identity.model.domain.Realm;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.groups.GroupType;
+
+/**
+ * Implements the Portal Identity Manager
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalIdentityManager implements IdentityManager
+{
+ private PortalRealm portalRealm = new PortalRealm();
+
+ public Realm bootstrap(String realmName)
+ {
+ return portalRealm;
+ }
+
+ public Realm bootstrap(String realmName, InputStream config)
+ {
+ //TODO: handle config
+ return portalRealm;
+ }
+
+ public Group createGroup(Realm realm, String groupName)
+ {
+ return null;
+ }
+
+ public Group createGroup(Realm realm, String groupName, GroupType groupType)
+ {
+ return null;
+ }
+
+ public Identity createIdentity(Realm realm, String identityName)
+ {
+ return null;
+ }
+
+ public Role createRole(Realm realm, String roleName, RoleType roleType)
+ {
+ return null;
+ }
+
+ public Session createSession(String sessionType, String identityName)
+ {
+ return null;
+ }
+
+ public Realm getRealm(String realmName, boolean shouldBootstrap)
+ {
+ return portalRealm;
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityStore.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityStore.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalIdentityStore.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,136 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import java.util.Collection;
+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.model.Identity;
+import org.jboss.identity.model.IdentityType;
+import org.jboss.identity.model.relation.RelationshipType;
+
+/**
+ * Portal identity store
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalIdentityStore implements IdentityStore
+{
+ public void addAttributes(Identity identity, Map<String, String[]> attributes) throws IdentityException
+ {
+ }
+
+ public Identity createIdentity(String name) throws IdentityException
+ {
+ return null;
+ }
+
+ public void createRelationship(Identity fromIdentity, Identity toIdentity, RelationshipType relationshipType)
+ throws IdentityException
+ {
+ }
+
+ public Collection<Identity> findIdentities(IdentityType identityType, int offset, int limit,
+ String orderedByAttributeName, boolean ascending) throws IdentityException
+ {
+ return null;
+ }
+
+ public Collection<Identity> findIdentities(IdentityType 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
+ {
+ 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 void removeRelationship(Identity fromIdentity, Identity toIdentity, RelationshipType 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/test/java/org/jboss/test/identity/impl/portal/PortalPersistenceManager.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalPersistenceManager.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalPersistenceManager.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,51 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import org.jboss.identity.api.managers.PersistenceManager;
+import org.jboss.identity.api.store.IdentityStore;
+import org.jboss.identity.api.store.IdentityStoreRepository;
+import org.jboss.identity.model.IdentityType;
+import org.jboss.identity.model.domain.Realm;
+
+/**
+ * Portal Persistence Manager
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalPersistenceManager implements PersistenceManager
+{
+ public IdentityStore getIdentityStore(Realm realm)
+ {
+ return null;
+ }
+
+ public IdentityStore getIdentityStore(Realm realm, IdentityType identityType)
+ {
+ return null;
+ }
+
+ public IdentityStoreRepository getIdentityStoreRepository()
+ {
+ return null;
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRealm.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRealm.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRealm.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,58 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import org.jboss.identity.model.domain.ModelRoot;
+import org.jboss.identity.model.domain.Realm;
+import org.jboss.identity.model.domain.SimpleModelRoot;
+
+/**
+ * Represents a Portal Realm
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalRealm implements Realm
+{
+ private ModelRoot identityModelRoot, groupModelRoot, relationshipModelRoot;
+
+ public void createModelRoots()
+ {
+ identityModelRoot = new SimpleModelRoot("Identity");
+ groupModelRoot = new SimpleModelRoot("Group");
+ relationshipModelRoot = new SimpleModelRoot("Relationship");
+ }
+
+ public ModelRoot getGroupModelRoot()
+ {
+ return this.groupModelRoot;
+ }
+
+ public ModelRoot getIdentityModelRoot()
+ {
+ return this.identityModelRoot;
+ }
+
+ public ModelRoot getRelationshipModelRoot()
+ {
+ return this.relationshipModelRoot;
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRelationshipManager.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRelationshipManager.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalRelationshipManager.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,132 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.identity.api.exception.PersistenceManagerNotFoundException;
+import org.jboss.identity.api.exception.SessionNotOpenException;
+import org.jboss.identity.api.managers.PersistenceManager;
+import org.jboss.identity.api.managers.RelationshipManager;
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.Role;
+import org.jboss.identity.model.domain.Realm;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.relation.RelationshipType;
+
+/**
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalRelationshipManager implements RelationshipManager
+{
+ public void associate(Group groupA, Group groupB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+
+ public void associate(Group groupA, List<Group> groupB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void associate(Realm realmA, Realm realmB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void associate(Realm realm, Identity identity, Role role) throws PersistenceManagerNotFoundException,
+ SessionNotOpenException
+ {
+ }
+
+ public void associate(Realm realm, Identity identity, List<Role> roleList)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void associate(Realm realm, Identity identity, Group group) throws PersistenceManagerNotFoundException,
+ SessionNotOpenException
+ {
+ }
+
+ public void associate(Realm realm, Identity identity, Set<Group> groupSet)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Group groupA, Group groupB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Group groupA, List<Group> groupB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Realm realmA, Realm realmB, RelationshipType relationshipType)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Realm realm, Identity identity, Role role) throws PersistenceManagerNotFoundException,
+ SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Realm realm, Identity identity, List<Role> roleList)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Realm realm, Identity identity, Group group) throws PersistenceManagerNotFoundException,
+ SessionNotOpenException
+ {
+ }
+
+ public void disassociate(Realm realm, Identity identity, Set<Group> groupSet)
+ throws PersistenceManagerNotFoundException, SessionNotOpenException
+ {
+ }
+
+ public PersistenceManager getPersistenceManager()
+ {
+ return null;
+ }
+
+ public RelationshipType getRelationship(Group fromGroup, Group toGroup)
+ {
+ return null;
+ }
+
+ public RelationshipType getRelationship(Realm fromRealm, Realm toRealm)
+ {
+ return null;
+ }
+
+ public void setPersistenceManager(PersistenceManager persistenceManager)
+ {
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalSession.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalSession.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/portal/PortalSession.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,90 @@
+/*
+ * 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.test.identity.impl.portal;
+
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.jboss.identity.api.exception.IdentityException;
+import org.jboss.identity.api.session.Session;
+import org.jboss.identity.api.session.SessionState;
+
+/**
+ * Portal Session
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalSession implements Session
+{
+ private static ConcurrentHashMap<String,PortalSession>
+ portalSessions = new ConcurrentHashMap<String,PortalSession>();
+
+ private String id = UUID.randomUUID().toString();
+
+ private SessionState state;
+
+ private PortalSession()
+ {
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void clear() throws IdentityException
+ {
+ }
+
+ public void close() throws IdentityException
+ {
+ state = SessionState.CLOSED;
+ }
+
+ public boolean isOpen()
+ {
+ return state != SessionState.CLOSED;
+ }
+
+ public void open() throws IdentityException
+ {
+ if(!isOpen())
+ state = SessionState.OPEN;
+ }
+
+ public void save() throws IdentityException
+ {
+ }
+
+ public static PortalSession getSession(String id)
+ {
+ //TODO: handle security better
+ return portalSessions.get(id);
+ }
+
+ public static PortalSession newSession()
+ {
+ PortalSession newPortalSession = new PortalSession();
+ portalSessions.put(newPortalSession.id, newPortalSession);
+ return newPortalSession;
+ }
+}
\ No newline at end of file
Added: trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java
===================================================================
--- trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java (rev 0)
+++ trunk/identity-impl/src/main/test/java/org/jboss/test/identity/impl/test/portal/PortalIdentityUnitTestCase.java 2008-07-22 23:16:09 UTC (rev 34)
@@ -0,0 +1,119 @@
+/*
+ * 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.test.identity.impl.test.portal;
+
+import org.jboss.identity.api.managers.IdentityManager;
+import org.jboss.identity.api.managers.RelationshipManager;
+import org.jboss.identity.model.Identity;
+import org.jboss.identity.model.groups.Group;
+import org.jboss.identity.model.groups.GroupType;
+import org.jboss.identity.model.groups.SimpleGroupType;
+import org.jboss.identity.model.relation.HierarchicalRelationshipType;
+import org.jboss.identity.model.relation.RelationshipType;
+import org.jboss.test.identity.impl.portal.PortalIdentityManager;
+import org.jboss.test.identity.impl.portal.PortalRealm;
+import org.jboss.test.identity.impl.portal.PortalRelationshipManager;
+
+import junit.framework.TestCase;
+
+/**
+ * Portal identity unit test
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Jul 22, 2008
+ */
+public class PortalIdentityUnitTestCase extends TestCase
+{
+ private RelationshipType hierarchy = new HierarchicalRelationshipType();
+ private RelationshipManager relationshipManager = new PortalRelationshipManager();
+ private IdentityManager identityManager = new PortalIdentityManager();
+ private PortalRealm portalRealm ;
+
+ protected void setUp() throws Exception
+ {
+ portalRealm = (PortalRealm) identityManager.bootstrap("portal");
+ portalRealm.createModelRoots();
+ }
+
+ public void testPortalIdentity() throws Exception
+ {
+ bootstrapOrganizationType();
+ }
+
+ /**
+ * Bootstrap the organization type system
+ */
+ private void bootstrapOrganizationType() throws Exception
+ {
+ //***************************************************
+ // Create the Group Model
+ //***************************************************
+ GroupType organizationGroupType = new SimpleGroupType("Organization");
+ Group redhatGroup = identityManager.createGroup(portalRealm, "RedHat",
+ organizationGroupType);
+
+ Group jbossGroup = identityManager.createGroup(portalRealm, "JBoss",
+ organizationGroupType);
+ Group rhelGroup = identityManager.createGroup(portalRealm, "RHEL",
+ organizationGroupType);
+
+ relationshipManager.associate(redhatGroup, jbossGroup, hierarchy);
+ relationshipManager.associate(redhatGroup, rhelGroup, hierarchy);
+
+ Group itGroup = identityManager.createGroup(portalRealm, "IT",
+ organizationGroupType);
+ Group hrGroup = identityManager.createGroup(portalRealm, "HR",
+ organizationGroupType);
+
+ relationshipManager.associate(jbossGroup, itGroup, hierarchy);
+ relationshipManager.associate(jbossGroup, hrGroup, hierarchy);
+
+ Group projectsGroup = identityManager.createGroup(portalRealm, "Projects",
+ organizationGroupType);
+ Group supportGroup = identityManager.createGroup(portalRealm, "Support",
+ organizationGroupType);
+
+ relationshipManager.associate(itGroup, projectsGroup, hierarchy);
+ relationshipManager.associate(itGroup, supportGroup, hierarchy);
+
+ Group portalGroup = identityManager.createGroup(portalRealm, "Portal",
+ organizationGroupType);
+ Group jbpmGroup = identityManager.createGroup(portalRealm, "jBPM",
+ organizationGroupType);
+ Group soaGroup = identityManager.createGroup(portalRealm, "SOA",
+ organizationGroupType);
+
+ relationshipManager.associate(projectsGroup, portalGroup, hierarchy);
+ relationshipManager.associate(projectsGroup, jbpmGroup, hierarchy);
+ relationshipManager.associate(projectsGroup, soaGroup, hierarchy);
+
+
+ //***************************************************
+ // Create the Identity Model
+ //***************************************************
+ //Create Identities - julien, theute and associate with portal group
+ Identity julien = identityManager.createIdentity(portalRealm, "julien");
+ Identity theute = identityManager.createIdentity(portalRealm, "theute");
+
+ relationshipManager.associate(portalRealm, julien, portalGroup);
+ relationshipManager.associate(portalRealm, theute, portalGroup);
+ }
+}
\ No newline at end of file