C# 클래스 SampleWebApp.TokenHelper

파일 보기 프로젝트 열기: upeo/inbloom-dotnet

공개 프로퍼티들

프로퍼티 타입 설명
HighTrustAccessTokenLifetime System.TimeSpan

공개 메소드들

메소드 설명
CreateAppEventClientContext ( SPRemoteEventProperties properties, bool useAppWeb ) : ClientContext

Creates a client context based on the properties of an app event

CreateRemoteEventReceiverClientContext ( SPRemoteEventProperties properties ) : ClientContext

Creates a client context based on the properties of a remote event receiver

EnsureTrailingSlash ( string url ) : string

Ensures that the specified URL ends with '/' if it is not null or empty.

GetAccessToken ( SharePointContextToken contextToken, string targetHost ) : OAuth2AccessTokenResponse

Retrieves an access token from ACS to call the source of the specified context token at the specified targetHost. The targetHost must be registered for the principal that sent the context token.

GetAccessToken ( string refreshToken, string targetPrincipalName, string targetHost, string targetRealm ) : OAuth2AccessTokenResponse

Uses the specified refresh token to retrieve an access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.

GetAccessToken ( string authorizationCode, string targetPrincipalName, string targetHost, string targetRealm, Uri redirectUri ) : OAuth2AccessTokenResponse

Uses the specified authorization code to retrieve an access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.

GetAppContextTokenRequestUrl ( string contextUrl, string redirectUri ) : string

Returns the SharePoint url to which the app should redirect the browser to request a new context token.

GetAppOnlyAccessToken ( string targetPrincipalName, string targetHost, string targetRealm ) : OAuth2AccessTokenResponse

Retrieves an app-only access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.

GetAuthorizationUrl ( string contextUrl, string scope ) : string

Returns the SharePoint url to which the app should redirect the browser to request consent and get back an authorization code.

GetAuthorizationUrl ( string contextUrl, string scope, string redirectUri ) : string

Returns the SharePoint url to which the app should redirect the browser to request consent and get back an authorization code.

GetClientContextWithAccessToken ( string targetUrl, string accessToken ) : ClientContext

Uses the specified access token to create a client context

GetClientContextWithAuthorizationCode ( string targetUrl, string authorizationCode, Uri redirectUri ) : ClientContext

Retrieves an access token from ACS using the specified authorization code, and uses that access token to create a client context

GetClientContextWithAuthorizationCode ( string targetUrl, string targetPrincipalName, string authorizationCode, string targetRealm, Uri redirectUri ) : ClientContext

Retrieves an access token from ACS using the specified authorization code, and uses that access token to create a client context

GetClientContextWithContextToken ( string targetUrl, string contextTokenString, string appHostUrl ) : ClientContext

Retrieves an access token from ACS using the specified context token, and uses that access token to create a client context

GetContextTokenFromRequest ( HttpRequest request ) : string

Retrieves the context token string from the specified request by looking for well-known parameter names in the POSTed form parameters and the querystring. Returns null if no context token is found.

GetContextTokenFromRequest ( System.Web.HttpRequestBase request ) : string

Retrieves the context token string from the specified request by looking for well-known parameter names in the POSTed form parameters and the querystring. Returns null if no context token is found.

GetRealmFromTargetUrl ( Uri targetApplicationUri ) : string

Get authentication realm from SharePoint

GetS2SAccessTokenWithWindowsIdentity ( Uri targetApplicationUri, System.Security.Principal.WindowsIdentity identity ) : string

Retrieves an S2S access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for the SharePoint at the targetApplicationUri. If no Realm is specified in web.config, an auth challenge will be issued to the targetApplicationUri to discover it.

GetS2SClientContextWithWindowsIdentity ( Uri targetApplicationUri, System.Security.Principal.WindowsIdentity identity ) : ClientContext

Retrieves an S2S client context with an access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for application at the targetApplicationUri using the targetRealm. If no Realm is specified in web.config, an auth challenge will be issued to the targetApplicationUri to discover it.

