/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs |
@@ -114,12 +114,13 @@ |
|
scene.AddCommand( |
"Archiving", this, "load iar", |
"load iar [-m|--merge] <first> <last> <inventory path> [<IAR path>]", |
"load iar [-m|--merge] <first> <last> <inventory path> <password> [<IAR path>]", |
"Load user inventory archive (IAR).", |
"-m|--merge is an option which merges the loaded IAR with existing inventory folders where possible, rather than always creating new ones" |
+ "<first> is user's first name." + Environment.NewLine |
+ "<last> is user's last name." + Environment.NewLine |
+ "<inventory path> is the path inside the user's inventory where the IAR should be loaded." + Environment.NewLine |
+ "<password> is the user's password." + Environment.NewLine |
+ "<IAR path> is the filesystem path or URI from which to load the IAR." |
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), |
HandleLoadInvConsoleCommand); |
@@ -126,7 +127,7 @@ |
|
scene.AddCommand( |
"Archiving", this, "save iar", |
"save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]", |
"save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]", |
"Save user inventory archive (IAR).", |
"<first> is the user's first name.\n" |
+ "<last> is the user's last name.\n" |
@@ -183,18 +184,18 @@ |
} |
|
public bool ArchiveInventory( |
Guid id, string firstName, string lastName, string invPath, Stream saveStream) |
Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream) |
{ |
return ArchiveInventory(id, firstName, lastName, invPath, saveStream, new Dictionary<string, object>()); |
return ArchiveInventory(id, firstName, lastName, invPath, pass, saveStream, new Dictionary<string, object>()); |
} |
|
public bool ArchiveInventory( |
Guid id, string firstName, string lastName, string invPath, Stream saveStream, |
Guid id, string firstName, string lastName, string invPath, string pass, Stream saveStream, |
Dictionary<string, object> options) |
{ |
if (m_scenes.Count > 0) |
{ |
UserAccount userInfo = GetUserInfo(firstName, lastName); |
UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
|
if (userInfo != null) |
{ |
@@ -229,7 +230,7 @@ |
} |
|
public bool ArchiveInventory( |
Guid id, string firstName, string lastName, string invPath, string savePath, |
Guid id, string firstName, string lastName, string invPath, string pass, string savePath, |
Dictionary<string, object> options) |
{ |
// if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath)) |
@@ -237,7 +238,7 @@ |
|
if (m_scenes.Count > 0) |
{ |
UserAccount userInfo = GetUserInfo(firstName, lastName); |
UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
|
if (userInfo != null) |
{ |
@@ -271,18 +272,18 @@ |
return false; |
} |
|
public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) |
public bool DearchiveInventory(string firstName, string lastName, string invPath, string pass, Stream loadStream) |
{ |
return DearchiveInventory(firstName, lastName, invPath, loadStream, new Dictionary<string, object>()); |
return DearchiveInventory(firstName, lastName, invPath, pass, loadStream, new Dictionary<string, object>()); |
} |
|
public bool DearchiveInventory( |
string firstName, string lastName, string invPath, Stream loadStream, |
string firstName, string lastName, string invPath, string pass, Stream loadStream, |
Dictionary<string, object> options) |
{ |
if (m_scenes.Count > 0) |
{ |
UserAccount userInfo = GetUserInfo(firstName, lastName); |
UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
|
if (userInfo != null) |
{ |
@@ -325,12 +326,12 @@ |
} |
|
public bool DearchiveInventory( |
string firstName, string lastName, string invPath, string loadPath, |
string firstName, string lastName, string invPath, string pass, string loadPath, |
Dictionary<string, object> options) |
{ |
if (m_scenes.Count > 0) |
{ |
UserAccount userInfo = GetUserInfo(firstName, lastName); |
UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
|
if (userInfo != null) |
{ |
@@ -382,10 +383,10 @@ |
|
List<string> mainParams = optionSet.Parse(cmdparams); |
|
if (mainParams.Count < 5) |
if (mainParams.Count < 6) |
{ |
m_log.Error( |
"[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> [<load file path>]"); |
"[INVENTORY ARCHIVER]: usage is load iar [-m|--merge] <first name> <last name> <inventory path> <user password> [<load file path>]"); |
return; |
} |
|
@@ -392,13 +393,14 @@ |
string firstName = mainParams[2]; |
string lastName = mainParams[3]; |
string invPath = mainParams[4]; |
string loadPath = (mainParams.Count > 5 ? mainParams[5] : DEFAULT_INV_BACKUP_FILENAME); |
string pass = mainParams[5]; |
string loadPath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
|
m_log.InfoFormat( |
"[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", |
loadPath, invPath, firstName, lastName); |
|
if (DearchiveInventory(firstName, lastName, invPath, loadPath, options)) |
if (DearchiveInventory(firstName, lastName, invPath, pass, loadPath, options)) |
m_log.InfoFormat( |
"[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", |
loadPath, firstName, lastName); |
@@ -442,10 +444,10 @@ |
|
try |
{ |
if (mainParams.Count < 5) |
if (mainParams.Count < 6) |
{ |
m_log.Error( |
"[INVENTORY ARCHIVER]: save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]"); |
"[INVENTORY ARCHIVER]: save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-e|--exclude=<name/uuid>] [-f|--excludefolder=<foldername/uuid>] [-v|--verbose]"); |
return; |
} |
|
@@ -455,7 +457,8 @@ |
string firstName = mainParams[2]; |
string lastName = mainParams[3]; |
string invPath = mainParams[4]; |
string savePath = (mainParams.Count > 5 ? mainParams[5] : DEFAULT_INV_BACKUP_FILENAME); |
string pass = mainParams[5]; |
string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); |
|
m_log.InfoFormat( |
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
@@ -464,7 +467,7 @@ |
lock (m_pendingConsoleSaves) |
m_pendingConsoleSaves.Add(id); |
|
ArchiveInventory(id, firstName, lastName, invPath, savePath, options); |
ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); |
} |
catch (InventoryArchiverException e) |
{ |
@@ -501,8 +504,9 @@ |
/// </summary> |
/// <param name="firstName"></param> |
/// <param name="lastName"></param> |
/// <param name="pass">User password</param> |
/// <returns></returns> |
protected UserAccount GetUserInfo(string firstName, string lastName) |
protected UserAccount GetUserInfo(string firstName, string lastName, string pass) |
{ |
UserAccount account |
= m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, firstName, lastName); |
@@ -514,7 +518,27 @@ |
firstName, lastName); |
return null; |
} |
return account; |
|
try |
{ |
string encpass = Util.Md5Hash(pass); |
if (m_aScene.AuthenticationService.Authenticate(account.PrincipalID, encpass, 1) != string.Empty) |
{ |
return account; |
} |
else |
{ |
m_log.ErrorFormat( |
"[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", |
firstName, lastName); |
return null; |
} |
} |
catch (Exception e) |
{ |
m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); |
return null; |
} |
} |
|
/// <summary> |
/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs |
@@ -70,7 +70,7 @@ |
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "meowfood"); |
UserAccountHelpers.CreateUserWithInventory(scene, m_uaLL1, "hampshire"); |
|
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", m_iarStream); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/", "meowfood", m_iarStream); |
InventoryItemBase foundItem1 |
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, m_item1Name); |
|
@@ -79,7 +79,7 @@ |
// Now try loading to a root child folder |
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xA", false); |
MemoryStream archiveReadStream = new MemoryStream(m_iarStream.ToArray()); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", archiveReadStream); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xA", "meowfood", archiveReadStream); |
|
InventoryItemBase foundItem2 |
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xA/" + m_item1Name); |
@@ -88,7 +88,7 @@ |
// Now try loading to a more deeply nested folder |
UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC", false); |
archiveReadStream = new MemoryStream(archiveReadStream.ToArray()); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", archiveReadStream); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "xB/xC", "meowfood", archiveReadStream); |
|
InventoryItemBase foundItem3 |
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, m_uaMT.PrincipalID, "xB/xC/" + m_item1Name); |
@@ -110,7 +110,7 @@ |
SceneHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
|
UserAccountHelpers.CreateUserWithInventory(scene, m_uaMT, "password"); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", m_iarStream); |
archiverModule.DearchiveInventory(m_uaMT.FirstName, m_uaMT.LastName, "/Objects", "password", m_iarStream); |
|
InventoryItemBase foundItem1 |
= InventoryArchiveUtils.FindItemByPath( |
@@ -127,6 +127,7 @@ |
|
string itemName = "You & you are a mean/man/"; |
string humanEscapedItemName = @"You & you are a mean\/man\/"; |
string userPassword = "meowfood"; |
|
InventoryArchiverModule archiverModule = new InventoryArchiverModule(); |
|
@@ -179,13 +180,13 @@ |
|
mre.Reset(); |
archiverModule.ArchiveInventory( |
Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); |
Guid.NewGuid(), userFirstName, userLastName, "Objects", userPassword, archiveWriteStream); |
mre.WaitOne(60000, false); |
|
// LOAD ITEM |
MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
|
archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", archiveReadStream); |
archiverModule.DearchiveInventory(userFirstName, userLastName, "Scripts", userPassword, archiveReadStream); |
|
InventoryItemBase foundItem1 |
= InventoryArchiveUtils.FindItemByPath( |
/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs |
@@ -110,7 +110,7 @@ |
|
mre.Reset(); |
m_archiverModule.ArchiveInventory( |
Guid.NewGuid(), userFirstName, userLastName, "/", archiveWriteStream); |
Guid.NewGuid(), userFirstName, userLastName, "/", userPassword, archiveWriteStream); |
mre.WaitOne(60000, false); |
|
// Test created iar |
@@ -179,7 +179,7 @@ |
|
mre.Reset(); |
m_archiverModule.ArchiveInventory( |
Guid.NewGuid(), userFirstName, userLastName, "f1", archiveWriteStream); |
Guid.NewGuid(), userFirstName, userLastName, "f1", userPassword, archiveWriteStream); |
mre.WaitOne(60000, false); |
|
// Test created iar |
@@ -267,7 +267,7 @@ |
|
mre.Reset(); |
m_archiverModule.ArchiveInventory( |
Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, archiveWriteStream); |
Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream); |
mre.WaitOne(60000, false); |
|
byte[] archive = archiveWriteStream.ToArray(); |
@@ -364,7 +364,7 @@ |
|
// When we're not saving assets, archiving is being done synchronously. |
m_archiverModule.ArchiveInventory( |
Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, archiveWriteStream, options); |
Guid.NewGuid(), userFirstName, userLastName, "Objects/" + item1Name, userPassword, archiveWriteStream, options); |
|
byte[] archive = archiveWriteStream.ToArray(); |
MemoryStream archiveReadStream = new MemoryStream(archive); |