SecureEnvironment.Create 方法

定义

创建一个安全的客户端会话进行权限管理操作。Creates a secure client session for rights management operations.

重载

Create(String, ContentUser)

使用给定权限清单为指定用户创建安全客户端会话。Creates a secure client session for a specified user with a given rights manifest.

Create(String, AuthenticationType, UserActivationMode)

创建给定了应用程序权限清单 AuthenticationTypeUserActivationMode 的安全客户端会话。Creates a secure client session given an application rights manifest, AuthenticationType, and UserActivationMode.

示例

下面的示例演示如何使用此方法创建安全环境。The following example shows how to use this method to create a secure environment.

string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
    StreamReader manifestReader = File.OpenText("rpc.xml");
    applicationManifest = manifestReader.ReadToEnd();
}

if (_secureEnv == null)
{
    if (SecureEnvironment.IsUserActivated(new ContentUser(
                _currentUserId, AuthenticationType.Windows)))
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest, new ContentUser(
                _currentUserId, AuthenticationType.Windows));
    }
    else
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest,
            AuthenticationType.Windows,
            UserActivationMode.Permanent);
    }
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
    Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
    applicationManifest = manifestReader.ReadToEnd()
End If

If _secureEnv Is Nothing Then
    If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
        _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
    Else
        _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
    End If
End If

Create(String, ContentUser)

使用给定权限清单为指定用户创建安全客户端会话。Creates a secure client session for a specified user with a given rights manifest.

public:
 static System::Security::RightsManagement::SecureEnvironment ^ Create(System::String ^ applicationManifest, System::Security::RightsManagement::ContentUser ^ user);
public static System.Security.RightsManagement.SecureEnvironment Create (string applicationManifest, System.Security.RightsManagement.ContentUser user);
static member Create : string * System.Security.RightsManagement.ContentUser -> System.Security.RightsManagement.SecureEnvironment
Public Shared Function Create (applicationManifest As String, user As ContentUser) As SecureEnvironment

参数

applicationManifest
String

应用程序权限清单。The application rights manifest.

user
ContentUser

要为其授予权限管理内容访问权限的用户或用户组。The user or user-group for granting access to rights managed content.

返回

一个用于激活、许可证绑定和其他权限管理操作的安全客户端会话。A secure client session for activation, license binding, and other rights management operations.

示例

下面的示例演示如何使用此方法创建安全环境。The following example shows how to use this method to create a secure environment.

string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
    StreamReader manifestReader = File.OpenText("rpc.xml");
    applicationManifest = manifestReader.ReadToEnd();
}

if (_secureEnv == null)
{
    if (SecureEnvironment.IsUserActivated(new ContentUser(
                _currentUserId, AuthenticationType.Windows)))
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest, new ContentUser(
                _currentUserId, AuthenticationType.Windows));
    }
    else
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest,
            AuthenticationType.Windows,
            UserActivationMode.Permanent);
    }
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
    Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
    applicationManifest = manifestReader.ReadToEnd()
End If

If _secureEnv Is Nothing Then
    If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
        _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
    Else
        _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
    End If
End If

注解

Create方法旨在与已激活的用户一起使用, 例如在从GetActivatedUsers返回的列表中提供。This Create method is intended for use with users that are already activated, such as provided in the list returned from GetActivatedUsers. 对尚未激活Create的用户使用备用方法。Use the alternate Create method for users that are not yet activated.

另请参阅

Create(String, AuthenticationType, UserActivationMode)

创建给定了应用程序权限清单 AuthenticationTypeUserActivationMode 的安全客户端会话。Creates a secure client session given an application rights manifest, AuthenticationType, and UserActivationMode.

public:
 static System::Security::RightsManagement::SecureEnvironment ^ Create(System::String ^ applicationManifest, System::Security::RightsManagement::AuthenticationType authentication, System::Security::RightsManagement::UserActivationMode userActivationMode);
public static System.Security.RightsManagement.SecureEnvironment Create (string applicationManifest, System.Security.RightsManagement.AuthenticationType authentication, System.Security.RightsManagement.UserActivationMode userActivationMode);
static member Create : string * System.Security.RightsManagement.AuthenticationType * System.Security.RightsManagement.UserActivationMode -> System.Security.RightsManagement.SecureEnvironment

参数

applicationManifest
String

应用程序权限清单。The application rights manifest.

authentication
AuthenticationType

身份验证的方法。The method of authentication.

userActivationMode
UserActivationMode

用户权限帐户证书的类型。The type of the user rights account certificate.

返回

一个用于激活、许可证绑定和其他权限管理操作的安全客户端会话。A secure client session for activation, license binding, and other rights management operations.

示例

下面的示例演示如何使用此方法创建安全环境。The following example shows how to use this method to create a secure environment.

string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
    StreamReader manifestReader = File.OpenText("rpc.xml");
    applicationManifest = manifestReader.ReadToEnd();
}

if (_secureEnv == null)
{
    if (SecureEnvironment.IsUserActivated(new ContentUser(
                _currentUserId, AuthenticationType.Windows)))
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest, new ContentUser(
                _currentUserId, AuthenticationType.Windows));
    }
    else
    {
        _secureEnv = SecureEnvironment.Create(
            applicationManifest,
            AuthenticationType.Windows,
            UserActivationMode.Permanent);
    }
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
    Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
    applicationManifest = manifestReader.ReadToEnd()
End If

If _secureEnv Is Nothing Then
    If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
        _secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
    Else
        _secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
    End If
End If

注解

Create方法适用于尚未激活的新用户。This Create method is intended for new users that are not yet activated.

激活新用户包括用于获取用户证书和客户端许可证证书的往返服务器事务。Activating a new user includes a roundtrip server transaction to obtain the User Certificate and Client License Certificate.

如果用户Create已激活, 如在从GetActivatedUsers返回的列表中提供, 则可以使用备用方法。The alternate Create method can be used if a user is already activated, such as provided in the list returned from GetActivatedUsers.

适用于