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"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<users>
|
<users>
|
||||||
<name>scmadmin</name>
|
<name>scmadmin</name>
|
||||||
<displayName>SCM Administrator</displayName>
|
<displayName>SCM Administrator</displayName>
|
||||||
<mail>scm-admin@scm-manager.com</mail>
|
<mail>scm-admin@scm-manager.com</mail>
|
||||||
<password>ff8f5c593a01f9fcd3ed48b09a4b013e8d8f3be7</password>
|
<password>ff8f5c593a01f9fcd3ed48b09a4b013e8d8f3be7</password>
|
||||||
<admin>true</admin>
|
<admin>true</admin>
|
||||||
<type>xml</type>
|
<type>xml</type>
|
||||||
</users>
|
</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.Collection;
|
||||||
import java.util.LinkedList;
|
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 */
|
/** Field description */
|
||||||
public static final String ADMIN_PATH = "/sonia/scm/config/admin-account.xml";
|
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 */
|
/** Field description */
|
||||||
public static final String STORE_NAME = "users";
|
public static final String STORE_NAME = "users";
|
||||||
|
|
||||||
@@ -227,7 +233,7 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
{
|
{
|
||||||
userDB = new XmlUserDatabase();
|
userDB = new XmlUserDatabase();
|
||||||
userDB.setCreationTime(System.currentTimeMillis());
|
userDB.setCreationTime(System.currentTimeMillis());
|
||||||
createAdminAccount();
|
createDefaultAccounts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,21 +358,24 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
/**
|
/**
|
||||||
* Method description
|
* 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
|
try
|
||||||
{
|
{
|
||||||
User user = JAXB.unmarshal(input, User.class);
|
User user = (User) unmarshaller.unmarshal(input);
|
||||||
|
|
||||||
userDB.add(user);
|
userDB.add(user);
|
||||||
storeDB();
|
storeDB();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.error("could not create AdminAccount", ex);
|
logger.error("could not create account", ex);
|
||||||
}
|
}
|
||||||
finally
|
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
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user