get rid of all jdo jpox dependencies Signed-off-by: olivier lamy <ol...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/repo Commit: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/commit/0537b856 Tree: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/tree/0537b856 Diff: http://git-wip-us.apache.org/repos/asf/archiva-redback-core/diff/0537b856 Branch: refs/heads/master Commit: 0537b8562ed46c5b4f56d88410d11ceae32f4320 Parents: effc4a2 Author: olivier lamy <ol...@apache.org> Authored: Sat Dec 31 10:21:49 2016 +0100 Committer: olivier lamy <ol...@apache.org> Committed: Sat Dec 31 10:21:49 2016 +0100 ---------------------------------------------------------------------- pom.xml | 88 +-- redback-common/pom.xml | 1 - redback-common/redback-common-jdo/pom.xml | 116 --- .../common/jdo/UserConfigurableJdoFactory.java | 132 ---- .../common/jdo/test/StoreManagerDebug.java | 113 --- .../main/resources/META-INF/spring-context.xml | 35 - .../redback-keys-jdo/pom.xml | 170 ----- .../archiva/redback/keys/jdo/JdoKeyManager.java | 187 ----- .../redback-keys-jdo/src/main/mdo/keys.mdo | 89 --- .../main/resources/META-INF/spring-context.xml | 32 - .../redback/keys/jdo/JdoKeyManagerTest.java | 102 --- .../src/test/resources/spring-context.xml | 48 -- .../redback-rbac-jdo/pom.xml | 156 ---- .../redback/rbac/jdo/JdoRbacManager.java | 711 ------------------- .../archiva/redback/rbac/jdo/JdoTool.java | 500 ------------- .../redback-rbac-jdo/src/main/mdo/rbac-jdo.mdo | 337 --------- .../main/resources/META-INF/spring-context.xml | 34 - .../redback/rbac/jdo/JdoRbacManagerTest.java | 219 ------ .../redback/rbac/jdo/RbacJdoModelStaxTest.java | 198 ------ .../src/test/resources/ehcache.xml | 90 --- .../src/test/resources/spring-context.xml | 85 --- .../redback-users-jdo/pom.xml | 176 ----- .../redback/users/jdo/JdoUserManager.java | 466 ------------ .../archiva/redback/users/jdo/JdoUserQuery.java | 136 ---- .../archiva/redback/users/jdo/Messages.java | 94 --- .../redback-users-jdo/src/main/mdo/user.mdo | 162 ----- .../main/resources/META-INF/spring-context.xml | 33 - .../redback/users/jdo/messages.properties | 18 - .../redback/users/jdo/JdoUserManagerTest.java | 117 --- .../src/test/resources/spring-context.xml | 58 -- .../src/test/resources/test.properties | 17 - 31 files changed, 2 insertions(+), 4718 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index c16a926..91954b6 100644 --- a/pom.xml +++ b/pom.xml @@ -387,36 +387,8 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.apache.archiva.redback.components</groupId> - <artifactId>spring-jdo2</artifactId> - <version>2.2</version> - <exclusions> - <exclusion> - <groupId>xerces</groupId> - <artifactId>xercesImpl</artifactId> - </exclusion> - <exclusion> - <groupId>xerces</groupId> - <artifactId>xmlParserAPIs</artifactId> - </exclusion> - </exclusions> - </dependency> <!-- Other --> <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <!-- must run at xalan 2.7.0, as ealier versions embed an ancient version - of bcel, which iterferes with the ability of jpox/jdo to run --> - <version>2.7.0</version> - </dependency> - <dependency> - <groupId>xml-apis</groupId> - <artifactId>xml-apis</artifactId> - <!-- Xalan 2.7.0 requires xml-apis version 1.3.02+ --> - <version>1.3.03</version> - </dependency> - <dependency> <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> <version>2.6</version> @@ -544,45 +516,6 @@ <version>${project.version}</version> </dependency> <dependency> - <groupId>jpox</groupId> - <artifactId>jpox</artifactId> - <version>1.1.9-1</version> - <scope>compile</scope> - <exclusions> - <!-- targeting JDK 1.4 we don't need this --> - <exclusion> - <groupId>javax.sql</groupId> - <artifactId>jdbc-stdext</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - - <exclusion> - <groupId>javax.resource</groupId> - <artifactId>connector</artifactId> - </exclusion> - <exclusion> - <groupId>javax.transaction</groupId> - <artifactId>jta</artifactId> - </exclusion> - - </exclusions> - </dependency> - <dependency> - <groupId>jpox</groupId> - <artifactId>jpox-ehcache</artifactId> - <version>1.1.9</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>ehcache</groupId> - <artifactId>ehcache</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>13.0.1</version> @@ -697,23 +630,11 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.6</source> - <target>1.6</target> + <source>1.7</source> + <target>1.7</target> </configuration> </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jpox-maven-plugin</artifactId> - <version>1.1.7</version> - <dependencies> - <dependency> - <groupId>org.apache.bcel</groupId> - <artifactId>bcel</artifactId> - <version>6.0</version> - </dependency> - </dependencies> - </plugin> - <plugin> <groupId>org.codehaus.modello</groupId> <artifactId>modello-maven-plugin</artifactId> <version>1.7</version> @@ -733,11 +654,6 @@ </configuration> </plugin> <plugin> - <groupId>org.apache.archiva.redback.components.modello</groupId> - <artifactId>jpox-modello-maven-plugin</artifactId> - <version>1.0</version> - </plugin> - <plugin> <groupId>org.apache.openjpa</groupId> <artifactId>openjpa-maven-plugin</artifactId> <version>${openjpa.version}</version> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-common/pom.xml ---------------------------------------------------------------------- diff --git a/redback-common/pom.xml b/redback-common/pom.xml index cefc84f..42e1350 100644 --- a/redback-common/pom.xml +++ b/redback-common/pom.xml @@ -29,7 +29,6 @@ <name>Redback :: Commons</name> <packaging>pom</packaging> <modules> - <module>redback-common-jdo</module> <module>redback-common-ldap</module> <module>redback-common-test-resources</module> <module>redback-common-jpa</module> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-common/redback-common-jdo/pom.xml ---------------------------------------------------------------------- diff --git a/redback-common/redback-common-jdo/pom.xml b/redback-common/redback-common-jdo/pom.xml deleted file mode 100644 index 275c641..0000000 --- a/redback-common/redback-common-jdo/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-common</artifactId> - <version>2.5-SNAPSHOT</version> - </parent> - - <artifactId>redback-common-jdo</artifactId> - <packaging>bundle</packaging> - <name>Redback :: JDO Common API</name> - - <dependencies> - <dependency> - <groupId>org.apache.archiva.redback.components</groupId> - <artifactId>spring-jdo2</artifactId> - </dependency> - <dependency> - <groupId>jpox</groupId> - <artifactId>jpox</artifactId> - <scope>compile</scope> - <exclusions> - <!-- targeting JDK 1.4 we don't need this --> - <exclusion> - <groupId>javax.sql</groupId> - <artifactId>jdbc-stdext</artifactId> - </exclusion> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - - <exclusion> - <groupId>javax.resource</groupId> - <artifactId>connector</artifactId> - </exclusion> - <exclusion> - <groupId>javax.transaction</groupId> - <artifactId>jta</artifactId> - </exclusion> - - </exclusions> - </dependency> - <dependency> - <groupId>org.hsqldb</groupId> - <artifactId>hsqldb</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-configuration</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - </dependency> - <dependency> - <groupId>javax.annotation</groupId> - <artifactId>jsr250-api</artifactId> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <configuration> - <instructions> - <Export-Package> - org.apache.archiva.redback.common.jdo*;version=${project.version};-split-package:=merge-first - </Export-Package> - <Import-Package> - javax.annotation, - javax.inject;version="[1,2)", - javax.jdo;version="[2,3)", - org.apache.archiva.redback.components.jdo;version=${project.version}, - org.apache.archiva.redback.configuration;version=${project.version}, - org.apache.commons.lang;version="[2.6,3)", - org.codehaus.plexus.interpolation;version="[1.9,2)", - org.jpox*;version="[1.1,2)", - org.springframework.stereotype;version="[3,4)", - org.slf4j;resolution:=optional - </Import-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/UserConfigurableJdoFactory.java ---------------------------------------------------------------------- diff --git a/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/UserConfigurableJdoFactory.java b/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/UserConfigurableJdoFactory.java deleted file mode 100644 index e511492..0000000 --- a/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/UserConfigurableJdoFactory.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.apache.archiva.redback.common.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory; -import org.apache.archiva.redback.configuration.UserConfiguration; -import org.apache.commons.lang.StringUtils; -import org.codehaus.plexus.interpolation.InterpolationException; -import org.codehaus.plexus.interpolation.PropertiesBasedValueSource; -import org.codehaus.plexus.interpolation.StringSearchInterpolator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; - -/** - * UserConfigurableJdoFactory - * - * @author <a href="mailto:joa...@erdfelt.com">Joakim Erdfelt</a> - */ -@Service("jdoFactory#users") -public class UserConfigurableJdoFactory - extends DefaultConfigurableJdoFactory -{ - - private Logger log = LoggerFactory.getLogger( getClass() ); - - private UserConfiguration userConfiguration; - - @Inject - public UserConfigurableJdoFactory( - @Named( value = "userConfiguration#default" ) UserConfiguration userConfiguration ) - { - this.userConfiguration = userConfiguration; - } - - private String getConfigString( String key, String currentValue, String defaultValue ) - { - String valueFromSysProps = System.getProperty( "redback." + key ); - if ( StringUtils.isNotEmpty( valueFromSysProps ) ) - { - return valueFromSysProps; - } - String value = null; - if ( StringUtils.isNotEmpty( currentValue ) ) - { - value = userConfiguration.getString( key, currentValue ); - } - else - { - value = userConfiguration.getString( key, defaultValue ); - } - // do some interpolation as we can have some ${plexus.home} etc... - StringSearchInterpolator interpolator = new StringSearchInterpolator(); - interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) ); - - try - { - return interpolator.interpolate( value ); - } - catch ( InterpolationException e ) - { - // ignore interpolation issue - log.warn( "skip issue during interpolation {}", e.getMessage() ); - return value; - } - } - - @PostConstruct - public void initialize() - { - String jdbcDriverName = - getConfigString( "jdbc.driver.name", super.getDriverName(), "org.apache.derby.jdbc.EmbeddedDriver" ); - String jdbcUrl = - getConfigString( "jdbc.url", super.getUrl(), "jdbc:derby:${plexus.home}/database;create=true" ); - - String jdbcUsername = getConfigString( "jdbc.username", super.getUserName(), "sa" ); - String jdbcPassword = getConfigString( "jdbc.password", super.getPassword(), "" ); - - super.setDriverName( jdbcDriverName ); - super.setUrl( jdbcUrl ); - super.setUserName( jdbcUsername ); - super.setPassword( jdbcPassword ); - - if ( StringUtils.isEmpty( super.persistenceManagerFactoryClass ) ) - { - super.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); - } - - if ( ( super.otherProperties == null ) || super.otherProperties.isEmpty() ) - { - super.setProperty( "org.jpox.autoCreateSchema", "true" ); - super.setProperty( "org.jpox.validateSchema", "false" ); - super.setProperty( "org.jpox.validateTables", "false" ); - super.setProperty( "org.jpox.validateConstraints", "false" ); - super.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); - super.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" ); - } - - super.initialize(); - } - - public UserConfiguration getUserConfiguration() - { - return userConfiguration; - } - - public void setUserConfiguration( UserConfiguration userConfiguration ) - { - this.userConfiguration = userConfiguration; - } -} http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/test/StoreManagerDebug.java ---------------------------------------------------------------------- diff --git a/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/test/StoreManagerDebug.java b/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/test/StoreManagerDebug.java deleted file mode 100644 index ea57a51..0000000 --- a/redback-common/redback-common-jdo/src/main/java/org/apache/archiva/redback/common/jdo/test/StoreManagerDebug.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.apache.archiva.redback.common.jdo.test; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -import javax.jdo.PersistenceManager; - -import org.jpox.AbstractPersistenceManagerFactory; -import org.jpox.ClassLoaderResolver; -import org.jpox.plugin.ConfigurationElement; -import org.jpox.plugin.Extension; -import org.jpox.store.rdbms.RDBMSManager; - -/** - * A extension to JPOX store manager that allows counting the SQL queries - * - * @author Carlos Sanchez - */ -public class StoreManagerDebug - extends RDBMSManager -{ - private static int counter; - - public StoreManagerDebug( ClassLoaderResolver clr, AbstractPersistenceManagerFactory pmf, String userName, - String password ) - { - super( clr, pmf, userName, password ); - } - - /** - * This method will change JPOX store manager extension so it uses our class instead of whatever is configured in - * the plugin.xml - * - * @param pmf - */ - public static void setup( AbstractPersistenceManagerFactory pmf ) - { - /* set our own Store Manager to allow counting SQL statements */ - Extension[] extensions = - pmf.getPMFContext().getPluginManager().getExtensionPoint( "org.jpox.store_manager" ).getExtensions(); - Extension e = extensions[0]; - for ( ConfigurationElement element : e.getConfigurationElements() ) - { - element.putAttribute( "class-name", StoreManagerDebug.class.getName() ); - } - } - - /** - * Get the currently configured store manager from JPOX. Will fail if - * {@link #setup(AbstractPersistenceManagerFactory)} is not called first. - * - * @param persistenceManager - * @return - */ - public static StoreManagerDebug getConfiguredStoreManager( PersistenceManager persistenceManager ) - { - return (StoreManagerDebug) ( (org.jpox.PersistenceManager) persistenceManager ).getStoreManager(); - } - - @Override - public int[] executeStatementBatch( String stmt, PreparedStatement ps ) - throws SQLException - { - counter++; - return super.executeStatementBatch( stmt, ps ); - } - - @Override - public ResultSet executeStatementQuery( String stmt, PreparedStatement ps ) - throws SQLException - { - counter++; - return super.executeStatementQuery( stmt, ps ); - } - - @Override - public int executeStatementUpdate( String stmt, PreparedStatement ps ) - throws SQLException - { - counter++; - return super.executeStatementUpdate( stmt, ps ); - } - - public void resetCounter() - { - counter = 0; - } - - public int counter() - { - return counter; - } -} http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml ---------------------------------------------------------------------- diff --git a/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml b/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml deleted file mode 100644 index 86a9fe9..0000000 --- a/redback-common/redback-common-jdo/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0"?> - -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" - default-lazy-init="true"> - - <bean name="jdoFactory#users" class="org.apache.archiva.redback.common.jdo.UserConfigurableJdoFactory"> - <constructor-arg> - <ref bean="userConfiguration#default"/> - </constructor-arg> - <!-- - <property name="config" ref="userConfiguration#default"/> - --> - </bean> -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/pom.xml ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/pom.xml b/redback-keys/redback-keys-providers/redback-keys-jdo/pom.xml deleted file mode 100644 index abf709c..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/pom.xml +++ /dev/null @@ -1,170 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-keys-providers</artifactId> - <version>2.5-SNAPSHOT</version> - </parent> - - <artifactId>redback-keys-jdo</artifactId> - <packaging>jar</packaging> - <name>Redback :: Key Management Provider :: JDO</name> - - <dependencies> - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-keys-api</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-common-jdo</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - </dependency> - <dependency> - <groupId>javax.annotation</groupId> - <artifactId>jsr250-api</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-keys-tests</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.hsqldb</groupId> - <artifactId>hsqldb</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>net.java.dev.stax-utils</groupId> - <artifactId>stax-utils</artifactId> - <version>20060502</version> - <exclusions> - <exclusion> - <groupId>com.bea.xml</groupId> - <artifactId>jsr173-ri</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <executions> - <execution> - <id>bundle-manifest</id> - <phase>process-classes</phase> - <goals> - <goal>manifest</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> - </archive> - </configuration> - </plugin> - <plugin> - <groupId>org.codehaus.modello</groupId> - <artifactId>modello-maven-plugin</artifactId> - <configuration> - <version>1.0.1</version> - <packageWithVersion>false</packageWithVersion> - <models> - <model>src/main/mdo/keys.mdo</model> - </models> - </configuration> - <executions> - <execution> - <id>modello-java</id> - <goals> - <goal>java</goal> - <goal>stax-reader</goal> - <goal>stax-writer</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.archiva.redback.components.modello</groupId> - <artifactId>jpox-modello-maven-plugin</artifactId> - <configuration> - <version>1.0.1</version> - <packageWithVersion>false</packageWithVersion> - <models> - <model>src/main/mdo/keys.mdo</model> - </models> - </configuration> - <executions> - <execution> - <id>modello-jpox</id> - <goals> - <goal>jpox-metadata-class</goal> - </goals> - </execution> - <execution> - <id>jpox-jdo-mapping</id> - <goals> - <goal>jpox-jdo-mapping</goal> - </goals> - <configuration> - <outputDirectory>${project.build.outputDirectory}/org/apache/archiva/redback/keys/jdo</outputDirectory> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jpox-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>enhance</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/java/org/apache/archiva/redback/keys/jdo/JdoKeyManager.java ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/java/org/apache/archiva/redback/keys/jdo/JdoKeyManager.java b/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/java/org/apache/archiva/redback/keys/jdo/JdoKeyManager.java deleted file mode 100644 index 1537f57..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/java/org/apache/archiva/redback/keys/jdo/JdoKeyManager.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.apache.archiva.redback.keys.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import org.apache.archiva.redback.components.jdo.JdoFactory; -import org.apache.archiva.redback.components.jdo.RedbackJdoUtils; -import org.apache.archiva.redback.components.jdo.RedbackObjectNotFoundException; -import org.apache.archiva.redback.components.jdo.RedbackStoreException; -import org.apache.archiva.redback.keys.AuthenticationKey; -import org.apache.archiva.redback.keys.AbstractKeyManager; -import org.apache.archiva.redback.keys.KeyManagerException; -import org.apache.archiva.redback.keys.KeyNotFoundException; -import org.codehaus.plexus.util.StringUtils; -import org.jpox.PersistenceManagerFactoryImpl; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.inject.Named; -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; -import java.util.Calendar; -import java.util.List; - -/** - * JdoKeyManager - * - * @author <a href="mailto:joa...@erdfelt.com">Joakim Erdfelt</a> - * - */ -@Service( "keyManager#jdo" ) -public class JdoKeyManager - extends AbstractKeyManager -{ - @Inject - @Named( value = "jdoFactory#users" ) - private JdoFactory jdoFactory; - - private PersistenceManagerFactory pmf; - - public AuthenticationKey createKey( String principal, String purpose, int expirationMinutes ) - throws KeyManagerException - { - JdoAuthenticationKey authkey = new JdoAuthenticationKey(); - authkey.setKey( super.generateUUID() ); - authkey.setForPrincipal( principal ); - authkey.setPurpose( purpose ); - - Calendar now = getNowGMT(); - authkey.setDateCreated( now.getTime() ); - - if ( expirationMinutes >= 0 ) - { - Calendar expiration = getNowGMT(); - expiration.add( Calendar.MINUTE, expirationMinutes ); - authkey.setDateExpires( expiration.getTime() ); - } - - return addKey( authkey ); - } - - public AuthenticationKey addKey( AuthenticationKey key ) - { - return (AuthenticationKey) RedbackJdoUtils.addObject( getPersistenceManager(), key ); - } - - public void eraseDatabase() - { - RedbackJdoUtils.removeAll( getPersistenceManager(), JdoAuthenticationKey.class ); - RedbackJdoUtils.removeAll( getPersistenceManager(), RedbackKeyManagementJdoModelloMetadata.class ); - } - - public AuthenticationKey findKey( String key ) - throws KeyNotFoundException, KeyManagerException - { - if ( StringUtils.isEmpty( key ) ) - { - throw new KeyNotFoundException( "Empty key not found." ); - } - - try - { - JdoAuthenticationKey authkey = (JdoAuthenticationKey) RedbackJdoUtils.getObjectById( - getPersistenceManager(), JdoAuthenticationKey.class, key ); - - if ( authkey == null ) - { - throw new KeyNotFoundException( "Key [" + key + "] not found." ); - } - assertNotExpired( authkey ); - - return authkey; - } - catch ( RedbackObjectNotFoundException e ) - { - throw new KeyNotFoundException( e.getMessage() ); - } - catch ( RedbackStoreException e ) - { - throw new KeyManagerException( - "Unable to get " + JdoAuthenticationKey.class.getName() + "', key '" + key + "' from jdo store." ); - } - } - - public void deleteKey( AuthenticationKey authkey ) - throws KeyManagerException - { - RedbackJdoUtils.removeObject( getPersistenceManager(), authkey ); - } - - public void deleteKey( String key ) - throws KeyManagerException - { - try - { - AuthenticationKey authkey = findKey( key ); - RedbackJdoUtils.removeObject( getPersistenceManager(), authkey ); - } - catch ( KeyNotFoundException e ) - { - // not found? nothing to do. - } - } - - @SuppressWarnings( "unchecked" ) - public List<AuthenticationKey> getAllKeys() - { - return RedbackJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoAuthenticationKey.class ); - } - - @PostConstruct - public void initialize() - { - pmf = jdoFactory.getPersistenceManagerFactory(); - - if ( pmf instanceof PersistenceManagerFactoryImpl ) - { - PersistenceManagerFactoryImpl jpoxpmf = (PersistenceManagerFactoryImpl) pmf; - if ( !StringUtils.equals( "JDK_DEFAULT_TIMEZONE", jpoxpmf.getDateTimezone() ) ) - { - throw new RuntimeException( "The JdoFactory property 'org.jpox.rdbms.dateTimezone' MUST BE " - + "Set to 'JDK_DEFAULT_TIMEZONE' in order for jpox and JdoKeyManager to operate correctly." ); - } - } - } - - private PersistenceManager getPersistenceManager() - { - PersistenceManager pm = pmf.getPersistenceManager(); - - pm.getFetchPlan().setMaxFetchDepth( 5 ); - - return pm; - } - - public String getId() - { - return "JDO Key Manager - " + this.getClass().getName(); - } - - public JdoFactory getJdoFactory() - { - return jdoFactory; - } - - public void setJdoFactory( JdoFactory jdoFactory ) - { - this.jdoFactory = jdoFactory; - } -} http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/mdo/keys.mdo ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/mdo/keys.mdo b/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/mdo/keys.mdo deleted file mode 100644 index 5c2ff59..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/mdo/keys.mdo +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0"?> - -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> - -<model> - <id>redback-keys-jdo</id> - <name>RedbackKeyManagementJdo</name> - <version>1.0.1</version> - <description>Archiva Redback :: Key Management JDO Store.</description> - <defaults> - <default> - <key>package</key> - <value>org.apache.archiva.redback.keys.jdo</value> - </default> - </defaults> - - <classes> - <class stash.storable="false" rootElement="true"> - <name>AuthenticationKeyDatabase</name> - <version>1.0.1+</version> - <fields> - <field jpox.column="AUTH_KEYS"> - <name>keys</name> - <version>1.0.1+</version> - <association> - <type>JdoAuthenticationKey</type> - <multiplicity>*</multiplicity> - </association> - </field> - </fields> - </class> - <class stash.storable="true" jpox.use-identifiers-as-primary-key="false"> - <name>JdoAuthenticationKey</name> - <version>1.0.0+</version> - <interfaces> - <interface>org.apache.archiva.redback.keys.AuthenticationKey</interface> - </interfaces> - <fields> - <field jpox.primary-key="true" - jpox.value-strategy="off" - jpox.persistence-modifier="persistent" - jpox.column="AUTHKEY"> - <name>key</name> - <version>1.0.0+</version> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>forPrincipal</name> - <version>1.0.0+</version> - <type>String</type> - <identifier>true</identifier> - </field> - <field> - <name>purpose</name> - <version>1.0.0+</version> - <type>String</type> - </field> - <field xml.format="long"> - <name>dateCreated</name> - <version>1.0.0+</version> - <type>Date</type> - </field> - <field xml.format="long"> - <name>dateExpires</name> - <version>1.0.0+</version> - <type>Date</type> - </field> - </fields> - </class> - </classes> -</model> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/resources/META-INF/spring-context.xml ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/resources/META-INF/spring-context.xml b/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/resources/META-INF/spring-context.xml deleted file mode 100644 index b757d07..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0"?> - -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:context="http://www.springframework.org/schema/context" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd - http://www.springframework.org/schema/context - http://www.springframework.org/schema/context/spring-context-3.0.xsd" - default-lazy-init="true"> - - <context:annotation-config /> - <context:component-scan base-package="org.apache.archiva.redback.keys.jdo"/> -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/java/org/apache/archiva/redback/keys/jdo/JdoKeyManagerTest.java ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/java/org/apache/archiva/redback/keys/jdo/JdoKeyManagerTest.java b/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/java/org/apache/archiva/redback/keys/jdo/JdoKeyManagerTest.java deleted file mode 100644 index 70f6d73..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/java/org/apache/archiva/redback/keys/jdo/JdoKeyManagerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.apache.archiva.redback.keys.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory; -import org.apache.archiva.redback.keys.KeyManager; -import org.apache.archiva.redback.keys.KeyManagerTestCase; -import org.jpox.SchemaTool; -import org.junit.Before; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.jdo.PersistenceManager; -import javax.jdo.PersistenceManagerFactory; -import java.net.URL; -import java.util.Map; -import java.util.Properties; - -/** - * JdoKeyManagerTest - * - * @author <a href="mailto:joa...@erdfelt.com">Joakim Erdfelt</a> - * - */ -public class JdoKeyManagerTest - extends KeyManagerTestCase -{ - - @Inject - @Named(value = "jdoFactory#users") - DefaultConfigurableJdoFactory jdoFactory; - - @Inject @Named(value = "keyManager#jdo") - KeyManager keyManager; - - - @Before - public void setUp() - throws Exception - { - - super.setUp(); - - assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() ); - - jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); //$NON-NLS-1$ - - jdoFactory.setDriverName( "org.hsqldb.jdbcDriver" ); //$NON-NLS-1$ - - jdoFactory.setUrl( "jdbc:hsqldb:mem:" + getName() ); //$NON-NLS-1$ - - jdoFactory.setUserName( "sa" ); //$NON-NLS-1$ - - jdoFactory.setPassword( "" ); //$NON-NLS-1$ - - jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$ - - jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" ); //$NON-NLS-1$ //$NON-NLS-2$ - - jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" ); //$NON-NLS-1$ //$NON-NLS-2$ - - jdoFactory.setProperty( "org.jpox.rdbms.dateTimezone", "JDK_DEFAULT_TIMEZONE" ); //$NON-NLS-1$ //$NON-NLS-2$ - - Properties properties = jdoFactory.getProperties(); - - for ( Map.Entry<Object,Object> entry : properties.entrySet() ) - { - System.setProperty( (String) entry.getKey(), (String) entry.getValue() ); - } - - SchemaTool.createSchemaTables( new URL[] { getClass() - .getResource( "/org/apache/archiva/redback/keys/jdo/package.jdo" ) }, new URL[] {}, null, false, null ); //$NON-NLS-1$ - - PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory(); - - assertNotNull( pmf ); - - PersistenceManager pm = pmf.getPersistenceManager(); - - pm.close(); - keyManager.eraseDatabase(); - setKeyManager( keyManager ); - } - -} http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/resources/spring-context.xml ---------------------------------------------------------------------- diff --git a/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/resources/spring-context.xml b/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/resources/spring-context.xml deleted file mode 100644 index dd75f72..0000000 --- a/redback-keys/redback-keys-providers/redback-keys-jdo/src/test/resources/spring-context.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0"?> - -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans - http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> - - <bean name="jdoFactory#users" class="org.apache.archiva.redback.components.jdo.DefaultConfigurableJdoFactory"> - <property name="driverName" value="org.hsqldb.jdbcDriver"/> - <property name="url" value="jdbc:hsqldb:mem:redback-users-tests" /> - <property name="userName" value="sa"/> - <property name="password" value=""/> - <property name="persistenceManagerFactoryClass" value="org.jpox.PersistenceManagerFactoryImpl"/> - <property name="otherProperties"> - <props> - <prop key="org.jpox.rdbms.dateTimezone">JDK_DEFAULT_TIMEZONE</prop> - </props> - </property> - </bean> - - <bean name="userConfiguration#default" class="org.apache.archiva.redback.configuration.DefaultUserConfiguration"> - <property name="registry" ref="test-conf"/> - </bean> - - <bean name="commons-configuration" class="org.apache.archiva.redback.components.registry.commons.CommonsConfigurationRegistry"> - </bean> - - <alias name="commons-configuration" alias="test-conf"/> - -</beans> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-rbac/redback-rbac-providers/redback-rbac-jdo/pom.xml ---------------------------------------------------------------------- diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jdo/pom.xml b/redback-rbac/redback-rbac-providers/redback-rbac-jdo/pom.xml deleted file mode 100644 index d3c4c73..0000000 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jdo/pom.xml +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you 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. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-rbac-providers</artifactId> - <version>2.5-SNAPSHOT</version> - </parent> - - <artifactId>redback-rbac-jdo</artifactId> - <packaging>bundle</packaging> - <name>Redback :: RBAC Provider :: JDO</name> - - <dependencies> - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-rbac-model</artifactId> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - </dependency> - <dependency> - <groupId>javax.annotation</groupId> - <artifactId>jsr250-api</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-rbac-tests</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - </dependency> - <dependency> - <groupId>org.apache.archiva.redback</groupId> - <artifactId>redback-common-jdo</artifactId> - </dependency> - <dependency> - <groupId>net.java.dev.stax-utils</groupId> - <artifactId>stax-utils</artifactId> - <version>20060502</version> - <exclusions> - <exclusion> - <groupId>com.bea.xml</groupId> - <artifactId>jsr173-ri</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-simple</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hsqldb</groupId> - <artifactId>hsqldb</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>jpox</groupId> - <artifactId>jpox-ehcache</artifactId> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>ehcache</groupId> - <artifactId>ehcache</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - </plugin> - <plugin> - <groupId>org.codehaus.modello</groupId> - <artifactId>modello-maven-plugin</artifactId> - <configuration> - <version>1.0.1</version> - <packageWithVersion>false</packageWithVersion> - <models> - <model>src/main/mdo/rbac-jdo.mdo</model> - </models> - </configuration> - <executions> - <execution> - <id>modello-java</id> - <goals> - <goal>java</goal> - <!-- TODO: Move these to plexus-security-authorization-rbac-model --> - <goal>stax-reader</goal> - <goal>stax-writer</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.archiva.redback.components.modello</groupId> - <artifactId>jpox-modello-maven-plugin</artifactId> - <configuration> - <version>1.0.1</version> - <packageWithVersion>false</packageWithVersion> - <models> - <model>src/main/mdo/rbac-jdo.mdo</model> - </models> - </configuration> - <executions> - <execution> - <id>modello-jpox</id> - <goals> - <goal>jpox-metadata-class</goal> - <goal>jpox-jdo-mapping</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>jpox-maven-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>enhance</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - -</project> http://git-wip-us.apache.org/repos/asf/archiva-redback-core/blob/0537b856/redback-rbac/redback-rbac-providers/redback-rbac-jdo/src/main/java/org/apache/archiva/redback/rbac/jdo/JdoRbacManager.java ---------------------------------------------------------------------- diff --git a/redback-rbac/redback-rbac-providers/redback-rbac-jdo/src/main/java/org/apache/archiva/redback/rbac/jdo/JdoRbacManager.java b/redback-rbac/redback-rbac-providers/redback-rbac-jdo/src/main/java/org/apache/archiva/redback/rbac/jdo/JdoRbacManager.java deleted file mode 100644 index ac565a3..0000000 --- a/redback-rbac/redback-rbac-providers/redback-rbac-jdo/src/main/java/org/apache/archiva/redback/rbac/jdo/JdoRbacManager.java +++ /dev/null @@ -1,711 +0,0 @@ -package org.apache.archiva.redback.rbac.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -import org.apache.archiva.redback.rbac.AbstractRBACManager; -import org.apache.archiva.redback.rbac.Operation; -import org.apache.archiva.redback.rbac.RBACManagerListener; -import org.apache.archiva.redback.rbac.RbacManagerException; -import org.apache.archiva.redback.rbac.RbacObjectInvalidException; -import org.apache.archiva.redback.rbac.RbacObjectNotFoundException; -import org.apache.archiva.redback.rbac.RbacPermanentException; -import org.apache.archiva.redback.rbac.Resource; -import org.apache.archiva.redback.rbac.Role; -import org.apache.archiva.redback.rbac.UserAssignment; -import org.apache.archiva.redback.rbac.Permission; -import org.apache.archiva.redback.rbac.RBACObjectAssertions; -import org.springframework.stereotype.Service; - -import javax.annotation.PostConstruct; -import javax.inject.Inject; -import javax.jdo.JDOHelper; -import javax.jdo.PersistenceManager; -import javax.jdo.Transaction; -import java.util.Collection; -import java.util.List; - -/** - * JdoRbacManager: - * - * @author <a href="mailto:joa...@erdfelt.com">Joakim Erdfelt</a> - * @author Jesse McConnell - * - */ -@Service( "rbacManager#jdo" ) -public class JdoRbacManager - extends AbstractRBACManager - implements RBACManagerListener -{ - @Inject - private JdoTool jdo; - - private boolean enableCache = true; - - // private static final String ROLE_DETAIL = "role-child-detail"; - private static final String ROLE_DETAIL = null; - - // ---------------------------------------------------------------------- - // Role methods - // ---------------------------------------------------------------------- - - /** - * Creates an implementation specific {@link Role}. - * - * Note: this method does not add the {@link Role} to the underlying store. - * a call to {@link #saveRole(Role)} is required to track the role created with this - * method call. - * - * @param name the name. - * @return the new {@link Role} object with an empty (non-null) {@link Role#getChildRoleNames()} object. - */ - public Role createRole( String name ) - { - Role role; - - try - { - role = getRole( name ); - } - catch ( RbacManagerException e ) - { - role = new JdoRole(); - role.setName( name ); - } - - return role; - } - - /** - * Method addRole - * - * @param role - */ - public Role saveRole( Role role ) - throws RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( role ); - - return jdo.saveObject( role, new String[]{ ROLE_DETAIL } ); - } - - public boolean roleExists( Role role ) - { - return jdo.objectExists( role ); - } - - public boolean roleExists( String name ) - { - try - { - return jdo.objectExistsById( JdoRole.class, name ); - } - catch ( RbacManagerException e ) - { - return false; - } - } - - /** - * @param roleName - * @return - * @throws RbacObjectNotFoundException - * @throws RbacManagerException - */ - public Role getRole( String roleName ) - throws RbacObjectNotFoundException, RbacManagerException - { - return jdo.getObjectById( JdoRole.class, roleName, ROLE_DETAIL ); - } - - /** - * Method getRoles - */ - @SuppressWarnings( "unchecked" ) - public List<Role> getAllRoles() - throws RbacManagerException - { - return (List<Role>) jdo.getAllObjects( JdoRole.class ); - } - - public void removeRole( Role role ) - throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( role ); - - if ( role.isPermanent() ) - { - throw new RbacPermanentException( "Unable to delete permanent role [" + role.getName() + "]" ); - } - - jdo.removeObject( role ); - } - - public void saveRoles( Collection<Role> roles ) - throws RbacObjectInvalidException, RbacManagerException - { - if ( roles == null ) - { - // Nothing to do. - return; - } - - // This is done in JdoRbacManager as opposed to JdoTool as we need to assertValid() on each role and - // also wrap the entire collection into a single atomic save/makePersistent. - - PersistenceManager pm = jdo.getPersistenceManager(); - Transaction tx = pm.currentTransaction(); - - try - { - tx.begin(); - - for ( Role role : roles ) - { - if ( ( JDOHelper.getObjectId( role ) != null ) && !JDOHelper.isDetached( role ) ) - { - // This is a fatal error that means we need to fix our code. - // Leave it as a JDOUserException, it's intentional. - throw new RbacManagerException( "Existing Role is not detached: " + role ); - } - - RBACObjectAssertions.assertValid( role ); - - pm.makePersistent( role ); - } - - tx.commit(); - } - finally - { - jdo.rollbackIfActive( tx ); - } - } - - // ---------------------------------------------------------------------- - // Permission methods - // ---------------------------------------------------------------------- - - /** - * Creates an implementation specific {@link Permission}. - * - * Note: this method does not add the {@link Permission} to the underlying store. - * a call to {@link #savePermission(Permission)} is required to track the permission created - * with this method call. - * - * @param name the name. - * @return the new Permission. - * @throws RbacManagerException - */ - public Permission createPermission( String name ) - throws RbacManagerException - { - Permission permission; - - try - { - permission = getPermission( name ); - log.debug( "Create Permission [{}] Returning Existing.", name ); - } - catch ( RbacObjectNotFoundException e ) - { - permission = new JdoPermission(); - permission.setName( name ); - log.debug( "Create Permission [{}] New JdoPermission.", name ); - } - - return permission; - } - - /** - * Creates an implementation specific {@link Permission} with specified {@link Operation}, - * and {@link Resource} identifiers. - * - * Note: this method does not add the Permission, Operation, or Resource to the underlying store. - * a call to {@link #savePermission(Permission)} is required to track the permission, operation, - * or resource created with this method call. - * - * @param name the name. - * @param operationName the {@link Operation#setName(String)} value - * @param resourceIdentifier the {@link Resource#setIdentifier(String)} value - * @return the new Permission. - * @throws RbacManagerException - */ - public Permission createPermission( String name, String operationName, String resourceIdentifier ) - throws RbacManagerException - { - Permission permission = new JdoPermission(); - permission.setName( name ); - - Operation operation; - try - { - operation = getOperation( operationName ); - } - catch ( RbacObjectNotFoundException e ) - { - operation = new JdoOperation(); - operation.setName( operationName ); - } - permission.setOperation( operation ); - - Resource resource; - try - { - resource = getResource( resourceIdentifier ); - } - catch ( RbacObjectNotFoundException e ) - { - resource = new JdoResource(); - resource.setIdentifier( resourceIdentifier ); - } - permission.setResource( resource ); - - return permission; - } - - public Permission savePermission( Permission permission ) - throws RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( permission ); - - return jdo.saveObject( permission, null ); - } - - public boolean permissionExists( Permission permission ) - { - return jdo.objectExists( permission ); - } - - public boolean permissionExists( String name ) - { - try - { - return jdo.objectExistsById( JdoPermission.class, name ); - } - catch ( RbacManagerException e ) - { - return false; - } - } - - public Permission getPermission( String permissionName ) - throws RbacObjectNotFoundException, RbacManagerException - { - return jdo.getObjectById( JdoPermission.class, permissionName, null ); - } - - @SuppressWarnings( "unchecked" ) - public List<Permission> getAllPermissions() - throws RbacManagerException - { - return (List<Permission>) jdo.getAllObjects( JdoPermission.class ); - } - - public void removePermission( Permission permission ) - throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( permission ); - - if ( permission.isPermanent() ) - { - throw new RbacPermanentException( "Unable to delete permanent permission [" + permission.getName() + "]" ); - } - - jdo.removeObject( permission ); - } - - // ---------------------------------------------------------------------- - // Operation methods - // ---------------------------------------------------------------------- - - /** - * Creates an implementation specific {@link Operation}. - * - * Note: this method does not add the {@link Operation} to the underlying store. - * a call to {@link #saveOperation(Operation)} is required to track the operation created - * with this method call. - * - * @param name the name. - * @return the new Operation. - * @throws RbacManagerException - */ - public Operation createOperation( String name ) - throws RbacManagerException - { - Operation operation; - - try - { - operation = getOperation( name ); - } - catch ( RbacObjectNotFoundException e ) - { - operation = new JdoOperation(); - operation.setName( name ); - } - - return operation; - } - - public Operation saveOperation( Operation operation ) - throws RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( operation ); - return jdo.saveObject( operation, null ); - } - - public boolean operationExists( Operation operation ) - { - return jdo.objectExists( operation ); - } - - public boolean operationExists( String name ) - { - try - { - return jdo.objectExistsById( JdoOperation.class, name ); - } - catch ( RbacManagerException e ) - { - return false; - } - } - - public Operation getOperation( String operationName ) - throws RbacObjectNotFoundException, RbacManagerException - { - return jdo.getObjectById( JdoOperation.class, operationName, null ); - } - - @SuppressWarnings( "unchecked" ) - public List<Operation> getAllOperations() - throws RbacManagerException - { - return (List<Operation>) jdo.getAllObjects( JdoOperation.class ); - } - - public void removeOperation( Operation operation ) - throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( operation ); - - if ( operation.isPermanent() ) - { - throw new RbacPermanentException( "Unable to delete permanent operation [" + operation.getName() + "]" ); - } - - jdo.removeObject( operation ); - } - - // ---------------------------------------------------------------------- - // Resource methods - // ---------------------------------------------------------------------- - - /** - * Creates an implementation specific {@link Resource}. - * - * Note: this method does not add the {@link Resource} to the underlying store. - * a call to {@link #saveResource(Resource)} is required to track the resource created - * with this method call. - * - * @param identifier the identifier. - * @return the new Resource. - * @throws RbacManagerException - */ - public Resource createResource( String identifier ) - throws RbacManagerException - { - Resource resource; - - try - { - resource = getResource( identifier ); - log.debug( "Create Resource [ {} ] Returning Existing.", identifier ); - } - catch ( RbacObjectNotFoundException e ) - { - resource = new JdoResource(); - resource.setIdentifier( identifier ); - log.debug( "Create Resource [ {} ] New JdoResource.", identifier ); - } - - return resource; - } - - public Resource saveResource( Resource resource ) - throws RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( resource ); - return jdo.saveObject( resource, null ); - } - - public boolean resourceExists( Resource resource ) - { - return jdo.objectExists( resource ); - } - - public boolean resourceExists( String identifier ) - { - try - { - return jdo.objectExistsById( JdoResource.class, identifier ); - } - catch ( RbacManagerException e ) - { - return false; - } - } - - public Resource getResource( String resourceIdentifier ) - throws RbacObjectNotFoundException, RbacManagerException - { - return jdo.getObjectById( JdoResource.class, resourceIdentifier, null ); - } - - @SuppressWarnings( "unchecked" ) - public List<Resource> getAllResources() - throws RbacManagerException - { - return (List<Resource>) jdo.getAllObjects( JdoResource.class ); - } - - public void removeResource( Resource resource ) - throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( resource ); - - if ( resource.isPermanent() ) - { - throw new RbacPermanentException( - "Unable to delete permanent resource [" + resource.getIdentifier() + "]" ); - } - - jdo.removeObject( resource ); - } - - // ---------------------------------------------------------------------- - // User Assignment methods - // ---------------------------------------------------------------------- - - /** - * Creates an implementation specific {@link UserAssignment}. - * - * Note: this method does not add the {@link UserAssignment} to the underlying store. - * a call to {@link #saveUserAssignment(UserAssignment)} is required to track the user - * assignment created with this method call. - * - * @param principal the principal reference to the user. - * @return the new UserAssignment with an empty (non-null) {@link UserAssignment#getRoleNames()} object. - */ - public UserAssignment createUserAssignment( String principal ) - { - UserAssignment ua; - - try - { - ua = getUserAssignment( principal ); - } - catch ( RbacManagerException e ) - { - ua = new JdoUserAssignment(); - ua.setPrincipal( principal ); - } - - return ua; - } - - /** - * Method addUserAssignment - * - * @param userAssignment - */ - public UserAssignment saveUserAssignment( UserAssignment userAssignment ) - throws RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( "Save User Assignment", userAssignment ); - - fireRbacUserAssignmentSaved( userAssignment ); - - return jdo.saveObject( userAssignment, new String[]{ ROLE_DETAIL } ); - } - - public boolean userAssignmentExists( String principal ) - { - try - { - return jdo.objectExistsById( JdoUserAssignment.class, principal ); - } - catch ( RbacManagerException e ) - { - return false; - } - } - - public boolean userAssignmentExists( UserAssignment assignment ) - { - return jdo.objectExists( assignment ); - } - - public UserAssignment getUserAssignment( String principal ) - throws RbacObjectNotFoundException, RbacManagerException - { - return jdo.getObjectById( JdoUserAssignment.class, principal, ROLE_DETAIL ); - } - - /** - * Method getAssignments - */ - @SuppressWarnings( "unchecked" ) - public List<UserAssignment> getAllUserAssignments() - throws RbacManagerException - { - return (List<UserAssignment>) jdo.getAllObjects( JdoUserAssignment.class ); - } - - /** - * Method getUserAssignmentsForRoles - */ - @SuppressWarnings( "unchecked" ) - public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames ) - throws RbacManagerException - { - return (List<UserAssignment>) jdo.getUserAssignmentsForRoles( JdoUserAssignment.class, null, roleNames ); - } - - /** - * Method removeAssignment - * - * @param userAssignment - */ - public void removeUserAssignment( UserAssignment userAssignment ) - throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException - { - RBACObjectAssertions.assertValid( userAssignment ); - - if ( userAssignment.isPermanent() ) - { - throw new RbacPermanentException( - "Unable to delete permanent user assignment [" + userAssignment.getPrincipal() + "]" ); - } - - fireRbacUserAssignmentRemoved( userAssignment ); - - jdo.removeObject( userAssignment ); - } - - public void eraseDatabase() - { - // Must delete in order so that FK constraints don't get violated - jdo.removeAll( JdoRole.class ); - jdo.removeAll( JdoPermission.class ); - jdo.removeAll( JdoOperation.class ); - jdo.removeAll( JdoResource.class ); - jdo.removeAll( JdoUserAssignment.class ); - jdo.removeAll( RbacJdoModelModelloMetadata.class ); - } - - @PostConstruct - public void initialize() - { - super.initialize(); - - jdo.setListener( this ); - if ( enableCache ) - { - jdo.enableCache( JdoRole.class ); - jdo.enableCache( JdoOperation.class ); - jdo.enableCache( JdoResource.class ); - jdo.enableCache( JdoUserAssignment.class ); - jdo.enableCache( JdoPermission.class ); - } - } - - public void rbacInit( boolean freshdb ) - { - fireRbacInit( freshdb ); - } - - public void rbacPermissionRemoved( Permission permission ) - { - fireRbacPermissionRemoved( permission ); - } - - public void rbacPermissionSaved( Permission permission ) - { - fireRbacPermissionSaved( permission ); - } - - public void rbacRoleRemoved( Role role ) - { - fireRbacRoleRemoved( role ); - } - - public void rbacRoleSaved( Role role ) - { - fireRbacRoleSaved( role ); - } - - - public void rbacUserAssignmentSaved( UserAssignment userAssignment ) - { - fireRbacUserAssignmentSaved( userAssignment ); - } - - public void rbacUserAssignmentRemoved( UserAssignment userAssignment ) - { - fireRbacUserAssignmentRemoved( userAssignment ); - } - - public JdoTool getJdo() - { - return jdo; - } - - public void setJdo( JdoTool jdo ) - { - this.jdo = jdo; - } - - public boolean isEnableCache() - { - return enableCache; - } - - public void setEnableCache( boolean enableCache ) - { - this.enableCache = enableCache; - } - - @Override - public boolean isFinalImplementation() - { - return true; - } - - public String getDescriptionKey() - { - return "archiva.redback.rbacmanager.jdo"; - } - - public boolean isReadOnly() - { - return false; - } -}