IsHighTrustApp ( ) : bool

Determines if this is a high trust app.

ReadAndValidateContextToken ( string contextTokenString, string appHostName = null ) : SharePointContextToken

Validate that a specified context token string is intended for this application based on the parameters specified in web.config. Parameters used from web.config used for validation include ClientId, HostedAppHostNameOverride, HostedAppHostName, ClientSecret, and Realm (if it is specified). If HostedAppHostNameOverride is present, it will be used for validation. Otherwise, if the appHostName is not null, it is used for validation instead of the web.config's HostedAppHostName. If the token is invalid, an exception is thrown. If the token is valid, TokenHelper's static STS metadata url is updated based on the token contents and a JsonWebSecurityToken based on the context token is returned.

비공개 메소드들

메소드 설명
CreateAcsClientContextForUrl ( SPRemoteEventProperties properties, Uri sharepointUrl ) : ClientContext
CreateJsonWebSecurityTokenHandler ( ) : JsonWebSecurityTokenHandler
GetAcsGlobalEndpointUrl ( ) : string
GetAcsMetadataEndpointUrl ( ) : string
GetAcsPrincipalName ( string realm ) : string
GetClaimsWithWindowsIdentity ( System.Security.Principal.WindowsIdentity identity ) : JsonWebTokenClaim[]
GetFormattedPrincipal ( string principalName, string hostName, string realm ) : string
GetS2SAccessTokenWithClaims ( string targetApplicationHostName, string targetRealm, IEnumerable claims ) : string
IssueToken ( string sourceApplication, string issuerApplication, string sourceRealm, string targetApplication, string targetRealm, string targetApplicationHostName, bool trustedForDelegation, IEnumerable claims, bool appOnly = false ) : string

메소드 상세

CreateAppEventClientContext() 공개 정적인 메소드

Creates a client context based on the properties of an app event
public static CreateAppEventClientContext ( SPRemoteEventProperties properties, bool useAppWeb ) : ClientContext
properties SPRemoteEventProperties Properties of an app event
useAppWeb bool True to target the app web, false to target the host web
리턴 ClientContext

CreateRemoteEventReceiverClientContext() 공개 정적인 메소드

Creates a client context based on the properties of a remote event receiver
public static CreateRemoteEventReceiverClientContext ( SPRemoteEventProperties properties ) : ClientContext
properties SPRemoteEventProperties Properties of a remote event receiver
리턴 ClientContext

EnsureTrailingSlash() 공개 정적인 메소드

Ensures that the specified URL ends with '/' if it is not null or empty.
public static EnsureTrailingSlash ( string url ) : string
url string The url.
리턴 string

GetAccessToken() 공개 정적인 메소드

Retrieves an access token from ACS to call the source of the specified context token at the specified targetHost. The targetHost must be registered for the principal that sent the context token.
public static GetAccessToken ( SharePointContextToken contextToken, string targetHost ) : OAuth2AccessTokenResponse
contextToken SharePointContextToken Context token issued by the intended access token audience
targetHost string Url authority of the target principal
리턴 OAuth2AccessTokenResponse

GetAccessToken() 공개 정적인 메소드

Uses the specified refresh token to retrieve an access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.
public static GetAccessToken ( string refreshToken, string targetPrincipalName, string targetHost, string targetRealm ) : OAuth2AccessTokenResponse
refreshToken string Refresh token to exchange for access token
targetPrincipalName string Name of the target principal to retrieve an access token for
targetHost string Url authority of the target principal
targetRealm string Realm to use for the access token's nameid and audience
리턴 OAuth2AccessTokenResponse

GetAccessToken() 공개 정적인 메소드

