C# Class com.microsoft.dx.officewopi.Security.WopiSecurity

Class handles token generation and validation for the WOPI host
Show file Open project: OfficeDev/PnP-WOPI Class Usage Examples

Public Methods

Method Description
GenerateToken ( string user, string container, string docId ) : System.IdentityModel.Tokens.JwtSecurityToken

Generates an access token for the user and file

GetUserFromToken ( string tokenString ) : string

Extracts the user information from a provided access token

ValidateToken ( string tokenString, string container, string docId ) : bool

Generates an access token specific to a user and file

WriteToken ( System.IdentityModel.Tokens.JwtSecurityToken token ) : string

Converts the JwtSecurityToken to a Base64 string that can be used by the Host

Private Methods

Method Description
getCert ( ) : X509Certificate2

Gets the self-signed certificate used to sign the access tokens

Method Details

GenerateToken() public method

Generates an access token for the user and file
public GenerateToken ( string user, string container, string docId ) : System.IdentityModel.Tokens.JwtSecurityToken
user string
container string
docId string
return System.IdentityModel.Tokens.JwtSecurityToken

GetUserFromToken() public static method

Extracts the user information from a provided access token
public static GetUserFromToken ( string tokenString ) : string
tokenString string
return string

ValidateToken() public static method

Generates an access token specific to a user and file
public static ValidateToken ( string tokenString, string container, string docId ) : bool
tokenString string
container string
docId string
return bool

WriteToken() public method

Converts the JwtSecurityToken to a Base64 string that can be used by the Host
public WriteToken ( System.IdentityModel.Tokens.JwtSecurityToken token ) : string
token System.IdentityModel.Tokens.JwtSecurityToken
return string