本文整理汇总了C#中Credentials类的典型用法代码示例。如果您正苦于以下问题:C# Credentials类的具体用法?C# Credentials怎么用?C# Credentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Credentials类属于命名空间,在下文中一共展示了Credentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateFromSourcedMo_Agreed
public void UpdateFromSourcedMo_Agreed()
{
using (TestMqServiceClient mq = new TestMqServiceClient())
{
Referral referral = (new SetData()).MinRegister();
Credentials cr = new Credentials { Organization = idLpu, Token = guid };
var result = mq.Register(cr, referral);
//обновляем данные
referral = (new SetData()).MinUpdateFromSourcedMo(result.IdMq);
referral.EventsInfo = new EventsInfo
{
Source = new EventSource
{
IsReferralReviewed = true,
ReferralCreateDate = ReferralData.eventsInfo.Source.ReferralCreateDate,
ReferralReviewDate = ReferralData.eventsInfo.Source.ReferralReviewDate
}
};
var updateResult = mq.UpdateFromSourcedMo(cr, referral);
}
if (Global.errors == "")
Assert.Pass();
else
Assert.Fail(Global.errors);
}
示例2: Test
public static void Test(string userName, string password, string sport)
{
ICredentials credentials = new Credentials { UserName = userName, Password = password };
var theSession = SessionFactory.CreateSession(new Uri(_url), credentials);
//Get the Unified Data Service
var theService = theSession.GetService("UnifiedDataAPI");
var theFeature = theService.GetFeature(sport);
//Get all the Resources (Fixtures) for the given sport
var theResources = theFeature.GetResources();
//Grab the first one, this is only an example after all
var theResource = theResources.First();
//Get the snapshot
var theSnapshot = theResource.GetSnapshot();
var fixtureSnapshot = JsonConvert.DeserializeObject<Fixture>(theSnapshot, new JsonSerializerSettings { Converters = new List<JsonConverter> { new IsoDateTimeConverter() }, NullValueHandling = NullValueHandling.Ignore });
System.Console.WriteLine(theSnapshot);
theResource.StreamConnected += (sender, args) => System.Console.WriteLine("Stream Connected");
theResource.StreamEvent += (sender, args) => System.Console.WriteLine(args.Update);
theResource.StreamDisconnected += (sender, args) => System.Console.WriteLine("Stream Disconnected");
//Start Streaming
theResource.StartStreaming();
//Wait 60 seconds, then stop the Stream
Thread.Sleep(600000);
theResource.StopStreaming();
}
示例3: GetCredentials
private Credentials GetCredentials()
{
var credentials = new Credentials();
try
{
if ( UserName.IsNullOrEmptyOrWhiteSpace() )
{
ErrorMessage = "The username field should not be empty";
return null;
}
if (TokenData.IsNullOrEmptyOrWhiteSpace())
{
ErrorMessage = AppResources.InvalidToken;
return null;
}
var tokenParts = TokenData.Split('/');
if ( tokenParts.Length != 2 || tokenParts[0].IsNullOrEmptyOrWhiteSpace() || tokenParts[1].IsNullOrEmptyOrWhiteSpace() )
{
ErrorMessage = AppResources.InvalidToken;
return null;
}
var identity = tokenParts[0];
var token = tokenParts[1];
credentials.Username = UserName;
credentials.Token = token;
credentials.Identity = identity;
}
catch ( Exception )
{
return null;
}
return credentials;
}
示例4: createTicketGrantingTicket
/** The validators to check the Credentials. */
//@NotNull
//private Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
/**
* @throws IllegalArgumentException if the Credentials are null or if given
* invalid credentials.
*/
public string createTicketGrantingTicket(Credentials credentials)
{
//Assert.notNull(credentials, "credentials cannot be null");
this.checkForErrors(credentials);
return this.centralAuthenticationService.createTicketGrantingTicket(credentials);
}
示例5: Authenticator
public Authenticator(Credentials credentials, IXmlSerializer serializer)
{
Ensure.ArgumentNotNull(credentials, "credentials");
Credentials = credentials;
_valueProvider = new SignatureValueProvider(serializer);
}
示例6: Init
private void Init()
{
if (ConfigurationReader == null)
{
ConfigurationReader = new zVirtualScenesHub.API.Configuration.WindowsStorageConfigurationReader();
}
try
{
Credentials = new Credentials();
var profilesIndex = ConfigurationReader.ReadSetting<string>("Profiles").Result;
if (!string.IsNullOrEmpty(profilesIndex))
{
Credentials = NewtonSerializer<Credentials>.FromJSON<Credentials>(profilesIndex);
foreach (var c in Credentials)
{
if (c.Default)
{
DefaultCredential = c;
break;
}
}
}
}
catch (Exception)
{
}
}
示例7: Equality
public void Equality()
{
Credentials oneA = new Credentials("a", "a", ServiceAccount.LocalService);
Credentials oneB = new Credentials("a", "a", ServiceAccount.LocalService);
Credentials two = new Credentials("2", "a", ServiceAccount.LocalService);
Credentials three = new Credentials("a", "2", ServiceAccount.LocalService);
Credentials four = new Credentials("a", "a", ServiceAccount.User);
oneA.Equals(oneA)
.ShouldBeTrue("instance equality");
oneA.Equals(oneB)
.ShouldBeTrue("value equality");
oneA.Equals(two)
.ShouldBeFalse("username");
oneA.Equals(three)
.ShouldBeFalse("password");
oneA.Equals(four)
.ShouldBeFalse("service account");
oneA.Equals(null)
.ShouldBeFalse("null");
}
示例8: TryAuthentifcate
public bool TryAuthentifcate(Credentials credentials, out Model.UserIdentity identity)
{
identity = null;
using (var database = DatabaseFactory.GetDatabase())
{
User user = database.Query<User>().FirstOrDefault(x => x.Name == credentials.UserName);
// Check if there is a User:
if (user == null)
{
return false;
}
// Make sure the Hashed Passwords match:
if (user.PasswordHash != cryptoService.ComputeHash(credentials.Password, user.PasswordSalt))
{
return false;
}
// We got a User, now obtain his claims from DB:
IList<Claim> claims = database.Fetch<Claim>(@"
select c.*
from auth.user u
inner join auth.user_claim uc on u.user_id = uc.user_id
inner join auth.claim c on uc.claim_id = c.claim_id
where u.user_id = @0", user.Id);
// And return the UserIdentity:
identity = Convert(user, claims);
return true;
}
}
示例9: ConnectToEWS
static private EWSConnection ConnectToEWS(Credentials credentials)
{
Logger.DebugFormat("Initializing FolderMailboxManager for email adderss {0}", credentials.EmailAddress);
var exchangeService = new ExchangeService(ExchangeVersion.Exchange2010_SP1)
{
Credentials = new WebCredentials(credentials.UserName, credentials.Password),
Timeout = 60000
};
exchangeService.AutodiscoverUrl(
credentials.EmailAddress,
x =>
{
Logger.DebugFormat("Following redirection for EWS autodiscover: {0}", x);
return true;
}
);
Logger.DebugFormat("Service URL: {0}", exchangeService.Url);
return new EWSConnection()
{
Service = exchangeService,
Router =
new RecipientsMailboxManagerRouter(
new EWSMailFolder(Folder.Bind(exchangeService, WellKnownFolderName.Inbox)))
};
}
示例10: Should_be_possible_be_possible_to_get_all_credential_informations
public void Should_be_possible_be_possible_to_get_all_credential_informations()
{
var credentials = new Credentials("mss", "lfernandes", "123456\\b", "RooT");
AssertCredentials(credentials, "mss", "lfernandes", "RooT");
Assert.AreEqual("123456\\b", credentials.GetPassword(), "An unexpected password value was found.");
}
示例11: If_username_was_given_with_embedded_domain_the_domain_field_must_be_ignored
public void If_username_was_given_with_embedded_domain_the_domain_field_must_be_ignored()
{
var credentialsWithDomainEmbeddedInUsernameAndInDomainField =
new Credentials(".", @"10.1.1.1\oval", string.Empty, string.Empty);
AssertCredentials(credentialsWithDomainEmbeddedInUsernameAndInDomainField, "10.1.1.1", "oval", string.Empty);
}
示例12: TabViewModelBase
//public delegate void TournamentsUpdatedEventHandler(object sender, EventArgs e);
//protected event TournamentsUpdatedEventHandler TournamentsUpdatedEvent
public TabViewModelBase()
{
if(Credentials == null)
{
Credentials = new Credentials();
}
}
示例13: GetResultDocument_NotEmptyDoc
public void GetResultDocument_NotEmptyDoc()
{
using (MqServiceClient mq = new MqServiceClient())
{
//Задаём статус направления "Зарегистрировано в РЕГИЗ.УО"
Referral referral = (new SetData()).MinRegister();
Credentials cr = new Credentials { Organization = idLpu, Token = guid };
var result = mq.Register(cr, referral);
//Задаём статус "Выдано пациенту"
referral = (new SetData()).SetStatus_PatientDocumentIssue(result.IdMq);
var res2 = mq.UpdateFromSourcedMo(cr, referral);
//Задаём статус "Выделена единица ресурса, целевой МО назначена дата приема"
referral = (new SetData()).MinChangePlannedResource(result.IdMq);
var res3 = mq.ChangePlannedResource(cr, referral);
//Задаём статус "Начато оказание медицинской помощи в целевой МО"
referral = (new SetData()).SetStatus_HealthCareStart(result.IdMq);
var res4 = mq.UpdateFromTargetMo(cr, referral);
//Задаём статус "Завершено оказание медицинской помощи в целевой МО"
referral = (new SetData()).SetStatus_HealthCareEnd(result.IdMq);
var res5 = mq.UpdateFromTargetMo(cr, referral);
referral = (new SetData()).GetResultDocument(result.IdMq);
var res6 = mq.GetResultDocument(cr, referral);
}
if (Global.errors == "")
Assert.Pass();
else
Assert.Fail(Global.errors);
}
示例14: CredentialStore
public CredentialStore(Configuration.IConfigurationReader configurationReader = null)
{
ConfigurationReader = configurationReader;
if (ConfigurationReader == null)
{
#if WINDOWS_PHONE
ConfigurationReader = new Configuration.IsolatedStorageConfigurationReader();
#else
ConfigurationReader = new Configuration.AppConfigConfigurationReader();
#endif
}
Credentials = new Credentials();
var profilesIndex = ConfigurationReader.ReadSetting<string>("Profiles");
if (!string.IsNullOrEmpty(profilesIndex))
{
Credentials = Newtonsoft.Json.JsonConvert.DeserializeObject<Credentials>(profilesIndex);
foreach (var c in Credentials)
{
if (c.Default)
{
DefaultCredential = c;
break;
}
}
}
SetupDefault();
}
示例15: CredentialStoreTest
private void CredentialStoreTest(string url, string username, string password)
{
try
{
Uri uri = new Uri(url, UriKind.Absolute);
Credentials writeCreds = new Credentials(username, password);
Credentials readCreds = null;
ICredentialStore priamryStore = new CredentialStore("prime-test");
priamryStore.WriteCredentials(uri, writeCreds);
if (priamryStore.ReadCredentials(uri, out readCreds))
{
Assert.AreEqual(writeCreds.Password, readCreds.Password, "Passwords did not match between written and read credentials");
Assert.AreEqual(writeCreds.Username, readCreds.Username, "Usernames did not match between written and read credentials");
}
else
{
Assert.Fail("Failed to read credentials");
}
priamryStore.DeleteCredentials(uri);
Assert.IsFalse(priamryStore.ReadCredentials(uri, out readCreds), "Deleted credentials were read back");
}
catch (Exception exception)
{
Assert.Fail(exception.Message);
}
}