Class OAuthAuthenticator
Represents an OAuth authentication class.
Implements
Inherited Members
Namespace: Terrasoft.Social.OAuth
Assembly: Terrasoft.Social.dll
Syntax
public abstract class OAuthAuthenticator : BaseService, IOAuthAuthenticator
Constructors
OAuthAuthenticator()
Default constructor.
Declaration
public OAuthAuthenticator()
OAuthAuthenticator(UserConnection)
Constructor with initialization instance of UserConnection.
Declaration
public OAuthAuthenticator(UserConnection userConnection)
Parameters
Type | Name | Description |
---|---|---|
UserConnection | userConnection | UserConnection instance. |
Properties
AditionalUrlParams
Declaration
protected Dictionary<string, string> AditionalUrlParams { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> |
ApplicationClassName
Current application class name.
Declaration
public string ApplicationClassName { get; }
Property Value
Type | Description |
---|---|
System.String |
ApplicationId
OAuth application identifier.
Declaration
protected virtual Guid ApplicationId { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
AuthenticationUrl
Application authentication url.
Declaration
public string AuthenticationUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
AuthorizeUrl
Application authorization url.
Declaration
protected abstract string AuthorizeUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
BpmDomainApplicationUrl
Bpm application domain url.
Declaration
protected string BpmDomainApplicationUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
ClientId
Application client identifier.
Declaration
protected virtual string ClientId { get; set; }
Property Value
Type | Description |
---|---|
System.String |
FinalStageRedirectUrl
Redirect url after completion of the authorization process.
Declaration
public virtual string FinalStageRedirectUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
RedirectUrl
OAuth application redirect url.
Declaration
public virtual string RedirectUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
Request
Declaration
protected virtual HttpRequest Request { get; set; }
Property Value
Type | Description |
---|---|
HttpRequest |
Resource
The App ID URI of the web API. Required for some applications.
Declaration
protected virtual string Resource { get; }
Property Value
Type | Description |
---|---|
System.String |
Response
Declaration
protected virtual HttpResponse Response { get; set; }
Property Value
Type | Description |
---|---|
HttpResponse |
Scope
Impersonation permissions granted to the client application.
Declaration
protected abstract string Scope { get; }
Property Value
Type | Description |
---|---|
System.String |
SecretKey
Application secret key.
Declaration
protected virtual string SecretKey { get; set; }
Property Value
Type | Description |
---|---|
System.String |
State
Current context state.
Declaration
public Dictionary<string, object> State { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.Object> |
TokenUrl
Application tokens url.
Declaration
protected abstract string TokenUrl { get; }
Property Value
Type | Description |
---|---|
System.String |
UserConnection
Declaration
protected override UserConnection UserConnection { get; set; }
Property Value
Type | Description |
---|---|
UserConnection |
Overrides
Methods
AppendCookieToResponse(Boolean, JObject)
Appends into response cookies result of authorization state.
Declaration
protected void AppendCookieToResponse(bool success, JObject values)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | success |
|
JObject | values | Additional parameters. |
AppendError(Exception)
Appends error info into response cookies.
Declaration
protected void AppendError(Exception ex)
Parameters
Type | Name | Description |
---|---|---|
System.Exception | ex | Cought excheption. |
AuthenticateUser(String)
Authentications user in the specific OAuth application.
Declaration
public virtual string AuthenticateUser(string userLogin)
Parameters
Type | Name | Description |
---|---|---|
System.String | userLogin | User login to the application. |
Returns
Type | Description |
---|---|
System.String |
GetOAuthUserCredentials(String)
Gets OAuth user credentials from the response after request an access token.
Declaration
protected virtual OAuthUserCredentials GetOAuthUserCredentials(string response)
Parameters
Type | Name | Description |
---|---|---|
System.String | response | Response as a |
Returns
Type | Description |
---|---|
OAuthUserCredentials | OAuthUserCredentials instance. |
GetStateAsString()
Returns value of State property as a string.
Declaration
protected virtual string GetStateAsString()
Returns
Type | Description |
---|---|
System.String | System.String object. |
GetSuccessResultObject(OAuthUserCredentials)
Returns success authorization flow result data.
Declaration
protected virtual JObject GetSuccessResultObject(OAuthUserCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
OAuthUserCredentials | credentials | User OAuth credentials. |
Returns
Type | Description |
---|---|
JObject |
Initialize()
Initializations OAuth application settings.
Declaration
protected virtual void Initialize()
PostprocessAuthentication(String, Guid)
Called at the end of the authorization process.
Declaration
protected abstract void PostprocessAuthentication(string userLogin, Guid tokenStorageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | userLogin | OAuth application user login. |
System.Guid | tokenStorageId | Created token storage identifier. |
ProcessAuthenticationCode(String)
Processes authentication code from OAuth application.
Declaration
public virtual void ProcessAuthenticationCode(string code)
Parameters
Type | Name | Description |
---|---|---|
System.String | code | Authentication code. |
ProcessSavingCredentialsFinish(Guid)
Processes saving credentials finish event.
Declaration
protected abstract void ProcessSavingCredentialsFinish(Guid tokenStorageId)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | tokenStorageId | Created token storage identifier. |
RedirectToBpm(String)
Redirects Response to bpmUrl
.
All server side redirects in OAuth flow must use this method for redirect.
Declaration
protected void RedirectToBpm(string bpmUrl)
Parameters
Type | Name | Description |
---|---|---|
System.String | bpmUrl | Full bpm'online page url string. |
RefreshAccessToken(String)
Returns access token for the specific user before saves it in the DB.
Declaration
public string RefreshAccessToken(string userLogin)
Parameters
Type | Name | Description |
---|---|---|
System.String | userLogin | User login to the application. |
Returns
Type | Description |
---|---|
System.String | New access token. |
SaveCredentials(OAuthUserCredentials)
Saves received credentials
to token storage and redirects to success authorization page.
Declaration
protected virtual void SaveCredentials(OAuthUserCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
OAuthUserCredentials | credentials | OAuthUserCredentials instance. |
SendRequest(String, NameValueCollection)
Sends get request with parameters
to url
.
Declaration
protected virtual byte[] SendRequest(string url, NameValueCollection parameters)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | Request service url. |
System.Collections.Specialized.NameValueCollection | parameters | Get parameters collection. |
Returns
Type | Description |
---|---|
System.Byte[] | Response bytes array. |
Remarks
External dependency realocation.
UpdateUserCredentials(OAuthUserCredentials, String)
Updates OAuth user credentials from the response after request an refreshing the access token.
Declaration
protected virtual OAuthUserCredentials UpdateUserCredentials(OAuthUserCredentials credentials, string response)
Parameters
Type | Name | Description |
---|---|---|
OAuthUserCredentials | credentials | Current user credentials what will be updated. |
System.String | response | Response as a |
Returns
Type | Description |
---|---|
OAuthUserCredentials | Refreshed OAuthUserCredentials instance. |
ValidateCredentials(OAuthUserCredentials)
Validates credentials
due for particular implementation logic.
Declaration
protected virtual bool ValidateCredentials(OAuthUserCredentials credentials)
Parameters
Type | Name | Description |
---|---|---|
OAuthUserCredentials | credentials | OAuthUserCredentials instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|