Uses the specified authorization code to retrieve an access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.
public static GetAccessToken ( string authorizationCode, string targetPrincipalName, string targetHost, string targetRealm, Uri redirectUri ) : OAuth2AccessTokenResponse
authorizationCode string Authorization code to exchange for access token
targetPrincipalName string Name of the target principal to retrieve an access token for
targetHost string Url authority of the target principal
targetRealm string Realm to use for the access token's nameid and audience
redirectUri System.Uri Redirect URI registerd for this app
리턴 OAuth2AccessTokenResponse

GetAppContextTokenRequestUrl() 공개 정적인 메소드

Returns the SharePoint url to which the app should redirect the browser to request a new context token.
public static GetAppContextTokenRequestUrl ( string contextUrl, string redirectUri ) : string
contextUrl string Absolute Url of the SharePoint site
redirectUri string Uri to which SharePoint should redirect the browser to with a context token
리턴 string

GetAppOnlyAccessToken() 공개 정적인 메소드

Retrieves an app-only access token from ACS to call the specified principal at the specified targetHost. The targetHost must be registered for target principal. If specified realm is null, the "Realm" setting in web.config will be used instead.
public static GetAppOnlyAccessToken ( string targetPrincipalName, string targetHost, string targetRealm ) : OAuth2AccessTokenResponse
targetPrincipalName string Name of the target principal to retrieve an access token for
targetHost string Url authority of the target principal
targetRealm string Realm to use for the access token's nameid and audience
리턴 OAuth2AccessTokenResponse

GetAuthorizationUrl() 공개 정적인 메소드

Returns the SharePoint url to which the app should redirect the browser to request consent and get back an authorization code.
public static GetAuthorizationUrl ( string contextUrl, string scope ) : string
contextUrl string Absolute Url of the SharePoint site
scope string Space-delimited permissions to request from the SharePoint site in "shorthand" format /// (e.g. "Web.Read Site.Write")
리턴 string

GetAuthorizationUrl() 공개 정적인 메소드

Returns the SharePoint url to which the app should redirect the browser to request consent and get back an authorization code.
public static GetAuthorizationUrl ( string contextUrl, string scope, string redirectUri ) : string
contextUrl string Absolute Url of the SharePoint site
scope string Space-delimited permissions to request from the SharePoint site in "shorthand" format /// (e.g. "Web.Read Site.Write")
redirectUri string Uri to which SharePoint should redirect the browser to after consent is /// granted
리턴 string

GetClientContextWithAccessToken() 공개 정적인 메소드

Uses the specified access token to create a client context
public static GetClientContextWithAccessToken ( string targetUrl, string accessToken ) : ClientContext
targetUrl string Url of the target SharePoint site
accessToken string Access token to be used when calling the specified targetUrl
리턴 ClientContext

GetClientContextWithAuthorizationCode() 공개 정적인 메소드

Retrieves an access token from ACS using the specified authorization code, and uses that access token to create a client context
public static GetClientContextWithAuthorizationCode ( string targetUrl, string authorizationCode, Uri redirectUri ) : ClientContext
targetUrl string Url of the target SharePoint site
authorizationCode string Authorization code to use when retrieving the access token from ACS
redirectUri System.Uri Redirect URI registerd for this app
리턴 ClientContext

GetClientContextWithAuthorizationCode() 공개 정적인 메소드

Retrieves an access token from ACS using the specified authorization code, and uses that access token to create a client context
public static GetClientContextWithAuthorizationCode ( string targetUrl, string targetPrincipalName, string authorizationCode, string targetRealm, Uri redirectUri ) : ClientContext
targetUrl string Url of the target SharePoint site
targetPrincipalName string Name of the target SharePoint principal
authorizationCode string Authorization code to use when retrieving the access token from ACS
targetRealm string Realm to use for the access token's nameid and audience
redirectUri System.Uri Redirect URI registerd for this app
리턴 ClientContext

GetClientContextWithContextToken() 공개 정적인 메소드

