1
/****************************************************************************
3
| Copyright (c) 2007 Novell, Inc.
6
| This program is free software; you can redistribute it and/or
7
| modify it under the terms of version 2 of the GNU General Public License as
8
| published by the Free Software Foundation.
10
| This program is distributed in the hope that it will be useful,
11
| but WITHOUT ANY WARRANTY; without even the implied warranty of
12
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
| GNU General Public License for more details.
15
| You should have received a copy of the GNU General Public License
16
| along with this program; if not, contact Novell, Inc.
18
| To contact Novell about this file by physical or electronic mail,
19
| you may find current contact information at www.novell.com
22
|***************************************************************************/
26
using System.Web.Services;
27
using System.Web.Services.Protocols;
28
using System.Collections;
33
namespace iFolder.WebService
36
/// iFolder Common Local Web Service
38
public abstract class iFolderCommonLocal : System.Web.Services.WebService
45
public iFolderCommonLocal()
54
/// Get information about the iFolder system.
56
/// <returns>An iFolderSystem object describing the system.</returns>
58
Description="Get information about the iFolder system.",
60
public virtual iFolderSystem GetSystem()
62
iFolderSystem result = null;
68
result = iFolderSystem.GetSystem();
72
SmartException.Throw(e);
79
/// Get information about the authenticated user's home iFolder server.
81
/// <returns>An iFolderServer object describing the user's home iFolder server.</returns>
83
Description="Get information about the authenticated user's home iFolder server.",
85
public virtual iFolderServer GetHomeServer()
87
iFolderServer result = null;
93
result = iFolderServer.GetHomeServer();
97
SmartException.Throw(e);
104
/// Get the location of the iFolder
106
/// <returns>The PrivateUrl of the iFolder's HomeServer.</returns>
108
Description="Get information about the authenticated user's home iFolder server.",
110
public virtual string GetiFolderLocation ( string ifolderID )
112
string result = null;
118
result = iFolder.GetiFolderLocation ( ifolderID );
122
SmartException.Throw(e);
129
/// Get all the searched orphaned ifolders
131
/// <returns>a list of orphaned ifolders. </returns>
134
Description="Get Orphaned iFolders",
136
public virtual iFolderSet GetOrphanediFolders(SearchOperation operation, string pattern, int index, int max )
138
iFolderSet OrphiFolderList = new iFolderSet();
143
OrphiFolderList = iFolder.GetOrphanediFolders ( operation, pattern, index, max, GetAccessID() );
147
SmartException.Throw(e);
150
return OrphiFolderList;
154
/// Checks whether an ifolder is orphaned or not
156
/// <returns>. string 'false' if the ifolder is not orphaned otherwise returns userID of prev owner</returns>
159
Description="check orphaned property",
161
public virtual string IsOrphanediFolder(string iFolderID)
163
string isorphaned = "";
169
isorphaned = iFolder.IsOrphanediFolder (iFolderID, GetAccessID() );
173
SmartException.Throw(e);
181
/// Get the list of recovery agents
183
/// <returns>The list containing recovery agents name</returns>
185
Description="Get the list of recovery agents",
187
public virtual string[] GetRAList ()
189
string[] result = null;
195
result = iFolder.GetRAList ();
199
SmartException.Throw(e);
206
/// Get the RA Certificate
208
/// <returns>The byte array containing the certificate</returns>
210
Description="Get the RA Certificate",
212
public virtual byte[] GetRACertificate(string rAgent)
214
byte [] result = null;
220
result = iFolder.GetRACertificate (rAgent);
224
SmartException.Throw(e);
231
/// Get the PassPhrase Status
233
/// <returns>The Status of pass-phrase</returns>
235
Description="Get the pass-phrase status",
237
public virtual bool IsPassPhraseSet ()
239
Store store = Store.GetStore();
240
Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
241
// Simias.Authentication.Status result = new Simias.Authentication.Status( Simias.Authentication.StatusCodes.UnknownDomain );
248
result = iFolderUser.IsPassPhraseSet(domain.ID, GetAccessID());
252
SmartException.Throw(e);
259
///Validate the passphrase for the correctness
261
///<returns>passPhrase.</returns>
262
[WebMethod(EnableSession=true, Description="Validate the passphrase for the correctness.")]
264
public virtual Simias.Authentication.Status ValidatePassPhrase(string passPhrase)
266
Store store = Store.GetStore();
267
Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
268
Simias.Authentication.Status result = new Simias.Authentication.Status( Simias.Authentication.StatusCodes.UnknownDomain );
273
result = iFolderUser.ValidatePassPhrase(domain.ID, passPhrase, GetAccessID());
277
SmartException.Throw(e);
285
///Set the passphrase and recovery agent
287
///<returns>passPhrase.</returns>
288
[WebMethod(EnableSession=true, Description="Set the passphrase and recovery agent.")]
290
public virtual void SetPassPhrase(string passPhrase, string recoveryAgentName, string publicKey)
292
Store store = Store.GetStore();
293
Simias.Storage.Domain domain = store.GetDomain(store.DefaultDomain);
298
iFolderUser.SetPassPhrase(domain.ID, passPhrase, recoveryAgentName, publicKey, GetAccessID() );
302
SmartException.Throw(e);
309
/// Get information about an iFolder Server.
311
/// <param name="serverID">The id of the iFolder Server.</param>
312
/// <returns>An iFolderServer object describing the iFolder Server.</returns>
314
Description="Get information about an iFolder Server.",
316
public virtual iFolderServer GetServer(string serverID)
318
iFolderServer result = null;
324
result = iFolderServer.GetServer(serverID);
328
SmartException.Throw(e);
335
/// Get information about all the iFolder servers.
337
/// <returns>An array of iFolderServer objects.</returns>
339
Description="Get information about all the iFolder servers.",
341
public virtual iFolderServer[] GetServers()
343
iFolderServer[] result = null;
349
result = iFolderServer.GetServers();
353
SmartException.Throw(e);
361
/// Get the home server for the user
363
/// <returns>Publiv url of the home server.</returns>
365
Description="Get the home server for the user.",
367
public virtual string GetHomeServerForUser( string username , string password)
371
result = iFolderServer.GetHomeServerForUser ( username, password );
379
/// <returns>An array of iFolderServer objects.</returns>
381
Description="Get information about the reports.",
383
public virtual string[] GetReports()
385
string[] result = null;
391
result = iFolderServer.GetReports ();
395
SmartException.Throw(e);
402
/// Get information about iFolder Servers identified by a search on name.
404
/// <param name="operation">The operation to compare the name and pattern.</param>
405
/// <param name="pattern">The pattern to search.</param>
406
/// <param name="index">The starting index for the search results.</param>
407
/// <param name="count">The max number of search results to be returned.</param>
408
/// <returns>A set of iFolder Server objects.</returns>
410
Description="Get information about iFolder Servers identified by a search on name.",
412
public virtual iFolderServerSet GetServersByName(SearchOperation operation, string pattern,
413
int index, int count)
415
iFolderServerSet result = null;
421
result = iFolderServer.GetServersByName(iFolderServerType.All, operation, pattern, index, count);
425
SmartException.Throw(e);
436
/// Delete an iFolder
438
/// <param name="ifolderID">The id of the iFolder to be deleted.</param>
439
/// <remarks>This API will accept multiple iFolder ids in a comma delimited list.</remarks>
441
Description="Delete an iFolder",
443
public virtual void DeleteiFolder(string ifolderID)
445
Hashtable exceptions = new Hashtable();
451
string accessID = GetAccessID();
453
string[] ids = ifolderID.Split(new char[] {',', ' '});
455
foreach(string id in ids)
461
iFolder.DeleteiFolder(id, accessID);
465
exceptions.Add(id, e);
472
SmartException.Throw(e);
475
SmartException.Throw(exceptions);
479
/// Get information about an iFolder.
481
/// <param name="ifolderID">The id of the iFolder.</param>
482
/// <returns>An iFolder object describing the iFolder.</returns>
484
Description="Get information about an iFolder.",
486
public virtual iFolder GetiFolder(string ifolderID)
488
iFolder result = null;
492
result = iFolder.GetiFolder(ifolderID, GetAccessID());
496
SmartException.Throw(e);
503
/// Get detailed information about an iFolder.
505
/// <param name="ifolderID">The id of the iFolder</param>
506
/// <returns>An iFolderDetails object describing the iFolder</returns>
507
/// <remarks>It is more expensive to call GetiFolderDetails than GetiFolder.</remarks>
509
Description="Get detailed information about an iFolder.",
511
public virtual iFolderDetails GetiFolderDetails(string ifolderID)
513
iFolderDetails result = null;
519
result = iFolderDetails.GetiFolderDetails(ifolderID, GetAccessID());
523
SmartException.Throw(e);
530
/// Set the description of an iFolder.
532
/// <param name="ifolderID">The id of the iFolder.</param>
533
/// <param name="description">The new description for the iFolder.</param>
535
Description="Set the description of an iFolder.",
537
public virtual void SetiFolderDescription(string ifolderID, string description)
543
iFolder.SetDescription(ifolderID, description, GetAccessID());
547
SmartException.Throw(e);
552
/// Publish an iFolder.
554
/// <param name="ifolderID">The id of the iFolder.</param>
555
/// <param name="publish">The published state of the iFolder</param>
557
Description="Publish an iFolder.",
559
public virtual void PublishiFolder(string ifolderID, bool publish)
565
iFolder.PublishiFolder(ifolderID, publish, GetAccessID());
569
SmartException.Throw(e);
578
/// Get a history of changes to an iFolder.
580
/// <param name="ifolderID">The id of the iFolder.</param>
581
/// <param name="itemID">The id of item to filter the results (can be null for no filtering).</param>
582
/// <param name="index">The starting index for the search results.</param>
583
/// <param name="max">The max number of search results to be returned.</param>
584
/// <returns>A set of ChangeEntry objects.</returns>
586
Description="Get a history of changes to an iFolder.",
588
public virtual ChangeEntrySet GetChanges(string ifolderID, string itemID, int index, int max)
590
ChangeEntrySet result = null;
596
result = ChangeEntry.GetChanges(ifolderID, itemID, index, max, GetAccessID());
600
SmartException.Throw(e);
607
/// To extract the aspx page from header
609
/// <param name="sender"></param>
610
/// <param name="e"></param>
612
Description="Get a trimmed url from full url",
614
public virtual string TrimUrl(string FullUrl)
616
string TrimmedUrl = "iFolders.aspx";
621
TrimmedUrl = FullUrl.Substring(FullUrl.LastIndexOf('/') + 1);
627
SmartException.Throw(e);
637
/// Get information about the authenticated user.
639
/// <returns>An iFolderUser object describing the authenticated user.</returns>
641
Description="Get information about the authenticated user.",
643
public virtual iFolderUser GetAuthenticatedUser()
645
iFolderUser result = null;
651
result = iFolderUser.GetUser(null, GetUserID(), GetAccessID());
655
SmartException.Throw(e);
662
/// Set the rights of a member on an iFolder.
664
/// <param name="ifolderID">The id of the iFolder.</param>
665
/// <param name="userID">The user id of the member.</param>
666
/// <param name="rights">The rights to be set.</param>
667
/// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
669
Description="Set the rights of a member on an iFolder.",
671
public virtual void SetMemberRights(string ifolderID, string userID, Rights rights)
673
Hashtable exceptions = new Hashtable();
679
string[] ids = userID.Split(new char[] {',', ' '});
681
foreach(string id in ids)
687
iFolderUser.SetMemberRights(ifolderID, id, rights, GetAccessID());
691
exceptions.Add(id, e);
698
SmartException.Throw(e);
701
SmartException.Throw(exceptions);
705
/// Add a member to an iFolder.
707
/// <param name="ifolderID">The id of iFolder.</param>
708
/// <param name="userID">The user id of the new member.</param>
709
/// <param name="rights">The rights of the new member on the iFolder.</param>
710
/// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
712
Description="Add a member to an iFolder.",
714
public virtual void AddMember(string ifolderID, string userID, Rights rights)
716
Hashtable exceptions = new Hashtable();
722
string[] ids = userID.Split(new char[] {',', ' '});
724
foreach(string id in ids)
730
iFolderUser.AddMember(ifolderID, id, rights, GetAccessID());
734
// save any exceptions
735
exceptions.Add(id, e);
742
SmartException.Throw(e);
745
SmartException.Throw(exceptions);
749
/// Remove a member from an iFolder.
751
/// <param name="ifolderID">The id of the iFolder.</param>
752
/// <param name="userID">The user id of the member.</param>
753
/// <remarks>This API will accept multiple user ids in a comma delimited list.</remarks>
755
Description="Remove a member from an iFolder.",
757
public virtual void RemoveMember(string ifolderID, string userID)
759
Hashtable exceptions = new Hashtable();
765
string[] ids = userID.Split(new char[] {',', ' '});
767
foreach(string id in ids)
773
iFolderUser.RemoveMember(ifolderID, id, GetAccessID());
777
exceptions.Add(id, e);
785
SmartException.Throw(e);
788
SmartException.Throw(exceptions);
792
/// Set the owner of an iFolder.
794
/// <param name="ifolderID">The id of the iFolder.</param>
795
/// <param name="userID">The user id of the new owner.</param>
797
Description="Set the owner of an iFolder.",
799
public virtual void SetiFolderOwner(string ifolderID, string userID, bool OrphanAdopt)
805
iFolderUser.SetOwner(ifolderID, userID, GetAccessID(), OrphanAdopt);
809
SmartException.Throw(e);
814
/// Get information about the members of an iFolder.
816
/// <param name="ifolderID">The id of the iFolder.</param>
817
/// <param name="index">The starting index for the search results.</param>
818
/// <param name="max">The max number of search results to be returned.</param>
819
/// <returns>A set of iFolderUser objects describing the members.</returns>
821
Description="Get information about the members of an iFolder.",
823
public virtual iFolderUserSet GetMembers(string ifolderID, int index, int max)
825
iFolderUserSet result = null;
831
result = iFolderUser.GetUsers(ifolderID, index, max, GetAccessID());
835
SmartException.Throw(e);
842
/// Get information about all of the iFolder users.
844
/// <param name="index">The starting index for the search results.</param>
845
/// <param name="max">The max number of search results to be returned.</param>
846
/// <returns>A set of iFolderUser objects.</returns>
848
Description="Get information about all of the iFolder users.",
850
public virtual iFolderUserSet GetUsers(int index, int max)
852
iFolderUserSet result = null;
858
result = iFolderUser.GetUsers(null, index, max, GetAccessID());
862
SmartException.Throw(e);
869
/// Get information about a user using an id or username.
871
/// <param name="userID">The id or username of the user.</param>
872
/// <returns>A iFolderUser object.</returns>
874
Description="Get information about a user using an id or username.",
876
public virtual iFolderUser GetUser(string userID)
878
iFolderUser result = null;
884
result = iFolderUser.GetUser(userID, GetAccessID());
888
SmartException.Throw(e);
895
/// Get detailed information about a user.
897
/// <param name="userID">The id of the user.</param>
898
/// <returns>A iFolderUserDetails object.</returns>
899
/// <remarks>It is more expensive to call GetUserDetails than GetUser.</remarks>
901
Description="Get User Details",
903
public virtual iFolderUserDetails GetUserDetails(string userID)
905
iFolderUserDetails result = null;
911
result = iFolderUserDetails.GetDetails(userID);
915
SmartException.Throw(e);
922
/// Get information about all of the iFolder users identified by the search property, operation, and pattern.
924
/// <param name="property">The property to search.</param>
925
/// <param name="operation">The operation to compare the property and pattern.</param>
926
/// <param name="pattern">The pattern to search</param>
927
/// <param name="index">The starting index for the search results.</param>
928
/// <param name="max">The max number of search results to be returned.</param>
929
/// <returns>A set of iFolderUser objects.</returns>
931
Description="Get information about all of the iFolder users identified by the search property, operation, and pattern.",
933
public virtual iFolderUserSet GetUsersBySearch(SearchProperty property, SearchOperation operation, string pattern, int index, int max)
935
iFolderUserSet result = null;
941
result = iFolderUser.GetUsers(property, operation, pattern, index, max, GetAccessID());
945
SmartException.Throw(e);
956
/// Get the access user's id.
958
protected abstract string GetAccessID();
961
/// Get the authenticated user's id.
963
protected abstract string GetUserID();
966
/// Authorize the authenticated user.
968
protected abstract void Authorize();