本文整理汇总了C#中Policy类的典型用法代码示例。如果您正苦于以下问题:C# Policy类的具体用法?C# Policy怎么用?C# Policy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Policy类属于命名空间,在下文中一共展示了Policy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// create web service proxy
// NOTE!!! When updating web reference in Visual Studio,
// don't forget to change its base class to Microsoft.Web.Services3.WebServicesClientProtocol then
WseSample.Service srv = new WseSample.Service();
// create custom SOAP header and assign it to web service
WseSample.BankAccountSettings settings = new WseSample.BankAccountSettings();
settings.PinCode = "1111";
srv.BankAccountSettingsValue = settings;
// create custom policy assertion and assign it to proxy
// for password we just use reversed username
// it's important, because UsernameTokenManager on the service side applies the same logic
// when looking for user password
UsernameClientAssertion assert = new UsernameClientAssertion("admin", "nimda");
// create policy
Policy policy = new Policy();
policy.Assertions.Add(assert);
// and set it to web service
srv.SetPolicy(policy);
// invoke web service method
bool valid = srv.CheckAccountStatus("123456");
Debug.WriteLine(valid);
}
示例2: Main
static void Main(string[] args)
{
MyMathServiceWse serviceProxy = new MyMathServiceWse();
//UsernameToken token = new UsernameToken("zhang3", "f0f5671b9ec568d03cbe126ce135a8b3d6ce6ab2", PasswordOption.SendPlainText);
//serviceProxy.SetClientCredential(token);
//X509Certificate2 myServerCert = new X509Certificate2("myServer.pem.cer");
//serviceProxy.SetServiceCredential(new X509SecurityToken(myServerCert));
UsernameForCertificateAssertion assert = new UsernameForCertificateAssertion();
assert.RenewExpiredSecurityContext = true;
assert.RequireSignatureConfirmation = false;
assert.Protection.DefaultOperation.Request.CustomSignedHeaders.Clear();
assert.Protection.DefaultOperation.Request.EncryptBody = true;
assert.Protection.DefaultOperation.Request.SignatureOptions = SignatureOptions.IncludeNone;
assert.Protection.DefaultOperation.Response.EncryptBody = false;
assert.Protection.DefaultOperation.Response.SignatureOptions = SignatureOptions.IncludeNone;
MutualCertificate10Assertion assertion1 = new MutualCertificate10Assertion()
{
EstablishSecurityContext = false,
RenewExpiredSecurityContext = true,
RequireSignatureConfirmation = false,
MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt,
RequireDerivedKeys = false,
TtlInSeconds = 300
};
//assertion1.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.My, "CN=myClient,OU=R & D department,O=BJ SOS Software Tech Co.\\, Ltd,L=Beijing,ST=Beijing,C=CN", X509FindType.FindBySubjectDistinguishedName);
assertion1.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.My, "1364458997", X509FindType.FindBySerialNumber);
assertion1.ServiceX509TokenProvider = new X509TokenProvider(StoreLocation.CurrentUser, StoreName.AddressBook, "1364458964", X509FindType.FindBySerialNumber);
Console.Out.WriteLine(111);
Console.Out.WriteLine(assertion1.ClientX509TokenProvider.GetToken());
Console.Out.WriteLine(111);
Console.Out.WriteLine(assertion1.ServiceX509TokenProvider.GetToken());
Console.Out.WriteLine(222);
//protection
assertion1.Protection.Request.SignatureOptions = SignatureOptions.IncludeSoapBody;
assertion1.Protection.Request.EncryptBody = true;
assertion1.Protection.Response.SignatureOptions = SignatureOptions.IncludeSoapBody;
assertion1.Protection.Response.EncryptBody = true;
assertion1.Protection.Fault.SignatureOptions = SignatureOptions.IncludeSoapBody;
assertion1.Protection.Fault.EncryptBody = false;
Policy policy = new Policy();
policy.Assertions.Add(assertion1);
serviceProxy.SetPolicy(policy);
//serviceProxy.RequestSoapContext.Addressing.Action = new Action("http://www.test.me/MyMath/add");
addRequest req = new addRequest();
req.x = 1;
req.y = 2;
addResponse resp = serviceProxy.add(req);
Console.Out.WriteLine("resp = " + [email protected]);
}
示例3: Forum
public Forum(String name, List<User> admins, Policy policy)
{
if (name == null || name.Length < 1)
{
Console.Out.WriteLine("Error: u idiot");
}
else if (admins == null || admins.Count < 1)
{
Console.Out.WriteLine("Error: u idiot2");
}
else if (policy == null)
{
Console.Out.WriteLine("Error: u idiot3");
}
else
{
this.name = name;
for (int i = 0; i < admins.Count; i++)
{
this.members.Add(admins.ElementAt(i));
this.admins.Add(i);
}
subforums = new List<SubForum>();
this.policy = policy;
}
}
示例4: Enqueue
public static void Enqueue(WaitCallback callback, Policy policy)
{
switch(policy)
{
case Policy.Immediate:
logger.Info("Immediately running callback {0}",
callback.Method.Name);
ThreadPool.QueueUserWorkItem(new WaitCallback(callback));
break;
case Policy.Queued:
lock (queue)
{
if (cooledDown)
{
logger.Info("Immediately putting callback {0}",
callback.Method.Name);
ThreadPool.QueueUserWorkItem(
new WaitCallback(callback));
}
else
{
logger.Debug("Queuing callback {0} for later execution",
callback.Method.Name);
queue.Add(callback);
}
}
break;
}
}
示例5: ReadJsonStringToPolicy
public static Policy ReadJsonStringToPolicy(string jsonString)
{
Policy policy = new Policy();
JsonData jPolicy = JsonMapper.ToObject(jsonString);
if (jPolicy[JsonDocumentFields.POLICY_ID] != null && jPolicy[JsonDocumentFields.POLICY_ID].IsString)
{
policy.Id = (string)jPolicy[JsonDocumentFields.POLICY_ID];
}
JsonData jStatements = jPolicy[JsonDocumentFields.STATEMENT] as JsonData;
if (jStatements != null && jStatements.IsArray)
{
foreach (JsonData jStatement in jStatements)
{
Statement statement = convertStatement(jStatement);
if (statement != null)
{
policy.Statements.Add(statement);
}
}
}
return policy;
}
示例6: Configure
public void Configure(WebServicesClientProtocol proxy)
{
// set proxy URL
string serverUrl = enterpriseServerUrl.Trim();
if (serverUrl.Length == 0)
throw new Exception("Enterprise Server URL could not be empty");
int idx = proxy.Url.LastIndexOf("/");
// strip the last slash if any
if (serverUrl[serverUrl.Length - 1] == '/')
serverUrl = serverUrl.Substring(0, serverUrl.Length - 1);
proxy.Url = serverUrl + proxy.Url.Substring(idx);
// set timeout
proxy.Timeout = 900000; //15 minutes // System.Threading.Timeout.Infinite;
if (!String.IsNullOrEmpty(username))
{
// create assertion
UsernameAssertion assert = new UsernameAssertion(username, password);
// apply policy
Policy policy = new Policy();
policy.Assertions.Add(assert);
proxy.SetPolicy(policy);
}
}
示例7: TextUndoTransaction
public TextUndoTransaction(TextUndoHistory textUndoHistory, ITextUndoTransaction parent)
{
_textUndoHistory = textUndoHistory;
_state = UndoTransactionState.Open;
_parent = parent;
MergePolicy = new Policy();
}
示例8: Page_Init
protected void Page_Init(object sender, EventArgs e)
{
ctx = new AriClinicContext("AriClinicContext");
// security control, it must be a user logged
if (Session["User"] == null)
Response.Redirect("Default.aspx");
else
{
user = CntAriCli.GetUser((Session["User"] as User).UserId, ctx);
Process proc = (from p in ctx.Processes
where p.Code == "policy"
select p).FirstOrDefault<Process>();
per = CntAriCli.GetPermission(user.UserGroup, proc, ctx);
btnAccept.Visible = per.Modify;
}
//
if (Request.QueryString["CustomerId"] != null)
{
patientId = Int32.Parse(Request.QueryString["CustomerId"]);
pat = CntAriCli.GetCustomer(patientId, ctx);
txtCustomer.Text = pat.FullName;
}
//
if (Request.QueryString["PolicyId"] != null)
{
policyId = Int32.Parse(Request.QueryString["PolicyId"]);
pol = CntAriCli.GetPolicy(policyId, ctx);
LoadData(pol);
}
else
{
LoadTypeCombo(null);
LoadInsuranceCombo(null);
}
}
示例9: AddAssertion
public void AddAssertion(PolicyAssertion assertion)
{
if (_securityPolicy == null)
_securityPolicy = new Policy();
_securityPolicy.Assertions.Add(assertion);
}
示例10: Executing_the_asynchronous_policies_using_the_synchronous_execute_should_throw_an_invalid_operation_exception
public void Executing_the_asynchronous_policies_using_the_synchronous_execute_should_throw_an_invalid_operation_exception(Policy asyncPolicy, string description)
{
Action action = () => asyncPolicy.Execute(() => { });
action.ShouldThrow<InvalidOperationException>()
.WithMessage("Please use the synchronous Retry, RetryForever, WaitAndRetry or CircuitBreaker methods when calling the synchronous Execute method.");
}
示例11: PolicyDomainModel
public PolicyDomainModel(Policy policyEntity)
{
Id = policyEntity.Id;
Number = policyEntity.Number;
SerialNumber = policyEntity.SerialNumber;
DeviceName = policyEntity.DeviceName;
}
示例12: writePolicy
private void writePolicy(Policy policy, JsonWriter generator)
{
generator.WriteObjectStart();
writePropertyValue(generator, JsonDocumentFields.VERSION, policy.Version);
if (policy.Id != null)
{
writePropertyValue(generator, JsonDocumentFields.POLICY_ID, policy.Id);
}
generator.WritePropertyName(JsonDocumentFields.STATEMENT);
generator.WriteArrayStart();
foreach (Statement statement in policy.Statements)
{
generator.WriteObjectStart();
if (statement.Id != null)
{
writePropertyValue(generator, JsonDocumentFields.STATEMENT_ID, statement.Id);
}
writePropertyValue(generator, JsonDocumentFields.STATEMENT_EFFECT, statement.Effect.ToString());
writePrincipals(statement, generator);
writeActions(statement, generator);
writeResources(statement, generator);
writeConditions(statement, generator);
generator.WriteObjectEnd();
}
generator.WriteArrayEnd();
generator.WriteObjectEnd();
}
示例13: AsyncExists
public AsyncExists(AsyncCluster cluster, Policy policy, Key key, ExistsListener listener)
: base(cluster)
{
this.policy = policy;
this.listener = listener;
this.key = key;
this.partition = new Partition(key);
}
示例14: Init
/// <summary>
/// 对某个WS进行初始化
/// </summary>
/// <param name="ws"></param>
/// <param name="username"></param>
/// <param name="password"></param>
public static void Init(WebServicesClientProtocol ws, string username, string password)
{
AppContext.UserName = username;
AppContext.Password = password;
Policy policy = new Policy();
policy.Assertions.Add(new MyAssertion());
ws.SetPolicy(policy);
}
示例15: ExsistingPolicy
public bool ExsistingPolicy(Policy toCheck)
{
var currentList = GetAll();
foreach (var c in currentList)
{
if (c.Title == toCheck.Title)
return true;
}
return false;
}