Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / Security / RightsManagement / Grant.cs / 1 / Grant.cs
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: This class represents a (ContentUser , ContentRight) pair.
//
// History:
// 06/01/2005: IgorBel : Initial Implementation
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using MS.Internal.Security.RightsManagement;
using SecurityHelper=MS.Internal.WindowsBase.SecurityHelper;
namespace System.Security.RightsManagement
{
///
/// ContentGrant class represent a (ContentUser , ContentRight) pair this is
/// a basic building block for structures that need to express information about rights granted to a document.
///
///
/// Critical: This class expose access to methods that eventually do one or more of the the following
/// 1. call into unmanaged code
/// 2. affects state/data that will eventually cross over unmanaged code boundary
/// 3. Return some RM related information which is considered private
///
/// TreatAsSafe: This attribute automatically applied to all public entry points. All the public entry points have
/// Demands for RightsManagementPermission at entry to counter the possible attacks that do
/// not lead to the unmanaged code directly(which is protected by another Demand there) but rather leave
/// some status/data behind which eventually might cross the unamanaged boundary.
///
[SecurityCritical(SecurityCriticalScope.Everything)]
public class ContentGrant
{
///
/// Constructor for the read only ContentGrant class. It takes values for user and right as parameters.
///
public ContentGrant(ContentUser user, ContentRight right)
: this(user, right, DateTime.MinValue, DateTime.MaxValue)
{
}
///
/// Constructor for the read only ContentGrant class. It takes values for
/// user, right, validFrom, and validUntil as parameters.
///
public ContentGrant(ContentUser user, ContentRight right, DateTime validFrom, DateTime validUntil)
{
SecurityHelper.DemandRightsManagementPermission();
// Add validation here
if (user == null)
{
throw new ArgumentNullException("user");
}
if ((right != ContentRight.View) &&
(right != ContentRight.Edit) &&
(right != ContentRight.Print) &&
(right != ContentRight.Extract) &&
(right != ContentRight.ObjectModel) &&
(right != ContentRight.Owner) &&
(right != ContentRight.ViewRightsData) &&
(right != ContentRight.Forward) &&
(right != ContentRight.Reply) &&
(right != ContentRight.ReplyAll) &&
(right != ContentRight.Sign) &&
(right != ContentRight.DocumentEdit) &&
(right != ContentRight.Export))
{
throw new ArgumentOutOfRangeException("right");
}
if (validFrom > validUntil)
{
throw new ArgumentOutOfRangeException("validFrom");
}
_user = user;
_right = right;
_validFrom = validFrom;
_validUntil = validUntil;
}
///
/// Read only User propery.
///
public ContentUser User
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _user;
}
}
///
/// Read only Right propery.
///
public ContentRight Right
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _right;
}
}
///
/// The starting validity time, in UTC time, for the grant.
///
public DateTime ValidFrom
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _validFrom;
}
}
///
/// The ending validity time, in UTC time, for the grant.
///
public DateTime ValidUntil
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _validUntil;
}
}
private ContentUser _user;
private ContentRight _right;
private DateTime _validFrom;
private DateTime _validUntil;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------------------------
//
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//
// Description: This class represents a (ContentUser , ContentRight) pair.
//
// History:
// 06/01/2005: IgorBel : Initial Implementation
//
//-----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using MS.Internal.Security.RightsManagement;
using SecurityHelper=MS.Internal.WindowsBase.SecurityHelper;
namespace System.Security.RightsManagement
{
///
/// ContentGrant class represent a (ContentUser , ContentRight) pair this is
/// a basic building block for structures that need to express information about rights granted to a document.
///
///
/// Critical: This class expose access to methods that eventually do one or more of the the following
/// 1. call into unmanaged code
/// 2. affects state/data that will eventually cross over unmanaged code boundary
/// 3. Return some RM related information which is considered private
///
/// TreatAsSafe: This attribute automatically applied to all public entry points. All the public entry points have
/// Demands for RightsManagementPermission at entry to counter the possible attacks that do
/// not lead to the unmanaged code directly(which is protected by another Demand there) but rather leave
/// some status/data behind which eventually might cross the unamanaged boundary.
///
[SecurityCritical(SecurityCriticalScope.Everything)]
public class ContentGrant
{
///
/// Constructor for the read only ContentGrant class. It takes values for user and right as parameters.
///
public ContentGrant(ContentUser user, ContentRight right)
: this(user, right, DateTime.MinValue, DateTime.MaxValue)
{
}
///
/// Constructor for the read only ContentGrant class. It takes values for
/// user, right, validFrom, and validUntil as parameters.
///
public ContentGrant(ContentUser user, ContentRight right, DateTime validFrom, DateTime validUntil)
{
SecurityHelper.DemandRightsManagementPermission();
// Add validation here
if (user == null)
{
throw new ArgumentNullException("user");
}
if ((right != ContentRight.View) &&
(right != ContentRight.Edit) &&
(right != ContentRight.Print) &&
(right != ContentRight.Extract) &&
(right != ContentRight.ObjectModel) &&
(right != ContentRight.Owner) &&
(right != ContentRight.ViewRightsData) &&
(right != ContentRight.Forward) &&
(right != ContentRight.Reply) &&
(right != ContentRight.ReplyAll) &&
(right != ContentRight.Sign) &&
(right != ContentRight.DocumentEdit) &&
(right != ContentRight.Export))
{
throw new ArgumentOutOfRangeException("right");
}
if (validFrom > validUntil)
{
throw new ArgumentOutOfRangeException("validFrom");
}
_user = user;
_right = right;
_validFrom = validFrom;
_validUntil = validUntil;
}
///
/// Read only User propery.
///
public ContentUser User
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _user;
}
}
///
/// Read only Right propery.
///
public ContentRight Right
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _right;
}
}
///
/// The starting validity time, in UTC time, for the grant.
///
public DateTime ValidFrom
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _validFrom;
}
}
///
/// The ending validity time, in UTC time, for the grant.
///
public DateTime ValidUntil
{
get
{
SecurityHelper.DemandRightsManagementPermission();
return _validUntil;
}
}
private ContentUser _user;
private ContentRight _right;
private DateTime _validFrom;
private DateTime _validUntil;
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridViewToolTip.cs
- DataGridViewToolTip.cs
- HtmlButton.cs
- UrlPath.cs
- SqlDataSourceQueryEditorForm.cs
- EventPropertyMap.cs
- UnknownBitmapDecoder.cs
- WebBrowserProgressChangedEventHandler.cs
- FatalException.cs
- MissingMemberException.cs
- XmlDataSourceNodeDescriptor.cs
- Animatable.cs
- DependencyPropertyKind.cs
- ListViewGroup.cs
- TabRenderer.cs
- DateTimeFormatInfo.cs
- OneOfScalarConst.cs
- Vector3DKeyFrameCollection.cs
- ExceptionNotification.cs
- Control.cs
- BindingGroup.cs
- WindowsListViewSubItem.cs
- HttpRuntime.cs
- ReceiveSecurityHeaderElementManager.cs
- TextDecorationLocationValidation.cs
- SoapProtocolImporter.cs
- Stroke2.cs
- SqlDataSource.cs
- ExtendedProperty.cs
- BitmapMetadataBlob.cs
- ConfigurationManagerHelper.cs
- XmlArrayAttribute.cs
- SafeNativeMethodsCLR.cs
- WebRequestModuleElement.cs
- MessageHeaderDescriptionCollection.cs
- Membership.cs
- GeneralTransformGroup.cs
- IndexedString.cs
- TypedDataSourceCodeGenerator.cs
- NavigatingCancelEventArgs.cs
- TreeSet.cs
- COM2Properties.cs
- ReferencedAssembly.cs
- DesignerLoader.cs
- StrokeIntersection.cs
- TextTreeFixupNode.cs
- Logging.cs
- DocumentPageView.cs
- PackageDigitalSignature.cs
- StringValidatorAttribute.cs
- PrefixQName.cs
- SQLBinary.cs
- CustomError.cs
- IPHostEntry.cs
- DataServiceHostWrapper.cs
- ImmComposition.cs
- NavigationPropertyEmitter.cs
- _RequestCacheProtocol.cs
- XslCompiledTransform.cs
- RuntimeUtils.cs
- AdapterUtil.cs
- FunctionImportElement.cs
- XmlSchemaSet.cs
- HierarchicalDataSourceControl.cs
- IPAddress.cs
- ApplicationServiceHelper.cs
- ObjectTypeMapping.cs
- Pair.cs
- MultilineStringConverter.cs
- AdCreatedEventArgs.cs
- SafeLibraryHandle.cs
- CacheMode.cs
- PageCatalogPart.cs
- TransformerInfo.cs
- UserControlAutomationPeer.cs
- DataGridViewCellFormattingEventArgs.cs
- CommandDesigner.cs
- SrgsRule.cs
- HttpModuleAction.cs
- DrawToolTipEventArgs.cs
- FormsAuthenticationTicket.cs
- StylusCollection.cs
- StrongNameIdentityPermission.cs
- WindowsTokenRoleProvider.cs
- TextTreeTextBlock.cs
- BulletChrome.cs
- ButtonField.cs
- DbParameterHelper.cs
- TemplateXamlTreeBuilder.cs
- NotifyCollectionChangedEventArgs.cs
- EntityDataSourceState.cs
- LeaseManager.cs
- SaveFileDialog.cs
- BindingCollection.cs
- FusionWrap.cs
- XamlFigureLengthSerializer.cs
- CodeBlockBuilder.cs
- UnsafeNativeMethodsPenimc.cs
- SubqueryTrackingVisitor.cs
- AcceleratedTokenAuthenticator.cs