[Nmailserver-commits] SF.net SVN: nmailserver: [190] NMail/trunk
Brought to you by:
dframpton-oss,
tmyroadctfig
|
From: <tmy...@us...> - 2007-05-08 13:20:37
|
Revision: 190
http://svn.sourceforge.net/nmailserver/?rev=190&view=rev
Author: tmyroadctfig
Date: 2007-05-08 06:20:38 -0700 (Tue, 08 May 2007)
Log Message:
-----------
Work on ACLs and calendars.
Modified Paths:
--------------
NMail/trunk/NMail/DataTypes/Calendar/CalendarEntry.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
NMail/trunk/NMail/NMail.csproj
NMail/trunk/NMail.LocalStore/LocalStore.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj
NMail/trunk/NMail.Server.Service/NMail.Server.Service.csproj
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
NMail/trunk/NMail.sln
Added Paths:
-----------
NMail/trunk/NMail.LocalStoreData.NHibernate/InternalUserGroupAdminAce.cs
NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml
NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetRemoveUserGroupAdminAceTest1.cs
Removed Paths:
-------------
NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs
Modified: NMail/trunk/NMail/DataTypes/Calendar/CalendarEntry.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/Calendar/CalendarEntry.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail/DataTypes/Calendar/CalendarEntry.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -77,7 +77,7 @@
#region Date/Time Properties
- private DateTime startTime;
+ private DateTime startTime = DateTime.Now;
/// <summary>
/// The time the event starts. (iCal "DTSTART")
@@ -163,7 +163,7 @@
// TODO: exdate, exrule
- private DateTime recurrenceId;
+ private DateTime recurrenceId = DateTime.Now;
/// <summary>
/// The recurrence Id for this recurrence of the entry. (iCal "RECURRENCE-ID-")
@@ -176,7 +176,7 @@
#region Change Management Component Properties
- private DateTime created;
+ private DateTime created = DateTime.Now;
/// <summary>
/// The date/time the entry was created. (iCal "CREATED")
@@ -186,7 +186,7 @@
set { created = value; }
}
- private DateTime timeStamp;
+ private DateTime timeStamp = DateTime.Now;
/// <summary>
/// The date/time this instance was created. (iCal "DTSTAMP")
@@ -196,7 +196,7 @@
set { timeStamp = value; }
}
- private DateTime lastModified;
+ private DateTime lastModified = DateTime.Now;
/// <summary>
/// The date/time the event was last modified. (iCal "LAST-MODIFIED")
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStore.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -576,12 +576,99 @@
void RemoveAdministrationAce(IAuthenticationToken authToken, string identifier);
#endregion
- LocalStoreCalendarResult CreateCalandar(IAuthenticationToken authToken, Calendar.Calendar calendar);
+ #region Calendar Manipulation
+ /// <summary>
+ /// Creates a new calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to create.</param>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ void CreateCalandar(IAuthenticationToken authToken, Calendar.Calendar calendar);
+ /// <summary>
+ /// Gets the calendar for the given name.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="name">The name to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
Calendar.Calendar GetCalandar(IAuthenticationToken authToken, string name, int parentFolderId);
+ /// <summary>
+ /// Gets the calendar for the given calendar Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendarId">The Id of the calendar to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
Calendar.Calendar GetCalandar(IAuthenticationToken authToken, int calendarId);
- LocalStoreCalendarResult DeleteCalandar(IAuthenticationToken authToken, int calendarId);
+ /// <summary>
+ /// Updates an existing calendar.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendar">The calendar to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ void UpdateCalandar(IAuthenticationToken authToken, Calendar.Calendar calendar);
+
+ /// <summary>
+ /// Removes a calendar from the local store.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
+ void DeleteCalandar(IAuthenticationToken authToken, int calendarId);
+ #endregion
+
+ #region Calendar Entry Manipulation
+ /// <summary>
+ /// Creates a new calendar entry.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entry">The entry to create.</param>
+ void CreateCalendarEntry(IAuthenticationToken authToken, CalendarEntry entry);
+
+ /// <summary>
+ /// Gets the entry for the given Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entryId">The entry Id to look up.</param>
+ /// <returns>The entry or null.</returns>
+ CalendarEntry GetCalendarEntry(IAuthenticationToken authToken, int entryId);
+
+ /// <summary>
+ /// Updates the given entry.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entry">The entry to update.</param>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
+ void UpdateCalendarEntry(IAuthenticationToken authToken, CalendarEntry entry);
+
+ /// <summary>
+ /// Gets a list of calendar entries.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="startTime">The start time for the entries returned.</param>
+ /// <param name="endTime">The end time for the entries returned.</param>
+ /// <param name="calendarId">The Id of the calendar to look in.</param>
+ /// <returns>The list of entries</returns>
+ IList<CalendarEntry> GetCalendarEntries(IAuthenticationToken authToken, DateTime startTime, DateTime endTime, int calendarId);
+
+ /// <summary>
+ /// Removes a calendar entry from the local store.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entryId">The Id of the calendar entry to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar entry are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar entry is invalid.</exception>
+ void DeleteCalendarEntry(IAuthenticationToken authToken, int entryId);
+ #endregion
}
}
Modified: NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail/DataTypes/LocalStore/ILocalStoreData.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -463,23 +463,110 @@
GenericAcl<SystemPrivilege> GetSystemPrivilegeAcl();
#endregion
+ #region User/Group Admin ACL
+ /// <summary>
+ /// Sets the user/group admin 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 SetUserGroupAdminPrivilegeAce(GenericAce<UserGroupAdminPrivilege> ace);
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ void RemoveUserGroupAdminPrivilegeAce(string identifier);
+
+ /// <summary>
+ /// Gets the user/group admin ACL.
+ /// </summary>
+ /// <returns>The user/group admin ACL.</returns>
+ GenericAcl<UserGroupAdminPrivilege> GetUserGroupAdminPrivilegeAcl();
+ #endregion
+
#region Calendar Manipulation
+ /// <summary>
+ /// Creates a new calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ void CreateCalandar(Calendar.Calendar calendar);
- void SaveCalandar(Calendar.Calendar calendar);
-
+ /// <summary>
+ /// Gets the calendar for the given name.
+ /// </summary>
+ /// <param name="name">The name to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
Calendar.Calendar GetCalandar(string name, int parentFolderId);
+ /// <summary>
+ /// Gets the calendar for the given calendar Id.
+ /// </summary>
+ /// <param name="calendarId">The Id of the calendar to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
Calendar.Calendar GetCalandar(int calendarId);
+ /// <summary>
+ /// Updates an existing calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ void UpdateCalandar(Calendar.Calendar calendar);
+
+ /// <summary>
+ /// Removes a calendar from the local store.
+ /// </summary>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
void DeleteCalandar(int calendarId);
#endregion
- void SaveCalendarEntry(CalendarEntry entry);
+ #region Calendar Entry Manipulation
+ /// <summary>
+ /// Creates a new calendar entry.
+ /// </summary>
+ /// <param name="entry">The entry to create.</param>
+ void CreateCalendarEntry(CalendarEntry entry);
+ /// <summary>
+ /// Gets the entry for the given Id.
+ /// </summary>
+ /// <param name="entryId">The entry Id to look up.</param>
+ /// <returns>The entry or null.</returns>
CalendarEntry GetCalendarEntry(int entryId);
+ /// <summary>
+ /// Updates the given entry.
+ /// </summary>
+ /// <param name="entry">The entry to update.</param>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
+ void UpdateCalendarEntry(CalendarEntry entry);
+
+ /// <summary>
+ /// Gets a list of calendar entries.
+ /// </summary>
+ /// <param name="startTime">The start time for the entries returned.</param>
+ /// <param name="endTime">The end time for the entries returned.</param>
+ /// <param name="calendarId">The Id of the calendar to look in.</param>
+ /// <returns>The list of entries</returns>
IList<CalendarEntry> GetCalendarEntries(DateTime startTime, DateTime endTime, int calendarId);
+ /// <summary>
+ /// Removes a calendar entry from the local store.
+ /// </summary>
+ /// <param name="entryId">The Id of the calendar entry to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar entry are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar entry is invalid.</exception>
void DeleteCalendarEntry(int entryId);
+ #endregion
}
}
Deleted: NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs
===================================================================
--- NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail/DataTypes/LocalStore/LocalStoreCalendarResult.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -1,29 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace NMail.DataTypes.LocalStore {
- public enum LocalStoreCalendarResult {
- /// <summary>
- /// The operation was completed successfully.
- /// </summary>
- OkSuccessful = 0,
-
- /// <summary>
- /// The create or rename failed because a folder with the same name already existed.
- /// </summary>
- AlreadyExists = 1,
-
- /// <summary>
- /// The operation failed because the parent folder was not found on the server.
- /// If the operation is on a subfolder that the user can't see due to permissions
- /// this will be returned.
- /// </summary>
- NonExistent = 2,
-
- /// <summary>
- /// The user is not permitted to perform the operation.
- /// </summary>
- NotPermitted = 2
- }
-}
Modified: NMail/trunk/NMail/NMail.csproj
===================================================================
--- NMail/trunk/NMail/NMail.csproj 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail/NMail.csproj 2007-05-08 13:20:38 UTC (rev 190)
@@ -149,7 +149,6 @@
<Compile Include="DataTypes\Calendar\ToDoEntry.cs" />
<Compile Include="DataTypes\Classification.cs" />
<Compile Include="DataTypes\LatLong.cs" />
- <Compile Include="DataTypes\LocalStore\LocalStoreCalendarResult.cs" />
<Compile Include="DataTypes\Message\IMultipartMessageBody.cs" />
<Compile Include="DataTypes\Service\BaseService.cs" />
<Compile Include="DataTypes\Service\BaseSession.cs" />
Modified: NMail/trunk/NMail.LocalStore/LocalStore.cs
===================================================================
--- NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.LocalStore/LocalStore.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -37,9 +37,7 @@
/// clients.
/// </summary>
public class LocalStore : MarshalByRefObject, ILocalStore {
-
- // TODO: check with AuthProvider that AuthTokens are valid
-
+
#region ILocalStore Members
#region Delivery & Validation
@@ -419,9 +417,13 @@
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of folders.</returns>
public IList<StoreFolder> GetFolders(IAuthenticationToken authToken) {
- // TODO: check for admin ACLs
- return LocalStoreData.GetFolders();
+ // Only show all folders to administrators
+ if (hasSystemPrivilege(authToken.Username, SystemPrivilege.EditAllAcls)) {
+ return LocalStoreData.GetFolders();
+ }
+
+ return new List<StoreFolder>();
}
#region Move Folder
@@ -472,8 +474,7 @@
/// <returns>The list of matching folders.</returns>
public IList<StoreFolder> GetMatching(IAuthenticationToken authToken, string queryFolder) {
// TODO: handle wildcards in the middle of mailbox names, e.g "A*" matches "Ab" and "Ac.d"
- // TODO: filter out any folders that the user can't see due to ACLs
-
+
StoreFolder resolvedFolder = GetStoreFolder(authToken, queryFolder);
List<StoreFolder> result = new List<StoreFolder>();
if (resolvedFolder != GetNominalStoreFolder(authToken)) {
@@ -483,6 +484,19 @@
// Get descendant folders
GetDescendants(authToken, resolvedFolder, result);
+ // Filter out any folders that the user can't see due to ACLs
+ List<StoreFolder> removeList = new List<StoreFolder>();
+
+ for (int i = 0; i < result.Count; i++) {
+ if (!hasFolderPrivilege(authToken.Username, result[i].FolderId, StoreFolderPrivilege.Lookup)) {
+ removeList.Add(result[i]);
+ }
+ }
+
+ foreach (StoreFolder folder in removeList) {
+ result.Remove(folder);
+ }
+
// Return the list of matching folders
return result;
}
@@ -1009,49 +1023,79 @@
#region User Management
- // TODO: ACLs for user management!!!
public LocalStoreUser GetUser(IAuthenticationToken authToken, string username) {
- return LocalStoreData.GetUser(username);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllUsers)) {
+ return LocalStoreData.GetUser(username);
+ }
+
+ return null;
}
public LocalStoreUser GetUser(IAuthenticationToken authToken, int userId) {
- return LocalStoreData.GetUser(userId);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllUsers)) {
+ return LocalStoreData.GetUser(userId);
+ }
+
+ return null;
}
public IList<LocalStoreUser> GetUsers(IAuthenticationToken authToken) {
- return LocalStoreData.GetUsers();
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllUsers)) {
+ return LocalStoreData.GetUsers();
+ }
+
+ return List<LocalStoreUser>();
}
public void CreateUser(IAuthenticationToken authToken, LocalStoreUser user) {
- LocalStoreData.CreateUser(user);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.CreateUsers)) {
+ LocalStoreData.CreateUser(user);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
public void DeleteUser(IAuthenticationToken authToken, int userId) {
- LocalStoreData.DeleteUser(userId);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.DeleteUsers)) {
+ LocalStoreData.DeleteUser(userId);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
public void UpdateUser(IAuthenticationToken authToken, LocalStoreUser user) {
- LocalStoreData.UpdateUser(user);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.EditUsers)) {
+ LocalStoreData.UpdateUser(user);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
public IList<EmailAddress> GetUserAddresses(IAuthenticationToken authToken, int userId) {
- List<EmailAddress> result = new List<EmailAddress>();
- IList<MailDomain> mailDomains = LocalStoreData.GetMailDomains();
- LocalStoreUser user = LocalStoreData.GetUser(userId);
- if (user != null) {
- foreach (MailDomain mailDomain in mailDomains) {
- foreach (ILocalStoreUserMap mapping in mailDomain.MailboxMappings) {
- IList<Mailbox> mailboxes = mapping.GetUserMailboxes(user.Username);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllUsers)) {
- foreach (Mailbox mailbox in mailboxes) {
- result.Add(new EmailAddress(mailbox, mailDomain.PrimaryHost));
+ List<EmailAddress> result = new List<EmailAddress>();
+ IList<MailDomain> mailDomains = LocalStoreData.GetMailDomains();
+ LocalStoreUser user = LocalStoreData.GetUser(userId);
+
+ if (user != null) {
+ foreach (MailDomain mailDomain in mailDomains) {
+ foreach (ILocalStoreUserMap mapping in mailDomain.MailboxMappings) {
+ IList<Mailbox> mailboxes = mapping.GetUserMailboxes(user.Username);
+
+ foreach (Mailbox mailbox in mailboxes) {
+ result.Add(new EmailAddress(mailbox, mailDomain.PrimaryHost));
+ }
}
}
}
+
+ return result;
+
+ } else {
+ throw new InvalidOperationException("Permission denied.");
}
-
- return result;
}
/// <summary>
@@ -1061,13 +1105,15 @@
/// <param name="userId">The Id of the user to get the folder for.</param>
/// <returns>The list of folders or null if the user Id is invalid or unauthorized.</returns>
public IList<StoreFolder> GetUserFolders(IAuthenticationToken authToken, int userId) {
- return this.LocalStoreData.GetUserFolders(userId);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllUsers)) {
+ return this.LocalStoreData.GetUserFolders(userId);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
#endregion
#region Group Management
- // TODO: ACLs for group management!!!!
-
/// <summary>
/// Gets the group for the given name.
/// </summary>
@@ -1075,7 +1121,11 @@
/// <param name="name">The name to look up.</param>
/// <returns>The matching group or null if non is found.</returns>
public LocalStoreGroup GetGroup(IAuthenticationToken authToken, string name) {
- return LocalStoreData.GetGroup(name);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllGroups)) {
+ return LocalStoreData.GetGroup(name);
+ }
+
+ return null;
}
/// <summary>
@@ -1085,7 +1135,11 @@
/// <param name="groupId">The Id of the group to look up.</param>
/// <returns>The matching group or null if non is found.</returns>
public LocalStoreGroup GetGroup(IAuthenticationToken authToken, int groupId) {
- return LocalStoreData.GetGroup(groupId);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllGroups)) {
+ return LocalStoreData.GetGroup(groupId);
+ }
+
+ return null;
}
/// <summary>
@@ -1094,7 +1148,11 @@
/// <param name="authToken">The authentication credentials.</param>
/// <returns>The list of groups.</returns>
public IList<LocalStoreGroup> GetGroups(IAuthenticationToken authToken) {
- return LocalStoreData.GetGroups();
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.ViewAllGroups)) {
+ return LocalStoreData.GetGroups();
+ }
+
+ return new List<LocalStoreGroup>();
}
/// <summary>
@@ -1106,7 +1164,11 @@
/// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
/// <exception cref="System.ArgumentException">The group is invalid.</exception>
public void CreateGroup(IAuthenticationToken authToken, LocalStoreGroup group) {
- LocalStoreData.CreateGroup(group);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.CreateGroups)) {
+ LocalStoreData.CreateGroup(group);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
/// <summary>
@@ -1117,7 +1179,11 @@
/// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
/// <exception cref="System.ArgumentException">The user is invalid.</exception>
public void DeleteGroup(IAuthenticationToken authToken, int groupId) {
- LocalStoreData.DeleteGroup(groupId);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.DeleteGroups)) {
+ LocalStoreData.DeleteGroup(groupId);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
/// <summary>
@@ -1129,7 +1195,11 @@
/// <exception cref="System.InvalidOperationException">Changes to the group are not permitted.</exception>
/// <exception cref="System.ArgumentException">The group is invalid.</exception>
public void UpdateGroup(IAuthenticationToken authToken, LocalStoreGroup group) {
- LocalStoreData.UpdateGroup(group);
+ if (hasUserGroupPrivilege(authToken.Username, UserGroupAdminPrivilege.EditGroups)) {
+ LocalStoreData.UpdateGroup(group);
+ } else {
+ throw new InvalidOperationException("Permission denied.");
+ }
}
#endregion
@@ -1286,25 +1356,144 @@
}
#endregion
- public LocalStoreCalendarResult CreateCalandar(IAuthenticationToken authToken, Calendar calendar) {
- LocalStoreData.SaveCalandar(calendar);
- return LocalStoreCalendarResult.OkSuccessful;
+ #region Calendar Manipulation
+ /// <summary>
+ /// Creates a new calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to create.</param>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ public void CreateCalandar(IAuthenticationToken authToken, Calendar calendar) {
+ // TODO: check privileges!!
+
+ LocalStoreData.CreateCalandar(calendar);
}
+ /// <summary>
+ /// Gets the calendar for the given name.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="name">The name to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
public Calendar GetCalandar(IAuthenticationToken authToken, string name, int parentFolderId) {
+ // TODO: check privileges!!
+
return LocalStoreData.GetCalandar(name, parentFolderId);
}
+ /// <summary>
+ /// Gets the calendar for the given calendar Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendarId">The Id of the calendar to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
public Calendar GetCalandar(IAuthenticationToken authToken, int calendarId) {
+ // TODO: check privileges!!
+
return LocalStoreData.GetCalandar(calendarId);
}
- public LocalStoreCalendarResult DeleteCalandar(IAuthenticationToken authToken, int calendarId) {
+ /// <summary>
+ /// Updates an existing calendar.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendar">The calendar to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ public void UpdateCalandar(IAuthenticationToken authToken, Calendar calendar) {
+ // TODO: check privileges!!
+
+ LocalStoreData.UpdateCalandar(calendar);
+ }
+
+ /// <summary>
+ /// Removes a calendar from the local store.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
+ public void DeleteCalandar(IAuthenticationToken authToken, int calendarId) {
+ // TODO: check privileges!!
+
LocalStoreData.DeleteCalandar(calendarId);
- return LocalStoreCalendarResult.OkSuccessful;
}
#endregion
+ #region Calendar Entry Manipulation
+ /// <summary>
+ /// Creates a new calendar entry.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entry">The entry to create.</param>
+ public void CreateCalendarEntry(IAuthenticationToken authToken, CalendarEntry entry) {
+ // TODO: check privileges!!
+
+ LocalStoreData.CreateCalendarEntry(entry);
+ }
+
+ /// <summary>
+ /// Gets the entry for the given Id.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entryId">The entry Id to look up.</param>
+ /// <returns>The entry or null.</returns>
+ public CalendarEntry GetCalendarEntry(IAuthenticationToken authToken, int entryId) {
+ // TODO: check privileges!!
+
+ return LocalStoreData.GetCalendarEntry(entryId);
+ }
+
+ /// <summary>
+ /// Updates the given entry.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entry">The entry to update.</param>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
+ public void UpdateCalendarEntry(IAuthenticationToken authToken, CalendarEntry entry) {
+ // TODO: check privileges!!
+
+ LocalStoreData.UpdateCalendarEntry(entry);
+ }
+
+ /// <summary>
+ /// Gets a list of calendar entries.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="startTime">The start time for the entries returned.</param>
+ /// <param name="endTime">The end time for the entries returned.</param>
+ /// <param name="calendarId">The Id of the calendar to look in.</param>
+ /// <returns>The list of entries</returns>
+ public IList<CalendarEntry> GetCalendarEntries(IAuthenticationToken authToken, DateTime startTime, DateTime endTime, int calendarId) {
+ // TODO: check privileges!!
+
+ return LocalStoreData.GetCalendarEntries(startTime, endTime, calendarId);
+ }
+
+ /// <summary>
+ /// Removes a calendar entry from the local store.
+ /// </summary>
+ /// <param name="authToken">The authentication credentials.</param>
+ /// <param name="entryId">The Id of the calendar entry to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar entry are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar entry is invalid.</exception>
+ public void DeleteCalendarEntry(IAuthenticationToken authToken, int entryId) {
+ // TODO: check privileges!!
+
+ LocalStoreData.DeleteCalendarEntry(entryId);
+ }
+ #endregion
+ #endregion
+
+ // TODO: check with AuthProvider that AuthTokens are valid
+
#region Privilege Checks
// TODO: check group permissions
@@ -1387,7 +1576,38 @@
return true;
}
#endregion
+
+ #region Has User/Group Privilege
+ /// <summary>
+ /// Checks if a identifier has a user group admin 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 hasUserGroupPrivilege(string identifier, UserGroupAdminPrivilege privilege) {
+ if (privilege == UserGroupAdminPrivilege.None) {
+ // Anyone is allowed no privileges, even if they're not on the ACL! ;-)
+ return true;
+ }
+
+ GenericAcl<UserGroupAdminPrivilege> userGroupAdminAcl = LocalStoreData.GetUserGroupAdminPrivilegeAcl();
+ GenericAce<UserGroupAdminPrivilege> identifierAce = userGroupAdminAcl[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.
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/InternalUserGroupAdminAce.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/InternalUserGroupAdminAce.cs (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/InternalUserGroupAdminAce.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NMail.DataTypes.ACLs;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.LocalStoreData.NHibernate {
+
+ internal class InternalUserGroupAdminAce : GenericAce<UserGroupAdminPrivilege> {
+
+ internal InternalUserGroupAdminAce() { }
+
+ private int aceId;
+
+ /// <summary>
+ /// The Id of this system ACE.
+ /// </summary>
+ public int AceId {
+ get { return aceId; }
+ set { aceId = value; }
+ }
+ }
+}
Added: NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml (rev 0)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/Mappings/NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml 2007-05-08 13:20:38 UTC (rev 190)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NMail.LocalStoreData.NHibernate" assembly="NMail.LocalStoreData.NHibernate" default-lazy="false">
+
+ <class name="NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce" table="UserGroupAdminAce">
+ <id name="AceId" type="Int32" unsaved-value="0">
+ <column name="AceId" not-null="true"/>
+ <generator class="native" />
+ </id>
+
+ <property name="Identifier" not-null="true" unique="true"/>
+
+ <property name="AceType" not-null="true" unique="true"/>
+
+ <property name="Privilege" not-null="true" unique="true"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NHibernateLocalStoreData.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -1575,24 +1575,48 @@
}
#endregion
- public void SaveCalandar(Calendar calendar) {
+ #region User/Group Admin ACL
+ /// <summary>
+ /// Sets the user/group admin 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>
+ public void SetUserGroupAdminPrivilegeAce(GenericAce<UserGroupAdminPrivilege> ace) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
using (ITransaction tx = session.BeginTransaction()) {
- if (calendar.CalendarId == 0) {
- // Check if any other calendars with the same name exists in this folder
- ICriteria criteria = session.CreateCriteria(typeof(Calendar));
- criteria.Add(Expression.Like("Name", calendar.Name));
- criteria.Add(Expression.Eq("ParentFolderId", calendar.ParentFolderId));
- IList<Calendar> existing = criteria.List<Calendar>();
+ InternalUserGroupAdminAce userGroupAdminAce = session.CreateCriteria(typeof(InternalUserGroupAdminAce))
+ .Add(Expression.Eq("Identifier", ace.Identifier))
+ .UniqueResult<InternalUserGroupAdminAce>();
- if (existing.Count > 0) {
- throw new DuplicateNameException("Calendar with the same name already exists in this folder.");
- }
+ if (userGroupAdminAce == null) {
+ userGroupAdminAce = new InternalUserGroupAdminAce();
+ }
- session.Save(calendar);
+ userGroupAdminAce.AceType = ace.AceType;
+ userGroupAdminAce.Identifier = ace.Identifier;
+ userGroupAdminAce.Privilege = ace.Privilege;
- } else {
- session.Update(calendar);
+ session.SaveOrUpdate(userGroupAdminAce);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Removes any ACE associated with the given identifier.
+ /// </summary>
+ /// <param name="identifier">The identifier to remove from the ACL.</param>
+ public void RemoveUserGroupAdminPrivilegeAce(string identifier) {
+ using (ISession session = NHibernateHelper.Factory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ IList<InternalUserGroupAdminAce> userGroupAdminAcl = session.CreateCriteria(typeof(InternalUserGroupAdminAce))
+ .Add(Expression.Eq("Identifier", identifier))
+ .List<InternalUserGroupAdminAce>();
+
+ foreach (InternalUserGroupAdminAce ace in userGroupAdminAcl) {
+ session.Delete(ace);
}
tx.Commit();
@@ -1601,70 +1625,200 @@
}
}
+ /// <summary>
+ /// Gets the user/group admin ACL.
+ /// </summary>
+ /// <returns>The user/group admin ACL.</returns>
+ public GenericAcl<UserGroupAdminPrivilege> GetUserGroupAdminPrivilegeAcl() {
+ using (ISession session = NHibernateHelper.Factory.OpenSession()) {
+ IList<InternalUserGroupAdminAce> systemAcl = session.CreateCriteria(typeof(InternalUserGroupAdminAce))
+ .List<InternalUserGroupAdminAce>();
+
+ GenericAcl<UserGroupAdminPrivilege> result = new GenericAcl<UserGroupAdminPrivilege>();
+
+ foreach (InternalUserGroupAdminAce ace in systemAcl) {
+ result.SetAce(ace);
+ }
+
+ return result;
+ }
+ }
+ #endregion
+
+ #region Calendar Manipulation
+ /// <summary>
+ /// Creates a new calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to create.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ public void CreateCalandar(Calendar calendar) {
+ using (ISession session = NHibernateHelper.Factory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Check if any other calendars with the same name exists in this folder
+ IList<Calendar> existing = session.CreateCriteria(typeof(Calendar))
+ .Add(Expression.Like("Name", calendar.Name))
+ .Add(Expression.Eq("ParentFolderId", calendar.ParentFolderId))
+ .List<Calendar>();
+
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("Calendar with the same name already exists in this folder.");
+ }
+
+ session.Save(calendar);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the calendar for the given name.
+ /// </summary>
+ /// <param name="name">The name to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
public Calendar GetCalandar(string name, int parentFolderId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
- ICriteria criteria = session.CreateCriteria(typeof(Calendar));
- criteria.Add(Expression.Like("Name", name));
- criteria.Add(Expression.Eq("ParentFolderId", parentFolderId));
- IList<Calendar> matches = criteria.List<Calendar>();
+ IList<Calendar> matches = session.CreateCriteria(typeof(Calendar))
+ .Add(Expression.Like("Name", name))
+ .Add(Expression.Eq("ParentFolderId", parentFolderId))
+ .List<Calendar>();
return (matches.Count == 1) ? matches[0] : null;
}
}
+ /// <summary>
+ /// Gets the calendar for the given calendar Id.
+ /// </summary>
+ /// <param name="calendarId">The Id of the calendar to look up.</param>
+ /// <returns>The matching calendar or null if non is found.</returns>
public Calendar GetCalandar(int calendarId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
return (Calendar) session.Load(typeof(Calendar), calendarId);
}
}
+ /// <summary>
+ /// Updates an existing calendar.
+ /// </summary>
+ /// <param name="calendar">The calendar to update.</param>
+ /// <exception cref="System.Data.DuplicateNameException">If a calendar with the same name already exists.</exception>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ public void UpdateCalandar(Calendar calendar) {
+ using (ISession session = NHibernateHelper.Factory.OpenSession()) {
+ using (ITransaction tx = session.BeginTransaction()) {
+ // Check if any other user with the same name exists in the system
+ IList<Calendar> existing = session.CreateCriteria(typeof(Calendar))
+ .Add(Expression.Like("Name", calendar.Name))
+ .Add(Expression.Eq("ParentFolderId", calendar.ParentFolderId))
+ .List<Calendar>();
+
+ if (existing.Count > 0) {
+ throw new DuplicateNameException("Calendar with the same name already exists in the folder.");
+ }
+
+ session.Update(calendar);
+
+ tx.Commit();
+ session.Close();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Removes a calendar from the local store.
+ /// </summary>
+ /// <param name="calendarId">The Id of the calendar to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar is invalid.</exception>
+ /// <exception cref="System.Data.ConstraintException">Calendar still has entries.</exception>
public void DeleteCalandar(int calendarId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
session.Delete("from Calendar as cal where cal.CalendarId = ?", calendarId, NHibernateUtil.Int32);
}
}
+ #endregion
- public void SaveCalendarEntry(CalendarEntry entry) {
+ #region Calendar Entry Manipulation
+ /// <summary>
+ /// Creates a new calendar entry.
+ /// </summary>
+ /// <param name="entry">The entry to create.</param>
+ public void CreateCalendarEntry(CalendarEntry entry) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
// Update the entry's change management fields
entry.LastModified = DateTime.Now;
entry.Sequence++;
// Save it to the database
- session.SaveOrUpdate(entry);
- session.Flush();
+ session.Save(entry);
}
}
+ /// <summary>
+ /// Gets the entry for the given Id.
+ /// </summary>
+ /// <param name="entryId">The entry Id to look up.</param>
+ /// <returns>The entry or null.</returns>
public CalendarEntry GetCalendarEntry(int entryId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
return (CalendarEntry) session.Load(typeof(CalendarEntry), entryId);
}
}
+ /// <summary>
+ /// Updates the given entry.
+ /// </summary>
+ /// <param name="entry">The entry to update.</param>
+ public void UpdateCalendarEntry(CalendarEntry entry) {
+ using (ISession session = NHibernateHelper.Factory.OpenSession()) {
+ // Update the entry's change management fields
+ entry.LastModified = DateTime.Now;
+ entry.Sequence++;
+
+ // Save it to the database
+ session.Update(entry);
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of calendar entries.
+ /// </summary>
+ /// <param name="startTime">The start time for the entries returned.</param>
+ /// <param name="endTime">The end time for the entries returned.</param>
+ /// <param name="calendarId">The Id of the calendar to look in.</param>
+ /// <returns>The list of entries</returns>
public IList<CalendarEntry> GetCalendarEntries(DateTime startTime, DateTime endTime, int calendarId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
- ICriteria criteria = session.CreateCriteria(typeof(CalendarEntry));
- criteria.Add(Expression.Eq("CalendarId", calendarId));
- criteria.Add(Expression.Ge("StartTime", startTime));
- IList<CalendarEntry> matches = criteria.List<CalendarEntry>();
+ IList<CalendarEntry> matches = session.CreateCriteria(typeof(CalendarEntry))
+ .Add(Expression.Ge("StartTime", startTime))
+ .Add(Expression.Le("StartTime", endTime))
+ .CreateCriteria("Calendar")
+ .Add(Expression.Eq("CalendarId", calendarId))
+ .List<CalendarEntry>();
- List<CalendarEntry> result = new List<CalendarEntry>();
- foreach (CalendarEntry entry in matches) {
- result.Add(entry);
- }
-
// TODO: catch recurrences, etc
- return result;
+ return matches;
}
}
+ /// <summary>
+ /// Removes a calendar entry from the local store.
+ /// </summary>
+ /// <param name="entryId">The Id of the calendar entry to delete.</param>
+ /// <exception cref="System.InvalidOperationException">Changes to the calendar entry are not permitted.</exception>
+ /// <exception cref="System.ArgumentException">The calendar entry is invalid.</exception>
public void DeleteCalendarEntry(int entryId) {
using (ISession session = NHibernateHelper.Factory.OpenSession()) {
session.Delete("from CalendarEntry as calE where calE.EntryId = ?", entryId, NHibernateUtil.Int64);
}
}
+ #endregion
#region Reinstall Schema
/// <summary>
Modified: NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj
===================================================================
--- NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.LocalStoreData.NHibernate/NMail.LocalStoreData.NHibernate.csproj 2007-05-08 13:20:38 UTC (rev 190)
@@ -48,6 +48,7 @@
<ItemGroup>
<Compile Include="AuthenticationUser.cs" />
<Compile Include="Configuration.cs" />
+ <Compile Include="InternalUserGroupAdminAce.cs" />
<Compile Include="InternalSystemAce.cs" />
<Compile Include="InternalUserObject.cs" />
<Compile Include="FolderSubscription.cs" />
@@ -65,6 +66,7 @@
<Content Include="hibernate-localstore-configuration.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
+ <EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.InternalUserGroupAdminAce.hbm.xml" />
<EmbeddedResource Include="Mappings\NMail.LocalStoreData.NHibernate.UserMailboxMapping.hbm.xml" />
</ItemGroup>
<ItemGroup>
Modified: NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj
===================================================================
--- NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.Server.Console/NMail.Server.Console.csproj 2007-05-08 13:20:38 UTC (rev 190)
@@ -112,11 +112,6 @@
<Project>{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}</Project>
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
</ProjectReference>
- <ProjectReference Include="..\NMail.LocalStoreData.MySql\NMail.LocalStoreData.MySql.csproj">
- <Name>NMail.LocalStoreData.MySql</Name>
- <Project>{90B33C2B-F945-478A-BBA0-4F66EF78B870}</Project>
- <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
- </ProjectReference>
<ProjectReference Include="..\NMail.LocalStoreData.NHibernate\NMail.LocalStoreData.NHibernate.csproj">
<Project>{72F7E307-F0A9-4750-9ED5-5A1F97725A11}</Project>
<Name>NMail.LocalStoreData.NHibernate</Name>
Modified: NMail/trunk/NMail.Server.Service/NMail.Server.Service.csproj
===================================================================
--- NMail/trunk/NMail.Server.Service/NMail.Server.Service.csproj 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.Server.Service/NMail.Server.Service.csproj 2007-05-08 13:20:38 UTC (rev 190)
@@ -109,11 +109,6 @@
<Project>{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}</Project>
<Name>NMail.ImapService</Name>
</ProjectReference>
- <ProjectReference Include="..\NMail.LocalStoreData.MySql\NMail.LocalStoreData.MySql.csproj">
- <Name>NMail.LocalStoreData.MySql</Name>
- <Project>{90B33C2B-F945-478A-BBA0-4F66EF78B870}</Project>
- <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
- </ProjectReference>
<ProjectReference Include="..\NMail.LocalStore\NMail.LocalStore.csproj">
<Name>NMail.LocalStore</Name>
<Project>{488A8890-EEE1-4ACC-9B35-3DDBE8E70D1D}</Project>
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest1.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -22,7 +22,7 @@
c1.OwnerUserId = 1;
c1.ParentFolderId = 1;
- localStoreData.SaveCalandar(c1);
+ localStoreData.CreateCalandar(c1);
Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateCalendarTest2.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -23,7 +23,7 @@
c1.OwnerUserId = 1;
c1.ParentFolderId = 1;
- localStoreData.SaveCalandar(c1);
+ localStoreData.CreateCalandar(c1);
Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
@@ -32,7 +32,7 @@
c2.OwnerUserId = 1;
c2.ParentFolderId = 1;
- localStoreData.SaveCalandar(c2);
+ localStoreData.CreateCalandar(c2);
Assert.Fail("Allowed duplicate calendar names.");
}
Modified: NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/CreateEventEntryTest1.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -22,7 +22,7 @@
c1.OwnerUserId = 1;
c1.ParentFolderId = 1;
- localStoreData.SaveCalandar(c1);
+ localStoreData.CreateCalandar(c1);
Assert.IsTrue(c1.CalendarId > 0, "Valid calendar Id.");
@@ -34,7 +34,7 @@
e1.Classification = NMail.DataTypes.Classification.Private;
e1.StartTime = startTime;
- localStoreData.SaveCalendarEntry(e1);
+ localStoreData.CreateCalendarEntry(e1);
IList<CalendarEntry> entries = localStoreData.GetCalendarEntries(startTime, DateTime.Now, c1.CalendarId);
Added: NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetRemoveUserGroupAdminAceTest1.cs
===================================================================
--- NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetRemoveUserGroupAdminAceTest1.cs (rev 0)
+++ NMail/trunk/NMail.UnitTests/LocalStoreData/GetSetRemoveUserGroupAdminAceTest1.cs 2007-05-08 13:20:38 UTC (rev 190)
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+using NMail.Configuration;
+using NMail.DataTypes.ACLs;
+using NMail.DataTypes.LocalStore;
+
+namespace NMail.UnitTests.LocalStoreData {
+ /// <summary>
+ /// Tests getting/settting/removing user/group admin ACEs.
+ /// </summary>
+ [TestFixture]
+ public class GetSetRemoveUserGroupAdminAceTest1 : BaseLocalStoreDataTest {
+
+ [Test]
+ public void TestUserGroupAdminAce() {
+ GenericAce<UserGroupAdminPrivilege> ace1 = new GenericAce<UserGroupAdminPrivilege>();
+ ace1.Identifier = "Test";
+ ace1.AceType = AcePrivilegeType.Allow;
+ ace1.Privilege = UserGroupAdminPrivilege.CreateGroups;
+ this.localStoreData.SetUserGroupAdminPrivilegeAce(ace1);
+
+ GenericAcl<UserGroupAdminPrivilege> acl1 = this.localStoreData.GetUserGroupAdminPrivilegeAcl();
+ Assert.IsTrue(acl1.Count > 0, "Valid ACL entry count 1.");
+ Assert.AreEqual(UserGroupAdminPrivilege.CreateGroups, acl1["Test"].Privilege, "acl[\"Test\"].Priv == CreateGroups.");
+ Assert.AreEqual(AcePrivilegeType.Allow, acl1["Test"].AceType, "acl[\"Test\"].PrivType == Allow.");
+
+ this.localStoreData.RemoveUserGroupAdminPrivilegeAce("Test");
+
+ GenericAcl<UserGroupAdminPrivilege> acl2 = this.localStoreData.GetUserGroupAdminPrivilegeAcl();
+ Assert.IsNull(acl2["Test"], "acl[\"Test\"] is null");
+ }
+ }
+}
Modified: NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj
===================================================================
--- NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.UnitTests/NMail.UnitTests.csproj 2007-05-08 13:20:38 UTC (rev 190)
@@ -54,6 +54,7 @@
<Compile Include="DataTypes\Helper\MimeHelperTests.cs" />
<Compile Include="DataTypes\Helper\StringTokenizerTests.cs" />
<Compile Include="LocalStoreData\BaseLocalStoreDataTest.cs" />
+ <Compile Include="LocalStoreData\GetSetRemoveUserGroupAdminAceTest1.cs" />
<Compile Include="LocalStoreData\GetSetRemoveSystemAceTest1.cs" />
<Compile Include="LocalStoreData\LoadSaveObjectTest1.cs" />
<Compile Include="LocalStoreData\PurgeDeletedMessagesTest1.cs" />
Modified: NMail/trunk/NMail.sln
===================================================================
--- NMail/trunk/NMail.sln 2007-05-08 11:35:52 UTC (rev 189)
+++ NMail/trunk/NMail.sln 2007-05-08 13:20:38 UTC (rev 190)
@@ -1,7 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C# Express 2005
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.LocalStoreData.MySql", "NMail.LocalStoreData.MySql\NMail.LocalStoreData.MySql.csproj", "{90B33C2B-F945-478A-BBA0-4F66EF78B870}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NMail.ImapService", "NMail.ImapService\NMail.ImapService.csproj", "{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoPrivileges", "MonoPrivileges\MonoPrivileges.csproj", "{18586CD8-276B-44E7-B0C1-B8537D8A8090}"
@@ -60,14 +58,6 @@
Release2005|Any CPU = Release2005|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Debug2005|Any CPU.Build.0 = Debug|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Release|Any CPU.Build.0 = Release|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Release2005|Any CPU.ActiveCfg = Release|Any CPU
- {90B33C2B-F945-478A-BBA0-4F66EF78B870}.Release2005|Any CPU.Build.0 = Release|Any CPU
{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6C6E9C2-5A17-4E00-9CE7-550C0359E023}.Debug2005|Any CPU.ActiveCfg = Debug|Any CPU
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|