本文整理汇总了C#中Credential类的典型用法代码示例。如果您正苦于以下问题:C# Credential类的具体用法?C# Credential怎么用?C# Credential使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Credential类属于命名空间,在下文中一共展示了Credential类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetAssetsAsync
public async Task<IEnumerable<Asset>> GetAssetsAsync(Credential credentials)
{
if (!(await AccessAllowed(credentials.AccessMask, CallEndPoint.AssetList)))
throw new UnauthorizedAccessException();
return await _repo.GetAssetsAsync(1, credentials);
}
开发者ID:Mikisto,项目名称:ApiService2,代码行数:7,代码来源:ApiService.cs
示例2: EncryptCredentialBasedOnCertificateOfServer
/// <summary>
/// Encrypt credential based on the public key of server
/// </summary>
/// <param name="credential"></param>
/// <param name="certificate"></param>
/// <returns></returns>
public byte[] EncryptCredentialBasedOnCertificateOfServer(Credential credential,X509Certificate2 certificate)
{
RSACryptoServiceProvider publicKey = (RSACryptoServiceProvider)certificate.PublicKey.Key;
string info = JsonConvert.SerializeObject(credential);
byte[] credentialInfoByte = publicKey.Encrypt(System.Text.Encoding.Default.GetBytes(info), false);
return credentialInfoByte;
}
开发者ID:jonaslsl,项目名称:modSIC,代码行数:13,代码来源:CollectServiceCryptoProvider.cs
示例3: AddRange
public void AddRange(Credential.Info[] cInfo)
{
foreach (Credential.Info cI in cInfo)
{
List.Add(cI);
}
}
开发者ID:hmaster20,项目名称:mRemoteNC,代码行数:7,代码来源:Credential.List.cs
示例4: AddDomainUserCredential
/// <summary>
/// Adds the domain user credential.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="userName">Name of the user.</param>
/// <param name="password">The password.</param>
public static void AddDomainUserCredential(string target, string userName, string password)
{
Credential userCredential = new Credential();
try
{
userCredential.TargetName = target;
userCredential.Type = (uint)CRED_TYPE.CRED_TYPE_DOMAIN_PASSWORD;
userCredential.UserName = userName;
userCredential.AttributeCount = 0;
userCredential.Persist = (uint)CRED_PERSIST.CRED_PERSIST_LOCAL_MACHINE;
byte[] bpassword = Encoding.Unicode.GetBytes(password);
userCredential.CredentialBlobSize = (uint)bpassword.Length;
userCredential.CredentialBlob = Marshal.StringToCoTaskMemUni(password);
if (!CredWrite(ref userCredential, (uint)0))
{
throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
}
}
finally
{
if (userCredential.CredentialBlob != null)
{
Marshal.FreeCoTaskMem(userCredential.CredentialBlob);
}
}
}
开发者ID:UhuruSoftware,项目名称:vcap-dotnet,代码行数:35,代码来源:SaveCredentials.cs
示例5: GetIndustryJobsAsync
public async Task<IEnumerable<IndustryJob>> GetIndustryJobsAsync(Credential credentials)
{
if (!(await AccessAllowed(credentials.AccessMask, CallEndPoint.IndustryJobs)))
throw new UnauthorizedAccessException();
return await _repo.GetIndustryJobsAsync(1, credentials);
}
开发者ID:Mikisto,项目名称:ApiService2,代码行数:7,代码来源:ApiService.cs
示例6: UserAuthenticated
private void UserAuthenticated(Credential credential)
{
if (credential != null)
{
DialogResult = true;
}
}
开发者ID:qwertylolman,项目名称:Stocktaking,代码行数:7,代码来源:Login.xaml.cs
示例7: GetTransactionsAsync
public async Task<IEnumerable<Transaction>> GetTransactionsAsync(Credential credentials)
{
if (!(await AccessAllowed(credentials.AccessMask, CallEndPoint.WalletTransactions)))
throw new UnauthorizedAccessException();
throw new NotImplementedException();
}
开发者ID:Mikisto,项目名称:ApiService2,代码行数:7,代码来源:ApiService.cs
示例8: PutCredential
public IHttpActionResult PutCredential(int id, Credential credential)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
if (id != credential.ID)
{
return BadRequest();
}
db.Entry(credential).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException)
{
if (!CredentialExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return StatusCode(HttpStatusCode.NoContent);
}
开发者ID:rmadziyauswa,项目名称:PasswordKeeper,代码行数:32,代码来源:CredentialsController.cs
示例9: Create
public ActionResult Create(CredentialCreateModel model)
{
if (ModelState.IsValid)
{
try
{
using (var db = new MySelfieEntities())
{
var entity = new Credential();
entity.MergeWithOtherType(model);
db.Credentials.Add(entity);
db.SaveChanges();
}
}
catch (Exception ex)
{
ModelState.AddModelError("ex", ex);
return View(model);
}
return RedirectToRoute("credential_index_g");
}
return View(model);
}
开发者ID:bennygrub,项目名称:msl,代码行数:31,代码来源:CredentialController.cs
示例10: ValidateCredentials
public bool ValidateCredentials(ICollection<Credential> credentials, string password, out Credential matched)
{
var ldapCred = credentials.FirstOrDefault(c => c.Type == CredentialType_LdapUser);
matched = ldapCred;
if (ldapCred != null)
{
try
{
LdapConnection connection = new LdapConnection(this.Configuration.Server);
connection.SessionOptions.SecureSocketLayer = true;
connection.SessionOptions.VerifyServerCertificate = (ldapConnection, certificate) =>
{
return true;
};
connection.AuthType = AuthType.Negotiate;
NetworkCredential credential = new NetworkCredential(ldapCred.Value, password);
connection.Credential = credential;
connection.Bind();
return true;
}
catch (Exception)
{
return false;
}
}
return false;
}
开发者ID:goitsk,项目名称:NuGetGallery,代码行数:30,代码来源:LdapService.cs
示例11: CheckPayooAccount
public String CheckPayooAccount(String username)
{
String result = "";
try
{
Credential credential = new Credential();
credential.APIUsername = ConfigurationManager.AppSettings["APIUsername"];
credential.APIPassword = ConfigurationManager.AppSettings["APIPassword"];
credential.APISignature = ConfigurationManager.AppSettings["APISignature"];
Caller caller = new Caller();
caller.InitCall(ConfigurationManager.AppSettings["PayooBusinessAPI"], credential,
Server.MapPath(@"..\App_Data\Certificates\biz_pkcs12.p12"), "alpe", Server.MapPath(@"..\App_Data\Certificates\payoo_public_cert.pem"));
CheckPayooAccountRequestType req = new CheckPayooAccountRequestType();
req.AccountID = username; // agentb2 ; vimp71 | [email protected]
CheckPayooAccountResponseType res = (CheckPayooAccountResponseType)caller.Call("CheckPayooAccount", req);
if (res.Ack == AckCodeType.Success)
{
result = "Valid";
}
else
{
result = "InValid Account";
}
}
catch (Exception ex)
{
result = "False";
throw ex;
}
return result;
}
开发者ID:centaurustech,项目名称:khainguyen-FirstStep,代码行数:34,代码来源:DuAnController.cs
示例12: AuthenticateAsync
public async Task<ICredential> AuthenticateAsync(Uri requestUri, Uri callbackUri = null)
{
var requestUriStrb = new StringBuilder();
requestUriStrb.Append(requestUri.AbsoluteUri);
if (callbackUri != null)
{
requestUriStrb.AppendFormat("&oauth_callback={0}", callbackUri.AbsoluteUri);
}
var listener = new HttpListener();
listener.Prefixes.Add(callbackUri.AbsoluteUri);
listener.Start();
System.Diagnostics.Process.Start(requestUriStrb.ToString());
var ctx = await listener.GetContextAsync();
var token = new Credential(ctx.Request.QueryString.Get("oauth_token"), ctx.Request.QueryString.Get("oauth_verifier"));
// empty response
// ctx.Response.ContentLength64 = 0;
// await ctx.Response.OutputStream.WriteAsync(new byte[0], 0, 0);
ctx.Response.OutputStream.Close();
listener.Stop();
return token;
}
开发者ID:luzianz,项目名称:TwitterClient,代码行数:29,代码来源:ConsoleWebAuthenticationBroker.cs
示例13: AddCredential
/// <summary>
/// Adds a credential to the credential locker.
/// </summary>
/// <param name="credential">The credential to be added.</param>
public static void AddCredential(Credential credential)
{
if (credential == null || string.IsNullOrEmpty(credential.ServiceUri))
return;
var serverInfo = IdentityManager.Current.FindServerInfo(credential.ServiceUri);
var host = serverInfo == null ? credential.ServiceUri : serverInfo.ServerUri;
string passwordValue = null; // value stored as password in the password locker
string userName = null;
var oAuthTokenCredential = credential as OAuthTokenCredential;
var arcGISTokenCredential = credential as ArcGISTokenCredential;
var arcGISNetworkCredential = credential as ArcGISNetworkCredential;
if (oAuthTokenCredential != null)
{
userName = oAuthTokenCredential.UserName;
if (!string.IsNullOrEmpty(oAuthTokenCredential.OAuthRefreshToken)) // refreshable OAuth token --> we store it so we'll be able to generate a new token from it
passwordValue = OAuthRefreshTokenPrefix + oAuthTokenCredential.OAuthRefreshToken;
else if (!string.IsNullOrEmpty(oAuthTokenCredential.Token))
passwordValue = OAuthAccessTokenPrefix + oAuthTokenCredential.Token;
}
else if (arcGISTokenCredential != null)
{
userName = arcGISTokenCredential.UserName;
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(arcGISTokenCredential.Password)) // Token generated from an username/password --> store the password
passwordValue = PasswordPrefix + arcGISTokenCredential.Password;
}
else if (arcGISNetworkCredential != null)
{
// networkcredential: store the password
if (arcGISNetworkCredential.Credentials != null)
{
NetworkCredential networkCredential = arcGISNetworkCredential.Credentials.GetCredential(new Uri(host), "");
if (networkCredential != null && !string.IsNullOrEmpty(networkCredential.Password))
{
userName = networkCredential.UserName;
if (!string.IsNullOrEmpty(networkCredential.Domain))
userName = networkCredential.Domain + "\\" + userName;
passwordValue = NetworkCredentialPasswordPrefix + networkCredential.Password;
}
}
}
// Store the value in the password locker
if (passwordValue != null)
{
var passwordVault = new PasswordVault();
var resource = ResourcePrefix + host;
// remove previous resource stored for the same host
try // FindAllByResource throws an exception when no pc are stored
{
foreach (PasswordCredential pc in passwordVault.FindAllByResource(resource))
passwordVault.Remove(pc);
}
catch {}
passwordVault.Add(new PasswordCredential(resource, userName, passwordValue));
}
}
开发者ID:skudev,项目名称:arcgis-toolkit-dotnet,代码行数:63,代码来源:CredentialManager.cs
示例14: UpdateDialog
public UpdateDialog(string fileName, Credential cred)
{
InitializeComponent();
FileName = fileName;
InitializeUI(cred);
}
开发者ID:nepalinazeer,项目名称:CredentialHub,代码行数:8,代码来源:UpdateDialog.cs
示例15: AddCredentialToCustomer
public void AddCredentialToCustomer(Credential credential, int customerID)
{
var customer = Customers.Where(c => c.ID == customerID).First();
credential.CustomerID = customer.ID;
credential.MyCustomer = customer;
customer.Credentials.Add(credential);
}
开发者ID:TheRealSplith,项目名称:Left4Edit,代码行数:8,代码来源:MemCustomerRepo.cs
示例16: AddCredentialToNode
public void AddCredentialToNode(Credential credential, int nodeID)
{
var node = CustDB.Nodes.Find(nodeID);
if (node == null)
throw new ArgumentException("Key not found");
node.Credentials.Add(credential);
}
开发者ID:TheRealSplith,项目名称:Left4Edit,代码行数:8,代码来源:EFCustomerRepo.cs
示例17: AddCredentialToCustomer
public void AddCredentialToCustomer(Credential credential, int customerID)
{
var customer = CustDB.Customers.Find(customerID);
if (customer == null)
throw new ArgumentException("Key not found");
customer.Credentials.Add(credential);
}
开发者ID:TheRealSplith,项目名称:Left4Edit,代码行数:8,代码来源:EFCustomerRepo.cs
示例18: AddCredential
/// <summary>
/// Adds a credential to the isolated storage.
/// </summary>
/// <param name="credential">The credential to be added.</param>
public static void AddCredential(Credential credential)
{
if (credential == null || string.IsNullOrEmpty(credential.ServiceUri))
return;
var serverInfo = IdentityManager.Current.FindServerInfo(credential.ServiceUri);
var host = serverInfo == null ? credential.ServiceUri : serverInfo.ServerUri;
string passwordValue = null; // value stored as password in the isolated storage
string userName = null;
var oAuthTokenCredential = credential as OAuthTokenCredential;
var arcGISTokenCredential = credential as ArcGISTokenCredential;
var arcGISNetworkCredential = credential as ArcGISNetworkCredential;
var certificateCredential = credential as CertificateCredential;
if (oAuthTokenCredential != null)
{
userName = oAuthTokenCredential.UserName;
if (!string.IsNullOrEmpty(oAuthTokenCredential.OAuthRefreshToken)) // refreshable OAuth token --> we store it so we'll be able to generate a new token from it
passwordValue = OAuthRefreshTokenPrefix + oAuthTokenCredential.OAuthRefreshToken;
else if (!string.IsNullOrEmpty(oAuthTokenCredential.Token))
passwordValue = OAuthAccessTokenPrefix + oAuthTokenCredential.Token;
}
else if (arcGISTokenCredential != null)
{
userName = arcGISTokenCredential.UserName;
if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(arcGISTokenCredential.Password)) // Token generated from an username/password --> store the password
passwordValue = PasswordPrefix + arcGISTokenCredential.Password;
}
else if (arcGISNetworkCredential != null)
{
// networkcredential: store the password
if (arcGISNetworkCredential.Credentials != null)
{
NetworkCredential networkCredential = arcGISNetworkCredential.Credentials.GetCredential(new Uri(host), "");
if (networkCredential != null && !string.IsNullOrEmpty(networkCredential.Password))
{
userName = networkCredential.UserName;
if (!string.IsNullOrEmpty(networkCredential.Domain))
userName = networkCredential.Domain + "\\" + userName;
passwordValue = NetworkCredentialPasswordPrefix + networkCredential.Password;
}
}
}
else if (certificateCredential != null)
{
// certificateCredential: store the serial number
if (certificateCredential.ClientCertificate != null)
{
passwordValue = CertificateCredentialPrefix + certificateCredential.ClientCertificate.GetSerialNumberString();
}
}
// Store the value in the isolated storage
if (passwordValue != null)
{
AddCachedCredential(host, userName, passwordValue);
}
}
开发者ID:skudev,项目名称:arcgis-toolkit-dotnet,代码行数:62,代码来源:CredentialManager.cs
示例19: Execute
public string Execute(Credential.CredentialBase credential)
{
Parameters.Clear();
Parameters.Add(_VenueId.ToString());
var result = Common.HttpPost(URL, Parameters, credential, HttpRequestMethod);
return result;
}
开发者ID:jonezy,项目名称:Epilogger-Collector,代码行数:9,代码来源:FlagDuplicate.cs
示例20: AddCredential
public void AddCredential(string type, string link)
{
var cred = new Credential();
cred.Type = type;
cred.Link = link;
cred.TenantId = TenantId;
this.Credentials.Add(cred);
}
开发者ID:jeswin,项目名称:CanYouCode,代码行数:9,代码来源:Consultant.cs
注:本文中的Credential类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论