Removing data-management module
This commit is contained in:
parent
fde0cc1374
commit
56a6c952f9
1
pom.xml
1
pom.xml
|
@ -54,7 +54,6 @@
|
|||
<module>redback-system</module>
|
||||
<module>redback-keys</module>
|
||||
<module>redback-users</module>
|
||||
<module>redback-data-management</module>
|
||||
<module>redback-integrations</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -1,131 +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>
|
||||
<artifactId>redback</artifactId>
|
||||
<groupId>org.apache.archiva.redback</groupId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>redback-data-management</artifactId>
|
||||
<properties>
|
||||
<site.staging.base>${project.parent.basedir}</site.staging.base>
|
||||
</properties>
|
||||
<name>Redback :: Data Management Utilities</name>
|
||||
<description>Back up, restore and upgrade utilities for JDO databases using XML</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback</groupId>
|
||||
<artifactId>redback-users-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback</groupId>
|
||||
<artifactId>redback-rbac-model</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback</groupId>
|
||||
<artifactId>redback-keys-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva.redback</groupId>
|
||||
<artifactId>redback-rbac-tests</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xmlunit</groupId>
|
||||
<artifactId>xmlunit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.derby</groupId>
|
||||
<artifactId>derby</artifactId>
|
||||
<version>10.13.1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
<artifactId>commons-collections</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-launcher</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-console-standalone</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<basedir>${basedir}</basedir>
|
||||
<derby.system.home>${project.build.directory}/test-home</derby.system.home>
|
||||
<openjpa.Log>${openjpa.Log}</openjpa.Log>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -1,61 +0,0 @@
|
|||
package org.apache.archiva.redback.management;
|
||||
|
||||
/*
|
||||
* 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.users.UserManager;
|
||||
import org.apache.archiva.redback.keys.KeyManager;
|
||||
import org.apache.archiva.redback.rbac.RBACManager;
|
||||
import org.apache.archiva.redback.rbac.RbacManagerException;
|
||||
import org.apache.archiva.redback.users.UserManagerException;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Data management tool API.
|
||||
*/
|
||||
public interface DataManagementTool
|
||||
{
|
||||
|
||||
void backupRBACDatabase( RBACManager manager, Path backupDirectory )
|
||||
throws RbacManagerException, IOException, XMLStreamException;
|
||||
|
||||
void backupUserDatabase( UserManager manager, Path backupDirectory )
|
||||
throws IOException, XMLStreamException, UserManagerException;
|
||||
|
||||
void backupKeyDatabase( KeyManager manager, Path backupDirectory )
|
||||
throws IOException, XMLStreamException;
|
||||
|
||||
void restoreRBACDatabase( RBACManager manager, Path backupDirectory )
|
||||
throws IOException, XMLStreamException, RbacManagerException;
|
||||
|
||||
void restoreUsersDatabase( UserManager manager, Path backupDirectory )
|
||||
throws IOException, XMLStreamException, UserManagerException;
|
||||
|
||||
void restoreKeysDatabase( KeyManager manager, Path backupDirectory )
|
||||
throws IOException, XMLStreamException;
|
||||
|
||||
void eraseRBACDatabase( RBACManager manager );
|
||||
|
||||
void eraseUsersDatabase( UserManager manager );
|
||||
|
||||
void eraseKeysDatabase( KeyManager manager );
|
||||
}
|
|
@ -1,34 +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.management"/>
|
||||
|
||||
</beans>
|
|
@ -1,458 +0,0 @@
|
|||
package org.apache.archiva.redback.management;
|
||||
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
import org.apache.archiva.redback.keys.AuthenticationKey;
|
||||
import org.apache.archiva.redback.keys.KeyManager;
|
||||
import org.apache.archiva.redback.keys.KeyManagerException;
|
||||
import org.apache.archiva.redback.rbac.*;
|
||||
import org.apache.archiva.redback.tests.utils.RBACDefaults;
|
||||
import org.apache.archiva.redback.users.User;
|
||||
import org.apache.archiva.redback.users.UserManager;
|
||||
import org.apache.archiva.redback.users.UserManagerException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.custommonkey.xmlunit.XMLAssert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
// @TODO: Investigate how to implement export with JPA
|
||||
@Ignore("Currently no JPA implementation")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
|
||||
public class DataManagementTest
|
||||
extends TestCase
|
||||
{
|
||||
@Inject
|
||||
private DataManagementTool dataManagementTool;
|
||||
|
||||
private Path targetDirectory;
|
||||
|
||||
@Inject
|
||||
@Named(value = "userManager#jpa")
|
||||
UserManager userManager;
|
||||
|
||||
@Inject
|
||||
@Named(value = "keyManager#jpa")
|
||||
KeyManager keyManager;
|
||||
|
||||
|
||||
@Inject
|
||||
@Named(value = "rbacManager#jpa")
|
||||
RBACManager rbacManager;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
targetDirectory = createBackupDirectory();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEraseUsers()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
dataManagementTool.eraseUsersDatabase( userManager );
|
||||
|
||||
createUserDatabase( userManager );
|
||||
|
||||
dataManagementTool.eraseUsersDatabase( userManager );
|
||||
|
||||
assertEmpty( userManager );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEraseKeys()
|
||||
throws Exception
|
||||
{
|
||||
|
||||
createKeyDatabase( keyManager );
|
||||
|
||||
dataManagementTool.eraseKeysDatabase( keyManager );
|
||||
|
||||
assertEmpty( keyManager );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackupRbac()
|
||||
throws Exception
|
||||
{
|
||||
RBACManager manager = rbacManager;
|
||||
|
||||
dataManagementTool.eraseRBACDatabase( manager );
|
||||
|
||||
createRbacDatabase( manager );
|
||||
|
||||
dataManagementTool.backupRBACDatabase( manager, targetDirectory );
|
||||
|
||||
Path backupFile = targetDirectory.resolve( "rbac.xml" );
|
||||
|
||||
assertTrue( "Check database exists", Files.exists(backupFile) );
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
IOUtils.copy( getClass().getResourceAsStream( "/expected-rbac.xml" ), sw );
|
||||
|
||||
XMLAssert.assertXMLEqual( new StringReader( sw.toString() ),
|
||||
new StringReader( FileUtils.readFileToString( backupFile.toFile() ) ) );
|
||||
|
||||
}
|
||||
|
||||
private void createRbacDatabase( RBACManager manager )
|
||||
throws RbacManagerException
|
||||
{
|
||||
RBACDefaults defaults = new RBACDefaults( manager );
|
||||
|
||||
defaults.createDefaults();
|
||||
|
||||
UserAssignment assignment = manager.createUserAssignment( "bob" );
|
||||
assignment.addRoleName( "Developer" );
|
||||
manager.saveUserAssignment( assignment );
|
||||
|
||||
assignment = manager.createUserAssignment( "betty" );
|
||||
assignment.addRoleName( "System Administrator" );
|
||||
manager.saveUserAssignment( assignment );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackupUsers()
|
||||
throws Exception
|
||||
{
|
||||
UserManager manager = userManager;
|
||||
|
||||
createUserDatabase( manager );
|
||||
|
||||
dataManagementTool.backupUserDatabase( manager, targetDirectory );
|
||||
|
||||
Path backupFile = targetDirectory.resolve( "users.xml" );
|
||||
|
||||
assertTrue( "Check database exists", Files.exists(backupFile) );
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
IOUtils.copy( getClass().getResourceAsStream( "/expected-users.xml" ), sw );
|
||||
|
||||
String actual = FileUtils.readFileToString( backupFile.toFile() ).trim();
|
||||
String expected = sw.toString().trim();
|
||||
|
||||
XMLAssert.assertXMLEqual( removeTimestampVariance( expected ), removeTimestampVariance( actual ) );
|
||||
|
||||
}
|
||||
|
||||
private void createUserDatabase( UserManager manager )
|
||||
throws UserManagerException
|
||||
{
|
||||
User user = manager.createUser( "smcqueen", "Steve McQueen", "the cooler king" );
|
||||
user.setPassword( "abc123" );
|
||||
manager.addUser( user );
|
||||
|
||||
user = manager.createUser( "bob", "Sideshow Bob", "bob_862@hotmail.com" );
|
||||
user.setPassword( "bobby862" );
|
||||
manager.addUser( user );
|
||||
|
||||
user = manager.createUser( "betty", "Betty", "betty@aol.com" );
|
||||
user.setPassword( "rover2" );
|
||||
manager.addUser( user );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBackupKeys()
|
||||
throws Exception
|
||||
{
|
||||
KeyManager manager = keyManager;
|
||||
|
||||
createKeyDatabase( manager );
|
||||
|
||||
Thread.sleep( 60000 );
|
||||
|
||||
dataManagementTool.backupKeyDatabase( manager, targetDirectory );
|
||||
|
||||
Path backupFile = targetDirectory.resolve( "keys.xml" );
|
||||
|
||||
assertTrue( "Check database exists", Files.exists(backupFile) );
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
IOUtils.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), sw );
|
||||
|
||||
String actual = FileUtils.readFileToString( backupFile.toFile() ).trim();
|
||||
String expected = sw.toString().trim();
|
||||
|
||||
XMLAssert.assertXMLEqual( removeKeyAndTimestampVariance( expected ), removeKeyAndTimestampVariance( actual ) );
|
||||
|
||||
}
|
||||
|
||||
private static void createKeyDatabase( KeyManager manager )
|
||||
throws KeyManagerException
|
||||
{
|
||||
manager.createKey( "bob", "Testing", 15 );
|
||||
manager.createKey( "betty", "Something", 25 );
|
||||
manager.createKey( "fred", "Else", 30 );
|
||||
manager.createKey( "tony", "Expired", 0 );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreRbac()
|
||||
throws Exception
|
||||
{
|
||||
RBACManager manager = rbacManager;
|
||||
|
||||
dataManagementTool.eraseRBACDatabase( manager );
|
||||
|
||||
assertEmpty( manager );
|
||||
|
||||
Path backupFile = targetDirectory.resolve("rbac.xml" );
|
||||
|
||||
InputStream is = getClass().getResourceAsStream( "/expected-rbac.xml" );
|
||||
|
||||
BufferedWriter fw = Files.newBufferedWriter(backupFile, StandardOpenOption.CREATE_NEW);
|
||||
|
||||
IOUtils.copy( is, fw );
|
||||
|
||||
is.close();
|
||||
|
||||
fw.close();
|
||||
|
||||
dataManagementTool.restoreRBACDatabase( manager, targetDirectory );
|
||||
|
||||
List<? extends Role> roles = manager.getAllRoles();
|
||||
List<? extends UserAssignment> assignments = manager.getAllUserAssignments();
|
||||
assertEquals( 4, roles.size() );
|
||||
assertEquals( 2, assignments.size() );
|
||||
assertEquals( 6, manager.getAllOperations().size() );
|
||||
assertEquals( 1, manager.getAllResources().size() );
|
||||
assertEquals( 6, manager.getAllPermissions().size() );
|
||||
|
||||
Role role = roles.get( 0 );
|
||||
assertEquals( "User Administrator", role.getName() );
|
||||
assertTrue( role.isAssignable() );
|
||||
assertEquals( 2, role.getPermissions().size() );
|
||||
assertPermission( role.getPermissions().get( 0 ), "Edit All Users", "edit-all-users", "*" );
|
||||
assertPermission( role.getPermissions().get( 1 ), "Remove Roles", "remove-roles", "*" );
|
||||
|
||||
role = roles.get( 1 );
|
||||
assertEquals( "System Administrator", role.getName() );
|
||||
assertTrue( role.isAssignable() );
|
||||
assertEquals( 1, role.getChildRoleNames().size() );
|
||||
assertEquals( "User Administrator", role.getChildRoleNames().get( 0 ) );
|
||||
assertEquals( 4, role.getPermissions().size() );
|
||||
assertPermission( role.getPermissions().get( 0 ), "Edit Configuration", "edit-configuration", "*" );
|
||||
assertPermission( role.getPermissions().get( 1 ), "Run Indexer", "run-indexer", "*" );
|
||||
assertPermission( role.getPermissions().get( 2 ), "Add Repository", "add-repository", "*" );
|
||||
assertPermission( role.getPermissions().get( 3 ), "Regenerate Index", "regenerate-index", "*" );
|
||||
|
||||
role = roles.get( 2 );
|
||||
assertEquals( "Trusted Developer", role.getName() );
|
||||
assertTrue( role.isAssignable() );
|
||||
assertEquals( 1, role.getChildRoleNames().size() );
|
||||
assertEquals( "System Administrator", role.getChildRoleNames().get( 0 ) );
|
||||
assertEquals( 1, role.getPermissions().size() );
|
||||
assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
|
||||
|
||||
role = roles.get( 3 );
|
||||
assertEquals( "Developer", role.getName() );
|
||||
assertTrue( role.isAssignable() );
|
||||
assertEquals( 1, role.getChildRoleNames().size() );
|
||||
assertEquals( "Trusted Developer", role.getChildRoleNames().get( 0 ) );
|
||||
assertEquals( 1, role.getPermissions().size() );
|
||||
assertPermission( role.getPermissions().get( 0 ), "Run Indexer", "run-indexer", "*" );
|
||||
|
||||
UserAssignment assignment = assignments.get( 0 );
|
||||
assertEquals( "bob", assignment.getPrincipal() );
|
||||
assertEquals( 1, assignment.getRoleNames().size() );
|
||||
assertEquals( "Developer", assignment.getRoleNames().get( 0 ) );
|
||||
|
||||
assignment = assignments.get( 1 );
|
||||
assertEquals( "betty", assignment.getPrincipal() );
|
||||
assertEquals( 1, assignment.getRoleNames().size() );
|
||||
assertEquals( "System Administrator", assignment.getRoleNames().get( 0 ) );
|
||||
}
|
||||
|
||||
private void assertEmpty( RBACManager manager )
|
||||
throws RbacManagerException
|
||||
{
|
||||
assertEquals( 0, manager.getAllRoles().size() );
|
||||
assertEquals( 0, manager.getAllUserAssignments().size() );
|
||||
assertEquals( 0, manager.getAllOperations().size() );
|
||||
assertEquals( 0, manager.getAllResources().size() );
|
||||
assertEquals( 0, manager.getAllPermissions().size() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreUsers()
|
||||
throws Exception
|
||||
{
|
||||
UserManager manager = userManager;
|
||||
|
||||
dataManagementTool.eraseUsersDatabase( manager );
|
||||
|
||||
assertEmpty( manager );
|
||||
|
||||
Path backupFile = targetDirectory.resolve( "users.xml" );
|
||||
|
||||
BufferedWriter fw = Files.newBufferedWriter(backupFile, StandardOpenOption.CREATE_NEW );
|
||||
|
||||
IOUtils.copy( getClass().getResourceAsStream( "/expected-users.xml" ), fw );
|
||||
|
||||
fw.close();
|
||||
|
||||
dataManagementTool.restoreUsersDatabase( manager, targetDirectory );
|
||||
|
||||
List<? extends User> users = manager.getUsers();
|
||||
assertEquals( 3, users.size() );
|
||||
|
||||
User user = users.get( 0 );
|
||||
assertEquals( "smcqueen", user.getUsername() );
|
||||
assertEquals( "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=", user.getEncodedPassword() );
|
||||
assertEquals( "Steve McQueen", user.getFullName() );
|
||||
assertEquals( "the cooler king", user.getEmail() );
|
||||
assertEquals( 1164424661686L, user.getLastPasswordChange().getTime() );
|
||||
assertEquals( Arrays.asList( new String[]{ "bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=" } ),
|
||||
user.getPreviousEncodedPasswords() );
|
||||
|
||||
user = users.get( 1 );
|
||||
assertEquals( "bob", user.getUsername() );
|
||||
assertEquals( "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=", user.getEncodedPassword() );
|
||||
assertEquals( "Sideshow Bob", user.getFullName() );
|
||||
assertEquals( "bob_862@hotmail.com", user.getEmail() );
|
||||
assertEquals( 1164424669526L, user.getLastPasswordChange().getTime() );
|
||||
assertEquals( Arrays.asList( new String[]{ "A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=" } ),
|
||||
user.getPreviousEncodedPasswords() );
|
||||
|
||||
user = users.get( 2 );
|
||||
assertEquals( "betty", user.getUsername() );
|
||||
assertEquals( "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=", user.getEncodedPassword() );
|
||||
assertEquals( "Betty", user.getFullName() );
|
||||
assertEquals( "betty@aol.com", user.getEmail() );
|
||||
assertEquals( 1164424669536L, user.getLastPasswordChange().getTime() );
|
||||
assertEquals( Arrays.asList( new String[]{ "L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=" } ),
|
||||
user.getPreviousEncodedPasswords() );
|
||||
}
|
||||
|
||||
private void assertEmpty( UserManager manager )
|
||||
throws UserManagerException
|
||||
{
|
||||
List<? extends User> users = manager.getUsers();
|
||||
assertEquals( 0, users.size() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRestoreKeys()
|
||||
throws Exception
|
||||
{
|
||||
KeyManager manager = keyManager;
|
||||
|
||||
dataManagementTool.eraseKeysDatabase( manager );
|
||||
|
||||
assertEmpty( manager );
|
||||
|
||||
Path backupFile = targetDirectory.resolve( "keys.xml" );
|
||||
|
||||
BufferedWriter fw = Files.newBufferedWriter( backupFile, StandardOpenOption.CREATE_NEW );
|
||||
|
||||
IOUtils.copy( getClass().getResourceAsStream( "/expected-keys.xml" ), fw );
|
||||
|
||||
fw.close();
|
||||
|
||||
dataManagementTool.restoreKeysDatabase( manager, targetDirectory );
|
||||
|
||||
List<AuthenticationKey> keys = manager.getAllKeys();
|
||||
assertEquals( 3, keys.size() );
|
||||
|
||||
AuthenticationKey key = keys.get( 0 );
|
||||
assertEquals( "248df0fec5d54e3eb11339f5e81d8bd7", key.getKey() );
|
||||
assertEquals( "bob", key.getForPrincipal() );
|
||||
assertEquals( "Testing", key.getPurpose() );
|
||||
assertEquals( 1164426311921L, key.getDateCreated().getTime() );
|
||||
assertEquals( 1164427211921L, key.getDateExpires().getTime() );
|
||||
|
||||
key = keys.get( 1 );
|
||||
assertEquals( "a98dddc2ae614a7c82f8afd3ba6e39fb", key.getKey() );
|
||||
assertEquals( "betty", key.getForPrincipal() );
|
||||
assertEquals( "Something", key.getPurpose() );
|
||||
assertEquals( 1164426315657L, key.getDateCreated().getTime() );
|
||||
assertEquals( 1164427815657L, key.getDateExpires().getTime() );
|
||||
|
||||
key = keys.get( 2 );
|
||||
assertEquals( "1428d2ca3a0246f0a1d979504e351388", key.getKey() );
|
||||
assertEquals( "fred", key.getForPrincipal() );
|
||||
assertEquals( "Else", key.getPurpose() );
|
||||
assertEquals( 1164426315664L, key.getDateCreated().getTime() );
|
||||
assertEquals( 1164428115664L, key.getDateExpires().getTime() );
|
||||
}
|
||||
|
||||
private void assertEmpty( KeyManager manager )
|
||||
{
|
||||
assertEquals( 0, manager.getAllKeys().size() );
|
||||
}
|
||||
|
||||
private String removeKeyAndTimestampVariance( String content )
|
||||
{
|
||||
return removeTagContent( removeTagContent( removeTagContent( content, "dateCreated" ), "dateExpires" ), "key" );
|
||||
}
|
||||
|
||||
private static String removeTimestampVariance( String content )
|
||||
{
|
||||
return removeTagContent( removeTagContent( content, "lastPasswordChange" ), "accountCreationDate" );
|
||||
}
|
||||
|
||||
private static String removeTagContent( String content, String field )
|
||||
{
|
||||
return content.replaceAll( "<" + field + ">.*</" + field + ">", "<" + field + "></" + field + ">" );
|
||||
}
|
||||
|
||||
private static void assertPermission( Permission permission, String name, String operation, String resource )
|
||||
{
|
||||
assertEquals( name, permission.getName() );
|
||||
assertEquals( operation, permission.getOperation().getName() );
|
||||
assertEquals( resource, permission.getResource().getIdentifier() );
|
||||
}
|
||||
|
||||
private static Path createBackupDirectory() throws IOException {
|
||||
String timestamp = new SimpleDateFormat( "yyyyMMdd.HHmmss", Locale.US ).format( new Date() );
|
||||
|
||||
Path targetDirectory = Files.createTempDirectory( "redback-test" ).resolve( "./target/backups/" + timestamp );
|
||||
Files.createDirectories(targetDirectory);
|
||||
|
||||
return targetDirectory;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +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.
|
||||
-->
|
||||
<authenticationKeyDatabase>
|
||||
<keys>
|
||||
<key>
|
||||
<key>248df0fec5d54e3eb11339f5e81d8bd7</key>
|
||||
<forPrincipal>bob</forPrincipal>
|
||||
<purpose>Testing</purpose>
|
||||
<dateCreated>1164426311921</dateCreated>
|
||||
<dateExpires>1164427211921</dateExpires>
|
||||
</key>
|
||||
<key>
|
||||
<key>a98dddc2ae614a7c82f8afd3ba6e39fb</key>
|
||||
<forPrincipal>betty</forPrincipal>
|
||||
<purpose>Something</purpose>
|
||||
<dateCreated>1164426315657</dateCreated>
|
||||
<dateExpires>1164427815657</dateExpires>
|
||||
</key>
|
||||
<key>
|
||||
<key>1428d2ca3a0246f0a1d979504e351388</key>
|
||||
<forPrincipal>fred</forPrincipal>
|
||||
<purpose>Else</purpose>
|
||||
<dateCreated>1164426315664</dateCreated>
|
||||
<dateExpires>1164428115664</dateExpires>
|
||||
</key>
|
||||
</keys>
|
||||
</authenticationKeyDatabase>
|
|
@ -1,152 +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.
|
||||
-->
|
||||
<rbacDatabase>
|
||||
<roles>
|
||||
<role>
|
||||
<name>User Administrator</name>
|
||||
<assignable>true</assignable>
|
||||
<permissions>
|
||||
<permission name="Edit All Users"></permission>
|
||||
<permission name="Remove Roles"></permission>
|
||||
</permissions>
|
||||
</role>
|
||||
<role>
|
||||
<name>System Administrator</name>
|
||||
<assignable>true</assignable>
|
||||
<childRoleNames>
|
||||
<childRoleName>User Administrator</childRoleName>
|
||||
</childRoleNames>
|
||||
<permissions>
|
||||
<permission name="Edit Configuration"></permission>
|
||||
<permission name="Run Indexer"></permission>
|
||||
<permission name="Add Repository"></permission>
|
||||
<permission name="Regenerate Index"></permission>
|
||||
</permissions>
|
||||
</role>
|
||||
<role>
|
||||
<name>Trusted Developer</name>
|
||||
<assignable>true</assignable>
|
||||
<childRoleNames>
|
||||
<childRoleName>System Administrator</childRoleName>
|
||||
</childRoleNames>
|
||||
<permissions>
|
||||
<permission name="Run Indexer"></permission>
|
||||
</permissions>
|
||||
</role>
|
||||
<role>
|
||||
<name>Developer</name>
|
||||
<assignable>true</assignable>
|
||||
<childRoleNames>
|
||||
<childRoleName>Trusted Developer</childRoleName>
|
||||
</childRoleNames>
|
||||
<permissions>
|
||||
<permission name="Run Indexer"></permission>
|
||||
</permissions>
|
||||
</role>
|
||||
</roles>
|
||||
<permissions>
|
||||
<permission>
|
||||
<name>Edit Configuration</name>
|
||||
<operation name="edit-configuration"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
<permission>
|
||||
<name>Run Indexer</name>
|
||||
<operation name="run-indexer"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
<permission>
|
||||
<name>Add Repository</name>
|
||||
<operation name="add-repository"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
<permission>
|
||||
<name>Edit All Users</name>
|
||||
<operation name="edit-all-users"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
<permission>
|
||||
<name>Remove Roles</name>
|
||||
<operation name="remove-roles"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
<permission>
|
||||
<name>Regenerate Index</name>
|
||||
<operation name="regenerate-index"></operation>
|
||||
<resource identifier="*"></resource>
|
||||
</permission>
|
||||
</permissions>
|
||||
<operations>
|
||||
<operation>
|
||||
<name>add-repository</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>edit-repository</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>delete-repository</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>edit-configuration</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>run-indexer</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>regenerate-index</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>get-reports</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>regenerate-reports</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>edit-user</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>edit-all-users</name>
|
||||
</operation>
|
||||
<operation>
|
||||
<name>remove-roles</name>
|
||||
</operation>
|
||||
</operations>
|
||||
<resources>
|
||||
<resource>
|
||||
<identifier>*</identifier>
|
||||
<permanent>true</permanent>
|
||||
</resource>
|
||||
</resources>
|
||||
<userAssignments>
|
||||
<userAssignment>
|
||||
<principal>bob</principal>
|
||||
<roleNames>
|
||||
<roleName>Developer</roleName>
|
||||
</roleNames>
|
||||
</userAssignment>
|
||||
<userAssignment>
|
||||
<principal>betty</principal>
|
||||
<roleNames>
|
||||
<roleName>System Administrator</roleName>
|
||||
</roleNames>
|
||||
</userAssignment>
|
||||
</userAssignments>
|
||||
</rbacDatabase>
|
|
@ -1,60 +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.
|
||||
-->
|
||||
<userDatabase>
|
||||
<users>
|
||||
<user>
|
||||
<username>smcqueen</username>
|
||||
<encodedPassword>bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=</encodedPassword>
|
||||
<fullName>Steve McQueen</fullName>
|
||||
<email>the cooler king</email>
|
||||
<lastPasswordChange>1164424661686</lastPasswordChange>
|
||||
<passwordChangeRequired>true</passwordChangeRequired>
|
||||
<previousEncodedPasswords>
|
||||
<previousEncodedPassword>bKE9UspwyIPg8LsQHkJaiehiTeUdstI5JZOvaoQRgJA=</previousEncodedPassword>
|
||||
</previousEncodedPasswords>
|
||||
<accountCreationDate>1164424661686</accountCreationDate>
|
||||
</user>
|
||||
<user>
|
||||
<username>bob</username>
|
||||
<encodedPassword>A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=</encodedPassword>
|
||||
<fullName>Sideshow Bob</fullName>
|
||||
<email>bob_862@hotmail.com</email>
|
||||
<lastPasswordChange>1164424669526</lastPasswordChange>
|
||||
<passwordChangeRequired>true</passwordChangeRequired>
|
||||
<previousEncodedPasswords>
|
||||
<previousEncodedPassword>A0MR+q0lm554bD6Uft60ztlYZ8N1pEqXhKNM9H7SlS8=</previousEncodedPassword>
|
||||
</previousEncodedPasswords>
|
||||
<accountCreationDate>1164424661686</accountCreationDate>
|
||||
</user>
|
||||
<user>
|
||||
<username>betty</username>
|
||||
<encodedPassword>L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=</encodedPassword>
|
||||
<fullName>Betty</fullName>
|
||||
<email>betty@aol.com</email>
|
||||
<lastPasswordChange>1164424669536</lastPasswordChange>
|
||||
<passwordChangeRequired>true</passwordChangeRequired>
|
||||
<previousEncodedPasswords>
|
||||
<previousEncodedPassword>L/mA/suWallwvYzw4wyRYkn5y8zWxAITuv4sLhJLN1E=</previousEncodedPassword>
|
||||
</previousEncodedPasswords>
|
||||
<accountCreationDate>1164424661686</accountCreationDate>
|
||||
</user>
|
||||
</users>
|
||||
</userDatabase>
|
|
@ -1,135 +0,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.
|
||||
|
||||
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Application Configuration
|
||||
|
||||
application.timestamp=EEE d MMM yyyy HH:mm:ss Z
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# JDBC Setup
|
||||
# keys restore need derby
|
||||
jdbc.url=jdbc:derby:memory:users-tests;create=true
|
||||
jdbc.driver.name=org.apache.derby.jdbc.EmbeddedDriver
|
||||
#jdbc.driver.name=org.hsqldb.jdbcDriver
|
||||
#jdbc.url=jdbc:hsqldb:mem:redback-test
|
||||
|
||||
jdbc.username=sa
|
||||
jdbc.password=
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Email Settings
|
||||
|
||||
email.jndiSessionName=java:comp/env/mail/Session
|
||||
email.smtp.host=localhost
|
||||
email.smtp.port=25
|
||||
email.smtp.ssl.enabled=false
|
||||
email.smtp.tls.enabled=false
|
||||
email.smtp.username=
|
||||
email.smtp.password=
|
||||
|
||||
#TODO: move description elsewhere, remove bad default
|
||||
# All emails sent by the system will be from the following address
|
||||
#email.from.address=${user.name}@localhost
|
||||
# All emails sent by the system will be from the following user name (used in conjunction with address)
|
||||
#email.from.name=Unconfigured Username
|
||||
|
||||
# If all email addresses (from new user registration) require an account validation email.
|
||||
email.validation.required=true
|
||||
# Timeout (in minutes) for the key generated for an email validation to remain valid.
|
||||
# 2880 minutes = 48 hours
|
||||
email.validation.timeout=2880
|
||||
# The subject line for the email message.
|
||||
email.validation.subject=Welcome
|
||||
|
||||
#TODO: move description elsewhere, remove bad default
|
||||
# Get the Feedback to use for any outgoing emails.
|
||||
# NOTE: if feedback.path starts with a "/" it is appended to the end of the value provided in application.url
|
||||
# This value can be in the format/syntax of "/feedback.action" or even "mailto:feedback@application.com"
|
||||
#email.feedback.path=/feedback.action
|
||||
|
||||
#Set the application base URL. The default is to derive it from the HTTP request
|
||||
#application.url=http://myurl.mycompany.com
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Auto Login Settings
|
||||
|
||||
security.rememberme.enabled=true
|
||||
# Timeout in days ( 365 days = 1 year )
|
||||
security.rememberme.timeout=7
|
||||
|
||||
# Single Sign On
|
||||
# Timeout in minutes
|
||||
security.signon.timeout=30
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Default Username Values
|
||||
redback.default.admin=admin
|
||||
redback.default.guest=guest
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Security Policies
|
||||
|
||||
#security.policy.password.encoder=
|
||||
security.policy.password.previous.count=6
|
||||
security.policy.password.expiration.enabled=true
|
||||
security.policy.password.expiration.days=90
|
||||
security.policy.password.expiration.notify.days=10
|
||||
security.policy.allowed.login.attempt=10
|
||||
|
||||
# turn off the perclick enforcement of various security policies, slightly
|
||||
# more heavyweight since it will ensure that the User object on each click
|
||||
# is up to date
|
||||
security.policy.strict.enforcement.enabled=true
|
||||
security.policy.strict.force.password.change.enabled=true
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# Password Rules
|
||||
security.policy.password.rule.alphanumeric.enabled=false
|
||||
security.policy.password.rule.alphacount.enabled=true
|
||||
security.policy.password.rule.alphacount.minimum=1
|
||||
security.policy.password.rule.characterlength.enabled=true
|
||||
security.policy.password.rule.characterlength.minimum=1
|
||||
security.policy.password.rule.characterlength.maximum=24
|
||||
security.policy.password.rule.musthave.enabled=true
|
||||
security.policy.password.rule.numericalcount.enabled=true
|
||||
security.policy.password.rule.numericalcount.minimum=1
|
||||
security.policy.password.rule.reuse.enabled=true
|
||||
security.policy.password.rule.nowhitespace.enabled=true
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# ldap settings
|
||||
#
|
||||
ldap.bind.authenticator.enabled=false
|
||||
|
||||
# ldap options for configuration via properties file
|
||||
#ldap.config.hostname=
|
||||
#ldap.config.port=
|
||||
#ldap.config.base.dn=
|
||||
#ldap.config.context.factory=
|
||||
#ldap.config.bind.dn=
|
||||
#ldap.config.password=
|
||||
#ldap.config.authentication.method=
|
||||
|
||||
# config parameter for the ConfigurableUserManager
|
||||
user.manager.impl=cached
|
||||
|
||||
|
||||
|
|
@ -1,64 +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" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
|
||||
|
||||
<context:property-placeholder system-properties-mode="OVERRIDE"/>
|
||||
|
||||
<alias name="userConfiguration#redback" alias="userConfiguration#default"/>
|
||||
|
||||
<!--
|
||||
*** jpa init ***
|
||||
Needed because of the dependency redback-user-cache -> redback-user-jpa
|
||||
***
|
||||
-->
|
||||
<bean name="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
|
||||
<property name="jpaVendorAdapter" >
|
||||
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter" />
|
||||
</property>
|
||||
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence-hsqldb.xml" />
|
||||
<property name="jpaPropertyMap">
|
||||
<map>
|
||||
<entry key="openjpa.ConnectionURL" value="jdbc:hsqldb:mem:redback_database" />
|
||||
<entry key="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver" />
|
||||
<entry key="openjpa.ConnectionUserName" value="sa" />
|
||||
<entry key="openjpa.ConnectionPassword" value="" />
|
||||
<entry key="openjpa.Log" value="slf4j" />
|
||||
<entry key="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
|
||||
<entry key="openjpa.jdbc.MappingDefaults"
|
||||
value="ForeignKeyDeleteAction=restrict,JoinForeignKeyDeleteAction=restrict"/>
|
||||
</map>
|
||||
</property>
|
||||
|
||||
</bean>
|
||||
|
||||
<bean name="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<tx:annotation-driven />
|
||||
<!-- **** jpa init *** -->
|
||||
</beans>
|
Loading…
Reference in New Issue