Revision: 41
Author: tmyroadctfig
Date: 2006-06-06 04:32:51 -0700 (Tue, 06 Jun 2006)
ViewCVS: http://svn.sourceforge.net/nmailserver/?rev=41&view=rev
Log Message:
-----------
Work on web administration interface and local store.
Modified Paths:
--------------
NMail/branches/luke-dev/NMail/Authentication/IAuthenticationProvider.cs
NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAce.cs
NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAcl.cs
NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAcl.cs
NMail/branches/luke-dev/NMail/ILocalStore.cs
NMail/branches/luke-dev/NMail/ILocalStoreData.cs
NMail/branches/luke-dev/NMail/NMail.csproj
NMail/branches/luke-dev/NMail.Administration.Web/App_Code/FolderDataSource.cs
NMail/branches/luke-dev/NMail.Administration.Web/App_Code/UserDataSource.cs
NMail/branches/luke-dev/NMail.Administration.Web/Default.aspx
NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx
NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/Images/nmail-logo.png
NMail/branches/luke-dev/NMail.Administration.Web/MailDomainDetails.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/MasterPage.master
NMail/branches/luke-dev/NMail.Administration.Web/StyleSheet.css
NMail/branches/luke-dev/NMail.Administration.Web/UserDetails.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx
NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx
NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx
NMail/branches/luke-dev/NMail.ImapService/Response/AclResponse.cs
NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs
NMail/branches/luke-dev/NMail.LocalStore/LocalStore.cs
NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
Added Paths:
-----------
NMail/branches/luke-dev/NMail/DataTypes/ACLs/SystemPrivilege.cs
NMail/branches/luke-dev/NMail/DataTypes/ACLs/UserGroupAdminPrivilege.cs
NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx
NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx.cs
NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx
NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx.cs
Removed Paths:
-------------
NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAce.cs
Modified: NMail/branches/luke-dev/NMail/Authentication/IAuthenticationProvider.cs
===================================================================
--- NMail/branches/luke-dev/NMail/Authentication/IAuthenticationProvider.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/Authentication/IAuthenticationProvider.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -17,6 +17,8 @@
using System;
+using NMail.DataTypes.ACLs;
+
namespace NMail.Authentication {
/// <summary>
/// The interface for an authentication provider that operates on username and
Modified: NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAce.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAce.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAce.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -23,14 +23,16 @@
/// <summary>
/// A generic access control entry for an ACL.
/// </summary>
- public class GenericAce {
+ public class GenericAce<PrivilegeType> {
/// <summary>
/// Creates a new access control entry.
/// </summary>
/// <param name="identifier">The identifier to associated the ACE with.</param>
+ /// <param name="privilege">The privileges.</param>
/// <param name="acePrivilegeType">Whether to allow or deny the privileges.</param>
- public GenericAce(string identifier, AcePrivilegeType acePrivilegeType) {
+ public GenericAce(string identifier, PrivilegeType privilege, AcePrivilegeType acePrivilegeType) {
this.identifier = identifier;
+ this.privilege = privilege;
this.acePrivilegeType = acePrivilegeType;
}
@@ -48,6 +50,20 @@
}
}
+ private PrivilegeType privilege;
+
+ /// <summary>
+ /// The privilege associated with this ACE.
+ /// </summary>
+ public PrivilegeType Privilege {
+ get {
+ return this.privilege;
+ }
+ set {
+ this.privilege = value;
+ }
+ }
+
private AcePrivilegeType acePrivilegeType;
/// <summary>
Modified: NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAcl.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAcl.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/GenericAcl.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -23,40 +23,23 @@
/// <summary>
/// A list of access control entries.
/// </summary>
- public class GenericAcl<AceType> where AceType : GenericAce {
+ public class GenericAcl<PrivilegeType> {
/// <summary>
/// A map of identifiers to access control entries.
/// </summary>
- protected Dictionary<string, AceType> entries = new Dictionary<string, AceType>(StringComparer.InvariantCultureIgnoreCase);
+ protected Dictionary<string, GenericAce<PrivilegeType>> entries = new Dictionary<string, GenericAce<PrivilegeType>>(StringComparer.InvariantCultureIgnoreCase);
/// <summary>
- /// Creates a new ACL for the given resource name.
+ /// Creates a new ACL.
/// </summary>
- /// <param name="resourceName">The name of the resource this ACL is for.</param>
- public GenericAcl(string resourceName) {
- this.resourceName = resourceName;
- }
+ public GenericAcl() {}
- private string resourceName;
-
/// <summary>
- /// The name of the resource this ACL is associated wtih.
- /// </summary>
- public string ResourceName {
- get {
- return this.resourceName;
- }
- set {
- this.resourceName = value;
- }
- }
-
- /// <summary>
/// Replaces the existing ACE for the associated identifier. If no ACE exists
/// for the given identifer the new ACE is simply added.
/// </summary>
/// <param name="ace">The ACE to set.</param>
- public void SetAce(AceType ace) {
+ public void SetAce(GenericAce<PrivilegeType> ace) {
lock (this) {
if (this.entries.ContainsKey(ace.Identifier)) {
this.entries.Remove(ace.Identifier);
@@ -90,7 +73,7 @@
/// </summary>
/// <param name="identifier">The identifier to look up.</param>
/// <returns>The identifier or null if non is found.</returns>
- public AceType this[string identifier] {
+ public GenericAce<PrivilegeType> this[string identifier] {
get {
lock (this) {
if (this.entries.ContainsKey(identifier)) {
Deleted: NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAce.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAce.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAce.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -1,53 +0,0 @@
-/*
- * Copyright 2004-2006 Luke Quinane and Daniel Frampton
- *
- * Licensed 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.
- *
- */
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NMail.DataTypes.ACLs {
- /// <summary>
- /// An access control entry for a store folder ACL.
- /// </summary>
- public class StoreFolderAce : GenericAce {
- /// <summary>
- /// Creates a new access control entry.
- /// </summary>
- /// <param name="identifier">The identifier to associated the ACE with.</param>
- /// <param name="privilege">The privileges.</param>
- /// <param name="aceType">Whether to allow or deny the privileges.</param>
- public StoreFolderAce(string identifier, StoreFolderPrivilege privilege, AcePrivilegeType aceType)
- : base(identifier, aceType) {
-
- this.privilege = privilege;
- }
-
- private StoreFolderPrivilege privilege;
-
- /// <summary>
- /// The privilege associated with this ACE.
- /// </summary>
- public StoreFolderPrivilege Privilege {
- get {
- return this.privilege;
- }
- set {
- this.privilege = value;
- }
- }
- }
-}
Modified: NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAcl.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAcl.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/StoreFolderAcl.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -21,14 +21,14 @@
namespace NMail.DataTypes.ACLs {
/// <summary>
- /// A list of access control entries.
+ /// A list of access control entries for a folder.
/// </summary>
- public class StoreFolderAcl : GenericAcl<StoreFolderAce> {
+ public class StoreFolderAcl : GenericAcl<StoreFolderPrivilege> {
/// <summary>
/// Creates a new ACL for the given folder.
/// </summary>
/// <param name="folder">The folder associated with the ACL.</param>
- public StoreFolderAcl(StoreFolder folder) : base(folder.FolderId.ToString()) {
+ public StoreFolderAcl(StoreFolder folder) : base() {
this.folder = folder;
}
Added: NMail/branches/luke-dev/NMail/DataTypes/ACLs/SystemPrivilege.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/SystemPrivilege.cs (rev 0)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/SystemPrivilege.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.ACLs {
+ /// <summary>
+ /// The possible privileges a user or group can have on the NMail system.
+ /// </summary>
+ [FlagsAttribute]
+ public enum SystemPrivilege : uint {
+ /// <summary>
+ /// No rights are granted.
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// The right to view the system privilege ACL.
+ /// </summary>
+ ViewSystemPrivileges = 1,
+
+ /// <summary>
+ /// The right to modify the system privilege ACL.
+ /// </summary>
+ ModifySystemPrivileges = 2,
+
+ /// <summary>
+ /// The right to edit any ACLs.
+ /// </summary>
+ EditAllAcls = 4,
+
+ /// <summary>
+ /// The right to create a new mail domain.
+ /// </summary>
+ CreateMailDomain = 8
+ }
+}
Added: NMail/branches/luke-dev/NMail/DataTypes/ACLs/UserGroupAdminPrivilege.cs
===================================================================
--- NMail/branches/luke-dev/NMail/DataTypes/ACLs/UserGroupAdminPrivilege.cs (rev 0)
+++ NMail/branches/luke-dev/NMail/DataTypes/ACLs/UserGroupAdminPrivilege.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,57 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NMail.DataTypes.ACLs {
+ /// <summary>
+ /// The possible privileges a user or group can have for editing other users and
+ /// groups.
+ /// </summary>
+ [FlagsAttribute]
+ public enum UserGroupAdminPrivilege : uint {
+ /// <summary>
+ /// No rights are granted.
+ /// </summary>
+ None = 0,
+
+ /// <summary>
+ /// The right to view all users in the system.
+ /// </summary>
+ ViewAllUsers = 1,
+
+ /// <summary>
+ /// The right to create new users.
+ /// </summary>
+ CreateUsers = 2,
+
+ /// <summary>
+ /// The right to edit existing users.
+ /// </summary>
+ EditUsers = 4,
+
+ /// <summary>
+ /// The right to delete existing users.
+ /// </summary>
+ DeleteUsers = 8,
+
+ /// <summary>
+ /// The right to view all groups in the system.
+ /// </summary>
+ ViewAllGroups = 16,
+
+ /// <summary>
+ /// The right to create new groups.
+ /// </summary>
+ CreateGroups = 32,
+
+ /// <summary>
+ /// The right to edit existing groups.
+ /// </summary>
+ EditGroups = 64,
+
+ /// <summary>
+ /// The right to delete existing groups.
+ /// </summary>
+ DeleteGroups = 128
+ }
+}
Modified: NMail/branches/luke-dev/NMail/ILocalStore.cs
===================================================================
--- NMail/branches/luke-dev/NMail/ILocalStore.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/ILocalStore.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -140,6 +140,13 @@
/// <param name="parent">The parent to get the children from.</param>
/// <returns>The list of folders.</returns>
StoreFolder[] GetChildren(IAuthenticationToken authToken, StoreFolder parent);
+
+ /// <summary>
+ /// Gets a list of all folders
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <returns>The list of folders.</returns>
+ StoreFolder[] GetFolders(IAuthenticationToken authToken);
#endregion
#region Folder Subscription
@@ -310,7 +317,7 @@
/// <param name="authToken">The authentication credentials.</param>
/// <param name="folder">The folder to set the ACE on.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- void SetStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, StoreFolderAce ace);
+ void SetStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, GenericAce<StoreFolderPrivilege> ace);
/// <summary>
/// Removes any ACE associated with the given user.
@@ -583,6 +590,54 @@
/// <returns>The list of user Ids.</returns>
int[] GetMailDomainUsers(IAuthenticationToken authToken, int mailDomainId);
#endregion
+
+ #region System ACL
+ /// <summary>
+ /// Sets the system privileges for the associated identifier. If no ACE exists for
+ /// the associated identifier one is added.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ void SetSystemPrivilegeAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace);
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ void RemoveSystemPrivilegeAce(IAuthenticationToken authToken, string identifier);
+
+ /// <summary>
+ /// Gets the system ACL.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <returns>The system ACL or null if insufficient privileges.</returns>
+ GenericAcl<SystemPrivilege> GetSystemPrivilegeAcl(IAuthenticationToken authToken);
+ #endregion
+
+ #region User and Group Administration
+ /// <summary>
+ /// Get the ACL that lists user's privileges for user and group administration.
+ /// </summary>
+ /// <param name="user">The user trying to get the admin ACL.</param>
+ /// <returns>The ACL or null if insufficient privileges.</returns>
+ GenericAcl<UserGroupAdminPrivilege> GetAdministrationAcl(IAuthenticationToken user);
+
+ /// <summary>
+ /// Sets the administration privileges for the associated identifier.
+ /// If no ACE exists for the associated identifier one is added.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace);
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ void RemoveAdministrationAce(IAuthenticationToken authToken, string identifier);
+ #endregion
}
/// <summary>
Modified: NMail/branches/luke-dev/NMail/ILocalStoreData.cs
===================================================================
--- NMail/branches/luke-dev/NMail/ILocalStoreData.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/ILocalStoreData.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -109,6 +109,12 @@
/// <param name="parent">The parent to get the children from.</param>
/// <returns>The list of folders.</returns>
StoreFolder[] GetChildren(StoreFolder parent);
+
+ /// <summary>
+ /// Gets a list of all folders
+ /// </summary>
+ /// <returns>The list of folders.</returns>
+ StoreFolder[] GetFolders();
#endregion
#region Folder Subscription
@@ -274,7 +280,7 @@
/// </summary>
/// <param name="folder">The folder to set the ACE on.</param>
/// <param name="ace">The privileges and the identifier to put.</param>
- void SetStoreFolderAce(StoreFolder folder, StoreFolderAce ace);
+ void SetStoreFolderAce(StoreFolder folder, GenericAce<StoreFolderPrivilege> ace);
/// <summary>
/// Removes any ACE associated with the given user.
@@ -491,5 +497,26 @@
/// <returns>The list of user Ids.</returns>
int[] GetMailDomainUsers(int mailDomainId);
#endregion
+
+ #region System ACL
+ /// <summary>
+ /// Sets the system privileges for the associated identifier. If no ACE exists for
+ /// the associated identifier one is added.
+ /// </summary>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ void SetSystemPrivilegeAce(GenericAce<SystemPrivilege> ace);
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ void RemoveSystemPrivilegeAce(string identifier);
+
+ /// <summary>
+ /// Gets the system ACL.
+ /// </summary>
+ /// <returns>The system ACL.</returns>
+ GenericAcl<SystemPrivilege> GetSystemPrivilegeAcl();
+ #endregion
}
}
Modified: NMail/branches/luke-dev/NMail/NMail.csproj
===================================================================
--- NMail/branches/luke-dev/NMail/NMail.csproj 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail/NMail.csproj 2006-06-06 11:32:51 UTC (rev 41)
@@ -122,12 +122,13 @@
<Compile Include="Configuration\ObjectConfigurationElement.cs" />
<Compile Include="Configuration\ObjectConfigurationElementCollection.cs" />
<Compile Include="Configuration\WildcardHostElementCollection.cs" />
+ <Compile Include="DataTypes\ACLs\SystemPrivilege.cs" />
<Compile Include="DataTypes\ACLs\GenericAce.cs" />
<Compile Include="DataTypes\ACLs\GenericAcl.cs" />
<Compile Include="DataTypes\ACLs\MailDomainPrivilege.cs" />
- <Compile Include="DataTypes\ACLs\StoreFolderAce.cs" />
<Compile Include="DataTypes\ACLs\StoreFolderAcl.cs" />
<Compile Include="DataTypes\ACLs\StoreFolderPrivilege.cs" />
+ <Compile Include="DataTypes\ACLs\UserGroupAdminPrivilege.cs" />
<Compile Include="DataTypes\LocalStoreGroup.cs" />
<Compile Include="DataTypes\ByteString.cs">
<SubType>Code</SubType>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/App_Code/FolderDataSource.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/App_Code/FolderDataSource.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/App_Code/FolderDataSource.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -13,6 +13,7 @@
using NMail;
using NMail.Authentication;
using NMail.DataTypes;
+using NMail.DataTypes.ACLs;
namespace NMail.Administration.Web
{
@@ -27,8 +28,7 @@
IAuthenticationToken authToken = (IAuthenticationToken)session["AuthToken"];
ILocalStore localStore = (ILocalStore)session["LocalStore"];
- //return new List<StoreFolder>(localStore.GetStoreFolder(authToken));
- return null;
+ return new List<StoreFolder>(localStore.GetFolders(authToken));
}
public static StoreFolder GetFolder(int folderId)
@@ -40,6 +40,15 @@
return localStore.GetStoreFolder(authToken, folderId);
}
+ public static StoreFolder GetFolder(string folderName)
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ IAuthenticationToken authToken = (IAuthenticationToken)session["AuthToken"];
+ ILocalStore localStore = (ILocalStore)session["LocalStore"];
+
+ return localStore.GetStoreFolder(authToken, folderName);
+ }
+
public static List<StoreFolder> GetSubFolders(int folderId)
{
IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
@@ -67,5 +76,14 @@
return localStore.CreateFolder(authToken, folderName);
}
+
+ public static StoreFolderAcl GetFolderAcl(int folderId)
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ IAuthenticationToken authToken = (IAuthenticationToken)session["AuthToken"];
+ ILocalStore localStore = (ILocalStore)session["LocalStore"];
+
+ return localStore.GetStoreFolderAcl(authToken, folderId);
+ }
}
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/App_Code/UserDataSource.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/App_Code/UserDataSource.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/App_Code/UserDataSource.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -32,6 +32,15 @@
return new List<LocalStoreUser>(users);
}
+ public static LocalStoreUser GetUser(string username)
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ IAuthenticationToken authToken = (IAuthenticationToken)session["AuthToken"];
+ ILocalStore localStore = (ILocalStore)session["LocalStore"];
+
+ return localStore.GetUser(authToken, username);
+ }
+
public static LocalStoreUser GetUser(int userId)
{
IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
@@ -58,5 +67,14 @@
return new List<StoreFolder>(localStore.GetUserFolders(authToken, userId));
}
+
+ public static LocalStoreUserResult CreateUesr(string Username, int? QuotaWarnLimit, int? QuotaHardLimit)
+ {
+ IHttpSessionState session = SessionStateUtility.GetHttpSessionStateFromContext(HttpContext.Current);
+ IAuthenticationToken authToken = (IAuthenticationToken)session["AuthToken"];
+ ILocalStore localStore = (ILocalStore)session["LocalStore"];
+
+ return localStore.CreateUser(authToken, Username, QuotaWarnLimit, QuotaHardLimit);
+ }
}
}
Added: NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx (rev 0)
+++ NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,27 @@
+<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CreateFolder.aspx.cs" Inherits="CreateFolder" Title="Untitled Page" %>
+<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <h2>Create New Folder</h2>
+ <asp:Literal ID="StatusMessage" runat="server"></asp:Literal>
+ <asp:DetailsView ID="FolderDetailsView" runat="server" AutoGenerateRows="False" CellPadding="4"
+ ForeColor="#333333" GridLines="None" DefaultMode="Insert" DataSourceID="CreateFolderDataSource" AutoGenerateInsertButton="True">
+ <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
+ <EditRowStyle BackColor="#2461BF" />
+ <RowStyle BackColor="#EFF3FB" />
+ <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
+ <Fields>
+ <asp:BoundField DataField="FolderName" HeaderText="Folder Name" SortExpression="FolderName" />
+ </Fields>
+ <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
+ <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <AlternatingRowStyle BackColor="White" />
+ </asp:DetailsView>
+ <asp:ObjectDataSource ID="CreateFolderDataSource" runat="server" InsertMethod="CreateFolder"
+ OnInserted="FolderDataSource_Inserted" OnInserting="FolderDataSource_Inserting"
+ SelectMethod="GetFolders" TypeName="NMail.Administration.Web.FolderDataSource">
+ <InsertParameters>
+ <asp:Parameter Name="folderName" Type="String" />
+ </InsertParameters>
+ </asp:ObjectDataSource>
+</asp:Content>
+
Added: NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx.cs (rev 0)
+++ NMail/branches/luke-dev/NMail.Administration.Web/CreateFolder.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,41 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Collections;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+using NMail;
+using NMail.DataTypes;
+using NMail.Administration.Web;
+
+public partial class CreateFolder : System.Web.UI.Page
+{
+ private string folderName;
+
+ protected void FolderDataSource_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
+ {
+ this.folderName = (string) e.InputParameters["FolderName"];
+ }
+
+ protected void FolderDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
+ {
+ LocalStoreFolderResult result = (LocalStoreFolderResult)e.ReturnValue;
+
+ switch (result)
+ {
+ case LocalStoreFolderResult.OkSuccessful:
+ StoreFolder folder = FolderDataSource.GetFolder(this.folderName);
+ Response.Redirect(string.Format("FolderDetails.aspx?FolderId={0}", folder.FolderId));
+ break;
+
+ default:
+ this.StatusMessage.Text = result.ToString();
+ break;
+ }
+ }
+}
Added: NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx (rev 0)
+++ NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,33 @@
+<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="CreateUser.aspx.cs" Inherits="CreateUser" Title="Untitled Page" %>
+<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <asp:Literal ID="StatusMessage" runat="server"></asp:Literal>
+ <h2>Create user</h2>
+ <asp:DetailsView ID="UserDetailsView" runat="server" AutoGenerateRows="False" CellPadding="4"
+ DataSourceID="CreateUserDataSource" DefaultMode="Insert" ForeColor="#333333"
+ GridLines="None">
+ <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
+ <EditRowStyle BackColor="#2461BF" />
+ <RowStyle BackColor="#EFF3FB" />
+ <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
+ <Fields>
+ <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
+ <asp:BoundField DataField="QuotaWarnLimit" HeaderText="Warn Quota" SortExpression="QuotaWarnLimit" />
+ <asp:BoundField DataField="QuotaHardLimit" HeaderText="Hard Quota" SortExpression="QuotaHardLimit" />
+ <asp:CommandField ShowInsertButton="True" />
+ </Fields>
+ <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
+ <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <AlternatingRowStyle BackColor="White" />
+ </asp:DetailsView>
+ <asp:ObjectDataSource ID="CreateUserDataSource" runat="server" InsertMethod="CreateUesr"
+ OnInserted="CreateUserDataSource_Inserted" OnInserting="CreateUserDataSource_Inserting"
+ SelectMethod="GetUsers" TypeName="NMail.Administration.Web.UserDataSource">
+ <InsertParameters>
+ <asp:Parameter Name="username" Type="String" />
+ <asp:Parameter Name="QuotaWarnLimit" Type="Int32" />
+ <asp:Parameter Name="QuotaHardLimit" Type="Int32" />
+ </InsertParameters>
+ </asp:ObjectDataSource>
+</asp:Content>
+
Added: NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx.cs (rev 0)
+++ NMail/branches/luke-dev/NMail.Administration.Web/CreateUser.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -0,0 +1,41 @@
+using System;
+using System.Data;
+using System.Configuration;
+using System.Collections;
+using System.Web;
+using System.Web.Security;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Web.UI.WebControls.WebParts;
+using System.Web.UI.HtmlControls;
+
+using NMail;
+using NMail.DataTypes;
+using NMail.Administration.Web;
+
+public partial class CreateUser : System.Web.UI.Page
+{
+ private string username;
+
+ protected void CreateUserDataSource_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
+ {
+ this.username = (string)e.InputParameters["Username"];
+ }
+
+ protected void CreateUserDataSource_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
+ {
+ LocalStoreUserResult result = (LocalStoreUserResult)e.ReturnValue;
+
+ switch (result)
+ {
+ case LocalStoreUserResult.OkSuccessful:
+ LocalStoreUser user = UserDataSource.GetUser(this.username);
+ Response.Redirect(string.Format("UserDetails.aspx?UserId={0}", user.UserId));
+ break;
+
+ default:
+ this.StatusMessage.Text = result.ToString();
+ break;
+ }
+ }
+}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/Default.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/Default.aspx 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/Default.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -1,17 +1,6 @@
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
-<script runat="server">
-
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
-</script>
-
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
- Where here!
+ Welcome to the NMail administration website.
</asp:Content>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -12,15 +12,15 @@
<asp:BoundField DataField="FolderId" HeaderText="Folder Id" SortExpression="FolderId" InsertVisible="False" ReadOnly="True" />
<asp:BoundField DataField="FolderName" HeaderText="Folder Name" ReadOnly="True" SortExpression="FolderName" />
<asp:BoundField DataField="NameSpace" HeaderText="Namespace" ReadOnly="True" SortExpression="NameSpace" InsertVisible="False" />
- <asp:CheckBoxField DataField="HasChildren" HeaderText="Has Children" SortExpression="HasChildren" InsertVisible="False" />
- <asp:CommandField ShowDeleteButton="True" ShowInsertButton="True" />
+ <asp:CheckBoxField DataField="HasChildren" HeaderText="Has Children" SortExpression="HasChildren" InsertVisible="False" ReadOnly="True" />
+ <asp:CommandField ShowDeleteButton="True" />
</Fields>
<FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:DetailsView>
<asp:ObjectDataSource ID="FolderDataSource" runat="server" SelectMethod="GetFolder"
- TypeName="NMail.Administration.Web.FolderDataSource" DeleteMethod="DeleteFolder" OnDeleted="FolderDataSource_Deleted" OnDeleting="FolderDataSource_Deleting" InsertMethod="CreateFolder" OnInserting="FolderDataSource_Inserting">
+ TypeName="NMail.Administration.Web.FolderDataSource" DeleteMethod="DeleteFolder" OnDeleted="FolderDataSource_Deleted" OnDeleting="FolderDataSource_Deleting" InsertMethod="CreateFolder">
<SelectParameters>
<asp:QueryStringParameter Name="folderId" QueryStringField="FolderId" Type="Int32" />
</SelectParameters>
@@ -56,5 +56,15 @@
<asp:QueryStringParameter Name="folderId" QueryStringField="FolderId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
+ <h2>Folder ACL</h2>
+ <asp:GridView ID="AclGridView" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
+ <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <RowStyle BackColor="#EFF3FB" />
+ <EditRowStyle BackColor="#2461BF" />
+ <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
+ <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
+ <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
+ <AlternatingRowStyle BackColor="White" />
+ </asp:GridView>
</asp:Content>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/FolderDetails.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -13,14 +13,6 @@
public partial class FolderDetails : System.Web.UI.Page
{
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
-
protected void FolderDataSource_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
{
e.InputParameters["folderId"] = Request.QueryString["FolderId"];
@@ -32,13 +24,17 @@
switch (result)
{
+ case LocalStoreFolderResult.OkSuccessful:
+ this.StatusMessage.Text = "Folder deleted.";
+ break;
+
case LocalStoreFolderResult.HasChildren:
this.StatusMessage.Text = "Cannot delete the folder because it still has sub-folders.";
break;
+
+ default:
+ this.StatusMessage.Text = result.ToString();
+ break;
}
}
- protected void FolderDataSource_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
- {
-
- }
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/Images/nmail-logo.png
===================================================================
(Binary files differ)
Modified: NMail/branches/luke-dev/NMail.Administration.Web/MailDomainDetails.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/MailDomainDetails.aspx.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/MailDomainDetails.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -10,12 +10,5 @@
using System.Web.UI.HtmlControls;
public partial class MailDomainDetails : System.Web.UI.Page
-{
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
+{
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/MasterPage.master
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/MasterPage.master 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/MasterPage.master 2006-06-06 11:32:51 UTC (rev 41)
@@ -2,18 +2,28 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<script runat="server">
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!this.Request.IsAuthenticated && !this.Request.Url.AbsoluteUri.EndsWith("Login.aspx"))
+ {
+ this.Response.Redirect("Login.aspx");
+ }
+ }
+</script>
+
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
- <form id="form1" runat="server">
- <div>
- <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
+ <form id="MainForm" runat="server">
+ <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
<tr>
- <td colspan="2" style="vertical-align: middle; width: 100%; border-bottom: darkgray thin solid;">
- <h1><img src="Images/nmail-logo.png" style="vertical-align: middle" /> NMail Web Administration</h1>
+ <td colspan="2" style="vertical-align: middle; width: 100%; border-bottom: darkgray thin solid; background-color: #eff3fb;">
+ <h1> <img src="Images/nmail-logo.png" style="vertical-align: middle" /> NMail Web Administration</h1>
</td>
</tr>
<tr>
@@ -27,22 +37,21 @@
</td>
</tr>
<tr>
- <td style="border-right-style: solid; border-right-color: darkgray; padding-right: 1em; padding-left: 1em; padding-bottom: 1em; padding-top: 1em;">
+ <td style="border-right-style: solid; border-right-color: darkgray; padding-right: 1em; padding-left: 1em; padding-bottom: 1em; padding-top: 1em; vertical-align: top; background-color: #eff3fb; height: 100%;">
<asp:TreeView ID="TreeView" runat="server" DataSourceID="SiteMapDataSource">
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource" runat="server" />
- </td>
- <td style="width: 100%; padding-right: 1em; padding-left: 1em; padding-bottom: 1em; padding-top: 1em;">
+ </td>
+ <td style="width: 100%; padding-right: 1em; padding-left: 1em; padding-bottom: 1em; padding-top: 1em; vertical-align: top;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
<tr>
- <td colspan="2" style="border-top-style: solid; border-top-color: darkgray;">
- <a href="http://nmailserver.sourceforege.net">NMail homepage.</a></td>
+ <td style="border-right-style: solid; background-color: #eff3fb; text-align: center; border-right-color: darkgray; top: 100%;"><a href="http://nmailserver.sourceforege.net">NMail homepage.</a></td>
+ <td style="height: 18px"></td>
</tr>
</table>
- </div>
</form>
</body>
</html>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/StyleSheet.css
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/StyleSheet.css 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/StyleSheet.css 2006-06-06 11:32:51 UTC (rev 41)
@@ -2,3 +2,13 @@
{
font-family: Sans-Serif;
}
+
+h1
+{
+ font-size: larger;
+}
+
+h2
+{
+ font-size: large;
+}
\ No newline at end of file
Modified: NMail/branches/luke-dev/NMail.Administration.Web/UserDetails.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/UserDetails.aspx.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/UserDetails.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -31,12 +31,4 @@
break;
}
}
-
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -1,5 +1,6 @@
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ViewFolders.aspx.cs" Inherits="ViewFolders" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <h2>Folders</h2>
<asp:GridView ID="FoldersGridView" runat="server" AutoGenerateColumns="False" CellPadding="4"
DataSourceID="FoldersDataSource" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
@@ -20,5 +21,7 @@
</asp:GridView>
<asp:ObjectDataSource ID="FoldersDataSource" runat="server" SelectMethod="GetFolders"
TypeName="NMail.Administration.Web.FolderDataSource"></asp:ObjectDataSource>
+ <br />
+ <a href="CreateFolder.aspx">Create new folder</a>
</asp:Content>
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewFolders.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -10,12 +10,5 @@
using System.Web.UI.HtmlControls;
public partial class ViewFolders : System.Web.UI.Page
-{
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
+{
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -1,5 +1,6 @@
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ViewMailDomains.aspx.cs" Inherits="ViewMailDomains" Title="Untitled Page" %>
<asp:Content ID="Content" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <h2>Mail Domains</h2>
<asp:ObjectDataSource ID="MailDomainDataSource" runat="server" SelectMethod="GetMailDomains" TypeName="NMail.Administration.Web.MailDomainDataSource" UpdateMethod="UpdateMailDomain">
<UpdateParameters>
<asp:Parameter Name="mailDomainId" Type="Int32" />
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx.cs
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewMailDomains.aspx.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -16,11 +16,4 @@
public partial class ViewMailDomains : System.Web.UI.Page
{
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
}
Modified: NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx
===================================================================
--- NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.Administration.Web/ViewUsers.aspx 2006-06-06 11:32:51 UTC (rev 41)
@@ -1,25 +1,15 @@
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %>
-<script runat="server">
-
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Request.IsAuthenticated)
- {
- Response.Redirect("Login.aspx");
- }
- }
-</script>
-
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" Runat="Server">
+ <h2>Users</h2>
<asp:GridView ID="GridView1" runat="server" DataSourceID="UserDataSource" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="UserId" HeaderText="UserId" SortExpression="UserId" />
+ <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
<asp:BoundField DataField="UserFolderId" HeaderText="UserFolderId" SortExpression="UserFolderId" />
<asp:BoundField DataField="QuotaWarnLimit" HeaderText="QuotaWarnLimit" SortExpression="QuotaWarnLimit" />
<asp:BoundField DataField="QuotaHardLimit" HeaderText="QuotaHardLimit" SortExpression="QuotaHardLimit" />
- <asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username" />
<asp:HyperLinkField DataNavigateUrlFields="UserId" DataNavigateUrlFormatString="UserDetails.aspx?UserId={0}"
HeaderText="Edit" Text="edit" />
</Columns>
@@ -32,5 +22,7 @@
</asp:GridView>
<asp:ObjectDataSource ID="UserDataSource" runat="server" SelectMethod="GetUsers"
TypeName="NMail.Administration.Web.UserDataSource"></asp:ObjectDataSource>
+ <br />
+ <a href="CreateUser.aspx">Create new user</a>
</asp:Content>
Modified: NMail/branches/luke-dev/NMail.ImapService/Response/AclResponse.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/Response/AclResponse.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.ImapService/Response/AclResponse.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -24,7 +24,7 @@
namespace NMail.ImapService.Response {
public class AclResponse : AbstractResponse {
- public AclResponse(string cmdString, Folder folder, StoreFolderAce ace) {
+ public AclResponse(string cmdString, Folder folder, GenericAce<StoreFolderPrivilege> ace) {
this.cmdString = cmdString;
this.ace = ace;
this.folder = folder;
@@ -32,7 +32,7 @@
private string cmdString;
- private StoreFolderAce ace;
+ private GenericAce<StoreFolderPrivilege> ace;
private Folder folder;
Modified: NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs
===================================================================
--- NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.ImapService/State/AuthenticatedState.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -386,7 +386,7 @@
public override void ProcessCommand(SetAclCommand cmd) {
try {
// Attempt to lookup the current privileges
- StoreFolderAce currentAce = null;
+ GenericAce<StoreFolderPrivilege> currentAce = null;
StoreFolder folder = LocalStore.GetStoreFolder(Session.AuthenticationToken, cmd.Folder);
if (folder != null) {
@@ -466,7 +466,7 @@
while (e.MoveNext()) {
// Send each entry in the ACL to the client
string currentIdentifier = e.Current;
- StoreFolderAce currentAce = currentAcl[currentIdentifier];
+ GenericAce<StoreFolderPrivilege> currentAce = currentAcl[currentIdentifier];
QueueResponse(new AclResponse("ACL", folder, currentAce));
}
@@ -530,7 +530,7 @@
if (currentAcl[username] != null) {
// Show the rights for the current user
- StoreFolderAce currentAce = currentAcl[username];
+ GenericAce<StoreFolderPrivilege> currentAce = currentAcl[username];
currentAce.Identifier = string.Empty;
QueueResponse(new AclResponse("MYRIGHTS", folder, currentAce));
}
Modified: NMail/branches/luke-dev/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/branches/luke-dev/NMail.LocalStore/LocalStore.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.LocalStore/LocalStore.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -35,6 +35,9 @@
/// clients.
/// </summary>
public class LocalStore : MarshalByRefObject, ILocalStore {
+
+ // TODO: check with AuthProvider that AuthTokens are valid
+
#region ILocalStore Members
#region Delivery & Validation
@@ -358,7 +361,7 @@
StoreFolder createdFolder = LocalStoreData.GetStoreFolder(resolvedFolder);
// Create an ACL for the folder
- StoreFolderAce ace = new StoreFolderAce(authToken.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
+ GenericAce<StoreFolderPrivilege> ace = new GenericAce<StoreFolderPrivilege>(authToken.Username, StoreFolderPrivilegeHelper.AllPrivileges, AcePrivilegeType.Allow);
LocalStoreData.SetStoreFolderAce(createdFolder, ace);
return LocalStoreFolderResult.OkSuccessful;
@@ -399,6 +402,17 @@
return LocalStoreFolderResult.NotPermitted;
}
}
+
+ /// <summary>
+ /// Gets a list of all folders
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <returns>The list of folders.</returns>
+ public StoreFolder[] GetFolders(IAuthenticationToken authToken) {
+ // TODO: check for admin ACLs
+
+ return LocalStoreData.GetFolders();
+ }
#endregion
#region Rename Folder
@@ -1129,10 +1143,11 @@
#endregion
#region Folder ACLs
- public void SetStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, StoreFolderAce ace) {
+ public void SetStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, GenericAce<StoreFolderPrivilege> ace) {
// Ensure the user has rights to alter the ACL
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)) {
+ if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)
+ || hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
// Set the ACE
LocalStoreData.SetStoreFolderAce(folder, ace);
}
@@ -1141,7 +1156,8 @@
public void RemoveStoreFolderAce(IAuthenticationToken authToken, StoreFolder folder, string identifier) {
// Ensure the user has rights to alter the ACL
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)) {
+ if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Admin)
+ || hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
// Remove the ACE
LocalStoreData.RemoveStoreFolderAce(folder, identifier);
}
@@ -1150,7 +1166,8 @@
public StoreFolderAcl GetStoreFolderAcl(IAuthenticationToken authToken, StoreFolder folder) {
// Ensure the user has rights to lookup the ACL
- if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Lookup)) {
+ if (hasFolderPrivilege(authToken.Username, folder.FolderId, StoreFolderPrivilege.Lookup)
+ || hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
// Return the ACL
StoreFolderAcl currentAcl = LocalStoreData.GetStoreFolderAcl(folder);
return currentAcl;
@@ -1235,14 +1252,100 @@
return this.LocalStoreData.GetMailDomainUsers(mailDomainId);
}
#endregion
+
+ #region System ACL
+ /// <summary>
+ /// Sets the system privileges for the associated identifier. If no ACE exists for
+ /// the associated identifier one is added.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ public void SetSystemPrivilegeAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace) {
+ // Ensure the user has rights to modifiy the system ACL
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ModifySystemPrivileges)) {
+ LocalStoreData.SetSystemPrivilegeAce(ace);
+ }
+ }
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ public void RemoveSystemPrivilegeAce(IAuthenticationToken authToken, string identifier) {
+ // Ensure the user has rights to modifiy the system ACL
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ModifySystemPrivileges)) {
+ LocalStoreData.RemoveSystemPrivilegeAce(identifier);
+ }
+ }
+
+ /// <summary>
+ /// Gets the system ACL.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <returns>The system ACL or null if insufficient privileges.</returns>
+ public GenericAcl<SystemPrivilege> GetSystemPrivilegeAcl(IAuthenticationToken authToken) {
+ // Ensure the user has rights to view the ACL
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.ViewSystemPrivileges)) {
+ return LocalStoreData.GetSystemPrivilegeAcl();
+
+ } else {
+ return null;
+ }
+ }
#endregion
+ #region User and Group Administration
+ /// <summary>
+ /// Get the ACL that lists user's privileges for user and group administration.
+ /// </summary>
+ /// <param name="user">The user trying to get the admin ACL.</param>
+ /// <returns>The ACL or null if insufficient privileges.</returns>
+ public GenericAcl<UserGroupAdminPrivilege> GetAdministrationAcl(IAuthenticationToken user) {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Sets the administration privileges for the associated identifier.
+ /// If no ACE exists for the associated identifier one is added.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="ace">The privileges and the identifier to put.</param>
+ public void SetAdministrationAce(IAuthenticationToken authToken, GenericAce<SystemPrivilege> ace) {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ public void RemoveAdministrationAce(IAuthenticationToken authToken, string identifier) {
+ throw new NotImplementedException();
+ }
+ #endregion
+ #endregion
+
+ #region Privilege Checks
+
+ // TODO: check group permissions
+ // TODO: apply deny ACEs over allow ACEs
+ // TODO: recursive ACEs?
+
+ #region Has Folder Privilege
+ /// <summary>
+ /// Checks if a user has a privilege on a folder.
+ /// </summary>
+ /// <param name="username">The user to check.</param>
+ /// <param name="folderId">The Id of the folder to check.</param>
+ /// <param name="privilege">The privilege to check for.</param>
+ /// <returns>True if the user has the privilege.</returns>
private bool hasFolderPrivilege(string username, int folderId, StoreFolderPrivilege privilege) {
// First check if the user has the required privilege on the folder
StoreFolder folder = LocalStoreData.GetStoreFolder(folderId);
StoreFolderAcl currentAcl = LocalStoreData.GetStoreFolderAcl(folder);
- StoreFolderAce userAce = currentAcl[username];
+ GenericAce<StoreFolderPrivilege> userAce = currentAcl[username];
if (privilege != StoreFolderPrivilege.None) {
if (userAce == null) {
@@ -1270,7 +1373,40 @@
// No parent (don't need Lookup priv) and user has the required privilege
return true;
}
+ #endregion
+
+ #region Has System Privilege
+ /// <summary>
+ /// Checks if a identifier has a system privilege.
+ /// </summary>
+ /// <param name="identifier">The identifier to check.</param>
+ /// <param name="privilege">The privilege to check for.</param>
+ /// <returns>True if the user has the privilege.</returns>
+ private bool hasSystemPrivilege(string identifier, SystemPrivilege privilege) {
+ if (privilege == SystemPrivilege.None) {
+ // Anyone is allowed no privileges, even if they're not on the ACL! ;-)
+ return true;
+ }
+ GenericAcl<SystemPrivilege> systemAcl = LocalStoreData.GetSystemPrivilegeAcl();
+ GenericAce<SystemPrivilege> identifierAce = systemAcl[identifier];
+
+ if (identifierAce == null) {
+ // Identifier isn't listed on the ACL
+ return false;
+ }
+
+ if ((identifierAce.AceType != AcePrivilegeType.Allow)
+ || ((identifierAce.Privilege & privilege) != privilege)) {
+ // Identifier doesn't have the required privilege
+ return false;
+ }
+
+ return true;
+ }
+ #endregion
+ #endregion
+
/// <summary>
/// The folder delimiter used by this local store.
/// </summary>
Modified: NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql
===================================================================
--- NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStore.sql 2006-06-06 11:32:51 UTC (rev 41)
@@ -273,7 +273,22 @@
END
//
+DROP PROCEDURE IF EXISTS GetFolders //
+CREATE PROCEDURE GetFolders
+(
+)
+BEGIN
+ SELECT
+ f.FolderId, f.Name, n.Name AS NameSpace
+ FROM
+ Folder f, Namespace n
+ WHERE
+ f.NameSpaceId = n.NameSpaceId;
+END
+//
+
+
-- -----------------------------------------------------------------------
--
-- User related stored procedures
@@ -841,6 +856,50 @@
//
+-- -----------------------------------------------------------------------
+--
+-- System ACL related stored procedures
+--
+-- -----------------------------------------------------------------------
+
+
+DROP PROCEDURE IF EXISTS GetSystemAcl //
+CREATE PROCEDURE GetSystemAcl
+()
+BEGIN
+
+ SELECT Identifier, Allow, Privilege FROM Acl WHERE Resource = 'System';
+
+END
+//
+
+DROP PROCEDURE IF EXISTS SetSystemAce //
+CREATE PROCEDURE SetSystemAce
+(
+ Identifier VARCHAR(100),
+ Allow BOOL,
+ Privilege INT UNSIGNED
+)
+BEGIN
+
+ REPLACE Acl (Identifier, Allow, Privilege, Resource) VALUES (Identifier, Allow, Privilege, 'System');
+
+END
+//
+
+DROP PROCEDURE IF EXISTS RemoveSystemAce //
+CREATE PROCEDURE RemoveSystemAce
+(
+ DeleteIdentifier VARCHAR(100)
+)
+BEGIN
+
+ DELETE FROM Acl WHERE Identifier = DeleteIdentifier AND Resource = 'System';
+
+END
+//
+
+
delimiter ;
@@ -859,8 +918,8 @@
INSERT INTO Subscription (UserId, FolderId) VALUES (1, 2);
INSERT INTO `Group` (Name) VALUES ("Administrators");
INSERT INTO UserGroupMap (GroupId, UserId) VALUES (1, 1);
+INSERT INTO Acl (Identifier, Allow, Privilege, Resource) VALUES ("Administrator", 1, 0xffffff, "System"); -- All privs
-
-- TODO: remove, for testing only
INSERT INTO User (UserName, Password, UserFolderId) VALUES ("Testing1", "changeme", 2);
INSERT INTO User (UserName, Password, UserFolderId) VALUES ("Testing2", "changeme", 2);
Modified: NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs
===================================================================
--- NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2006-06-02 13:26:56 UTC (rev 40)
+++ NMail/branches/luke-dev/NMail.LocalStoreData.MySql/MySqlLocalStoreData.cs 2006-06-06 11:32:51 UTC (rev 41)
@@ -434,6 +434,32 @@
}
#endregion
+ /// <summary>
+ /// Gets a list of all folders
+ /// </summary>
+ /// <returns>The list of folders.</returns>
+ public StoreFolder[] GetFolders() {
+ using (MySqlConnection cnn = GetConnection()) {
+ using (MySqlCommand cmd = cnn.CreateCommand()) {
+ cmd.CommandType = CommandType.StoredProcedure;
+ cmd.CommandText = "GetFolders";
+
+ List<StoreFolder> folders = new List<StoreFolder>();
+ MySqlDataReader reader = cmd.ExecuteReader();
+
+ while (reader.Read()) {
+ int folderId = (int) reader["FolderId"];
+ string nameSpace = (string) reader["NameSpace"];
+ string name = (string) reader["Name"];
+
+ // TODO: Get HasChildren from the reader
+ folders.Add(new StoreFolder(nameSpace, name, folderId, false));
+ }
+
+ return folders.ToArray();
+ }
+ }
+ }
#endregion
#region Folder Subscription
@@...
[truncated message content] |