Index: xword/XWikiLib/LoginData.cs
===================================================================
--- xword/XWikiLib/LoginData.cs (revision 0)
+++ xword/XWikiLib/LoginData.cs (revision 0)
@@ -0,0 +1,195 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO.IsolatedStorage;
+using System.IO;
+
+namespace XWiki
+{
+ ///
+ /// Provindes functionality for storing authentication data.
+ ///
+ public class LoginData
+ {
+ public const string XWORD_LOGIN_DATA_FILENAME = "XWordLoginData";
+
+ private string filename;
+
+ ///
+ /// Creates an instance of the LoginData
.
+ ///
+ ///
+ /// Name of the file in which the authentication data will be stored.
+ /// Default is LoginData.XWORD_LOGIN_DATA_FILENAME
;
+ ///
+ public LoginData(string filename)
+ {
+ if (filename != null)
+ {
+ this.filename = filename;
+ }
+ else
+ {
+ this.filename = XWORD_LOGIN_DATA_FILENAME;
+ }
+ }
+
+ ///
+ /// Writes the user credentials to the disk for automatic login
+ ///
+ /// Array of strings containing the credentials
+ /// True if the operation is uscessfull. False otherwise.
+ public bool WriteCredentials(String[] credentials)
+ {
+ IsolatedStorageFile isFile = null;
+ IsolatedStorageFileStream stream = null;
+ StreamWriter writer = null;
+
+ bool successfulWrite = false;
+
+ try
+ {
+
+ isFile = IsolatedStorageFile.GetUserStoreForAssembly();
+ stream = new IsolatedStorageFileStream(filename, FileMode.Create, isFile);
+ writer = new StreamWriter(stream);
+ foreach (String s in credentials)
+ {
+ writer.WriteLine(s);
+ }
+ successfulWrite = true;
+ }
+ catch (IOException ioException)
+ {
+ Log.Exception(ioException);
+ }
+ catch (Exception exception)
+ {
+ Log.Exception(exception);
+ }
+ finally
+ {
+ if (writer != null)
+ {
+ writer.Close();
+ }
+ if (stream != null)
+ {
+ stream.Close();
+ }
+ if (isFile != null)
+ {
+ isFile.Dispose();
+ isFile.Close();
+ }
+ }
+
+ return successfulWrite;
+ }
+ ///
+ /// Gets the last used credentials.
+ ///
+ /// Array of strings containing the last used credentials
+ public String[] GetCredentials()
+ {
+ String[] credentials = new String[3];
+ IsolatedStorageFile isFile = null;
+ IsolatedStorageFileStream stream = null;
+ StreamReader reader = null;
+ try
+ {
+ isFile = IsolatedStorageFile.GetUserStoreForAssembly();
+ stream = new IsolatedStorageFileStream(filename, FileMode.Open, isFile);
+ reader = new StreamReader(stream);
+ int i = 0;
+ while (!reader.EndOfStream)
+ {
+ String s = reader.ReadLine();
+ credentials[i] = s;
+ i++;
+ }
+ }
+ catch (Exception ex)
+ {
+ Log.ExceptionSummary(ex);
+ credentials = null;
+ }
+ finally
+ {
+ if (reader != null)
+ {
+ reader.Close();
+ }
+ if (stream != null)
+ {
+ stream.Close();
+ }
+ if (isFile != null)
+ {
+ isFile.Dispose();
+ isFile.Close();
+ }
+
+ }
+ return credentials;
+ }
+
+ ///
+ /// Erases the last saved credentials form isolated storage.
+ ///
+ public void ClearCredentials()
+ {
+ IsolatedStorageFile isFile = null;
+ try
+ {
+ isFile = IsolatedStorageFile.GetUserStoreForAssembly();
+ isFile.DeleteFile(filename);
+ }
+ catch (IsolatedStorageException ex)
+ {
+ Log.ExceptionSummary(ex);
+ }
+ finally
+ {
+ if (isFile != null)
+ {
+ isFile.Dispose();
+ isFile.Close();
+ }
+ }
+ }
+
+ ///
+ /// Specifies if the last user saved his credentials for autologin.
+ ///
+ ///
+ public bool CanAutoLogin()
+ {
+ IsolatedStorageFile isFile = null;
+ bool canAutoLogin = false;
+
+ try
+ {
+ isFile = IsolatedStorageFile.GetUserStoreForAssembly();
+ canAutoLogin = (isFile.GetFileNames(filename).Length > 0);
+ }
+ catch (Exception exception)
+ {
+ Log.Exception(exception);
+ }
+ finally
+ {
+ if (isFile != null)
+ {
+ isFile.Dispose();
+ isFile.Close();
+ }
+ }
+
+ return canAutoLogin;
+ }
+
+
+ }
+}
Index: xword/XWikiLib/XWikiLib.csproj
===================================================================
--- xword/XWikiLib/XWikiLib.csproj (revision 22911)
+++ xword/XWikiLib/XWikiLib.csproj (working copy)
@@ -61,6 +61,7 @@
+
True
Index: xword/XWord/AddinSettingsFormManager.cs
===================================================================
--- xword/XWord/AddinSettingsFormManager.cs (revision 22911)
+++ xword/XWord/AddinSettingsFormManager.cs (working copy)
@@ -184,7 +184,7 @@
addin.serverURL = addinSettingsForm.ServerURL;
addin.username = addinSettingsForm.UserName;
addin.password = addinSettingsForm.Password;
- LoginData loginData = new LoginData();
+ LoginData loginData = new LoginData(LoginData.XWORD_LOGIN_DATA_FILENAME);
addin.Client = XWikiClientFactory.CreateXWikiClient(addin.ClientType,
addin.serverURL, addin.username, addin.password);
Index: xword/XWord/Login.cs
===================================================================
--- xword/XWord/Login.cs (revision 22911)
+++ xword/XWord/Login.cs (working copy)
@@ -1,174 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Security = System.Security;
-using System.IO;
-using System.IO.IsolatedStorage;
-using XWiki;
-
-namespace XWord
-{
- ///
- /// Provindes functionality for storing authentication data.
- ///
- public class LoginData
- {
- private string filename = "XWordLoginData";
-
- ///
- /// Writes the user credentials to the disk for automatic login
- ///
- /// Array of strings containing the credentials
- /// True if the operation is uscessfull. False otherwise.
- public bool WriteCredentials(String[] credentials)
- {
- IsolatedStorageFile isFile = null;
- IsolatedStorageFileStream stream = null;
- StreamWriter writer = null;
-
- bool successfulWrite = false;
-
- try
- {
-
- isFile = IsolatedStorageFile.GetUserStoreForAssembly();
- stream = new IsolatedStorageFileStream(filename, FileMode.Create, isFile);
- writer = new StreamWriter(stream);
- foreach (String s in credentials)
- {
- writer.WriteLine(s);
- }
- successfulWrite = true;
- }
- catch (IOException ioException)
- {
- Log.Exception(ioException);
- }
- catch (Exception exception)
- {
- Log.Exception(exception);
- }
- finally
- {
- if (writer != null)
- {
- writer.Close();
- }
- if (stream != null)
- {
- stream.Close();
- }
- if (isFile != null)
- {
- isFile.Dispose();
- isFile.Close();
- }
- }
-
- return successfulWrite;
- }
- ///
- /// Gets the last used credentials.
- ///
- /// Array of strings containing the last used credentials
- public String[] GetCredentials()
- {
- String[] credentials = new String[3];
- IsolatedStorageFile isFile=null;
- IsolatedStorageFileStream stream = null;
- StreamReader reader = null;
- try
- {
- isFile = IsolatedStorageFile.GetUserStoreForAssembly();
- stream = new IsolatedStorageFileStream(filename, FileMode.Open, isFile);
- reader = new StreamReader(stream);
- int i = 0;
- while (!reader.EndOfStream)
- {
- String s = reader.ReadLine();
- credentials[i] = s;
- i++;
- }
- }
- catch (Exception ex)
- {
- Log.ExceptionSummary(ex);
- credentials = null;
- }
- finally
- {
- if (reader != null)
- {
- reader.Close();
- }
- if (stream != null)
- {
- stream.Close();
- }
- if (isFile != null)
- {
- isFile.Dispose();
- isFile.Close();
- }
-
- }
- return credentials;
- }
-
- ///
- /// Erases the last saved credentials form isolated storage.
- ///
- public void ClearCredentials()
- {
- IsolatedStorageFile isFile=null;
- try
- {
- isFile = IsolatedStorageFile.GetUserStoreForAssembly();
- isFile.DeleteFile(filename);
- }
- catch (IsolatedStorageException ex)
- {
- Log.ExceptionSummary(ex);
- }
- finally
- {
- if (isFile != null)
- {
- isFile.Dispose();
- isFile.Close();
- }
- }
- }
-
- ///
- /// Specifies if the last user saved his credentials for autologin.
- ///
- ///
- public bool CanAutoLogin()
- {
- IsolatedStorageFile isFile=null;
- bool canAutoLogin = false;
-
- try
- {
- isFile = IsolatedStorageFile.GetUserStoreForAssembly();
- canAutoLogin = (isFile.GetFileNames(filename).Length > 0);
- }
- catch (Exception exception)
- {
- Log.Exception(exception);
- }
- finally
- {
- if (isFile != null)
- {
- isFile.Dispose();
- isFile.Close();
- }
- }
-
- return canAutoLogin;
- }
- }
-}
Index: xword/XWord/XWikiAddIn.cs
===================================================================
--- xword/XWord/XWikiAddIn.cs (revision 22911)
+++ xword/XWord/XWikiAddIn.cs (working copy)
@@ -683,7 +683,7 @@
///
private bool AutoLogin()
{
- LoginData loginData = new LoginData();
+ LoginData loginData = new LoginData(LoginData.XWORD_LOGIN_DATA_FILENAME);
bool canAutoLogin = loginData.CanAutoLogin();
if (canAutoLogin)
{
Index: xword/XWord/XWord.csproj
===================================================================
--- xword/XWord/XWord.csproj (revision 22911)
+++ xword/XWord/XWord.csproj (working copy)
@@ -218,7 +218,6 @@
LoadingDialog.cs
-
Code