mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
create anonymous account
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<users>
|
||||
<name>scmadmin</name>
|
||||
<displayName>SCM Administrator</displayName>
|
||||
<mail>scm-admin@scm-manager.com</mail>
|
||||
<password>ff8f5c593a01f9fcd3ed48b09a4b013e8d8f3be7</password>
|
||||
<admin>true</admin>
|
||||
<type>xml</type>
|
||||
<name>scmadmin</name>
|
||||
<displayName>SCM Administrator</displayName>
|
||||
<mail>scm-admin@scm-manager.com</mail>
|
||||
<password>ff8f5c593a01f9fcd3ed48b09a4b013e8d8f3be7</password>
|
||||
<admin>true</admin>
|
||||
<type>xml</type>
|
||||
</users>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
Document : anonymous-account.xml
|
||||
Created on : December 30, 2010, 12:44 PM
|
||||
Author : sdorra
|
||||
Description:
|
||||
Purpose of the document follows.
|
||||
-->
|
||||
|
||||
<users>
|
||||
<name>anonymous</name>
|
||||
<displayName>SCM Anonymous</displayName>
|
||||
<mail>scm-anonymous@scm-manager.com</mail>
|
||||
<admin>false</admin>
|
||||
<type>xml</type>
|
||||
</users>
|
||||
@@ -63,7 +63,9 @@ import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -76,6 +78,10 @@ public class XmlUserManager extends AbstractUserManager
|
||||
/** Field description */
|
||||
public static final String ADMIN_PATH = "/sonia/scm/config/admin-account.xml";
|
||||
|
||||
/** Field description */
|
||||
public static final String ANONYMOUS_PATH =
|
||||
"/sonia/scm/config/anonymous-account.xml";
|
||||
|
||||
/** Field description */
|
||||
public static final String STORE_NAME = "users";
|
||||
|
||||
@@ -227,7 +233,7 @@ public class XmlUserManager extends AbstractUserManager
|
||||
{
|
||||
userDB = new XmlUserDatabase();
|
||||
userDB.setCreationTime(System.currentTimeMillis());
|
||||
createAdminAccount();
|
||||
createDefaultAccounts();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,21 +358,24 @@ public class XmlUserManager extends AbstractUserManager
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param unmarshaller
|
||||
* @param path
|
||||
*/
|
||||
private void createAdminAccount()
|
||||
private void createDefaultAccount(Unmarshaller unmarshaller, String path)
|
||||
{
|
||||
InputStream input = XmlUserManager.class.getResourceAsStream(ADMIN_PATH);
|
||||
InputStream input = XmlUserManager.class.getResourceAsStream(path);
|
||||
|
||||
try
|
||||
{
|
||||
User user = JAXB.unmarshal(input, User.class);
|
||||
User user = (User) unmarshaller.unmarshal(input);
|
||||
|
||||
userDB.add(user);
|
||||
storeDB();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.error("could not create AdminAccount", ex);
|
||||
logger.error("could not create account", ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -374,6 +383,26 @@ public class XmlUserManager extends AbstractUserManager
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
private void createDefaultAccounts()
|
||||
{
|
||||
try
|
||||
{
|
||||
JAXBContext context = JAXBContext.newInstance(User.class);
|
||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||
|
||||
createDefaultAccount(unmarshaller, ADMIN_PATH);
|
||||
createDefaultAccount(unmarshaller, ANONYMOUS_PATH);
|
||||
}
|
||||
catch (JAXBException ex)
|
||||
{
|
||||
logger.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user