-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
386 changed files
with
8,616 additions
and
2,646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using RestSharp.Authenticators; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class Anonymous : IAuthentication | ||
{ | ||
public IAuthenticator GetAuthenticator() => null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using RestSharp; | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class ApiKey : IAuthentication | ||
{ | ||
public IScalarResolver<string> Name { get; } | ||
public IScalarResolver<string> Value { get; } | ||
|
||
public ApiKey(IScalarResolver<string> name, IScalarResolver<string> value) | ||
=> (Name, Value) = (name, value); | ||
|
||
public ApiKey(IScalarResolver<string> value) | ||
: this(new LiteralScalarResolver<string>("apiKey"), value) { } | ||
|
||
public IAuthenticator GetAuthenticator() => new ApiKeyAuthenticator(Name.Execute(), Value.Execute()); | ||
|
||
public class ApiKeyAuthenticator : IAuthenticator | ||
{ | ||
public string Name { get; } | ||
public string Value { get; } | ||
|
||
public ApiKeyAuthenticator(string name, string value) | ||
=> (Name, Value) = (name, value); | ||
|
||
public void Authenticate(IRestClient client, IRestRequest request) | ||
{ | ||
request.AddHeader(Name, Value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class HttpBasic : IAuthentication | ||
{ | ||
public IScalarResolver<string> Username { get; } | ||
public IScalarResolver<string> Password { get; } | ||
|
||
public HttpBasic(IScalarResolver<string> username, IScalarResolver<string> password) | ||
=> (Username, Password) = (username, password); | ||
|
||
public IAuthenticator GetAuthenticator() => new HttpBasicAuthenticator(Username.Execute(), Password.Execute()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public interface IAuthentication | ||
{ | ||
IAuthenticator GetAuthenticator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class NtlmCurrentUser : IAuthentication | ||
{ | ||
public NtlmCurrentUser() | ||
{ } | ||
|
||
public IAuthenticator GetAuthenticator() => new NtlmAuthenticator(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class NtlmUserPassword : IAuthentication | ||
{ | ||
public IScalarResolver<string> Username { get; } | ||
public IScalarResolver<string> Password { get; } | ||
|
||
public NtlmUserPassword(IScalarResolver<string> username, IScalarResolver<string> password) | ||
=> (Username, Password) = (username, password); | ||
|
||
public IAuthenticator GetAuthenticator() => new NtlmAuthenticator(Username.Execute(), Password.Execute()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using RestSharp.Authenticators; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Authentication | ||
{ | ||
public class OAuth2 : IAuthentication | ||
{ | ||
public IScalarResolver<string> AccessToken { get; } | ||
public IScalarResolver<string> TokenType { get; } | ||
|
||
public OAuth2(IScalarResolver<string> accessToken, IScalarResolver<string> tokenType) | ||
=> (AccessToken, TokenType) = (accessToken, tokenType); | ||
|
||
public OAuth2(IScalarResolver<string> accessToken) | ||
: this(accessToken, new LiteralScalarResolver<string>("OAuth")) { } | ||
|
||
public IAuthenticator GetAuthenticator() => new OAuth2AuthorizationRequestHeaderAuthenticator(AccessToken.Execute(), TokenType.Execute()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Rest | ||
{ | ||
public class HeaderRest | ||
{ | ||
public IScalarResolver<string> Name { get; } | ||
public IScalarResolver<string> Value { get; } | ||
|
||
public HeaderRest(IScalarResolver<string> name, IScalarResolver<string> value) | ||
=> (Name, Value) = (name, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.Api.Rest | ||
{ | ||
public class ParameterRest | ||
{ | ||
public IScalarResolver<string> Name { get; } | ||
public IScalarResolver<string> Value { get; } | ||
|
||
public ParameterRest(IScalarResolver<string> name, IScalarResolver<string> value) | ||
=> (Name, Value) = (name, value); | ||
} | ||
} |
Oops, something went wrong.