Retrieves an access token from ACS using the specified context token, and uses that access token to create a client context
public static GetClientContextWithContextToken ( string targetUrl, string contextTokenString, string appHostUrl ) : ClientContext
targetUrl string Url of the target SharePoint site
contextTokenString string Context token received from the target SharePoint site
appHostUrl string Url authority of the hosted app. If this is null, the value in the HostedAppHostName /// of web.config will be used instead
리턴 ClientContext

GetContextTokenFromRequest() 공개 정적인 메소드

Retrieves the context token string from the specified request by looking for well-known parameter names in the POSTed form parameters and the querystring. Returns null if no context token is found.
public static GetContextTokenFromRequest ( HttpRequest request ) : string
request HttpRequest HttpRequest in which to look for a context token
리턴 string

GetContextTokenFromRequest() 공개 정적인 메소드

Retrieves the context token string from the specified request by looking for well-known parameter names in the POSTed form parameters and the querystring. Returns null if no context token is found.
public static GetContextTokenFromRequest ( System.Web.HttpRequestBase request ) : string
request System.Web.HttpRequestBase HttpRequest in which to look for a context token
리턴 string

GetRealmFromTargetUrl() 공개 정적인 메소드

Get authentication realm from SharePoint
public static GetRealmFromTargetUrl ( Uri targetApplicationUri ) : string
targetApplicationUri System.Uri Url of the target SharePoint site
리턴 string

GetS2SAccessTokenWithWindowsIdentity() 공개 정적인 메소드

Retrieves an S2S access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for the SharePoint at the targetApplicationUri. If no Realm is specified in web.config, an auth challenge will be issued to the targetApplicationUri to discover it.
public static GetS2SAccessTokenWithWindowsIdentity ( Uri targetApplicationUri, System.Security.Principal.WindowsIdentity identity ) : string
targetApplicationUri System.Uri Url of the target SharePoint site
identity System.Security.Principal.WindowsIdentity Windows identity of the user on whose behalf to create the access token
리턴 string

GetS2SClientContextWithWindowsIdentity() 공개 정적인 메소드

Retrieves an S2S client context with an access token signed by the application's private certificate on behalf of the specified WindowsIdentity and intended for application at the targetApplicationUri using the targetRealm. If no Realm is specified in web.config, an auth challenge will be issued to the targetApplicationUri to discover it.
public static GetS2SClientContextWithWindowsIdentity ( Uri targetApplicationUri, System.Security.Principal.WindowsIdentity identity ) : ClientContext
targetApplicationUri System.Uri Url of the target SharePoint site
identity System.Security.Principal.WindowsIdentity Windows identity of the user on whose behalf to create the access token
리턴 ClientContext

IsHighTrustApp() 공개 정적인 메소드

Determines if this is a high trust app.
public static IsHighTrustApp ( ) : bool
리턴 bool

ReadAndValidateContextToken() 공개 정적인 메소드

Validate that a specified context token string is intended for this application based on the parameters specified in web.config. Parameters used from web.config used for validation include ClientId, HostedAppHostNameOverride, HostedAppHostName, ClientSecret, and Realm (if it is specified). If HostedAppHostNameOverride is present, it will be used for validation. Otherwise, if the appHostName is not null, it is used for validation instead of the web.config's HostedAppHostName. If the token is invalid, an exception is thrown. If the token is valid, TokenHelper's static STS metadata url is updated based on the token contents and a JsonWebSecurityToken based on the context token is returned.
public static ReadAndValidateContextToken ( string contextTokenString, string appHostName = null ) : SharePointContextToken
contextTokenString string The context token to validate
appHostName string The URL authority, consisting of Domain Name System (DNS) host name or IP address and the port number, to use for token audience validation. /// If null, HostedAppHostName web.config setting is used instead. HostedAppHostNameOverride web.config setting, if present, will be used /// for validation instead of .
리턴 SharePointContextToken

프로퍼티 상세

HighTrustAccessTokenLifetime 공개적으로 정적으로 프로퍼티

Lifetime of HighTrust access token, 12 hours.
public static TimeSpan,System HighTrustAccessTokenLifetime
리턴 System.TimeSpan