CPE_learningsite
This repository has no backups
This repository's network speed is throttled to 100KB/sec
Upgrade your account to fix these warnings, or use backups.vc for automated backups
4cd176a439ea516368a5d8827cdf8726027259a6
CPE_learningsite / CPE / CPE.App / CPE.App.Web / Connect / Session.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
using System; using System.IO; using System.Xml.Serialization; using System.Web.Script.Serialization; namespace CPE.App.Web.Connect { /// <summary> /// Holds the various parameters for connecting to the API including the hostname and session key. /// </summary> [Serializable] public class Session { /// <summary> /// The host to access for connecting to the API. /// </summary> /// <example>https://admin.acrobat.com</example> public string Hostname { get; set; } /// <summary> /// The unique encrypted key that identifies this login and session to Connect. /// </summary> public string SessionKey { get; set; } /// <summary> /// Specifies the hostname of the proxy to route all requests through. /// </summary> public string Proxy { get; set; } /// <summary> /// Initializes a new session. /// </summary> public Session() { } /// <summary> /// Checks whether the current session is working and valid. /// </summary> public bool IsValid() { // Only logged in users may view shortcuts var request = new Request(this, "sco-shortcuts"); return (request.Execute() && request.Status == Status.OK); } /// <summary> /// Checks whether the current session's login has administrative permissions. /// </summary> public bool IsAdministrator() { // Call admin-only report-quotas action var request = new Request(this, "report-quotas"); return (request.Execute() && request.Status == Status.OK); } private CommonInfo _commonInfo; public CommonInfo CommonInfo { get { if (_commonInfo == null) { // Query common-info for user information var request = new Request(this, "common-info"); if (request.Execute() && request.Status == Status.OK) _commonInfo = new CommonInfo(request.XmlResults); } return _commonInfo; } } /// <summary> /// Returns the user information tied to this session. /// </summary> public CommonInfo.UserInfo UserInfo { get { var common = CommonInfo; if (common != null) return common.User; return null; } } private PrincipalInfo _principalInfo = null; /// <summary> /// Returns the detailed principal information for the user tied to this session. /// </summary> public PrincipalInfo PrincipalInfo { get { if (_principalInfo == null) { var request = new Request(this, "principal-info"); request.Parameters.Add("principal-id", UserInfo.UserId.ToString()); if (request.Execute() && request.Status == Status.OK) { _principalInfo = new PrincipalInfo(request.XmlResults); } } return _principalInfo; } } } } |
Commits for CPE_learningsiteCPE/CPE.App/CPE.App.Web/Connect/Session.cs
Revision | Author | Commited | Message |
---|---|---|---|
4cd176 ... | v.shishlov | Fri 27 Aug, 2021 14:33:17 +0000 | initial commit |