(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sat, 1 May 2010 09:45:29 +0000 (09:45 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Sat, 1 May 2010 09:45:29 +0000 (09:45 +0000)
16 files changed:
security/impl/src/main/java/org/wamblee/usermgt/jpa/JpaGroupSet.java
security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/AuthorizationMappingFiles.java [deleted file]
security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateGroupSet.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationLightComponent.java [deleted file]
security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UsermgtHibernateMappingFiles.java [deleted file]
security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java [deleted file]
security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java [deleted file]
security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java [deleted file]
security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java [deleted file]
security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/UserMgtRepositoryTestContainer.java [deleted file]

index b9db23975f748f71e3124eb7a45b5d4c8a18bd7b..2150b43a653f05d2ad5cc5946ed7af2ea3407432 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2005-2010 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.wamblee.usermgt.jpa;
 
 import java.util.List;
@@ -11,6 +26,11 @@ import org.wamblee.persistence.JpaMergeSupport;
 import org.wamblee.usermgt.Group;
 import org.wamblee.usermgt.GroupSet;
 
+/**
+ * Group set backed by the database.
+ * 
+ * @author Erik Brakkee
+ */
 public class JpaGroupSet implements GroupSet {
 
     private EntityManager em;
diff --git a/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/AuthorizationMappingFiles.java b/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/AuthorizationMappingFiles.java
deleted file mode 100644 (file)
index b8c6f9e..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.security.authorization.hibernate;
-
-import org.wamblee.usermgt.hibernate.UsermgtHibernateMappingFiles;
-
-/**
- * Mapping files for authorization.
- * 
- * @author Erik Brakkee
- */
-public class AuthorizationMappingFiles extends UsermgtHibernateMappingFiles {
-    /**
-     * Creates a new AuthorizationMappingFiles object.
-     */
-    public AuthorizationMappingFiles() {
-        super(new String[] { "hbm/AuthorizationRule.hbm.xml",
-            "hbm/UserCondition.hbm.xml", "hbm/AuthorizationService.hbm.xml",
-            "hbm/OperationCondition.hbm.xml", "hbm/PathCondition.hbm.xml",
-            "hbm/TestAuthorizationRule.hbm.xml" });
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java b/security/jpatest/src/main/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationService.java
deleted file mode 100644 (file)
index a78b2ac..0000000
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.security.authorization.hibernate;
-
-import java.util.List;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-import org.wamblee.security.authorization.AbstractAuthorizationRule;
-import org.wamblee.security.authorization.AbstractAuthorizationService;
-import org.wamblee.security.authorization.AuthorizationRule;
-import org.wamblee.security.authorization.DefaultAuthorizationService;
-import org.wamblee.security.authorization.Operation;
-import org.wamblee.usermgt.UserAccessor;
-
-/**
- * Authorization service with persistent storage. This is a wrapper for
- * {@link org.wamblee.security.authorization.DefaultAuthorizationService} which
- * refreshes the state of the service at certain time intervals.
- * 
- * @author Erik Brakkee
- */
-public class PersistentAuthorizationService extends AbstractAuthorizationService {
-    /**
-     * Name of query to find the service by name.
-     */
-    private static final String FIND_QUERY = "findAuthorizationServiceByName";
-
-    /**
-     * Name of the query parameter for the service name.
-     */
-    private static final String NAME_PARAM = "name";
-
-    /**
-     * Authorization service to use.
-     */
-    private DefaultAuthorizationService service;
-
-    /**
-     * Hibernate template to use.
-     */
-    private HibernateTemplate template;
-
-    /**
-     * User accessor.
-     */
-    private UserAccessor userAccessor;
-
-    /**
-     * Name of the service.
-     */
-    private String name;
-
-    /**
-     * Refresh interval in milliseconds.
-     */
-    private final long refreshInterval;
-
-    /**
-     * Last refresh time.
-     */
-    private long lastRefreshTime;
-
-    /**
-     * Constructs the persistent service.
-     * 
-     * @param aName
-     *            Name of the service.
-     * @param aTemplate
-     *            Hibernate template for hibernate usage.
-     * @param aAccessor
-     *            User accessor.
-     * @param aRefresh
-     *            Whether or not to refresh the state of the service at the
-     *            start of every operation.
-     */
-    public PersistentAuthorizationService(String aName,
-        HibernateTemplate aTemplate, UserAccessor aAccessor,
-        long aRefreshInterval) {
-        template = aTemplate;
-        refreshInterval = aRefreshInterval;
-        lastRefreshTime = System.currentTimeMillis();
-        userAccessor = aAccessor;
-        name = aName;
-    }
-    
-    @Override
-    public void setUserAccessor(UserAccessor aUserAccessor) {
-        userAccessor = aUserAccessor;   
-    }
-
-    /**
-     * Initialize service if needed.
-     * 
-     */
-    private void initialize() {
-        if (service == null) {
-            List<DefaultAuthorizationService> result = template
-                .findByNamedQueryAndNamedParam(FIND_QUERY, NAME_PARAM, name);
-
-            if (result.size() > 1) {
-                throw new IllegalArgumentException(
-                    "Returned more than one service for name '" + name + "' (" +
-                        result.size() + ")");
-            }
-
-            if (result.size() == 0) {
-                service = new DefaultAuthorizationService(userAccessor, name);
-                template.persist(service);
-            } else {
-                service = result.get(0);
-                service.setUserAccessor(userAccessor);
-            }
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationService#isAllowed(java
-     * .lang.Object, org.wamblee.security.authorization.Operation)
-     */
-    public boolean isAllowed(Object aResource, Operation aOperation) {
-        initialize();
-        refresh();
-
-        return service.isAllowed(aResource, aOperation);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.security.authorization.AuthorizationService#check(T,
-     * org.wamblee.security.authorization.Operation)
-     */
-    public <T> T check(T aResource, Operation aOperation) {
-        initialize();
-        refresh();
-
-        return service.check(aResource, aOperation);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.security.authorization.AuthorizationService#getRules()
-     */
-    public AuthorizationRule[] getRules() {
-        initialize();
-        refresh();
-
-        return service.getRules();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationService#appendRule(org
-     * .wamblee.security.authorization.AuthorizationRule)
-     */
-    public void appendRule(AuthorizationRule aRule) {
-        initialize();
-        refresh();
-        service.appendRule(aRule);
-        save();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationService#removeRule(int)
-     */
-    public void removeRule(int aIndex) {
-        initialize();
-        refresh();
-        service.removeRule(aIndex);
-        save();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationService#insertRuleAfter
-     * (int, org.wamblee.security.authorization.AuthorizationRule)
-     */
-    public void insertRuleAfter(int aIndex, AuthorizationRule aRule) {
-        initialize();
-        refresh();
-        service.insertRuleAfter(aIndex, aRule);
-        save();
-    }
-
-    /**
-     * Refreshes the state of the service through hibernate.
-     */
-    private synchronized void refresh() {
-        long time = System.currentTimeMillis();
-
-        if ((time - lastRefreshTime) > refreshInterval) {
-            template.refresh(service);
-            lastRefreshTime = time;
-        }
-    }
-
-    /**
-     * Saves any changes to the service state if necessary.
-     */
-    private void save() {
-       // HibernateSupport.merge(template, service);
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/UserGroupRepositoryComponent.java
deleted file mode 100644 (file)
index 118da98..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.hibernate.SessionFactory;
-import org.wamblee.cache.EhCache;
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.core.RequiredInterface;
-import org.wamblee.system.spring.SpringComponent;
-
-/**
- * 
- * @author $author$
- * @version $Revision$
- */
-public class UserGroupRepositoryComponent extends SpringComponent {
-    /**
-     * Creates a new UserGroupRepositoryComponent object.
-     * 
-     */
-    public UserGroupRepositoryComponent(String aName) {
-        super(
-            aName,
-            new String[] { "spring/org.wamblee.security.usermgt-repositories.xml" },
-            createProvided(), createRequired());
-    }
-
-    private static Map<RequiredInterface, String> createRequired() {
-        Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
-        required.put(new DefaultRequiredInterface("sessionFactory",
-            SessionFactory.class), "sessionFactory");
-
-        return required;
-    }
-
-    private static Map<String, ProvidedInterface> createProvided() {
-        Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-        provided.put("userCache", new DefaultProvidedInterface("cache",
-            EhCache.class));
-        provided.put(UserSet.class.getName(), new DefaultProvidedInterface(
-            "userset", UserSet.class));
-        provided.put(GroupSet.class.getName(), new DefaultProvidedInterface(
-            "groupset", GroupSet.class));
-
-        return provided;
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationComponent.java
deleted file mode 100644 (file)
index 2c01e65..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import java.io.IOException;
-
-import javax.sql.DataSource;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-import org.springframework.transaction.PlatformTransactionManager;
-import org.wamblee.security.authorization.AbstractAuthorizationService;
-import org.wamblee.security.authorization.hibernate.AuthorizationMappingFiles;
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.components.ORMappingConfig;
-import org.wamblee.system.core.Component;
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.spring.component.HibernateComponent;
-import org.wamblee.usermgt.UserAccessor;
-
-/**
- * 
- * @author $author$
- * @version $Revision$
- */
-public class AuthorizationComponent extends DefaultContainer {
-    private ProvidedInterface transactionMgr = new DefaultProvidedInterface(
-        "transactionManager", PlatformTransactionManager.class);
-
-    private ProvidedInterface hibernateTemplate = new DefaultProvidedInterface(
-        "hibernateTemplate", HibernateTemplate.class);
-
-    private ProvidedInterface authorizationService = new DefaultProvidedInterface(
-        "authorizationService", AbstractAuthorizationService.class);
-
-    /**
-     * Creates a new AuthorizationComponent object.
-     * 
-     * 
-     */
-    public AuthorizationComponent(String aName, boolean aExposeInternals)
-        throws IOException {
-        super(aName);
-
-        ObjectConfiguration authConfig = new ObjectConfiguration(
-            AuthorizationMappingFiles.class);
-        authConfig.getSetterConfig().initAllSetters();
-        addComponent("mappingFiles", new AuthorizationMappingFiles(),
-            authConfig);
-
-        Component<?> hibernate = new HibernateComponent("hibernate");
-        addComponent(hibernate);
-
-        Component<?> authorization = new AuthorizationLightComponent(
-            "authorization");
-        addComponent(authorization);
-
-        addRequiredInterface(new DefaultRequiredInterface("datasource",
-            DataSource.class));
-        addRequiredInterface(new DefaultRequiredInterface("userAccessor",
-            UserAccessor.class));
-        addRequiredInterface(new DefaultRequiredInterface("ormconfig",
-            ORMappingConfig.class));
-
-        if (aExposeInternals) {
-            addProvidedInterface(transactionMgr);
-            addProvidedInterface(hibernateTemplate);
-        }
-
-        addProvidedInterface(authorizationService);
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/AuthorizationLightComponent.java
deleted file mode 100644 (file)
index 29e2984..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-import org.wamblee.security.authorization.AbstractAuthorizationService;
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.core.RequiredInterface;
-import org.wamblee.system.spring.SpringComponent;
-import org.wamblee.usermgt.UserAccessor;
-
-/**
- * Light version of the user administration component that requires external
- * datasource, and userset and group set components, as well as an external
- * hibernate session factory.
- * 
- * @author Erik Brakkee
- */
-public class AuthorizationLightComponent extends SpringComponent {
-    /**
-     * Creates a new AuthorizationLightComponent object.
-     * 
-     */
-    public AuthorizationLightComponent(String aName) {
-        super(aName,
-            new String[] { "spring/org.wamblee.security.authorization.xml" },
-            createProvided(), createRequired());
-    }
-
-    private static Map<RequiredInterface, String> createRequired() {
-        Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
-        required.put(new DefaultRequiredInterface("userArccessor",
-            UserAccessor.class), UserAccessor.class.getName());
-        required.put(new DefaultRequiredInterface("hibernateTemplate",
-            HibernateTemplate.class), HibernateTemplate.class.getName());
-
-        return required;
-    }
-
-    private static Map<String, ProvidedInterface> createProvided() {
-        Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-        provided.put(AbstractAuthorizationService.class.getName(),
-            new DefaultProvidedInterface(AbstractAuthorizationService.class.getName(),
-                AbstractAuthorizationService.class));
-
-        return provided;
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateGroupSet.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateGroupSet.java
deleted file mode 100644 (file)
index 1b359e2..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.wamblee.persistence.hibernate.HibernateSupport;
-
-import org.wamblee.usermgt.Group;
-import org.wamblee.usermgt.GroupSet;
-
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Set of groups backed by the database.
- * 
- * @author Erik Brakkee
- */
-public class HibernateGroupSet extends HibernateSupport implements GroupSet {
-    private static final String QUERY_FIND_BY_NAME = "findGroupByName";
-
-    private static final String PARAM_NAME = "name";
-
-    private static final String QUERY_COUNT_GROUPS = "countGroups";
-
-    /**
-     * Creates a new HibernateGroupSet object.
-     */
-    public HibernateGroupSet() {
-        // Empty
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.GroupSet#groupModified(org.wamblee.usermgt.Group)
-     */
-    public void groupModified(Group aGroup) {
-        assert aGroup.getPrimaryKey() != null;
-        //super.merge(aGroup);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#find(java.lang.String)
-     */
-    public Group find(String aName) {
-        List list = getHibernateTemplate().findByNamedQueryAndNamedParam(
-            QUERY_FIND_BY_NAME, PARAM_NAME, aName);
-
-        if (list.size() > 1) {
-            throw new RuntimeException(
-                "More than one group with the same name '" + aName + "'");
-        }
-
-        if (list.size() == 0) {
-            return null;
-        }
-
-        return new Group((Group) list.get(0));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#contains(org.wamblee.usermgt.Group)
-     */
-    public boolean contains(Group aGroup) {
-        return find(aGroup.getName()) != null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#add(org.wamblee.usermgt.Group)
-     */
-    public boolean add(Group aGroup) {
-        assert aGroup.getPrimaryKey() == null;
-
-        if (contains(aGroup)) {
-            return false;
-        }
-
-        //super.merge(aGroup);
-
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#remove(org.wamblee.usermgt.Group)
-     */
-    public boolean remove(Group aGroup) {
-        assert aGroup.getPrimaryKey() != null;
-
-        if (!contains(aGroup)) {
-            return false;
-        }
-
-        Group group = (Group) getHibernateTemplate().merge(aGroup);
-        getHibernateTemplate().delete(group);
-       // aGroup.setPrimaryKey(null);
-       // aGroup.setPersistedVersion(-1);
-
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#list()
-     */
-    public Set<Group> list() {
-        Set<Group> groups = new TreeSet<Group>();
-        List<Group> list = getHibernateTemplate().loadAll(Group.class);
-
-        for (Group group : list) {
-            groups.add(new Group(group));
-        }
-
-        return groups;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.GroupSet#size()
-     */
-    public int size() {
-        Long result = (Long) getHibernateTemplate().findByNamedQuery(
-            QUERY_COUNT_GROUPS).get(0);
-
-        return result.intValue();
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/HibernateUserSet.java
deleted file mode 100644 (file)
index 44348ec..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.hibernate.SessionFactory;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-
-import org.wamblee.cache.Cache;
-
-import org.wamblee.persistence.hibernate.HibernateSupport;
-
-import org.wamblee.security.encryption.MessageDigester;
-
-import org.wamblee.usermgt.AbstractUserSet;
-import org.wamblee.usermgt.Group;
-import org.wamblee.usermgt.NameValidator;
-import org.wamblee.usermgt.User;
-
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * User set backed by the database.
- * 
- * @author Erik Brakkee
- */
-public class HibernateUserSet extends AbstractUserSet {
-    private static final String QUERY_FIND_BY_NAME = "findUserByName";
-
-    private static final String QUERY_FIND_BY_GROUP_NAME = "findUserByGroupName";
-
-    private static final String PARAM_NAME = "name";
-
-    private static final String QUERY_COUNT_USERS = "countUsers";
-
-    /**
-     * Cache of users. Every user in the cache has its password validator and
-     * encoder set.
-     */
-    private Cache<String, User> cache;
-
-    /**
-     * Spring hibernate support.
-     */
-    private HibernateSupport hibernateSupport;
-
-    /**
-     * Constructs a user set backed by the database.
-     * 
-     * @param aCache
-     *            User cache to use.
-     */
-    public HibernateUserSet(Cache<String, User> aCache,
-        NameValidator aPasswordValidator, MessageDigester aPasswordEncoder) {
-        super(aPasswordValidator, aPasswordEncoder);
-        cache = aCache;
-        hibernateSupport = new HibernateSupport();
-    }
-
-    /**
-     * Sets the session factory.
-     * 
-     * @param aFactory
-     *            Session factory.
-     */
-    public void setSessionFactory(SessionFactory aFactory) {
-        hibernateSupport.setSessionFactory(aFactory);
-    }
-
-    /**
-     * Gets the hibernate template.
-     * 
-     * @return Hibernate template.
-     */
-    private HibernateTemplate getHibernateTemplate() {
-        return hibernateSupport.getHibernateTemplate();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#userModified(org.wamblee.usermgt.User)
-     */
-    public void userModified(User aUser) {
-        assert aUser.getPrimaryKey() != null;
-        //hibernateSupport.merge(aUser)
-        cache.remove(aUser.getName());
-        setPasswordInfo(aUser);
-        cache.put(aUser.getName(), new User(aUser));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#find(java.lang.String)
-     */
-    public User find(String aName) {
-        User user = cache.get(aName);
-
-        if (user != null) {
-            return user;
-        }
-
-        List result = getHibernateTemplate().findByNamedQueryAndNamedParam(
-            QUERY_FIND_BY_NAME, PARAM_NAME, aName);
-
-        if (result.size() > 1) {
-            throw new RuntimeException(
-                "Implementation problem, more than one user with the same name!");
-        }
-
-        if (result.size() == 0) {
-            return null;
-        }
-
-        user = (User) result.get(0);
-        setPasswordInfo(user);
-        cache.put(aName, user);
-
-        return new User(user);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#contains(org.wamblee.usermgt.User)
-     */
-    public boolean contains(User aUser) {
-        return find(aUser.getName()) != null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#add(org.wamblee.usermgt.User)
-     */
-    public boolean add(User aUser) {
-        assert aUser.getPrimaryKey() == null;
-
-        if (contains(aUser)) {
-            return false;
-        }
-
-        getHibernateTemplate().saveOrUpdate(aUser);
-        setPasswordInfo(aUser);
-        cache.put(aUser.getName(), aUser);
-
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#remove(org.wamblee.usermgt.User)
-     */
-    public boolean remove(User aUser) {
-        assert aUser.getPrimaryKey() != null;
-
-        if (!contains(aUser)) {
-            return false;
-        }
-
-        User user = (User) getHibernateTemplate().merge(aUser);
-        getHibernateTemplate().delete(user);
-        //aUser.setPersistedVersion(-1);
-        //aUser.setPrimaryKey(null);
-        cache.remove(aUser.getName());
-
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#list()
-     */
-    public Set<User> list() {
-        Set<User> users = new TreeSet<User>();
-        List<User> list = getHibernateTemplate().loadAll(User.class);
-
-        for (User user : list) {
-            setPasswordInfo(user);
-            users.add(new User(user));
-        }
-
-        return users;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#list(org.wamblee.usermgt.Group)
-     */
-    public Set<User> list(Group aGroup) {
-        Set<User> users = new TreeSet<User>();
-        List<User> list = getHibernateTemplate().findByNamedQueryAndNamedParam(
-            QUERY_FIND_BY_GROUP_NAME, PARAM_NAME, aGroup.getName());
-
-        for (User user : list) {
-            setPasswordInfo(user);
-            users.add(new User(user));
-        }
-
-        return users;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserSet#size()
-     */
-    public int size() {
-        Long result = (Long) getHibernateTemplate().findByNamedQuery(
-            QUERY_COUNT_USERS).get(0);
-
-        return result.intValue();
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationComponent.java
deleted file mode 100644 (file)
index 65ee1e3..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.springframework.orm.hibernate3.HibernateTemplate;
-
-import org.springframework.transaction.PlatformTransactionManager;
-
-import org.wamblee.cache.EhCache;
-
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.components.ORMappingConfig;
-import org.wamblee.system.core.Component;
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.core.Scope;
-import org.wamblee.system.spring.component.HibernateComponent;
-
-import org.wamblee.usermgt.UserAdministration;
-import org.wamblee.usermgt.UserGroupRepositoryComponent;
-
-import java.io.IOException;
-
-import javax.sql.DataSource;
-
-/**
- * 
- * @author $author$
- * @version $Revision$
- */
-public class UserAdministrationComponent extends DefaultContainer {
-    private ProvidedInterface transactionMgr = new DefaultProvidedInterface(
-        "transactionManager", PlatformTransactionManager.class);
-
-    private ProvidedInterface userCache = new DefaultProvidedInterface(
-        "userCache", EhCache.class);
-
-    private ProvidedInterface hibernateTemplate = new DefaultProvidedInterface(
-        "hibernateTemplate", HibernateTemplate.class);
-
-    private ProvidedInterface userMgt = new DefaultProvidedInterface(
-        "usermgt", UserAdministration.class);
-
-    /**
-     * Creates a new UserAdministrationComponent object.
-     * 
-     * 
-     */
-    public UserAdministrationComponent(String aName, boolean aExposeInternals)
-        throws IOException {
-        super(aName);
-
-        ObjectConfiguration mappingFilesConfig = new ObjectConfiguration(
-            UsermgtHibernateMappingFiles.class);
-        mappingFilesConfig.getSetterConfig().initAllSetters();
-        addComponent("mappingFiles", new UsermgtHibernateMappingFiles(),
-            mappingFilesConfig);
-
-        Component<?> hibernate = new HibernateComponent("hibernate");
-        addComponent(hibernate);
-
-        Component<?> repository = new UserGroupRepositoryComponent(
-            "usersgroups");
-        addComponent(repository);
-
-        Component<?> usermgt = new UserAdministrationLightComponent(
-            "usermgtlight");
-        addComponent(usermgt);
-
-        addRequiredInterface(new DefaultRequiredInterface("datasource",
-            DataSource.class));
-        addRequiredInterface(new DefaultRequiredInterface("ormconfig",
-            ORMappingConfig.class));
-
-        if (aExposeInternals) {
-            addProvidedInterface(transactionMgr);
-            addProvidedInterface(userCache);
-            addProvidedInterface(hibernateTemplate);
-        }
-
-        addProvidedInterface(userMgt);
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationLightComponent.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UserAdministrationLightComponent.java
deleted file mode 100644 (file)
index fe1a731..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.wamblee.system.core.DefaultProvidedInterface;
-import org.wamblee.system.core.DefaultRequiredInterface;
-import org.wamblee.system.core.ProvidedInterface;
-import org.wamblee.system.core.RequiredInterface;
-import org.wamblee.system.spring.SpringComponent;
-
-import org.wamblee.usermgt.GroupSet;
-import org.wamblee.usermgt.UserAdministration;
-import org.wamblee.usermgt.UserSet;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Light version of the user administration component that requires external
- * datasource, and userset and group set components, as well as an external
- * hibernate session factory.
- * 
- * @author Erik Brakkee
- */
-public class UserAdministrationLightComponent extends SpringComponent {
-    /**
-     * Creates a new UserAdministrationLightComponent object.
-     * 
-     */
-    public UserAdministrationLightComponent(String aName) {
-        super(aName,
-            new String[] { "spring/org.wamblee.security.usermgt.xml" },
-            createProvided(), createRequired());
-    }
-
-    private static Map<RequiredInterface, String> createRequired() {
-        Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
-        required.put(new DefaultRequiredInterface("userSet", UserSet.class),
-            UserSet.class.getName());
-        required.put(new DefaultRequiredInterface("groupSet", GroupSet.class),
-            GroupSet.class.getName());
-
-        return required;
-    }
-
-    private static Map<String, ProvidedInterface> createProvided() {
-        Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-        provided.put(UserAdministration.class.getName(),
-            new DefaultProvidedInterface(
-                "org.wamblee.usermgt.UserAdministration",
-                UserAdministration.class));
-
-        return provided;
-    }
-}
diff --git a/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UsermgtHibernateMappingFiles.java b/security/jpatest/src/main/java/org/wamblee/usermgt/hibernate/UsermgtHibernateMappingFiles.java
deleted file mode 100644 (file)
index 6d8c70f..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.wamblee.persistence.hibernate.HibernateMappingFiles;
-
-import java.util.Collections;
-
-/**
- * Hibernate mapping files for user management.
- * 
- * @author Erik Brakkee
- */
-public class UsermgtHibernateMappingFiles extends HibernateMappingFiles {
-    /**
-     * Creates a new UsermgtHibernateMappingFiles object.
-     */
-    public UsermgtHibernateMappingFiles() {
-        super(new String[] { "hbm/Group.hbm.xml", "hbm/User.hbm.xml" });
-    }
-
-    /**
-     * Creates a new UsermgtHibernateMappingFiles object.
-     * 
-     */
-    public UsermgtHibernateMappingFiles(String[] aFiles) {
-        this();
-        Collections.addAll(this, aFiles);
-    }
-}
diff --git a/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java b/security/jpatest/src/test/java/org/wamblee/security/authorization/hibernate/PersistentAuthorizationServiceTest.java
deleted file mode 100644 (file)
index 15fc40e..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.security.authorization.hibernate;
-
-import java.sql.SQLException;
-
-import org.apache.log4j.Logger;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.MySQL5InnoDBDialect;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.springframework.orm.hibernate3.HibernateTemplate;
-import org.wamblee.security.authorization.AuthorizationService;
-import org.wamblee.security.authorization.AuthorizationServiceTest;
-import org.wamblee.security.authorization.TestUserAccessor;
-import org.wamblee.system.adapters.ClassConfiguration;
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.components.DatabaseComponentFactory;
-import org.wamblee.system.core.Scope;
-import org.wamblee.system.spring.component.DatabaseTesterComponent;
-import org.wamblee.system.spring.component.DatasourceComponent;
-import org.wamblee.usermgt.UserAccessor;
-import org.wamblee.usermgt.hibernate.AuthorizationComponent;
-
-/**
- * Unit test for the persistent authorization service.
- * 
- * @author Erik Brakkee
- */
-@org.junit.Ignore
-public class PersistentAuthorizationServiceTest extends
-    AuthorizationServiceTest {
-    private static final Logger LOGGER = Logger
-        .getLogger(PersistentAuthorizationServiceTest.class);
-
-    private static final String SERVICE_TABLE = "AUTHORIZATION_SERVICE";
-
-    private static final String RULES_TABLE = "AUTHORIZATION_RULES";
-
-    private static final String SERVICE_RULES_TABLE = "AUTHORIZATION_SERVICE_RULES";
-
-    private static final String OPERATIONCOND_TABLE = "OPERATION_CONDITIONS";
-
-    private static final String PATHCOND_TABLE = "PATH_CONDITIONS";
-
-    private static final String USERCOND_TABLE = "USER_CONDITIONS";
-
-    private DefaultContainer container;
-
-    private Scope scope;
-
-    private DatabaseTesterComponent databaseTester;
-
-    private UserAccessor userAccessor;
-
-    private HibernateTemplate hibernateTemplate;
-
-    private AuthorizationService authorizationService;
-
-    @Override
-    protected void setUp() throws Exception {
-        container = new DefaultContainer("top");
-        DatabaseComponentFactory.addDatabaseConfig(container);
-        container.addComponent(new DatasourceComponent("datasource"));
-
-        ClassConfiguration useraccessorConfig = new ClassConfiguration(
-            TestUserAccessor.class);
-        useraccessorConfig.getObjectConfig().getSetterConfig().initAllSetters();
-        container.addComponent("userAccessor", useraccessorConfig);
-        container
-            .addComponent(new AuthorizationComponent("authorization", true));
-
-        ClassConfiguration dbtesterConfig = new ClassConfiguration(
-            DatabaseTesterComponent.class);
-        dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters();
-        container.addComponent("databaseTester", dbtesterConfig);
-
-        ObjectConfiguration config = new ObjectConfiguration(
-            PersistentAuthorizationServiceTest.class);
-        config.getSetterConfig().clear().add("setUserAccessor").add(
-            "setDatabaseTester").add("setHibernateTemplate").add(
-            "setAuthorizationService");
-        container.addComponent("testcase", this, config);
-
-        scope = container.start();
-
-        databaseTester.cleanDatabase();
-
-        super.setUp();
-    }
-
-    public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) {
-        databaseTester = aDatabaseTester;
-    }
-
-    public void setUserAccessor(UserAccessor aUserAccessor) {
-        userAccessor = aUserAccessor;
-    }
-
-    public void setHibernateTemplate(HibernateTemplate aHibernateTemplate) {
-        hibernateTemplate = aHibernateTemplate;
-    }
-
-    public void setAuthorizationService(
-        AuthorizationService aAuthorizationService) {
-        authorizationService = aAuthorizationService;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationServiceTest#createService
-     * ()
-     */
-    @Override
-    protected AuthorizationService createService() {
-        PersistentAuthorizationService service = new PersistentAuthorizationService(
-            "DEFAULT", hibernateTemplate, createUserAccessor(), 10000);
-
-        return service;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.security.authorization.AuthorizationServiceTest#checkRuleCount
-     * (int)
-     */
-    @Override
-    protected void checkRuleCount(int aCount) {
-        try {
-            assertEquals(1, databaseTester.getTableSize(SERVICE_TABLE));
-            assertEquals(aCount, databaseTester.getTableSize(RULES_TABLE));
-            assertEquals(aCount, databaseTester
-                .getTableSize(SERVICE_RULES_TABLE));
-            assertEquals(aCount, databaseTester.getTableSize(USERCOND_TABLE));
-            assertEquals(aCount, databaseTester.getTableSize(PATHCOND_TABLE));
-            assertEquals(aCount, databaseTester
-                .getTableSize(OPERATIONCOND_TABLE));
-        } catch (SQLException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public void testSchemaExport() {
-        Configuration config = new Configuration();
-
-        for (String mappingFile : new AuthorizationMappingFiles()) {
-            config.addResource(mappingFile);
-        }
-
-        config.setProperty("hibernate.dialect", MySQL5InnoDBDialect.class
-            .getName());
-
-        SchemaExport exporter = new SchemaExport(config);
-        exporter.setOutputFile("target/mysql5.schema.sql");
-        exporter.create(true, false);
-    }
-
-    public void testPerformance() {
-        PersistentAuthorizationService service = (PersistentAuthorizationService) getService();
-
-        int n = 1000;
-        long time = System.currentTimeMillis();
-
-        for (int i = 0; i < n; i++) {
-            testFirstRuleGrants();
-            resetTestRules();
-            testSecondRuleDenies();
-            resetTestRules();
-            testThirdRuleGrants();
-            resetTestRules();
-            testNoRulesSupportResource();
-        }
-
-        LOGGER.info("Executed " + (4 * n) + " authorization checks in " +
-            ((float) (System.currentTimeMillis() - time) / (float) 1000) +
-            " seconds.");
-    }
-}
diff --git a/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java b/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateGroupSetTest.java
deleted file mode 100644 (file)
index 25bb7f8..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.junit.Ignore;
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.core.Scope;
-import org.wamblee.system.spring.component.DatabaseTesterComponent;
-
-import org.wamblee.test.spring.TestTransactionCallback;
-
-import org.wamblee.usermgt.GroupSet;
-import org.wamblee.usermgt.InMemoryGroupSetTest;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Tests for {@link org.wamblee.usermgt.hibernate.HibernateGroupSet}
- * 
- * @author Erik Brakkee
- */
-@Ignore
-public class HibernateGroupSetTest extends InMemoryGroupSetTest {
-    private static final String GROUP_TABLE = "GROUPS";
-
-    private static final String GROUP_QUERY = "select * from " + GROUP_TABLE +
-        " where name = ?";
-
-    private DefaultContainer container;
-
-    private Scope scope;
-
-    private DatabaseTesterComponent databaseTester;
-
-    private GroupSet groupSet;
-
-    @Override
-    protected void setUp() throws Exception {
-        container = new UserMgtRepositoryTestContainer("top");
-
-        ObjectConfiguration config = new ObjectConfiguration(
-            HibernateGroupSetTest.class);
-        config.getSetterConfig().clear().add("setGroupSet").add(
-            "setDatabaseTester");
-        container.addComponent("testcase", this, config);
-
-        scope = container.start();
-
-        databaseTester.cleanDatabase();
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        container.stop(scope);
-        super.tearDown();
-    }
-
-    public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) {
-        databaseTester = aDatabaseTester;
-    }
-
-    public void setGroupSet(GroupSet aGroupSet) {
-        groupSet = aGroupSet;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
-     */
-    @Override
-    protected void checkGroupCount(int aSize) throws Exception {
-        databaseTester.flush();
-        super.checkGroupCount(aSize);
-        assertEquals(aSize, databaseTester.getTableSize(GROUP_TABLE));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String
-     * )
-     */
-    @Override
-    protected void checkGroupExists(final String aGroup) throws SQLException {
-        databaseTester.flush();
-
-        Map<String, Integer> result = databaseTester
-            .executeTransaction(new TestTransactionCallback() {
-                /*
-                 * (non-Javadoc)
-                 * 
-                 * @see org.wamblee.test.TestTransactionCallback#execute()
-                 */
-                @Override
-                public Map execute() throws Exception {
-                    ResultSet result = databaseTester.executeQuery(GROUP_QUERY,
-                        aGroup);
-                    Map<String, Integer> res = new HashMap<String, Integer>();
-                    res.put("result", databaseTester.countResultSet(result));
-
-                    return res;
-                }
-            });
-
-        int count = result.get("result");
-        assertEquals(1, count);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang
-     * .String)
-     */
-    @Override
-    protected void checkGroupNotExists(String aGroup) throws SQLException {
-        databaseTester.flush();
-
-        ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup);
-        assertEquals(0, databaseTester.countResultSet(result));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryGroupSetTest#createGroupSet()
-     */
-    @Override
-    protected GroupSet createGroupSet() {
-        return groupSet;
-    }
-}
diff --git a/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java b/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserAdministrationTest.java
deleted file mode 100644 (file)
index 158b0f0..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Ignore;
-
-import org.wamblee.cache.EhCache;
-
-import org.wamblee.system.adapters.ClassConfiguration;
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.components.DatabaseComponentFactory;
-import org.wamblee.system.core.Scope;
-import org.wamblee.system.spring.component.DatabaseTesterComponent;
-import org.wamblee.system.spring.component.DatasourceComponent;
-
-import org.wamblee.test.spring.TestTransactionCallbackWithoutResult;
-
-import org.wamblee.usermgt.UserAdministration;
-import org.wamblee.usermgt.UserAdministrationImplTest;
-
-import java.io.Serializable;
-
-import java.lang.reflect.Method;
-
-import java.sql.SQLException;
-
-/**
- * User administration tests with persistence based on Hibernate. This executes
- * the same test cases as {@link org.wamblee.usermgt.UserAdministrationImplTest}
- * with in addition, one test case that executes all Hibernate test cases
- * separately with each test case in its own transaction.
- * 
- * @author Erik Brakkee
- */
-@Ignore
-public class HibernateUserAdministrationTest extends UserAdministrationImplTest {
-    private static final Log LOG = LogFactory
-        .getLog(HibernateUserAdministrationTest.class);
-
-    private DefaultContainer container;
-
-    private Scope scope;
-
-    private DatabaseTesterComponent databaseTester;
-
-    private EhCache<Serializable, Serializable> userCache;
-
-    private UserAdministration userAdmin;
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserAdministrationImplTest#setUp()
-     */
-    @Override
-    protected void setUp() throws Exception {
-        container = new DefaultContainer("top");
-        DatabaseComponentFactory.addDatabaseConfig(container);
-        container.addComponent(new DatasourceComponent("datasource"));
-        container.addComponent(new UserAdministrationComponent("admin", true));
-
-        ClassConfiguration dbtesterConfig = new ClassConfiguration(
-            DatabaseTesterComponent.class);
-        dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters();
-        container.addComponent("databaseTester", dbtesterConfig);
-
-        ObjectConfiguration config = new ObjectConfiguration(
-            HibernateUserAdministrationTest.class);
-        config.getSetterConfig().clear().add("setUserCache").add(
-            "setDatabaseTester").add("setUserAdmin");
-        container.addComponent("testcase", this, config);
-
-        scope = container.start();
-
-        databaseTester.cleanDatabase();
-
-        super.setUp();
-        clearUserCache();
-    }
-
-    public void setUserCache(EhCache<Serializable, Serializable> aUserCache) {
-        userCache = aUserCache;
-    }
-
-    public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) {
-        databaseTester = aDatabaseTester;
-    }
-
-    public void setUserAdmin(UserAdministration aUserAdmin) {
-        userAdmin = aUserAdmin;
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        container.stop(scope);
-        super.tearDown();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.UserAdministrationImplTest#createAdmin()
-     */
-    @Override
-    protected UserAdministration createAdmin() {
-        return userAdmin;
-    }
-
-    public void testAllTestsInASeparateTransaction() throws SQLException {
-        Method[] methods = UserAdministrationImplTest.class.getMethods();
-
-        for (final Method method : methods) {
-            if (method.getName().startsWith("test")) {
-                databaseTester.cleanDatabase();
-                clearUserCache();
-                databaseTester
-                    .executeTransaction(new TestTransactionCallbackWithoutResult() {
-                        public void execute() throws Exception {
-                            LOG.info("Running test " + method.getName());
-
-                            try {
-                                method
-                                    .invoke(HibernateUserAdministrationTest.this);
-                            } catch (Throwable t) {
-                                LOG.error("Test " + method.getName() +
-                                    " failed");
-                                throw new RuntimeException(t.getMessage(), t);
-                            } finally {
-                                LOG.info("Test " + method.getName() +
-                                    " finished");
-                            }
-                        }
-                    });
-            }
-        }
-    }
-
-    private void clearUserCache() {
-        userCache.clear();
-    }
-}
diff --git a/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java b/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/HibernateUserSetTest.java
deleted file mode 100644 (file)
index 1140310..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.junit.Ignore;
-import org.wamblee.cache.EhCache;
-
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.core.Scope;
-import org.wamblee.system.spring.component.DatabaseTesterComponent;
-
-import org.wamblee.usermgt.Group;
-import org.wamblee.usermgt.GroupSet;
-import org.wamblee.usermgt.InMemoryUserSetTest;
-import org.wamblee.usermgt.User;
-import org.wamblee.usermgt.UserMgtException;
-import org.wamblee.usermgt.UserSet;
-
-import java.io.Serializable;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import java.util.Set;
-
-/**
- * Tests for {@link org.wamblee.usermgt.hibernate.HibernateGroupSet}
- * 
- * @author Erik Brakkee
- */
-@Ignore
-public class HibernateUserSetTest extends InMemoryUserSetTest {
-    private static final String USER_TABLE = "USERS";
-
-    private static final String GROUP_TABLE = "GROUPS";
-
-    private static final String USER_QUERY = "select * from " + USER_TABLE +
-        " where name = ?";
-
-    private static final String GROUP_QUERY = "select * from " + GROUP_TABLE +
-        " where name = ?";
-
-    private DefaultContainer container;
-
-    private Scope scope;
-
-    private UserSet userset;
-
-    private GroupSet groupset;
-
-    private EhCache<Serializable, Serializable> userCache;
-
-    private DatabaseTesterComponent databaseTester;
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryUserSetTest#setUp()
-     */
-    @Override
-    protected void setUp() throws Exception {
-        container = new UserMgtRepositoryTestContainer("top");
-
-        ObjectConfiguration config = new ObjectConfiguration(
-            HibernateUserSetTest.class);
-        config.getSetterConfig().clear().add("setUserset").add("setGroupset")
-            .add("setDatabaseTester").add("setUserCache");
-        container.addComponent("testcase", this, config);
-
-        scope = container.start();
-
-        clearUserCache();
-        databaseTester.cleanDatabase();
-
-        super.setUp();
-    }
-
-    public void setUserset(UserSet aUserset) {
-        userset = aUserset;
-    }
-
-    public void setGroupset(GroupSet aGroupset) {
-        groupset = aGroupset;
-    }
-
-    public void setUserCache(EhCache<Serializable, Serializable> aUserCache) {
-        userCache = aUserCache;
-    }
-
-    public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) {
-        databaseTester = aDatabaseTester;
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        container.stop(scope);
-        super.tearDown();
-    }
-
-    /**
-     * Clears the user cache.
-     */
-    private void clearUserCache() {
-        userCache.clear();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
-     */
-    @Override
-    protected void checkUserCount(int aSize) throws Exception {
-        databaseTester.flush();
-        super.checkUserCount(aSize);
-        assertEquals(aSize, databaseTester.getTableSize(USER_TABLE));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String
-     * )
-     */
-    @Override
-    protected void checkUserExists(String aUser) throws SQLException {
-        databaseTester.flush();
-
-        ResultSet result = databaseTester.executeQuery(USER_QUERY, aUser);
-        assertEquals(1, databaseTester.countResultSet(result));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang
-     * .String)
-     */
-    @Override
-    protected void checkUserNotExists(String aUser) throws SQLException {
-        databaseTester.flush();
-
-        ResultSet result = databaseTester.executeQuery(USER_QUERY, aUser);
-        assertEquals(0, databaseTester.countResultSet(result));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
-     */
-    @Override
-    protected void checkGroupCount(int aSize) throws SQLException {
-        databaseTester.flush();
-        assertEquals(aSize, databaseTester.getTableSize(GROUP_TABLE));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String
-     * )
-     */
-    @Override
-    protected void checkGroupExists(String aGroup) throws SQLException {
-        databaseTester.flush();
-
-        ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup);
-        assertEquals(1, databaseTester.countResultSet(result));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang
-     * .String)
-     */
-    @Override
-    protected void checkGroupNotExists(String aGroup) throws SQLException {
-        databaseTester.flush();
-
-        ResultSet result = databaseTester.executeQuery(GROUP_QUERY, aGroup);
-        assertEquals(0, databaseTester.countResultSet(result));
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryGroupSetTest#createGroupSet()
-     */
-    @Override
-    protected UserSet createUserSet() {
-        return userset;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.wamblee.usermgt.InMemoryUserSetTest#createGroupSet()
-     */
-    @Override
-    protected GroupSet createGroupSet() {
-        return groupset;
-    }
-
-    /**
-     * Reproduction of a bug. Create a user which is in group1 Add it to a
-     * second group group2. Remove the user from group1. Verify the user is in
-     * group2.
-     * 
-     */
-    public void testVerifyAddRemove() throws SQLException, UserMgtException {
-        databaseTester.cleanDatabase(); // just to be sure.
-
-        GroupSet groups = getGroups();
-        assertEquals(0, groups.size());
-
-        Group group1 = createGroup("group1");
-        Group group2 = createGroup("group2");
-        groups.add(group1);
-        groups.add(group2);
-        checkGroupExists("group1");
-        checkGroupExists("group2");
-
-        User user = createUser("user", PASSWORD, group1);
-        getUsers().add(user);
-        checkUserExists("user");
-
-        addUserToGroup(user, group2);
-        getUsers().userModified(user);
-        clearUserCache();
-
-        User user2 = getUsers().find("user");
-        Set<Group> userGroups = user2.getGroups();
-        assertTrue(user2.isInGroup("group1"));
-        assertTrue(user2.isInGroup("group2"));
-        assertEquals(2, userGroups.size());
-
-        removeUserFromGroup(user, group1);
-        getUsers().userModified(user);
-        clearUserCache();
-        user2 = getUsers().find("user");
-        userGroups = user2.getGroups();
-        assertFalse(user2.isInGroup("group1"));
-        assertTrue(user2.isInGroup("group2"));
-        assertEquals(1, userGroups.size());
-    }
-}
diff --git a/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/UserMgtRepositoryTestContainer.java b/security/jpatest/src/test/java/org/wamblee/usermgt/hibernate/UserMgtRepositoryTestContainer.java
deleted file mode 100644 (file)
index 6b21a8f..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2005-2010 the original author or authors.
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */ 
-package org.wamblee.usermgt.hibernate;
-
-import org.wamblee.system.adapters.ClassConfiguration;
-import org.wamblee.system.adapters.DefaultContainer;
-import org.wamblee.system.adapters.ObjectConfiguration;
-import org.wamblee.system.components.DatabaseComponentFactory;
-import org.wamblee.system.spring.component.DatabaseTesterComponent;
-import org.wamblee.system.spring.component.DatasourceComponent;
-import org.wamblee.system.spring.component.HibernateComponent;
-
-import org.wamblee.usermgt.UserGroupRepositoryComponent;
-
-import java.io.IOException;
-
-/**
- * Test container for repository tests of user management.
- * 
- * @author Erik Brakkee
- */
-public class UserMgtRepositoryTestContainer extends DefaultContainer {
-    /**
-     * Creates a new UserMgtRepositoryTestContainer object.
-     * 
-     * 
-     */
-    public UserMgtRepositoryTestContainer(String aName) throws IOException {
-        super(aName);
-        DatabaseComponentFactory.addDatabaseConfig(this);
-        addComponent(new DatasourceComponent("datasource"));
-
-        ObjectConfiguration mappingFilesConfig = new ObjectConfiguration(
-            UsermgtHibernateMappingFiles.class);
-        mappingFilesConfig.getSetterConfig().initAllSetters();
-        addComponent("mappingFiles", new UsermgtHibernateMappingFiles(),
-            mappingFilesConfig);
-        addComponent(new HibernateComponent("hibernate"));
-        addComponent(new UserGroupRepositoryComponent("usersgroups"));
-
-        ClassConfiguration dbtesterConfig = new ClassConfiguration(
-            DatabaseTesterComponent.class);
-        dbtesterConfig.getObjectConfig().getSetterConfig().initAllSetters();
-        addComponent("databaseTester", dbtesterConfig);
-    }
-}