Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="X509CertificateCredentials"/> class.
        /// </summary>
        /// <remarks>The X509Certificate2 argument should have private key in order to sign the message.</remarks>
        /// <param name="certificate">The X509Certificate2 object.</param>
        public X509CertificateCredentials(X509Certificate2 certificate)
            : base(null, true)
        {
            EwsUtilities.ValidateParam(certificate, "certificate");

            if (!certificate.HasPrivateKey)
            {
                throw new ServiceValidationException(Strings.CertificateHasNoPrivateKey);
            }

            this.certificate = certificate;

            string certId = WSSecurityUtilityIdSignedXml.GetUniqueId();

            this.SecurityToken = string.Format(
                X509CertificateCredentials.BinarySecurityTokenFormat,
                certId,
                Convert.ToBase64String(this.certificate.GetRawCertData()));

            SafeXmlDocument doc = new SafeXmlDocument();

            doc.PreserveWhitespace = true;
            doc.LoadXml(string.Format(X509CertificateCredentials.KeyInfoClauseFormat, certId));
            this.keyInfoClause = new KeyInfoNode(doc.DocumentElement);
        }
        /// <summary>
        /// Validates the request.
        /// </summary>
        internal override void Validate()
        {
            base.Validate();

            EwsUtilities.ValidateParam(this.Domains, "domains");
            EwsUtilities.ValidateParam(this.Settings, "settings");

            if (this.Settings.Count == 0)
            {
                throw new ServiceValidationException(Strings.InvalidAutodiscoverSettingsCount);
            }

            if (domains.Count == 0)
            {
                throw new ServiceValidationException(Strings.InvalidAutodiscoverDomainsCount);
            }

            foreach (string domain in this.domains)
            {
                if (string.IsNullOrEmpty(domain))
                {
                    throw new ServiceValidationException(Strings.InvalidAutodiscoverDomain);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceId"/> class.
        /// </summary>
        /// <param name="uniqueId">The unique id.</param>
        internal ServiceId(string uniqueId)
            : this()
        {
            EwsUtilities.ValidateParam(uniqueId, "uniqueId");

            this.uniqueId = uniqueId;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FolderPermission"/> class.
        /// </summary>
        /// <param name="userId">The Id of the user  the permission applies to.</param>
        /// <param name="permissionLevel">The level of the permission.</param>
        public FolderPermission(UserId userId, FolderPermissionLevel permissionLevel)
        {
            EwsUtilities.ValidateParam(userId, "userId");

            this.userId          = userId;
            this.PermissionLevel = permissionLevel;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SubscriptionBase"/> class.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="id">The id.</param>
        internal SubscriptionBase(ExchangeService service, string id)
            : this(service)
        {
            EwsUtilities.ValidateParam(id, "id");

            this.id = id;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExtendedProperty"/> class.
        /// </summary>
        /// <param name="propertyDefinition">The definition of the extended property.</param>
        internal ExtendedProperty(ExtendedPropertyDefinition propertyDefinition)
            : this()
        {
            EwsUtilities.ValidateParam(propertyDefinition, "propertyDefinition");

            this.propertyDefinition = propertyDefinition;
        }
Exemplo n.º 7
0
 void Validate()
 {
     super.Validate();
     EwsUtilities.ValidateParam(this.name, "name");
     EwsUtilities.ValidateParam(this.parentFolderId, "parentFolderId");
     this.ParentFolderId.Validate(this.Service.RequestedServerVersion);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Validates this instance.
 /// </summary>
 internal override void InternalValidate()
 {
     base.InternalValidate();
     EwsUtilities.ValidateParam(this.displayName, "DisplayName");
     EwsUtilities.ValidateParamAllowNull(this.annotation, "Annotation");
     EwsUtilities.ValidateParamAllowNull(this.personaPostalAddress, "PersonaPostalAddress");
 }
 /// <summary>
 /// Validate request.
 /// </summary>
 internal override void Validate()
 {
     base.Validate();
     EwsUtilities.ValidateParam(this.name, "name");
     EwsUtilities.ValidateParam(this.parentFolderId, "parentFolderId");
     this.ParentFolderId.Validate(this.Service.RequestedServerVersion);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DualAuthCredentials"/> class.
        /// </summary>
        /// <param name="clientCertificates">The client certificates.</param>
        /// <param name="userName">The username.</param>
        /// <param name="password">The password.</param>
        public DualAuthCredentials(X509CertificateCollection clientCertificates, string userName, string password)
        {
            EwsUtilities.ValidateParam(clientCertificates, "clientCertificates");

            this.clientCertificates = clientCertificates;
            this.credentials        = new NetworkCredential(userName, password);
        }
Exemplo n.º 11
0
    void Validate()
    {
        super.Validate();

        EwsUtilities.ValidateParam(this.SmtpAddress, "SmtpAddress");
        EwsUtilities.ValidateParam(this.OofSettings, "OofSettings");
    }
Exemplo n.º 12
0
        /// <summary>
        /// Validate request..
        /// </summary>
        internal override void Validate()
        {
            base.Validate();

            EwsUtilities.ValidateParam(this.SmtpAddress, "SmtpAddress");
            EwsUtilities.ValidateParam(this.OofSettings, "OofSettings");
        }
        /// <summary>
        /// Validate request.
        /// </summary>
        internal override void Validate()
        {
            base.Validate();
            EwsUtilities.ValidateParam(this.PropertySet, "PropertySet");
            EwsUtilities.ValidateParam(this.SyncFolderId, "SyncFolderId");
            this.SyncFolderId.Validate(this.Service.RequestedServerVersion);

            // SyncFolderItemsScope enum was introduced with Exchange2010.  Only
            // value NormalItems is valid with previous server versions.
            if (this.Service.RequestedServerVersion < ExchangeVersion.Exchange2010 &&
                this.syncScope != SyncFolderItemsScope.NormalItems)
            {
                throw new ServiceVersionException(
                          string.Format(
                              Strings.EnumValueIncompatibleWithRequestVersion,
                              this.syncScope.ToString(),
                              this.syncScope.GetType().Name,
                              ExchangeVersion.Exchange2010));
            }

            // NumberOfDays was introduced with Exchange 2013.
            if (this.Service.RequestedServerVersion < ExchangeVersion.Exchange2013 &&
                this.NumberOfDays != 0)
            {
                throw new ServiceVersionException(
                          string.Format(
                              Strings.ParameterIncompatibleWithRequestVersion,
                              "numberOfDays",
                              ExchangeVersion.Exchange2013));
            }

            // SyncFolderItems can only handle summary properties
            this.PropertySet.ValidateForRequest(this, true /*summaryPropertiesOnly*/);
        }
        /// <summary>
        /// Validates the request.
        /// </summary>
        internal override void Validate()
        {
            base.Validate();

            EwsUtilities.ValidateParam(this.SmtpAddresses, "smtpAddresses");
            EwsUtilities.ValidateParam(this.Settings, "settings");

            if (this.Settings.Count == 0)
            {
                throw new ServiceValidationException(Strings.InvalidAutodiscoverSettingsCount);
            }

            if (this.SmtpAddresses.Count == 0)
            {
                throw new ServiceValidationException(Strings.InvalidAutodiscoverSmtpAddressesCount);
            }

            foreach (string smtpAddress in this.SmtpAddresses)
            {
                if (string.IsNullOrEmpty(smtpAddress))
                {
                    throw new ServiceValidationException(Strings.InvalidAutodiscoverSmtpAddress);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Moves this folder to a specific folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder in which to move this folder.</param>
        /// <returns>A new folder representing this folder in its new location. After Move completes, this folder does not exist anymore.</returns>
        public Folder Move(FolderId destinationFolderId)
        {
            this.ThrowIfThisIsNew();

            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            return(this.Service.MoveFolder(this.Id, destinationFolderId));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Obtains a grouped list of items by searching the contents of this folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="queryString">query string to be used for indexed search</param>
        /// <param name="view">The view controlling the number of items returned.</param>
        /// <param name="groupBy">The grouping criteria.</param>
        /// <returns>A collection of grouped items representing the contents of this folder.</returns>
        public GroupedFindItemsResults <Item> FindItems(string queryString, ItemView view, Grouping groupBy)
        {
            EwsUtilities.ValidateParam(groupBy, "groupBy");

            ServiceResponseCollection <FindItemResponse <Item> > responses = this.InternalFindItems <Item>(queryString, view, groupBy);

            return(responses[0].GroupedFindResults);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Obtains a grouped list of items by searching the contents of this folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="queryString">query string to be used for indexed search</param>
        /// <param name="view">The view controlling the number of items returned.</param>
        /// <param name="groupBy">The grouping criteria.</param>
        /// <returns>A collection of grouped items representing the contents of this folder.</returns>
        public async Task <GroupedFindItemsResults <Item> > FindItems(string queryString, ItemView view, Grouping groupBy)
        {
            EwsUtilities.ValidateParam(groupBy, "groupBy");

            ServiceResponseCollection <FindItemResponse <Item> > responses = await this.InternalFindItems <Item>(queryString, view, groupBy).ConfigureAwait(false);

            return(responses[0].GroupedFindResults);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Copies this folder into a specific folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder in which to copy this folder.</param>
        /// <returns>A Folder representing the copy of this folder.</returns>
        public Task <Folder> Copy(FolderId destinationFolderId)
        {
            this.ThrowIfThisIsNew();

            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            return(this.Service.CopyFolder(this.Id, destinationFolderId));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Moves this folder to a specific folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder in which to move this folder.</param>
        /// <returns>A new folder representing this folder in its new location. After Move completes, this folder does not exist anymore.</returns>
        public Task <Folder> Move(FolderId destinationFolderId, CancellationToken token = default(CancellationToken))
        {
            this.ThrowIfThisIsNew();

            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            return(this.Service.MoveFolder(this.Id, destinationFolderId, token));
        }
Exemplo n.º 20
0
        /// <summary>
        /// Internal constructor.
        /// </summary>
        /// <param name="service">EWS service to which this object belongs.</param>
        internal ServiceObject(ExchangeService service)
        {
            EwsUtilities.ValidateParam(service, "service");
            EwsUtilities.ValidateServiceObjectVersion(this, service.RequestedServerVersion);

            this.service     = service;
            this.propertyBag = new PropertyBag(this);
        }
Exemplo n.º 21
0
 void InternalValidate()
 {
     super.InternalValidate();
     EwsUtilities.ValidateParam(this.displayName, "DisplayName");
     EwsUtilities.ValidateParam(this.conditions, "Conditions");
     EwsUtilities.ValidateParam(this.exceptions, "Exceptions");
     EwsUtilities.ValidateParam(this.actions, "Actions");
 }
Exemplo n.º 22
0
 void InternalValidate()
 {
     super.InternalValidate();
     EwsUtilities.ValidateParam(this.fromAddresses, "FromAddresses");
     EwsUtilities.ValidateParam(this.sentToAddresses, "SentToAddresses");
     EwsUtilities.ValidateParam(this.withinDateRange, "WithinDateRange");
     EwsUtilities.ValidateParam(this.withinSizeRange, "WithinSizeRange");
 }
Exemplo n.º 23
0
        /// <summary>
        /// Moves this item to a the specified folder. Calling this method results in a call to EWS.
        /// <para>
        /// Move returns null if the move operation is across two mailboxes or between a mailbox and a
        /// public folder.
        /// </para>
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder to which to move this item.</param>
        /// <returns>The moved copy of this item.</returns>
        public Item Move(FolderId destinationFolderId)
        {
            this.ThrowIfThisIsNew();
            this.ThrowIfThisIsAttachment();

            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            return(this.Service.MoveItem(this.Id, destinationFolderId));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Saves this item in a specific folder. Calling this method results in at least one call to EWS.
        /// Mutliple calls to EWS might be made if attachments have been added.
        /// </summary>
        /// <param name="parentFolderId">The Id of the folder in which to save this item.</param>
        public void Save(FolderId parentFolderId)
        {
            EwsUtilities.ValidateParam(parentFolderId, "parentFolderId");

            this.InternalCreate(
                parentFolderId,
                MessageDisposition.SaveOnly,
                null);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Saves this appointment in the specified folder. Calling this method results in at least one call to EWS.
        /// Mutliple calls to EWS might be made if attachments have been added.
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder in which to save this appointment.</param>
        /// <param name="sendInvitationsMode">Specifies if and how invitations should be sent if this appointment is a meeting.</param>
        public void Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode)
        {
            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            this.InternalCreate(
                destinationFolderId,
                null,
                sendInvitationsMode);
        }
Exemplo n.º 26
0
 /// <summary>
 /// Validate request.
 /// </summary>
 internal override void Validate()
 {
     base.Validate();
     EwsUtilities.ValidateParamCollection(this.Attachments, "Attachments");
     for (int i = 0; i < this.Attachments.Count; i++)
     {
         EwsUtilities.ValidateParam(this.Attachments[i].Id, string.Format("Attachment[{0}].Id", i));
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="OnlineMeetingSettings"/> class from another OnlineMeetingSettings instance.
        /// </summary>
        /// <param name="onlineMeetingSettings">OnlineMeetingSettings instance to copy.</param>
        internal OnlineMeetingSettings(OnlineMeetingSettings onlineMeetingSettings)
            : this()
        {
            EwsUtilities.ValidateParam(onlineMeetingSettings, "OnlineMeetingSettings");

            this.LobbyBypass = onlineMeetingSettings.LobbyBypass;
            this.AccessLevel = onlineMeetingSettings.AccessLevel;
            this.Presenters  = onlineMeetingSettings.Presenters;
        }
        /// <summary>
        /// Adds the specified permissions to the collection.
        /// </summary>
        /// <param name="permissions">The permissions to add.</param>
        public void AddRange(IEnumerable <FolderPermission> permissions)
        {
            EwsUtilities.ValidateParam(permissions, "permissions");

            foreach (FolderPermission permission in permissions)
            {
                this.Add(permission);
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// Saves this appointment in the specified folder. Calling this method results in at least one call to EWS.
        /// Mutliple calls to EWS might be made if attachments have been added.
        /// </summary>
        /// <param name="destinationFolderId">The Id of the folder in which to save this appointment.</param>
        /// <param name="sendInvitationsMode">Specifies if and how invitations should be sent if this appointment is a meeting.</param>
        public System.Threading.Tasks.Task Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode)
        {
            EwsUtilities.ValidateParam(destinationFolderId, "destinationFolderId");

            return(this.InternalCreate(
                       destinationFolderId,
                       null,
                       sendInvitationsMode));
        }
Exemplo n.º 30
0
        /// <summary>
        /// Obtains a grouped list of items by searching the contents of this folder. Calling this method results in a call to EWS.
        /// </summary>
        /// <param name="view">The view controlling the number of items returned.</param>
        /// <param name="groupBy">The grouping criteria.</param>
        /// <returns>A collection of grouped items representing the contents of this folder.</returns>
        public GroupedFindItemsResults <Item> FindItems(ItemView view, Grouping groupBy)
        {
            EwsUtilities.ValidateParam(groupBy, "groupBy");

            return(this.FindItems(
                       (SearchFilter)null,
                       view,
                       groupBy));
        }