AuthorizationRule
Namespace:
Azure.Messaging.ServiceBus
We found 10 examples in language CSharp for this search.
You will see 33 fragments of code.
Other methods
Other methods
Project:DataPlatformDemos
File:AuthorizationRuleWrapper.cs
Examples:1
#region Copyright
//=======================================================================================
// Microsoft Azure Customer Advisory Team
//
// This sample is supplemental to the technical guidance published on my personal
// blog at http://blogs.msdn.com/b/paolos/.
//
// Author: Paolo Salvatori
//=======================================================================================
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// LICENSED UNDER THE APACHE LICENSE, VERSION 2.0 (THE "LICENSE"); YOU MAY NOT USE THESE
// FILES EXCEPT IN COMPLIANCE WITH THE LICENSE. YOU MAY OBTAIN A COPY OF THE LICENSE AT
// http://www.apache.org/licenses/LICENSE-2.0
// UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, SOFTWARE DISTRIBUTED UNDER THE
// LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, EITHER EXPRESS OR IMPLIED. SEE THE LICENSE FOR THE SPECIFIC LANGUAGE GOVERNING
// PERMISSIONS AND LIMITATIONS UNDER THE LICENSE.
//=======================================================================================
#endregion
#region Using Directives
using System;
using Microsoft.ServiceBus.Messaging;
using System.Linq;
#endregion
namespace Microsoft.WindowsAzure.CAT.ServiceBusExplorer
{
public class AuthorizationRuleWrapper
{
#region Private Fields
private bool manage;
private bool send;
private bool listen;
private string keyName;
private string primaryKey;
private string secondaryKey;
private string claimType;
private string claimValue;
private string issuerName;
#endregion
#region Public Constructor
public AuthorizationRuleWrapper()
{
}
public AuthorizationRuleWrapper(AuthorizationRule rule)
{
KeyName = rule.KeyName;
if (rule is SharedAccessAuthorizationRule)
{
var sharedAccessAuthorizationRule = rule as SharedAccessAuthorizationRule;
PrimaryKey = sharedAccessAuthorizationRule.PrimaryKey;
SecondaryKey = sharedAccessAuthorizationRule.SecondaryKey;
}
Manage = rule.Rights.Contains(AccessRights.Manage);
Send = rule.Rights.Contains(AccessRights.Send);
Listen = rule.Rights.Contains(AccessRights.Listen);
ClaimType = rule.ClaimType;
ClaimValue = rule.ClaimValue;
IssuerName = rule.IssuerName;
Revision = rule.Revision;
CreatedTime = rule.CreatedTime;
ModifiedTime = rule.ModifiedTime;
AuthorizationRule = rule;
}
#endregion
#region Public Properties
public string KeyName
{
get
{
return keyName;
}
set
{
keyName = value;
if (AuthorizationRule != null)
{
AuthorizationRule.KeyName = value;
}
}
}
public string PrimaryKey
{
get
{
return primaryKey;
}
set
{
primaryKey = value;
var rule = AuthorizationRule as SharedAccessAuthorizationRule;
if (rule != null)
{
rule.PrimaryKey = value;
}
}
}
public string SecondaryKey
{
get
{
return secondaryKey;
}
set
{
secondaryKey = value;
var rule = AuthorizationRule as SharedAccessAuthorizationRule;
if (rule != null)
{
rule.SecondaryKey = value;
}
}
}
public string ClaimType
{
get
{
return claimType;
}
set
{
claimType = value;
if (AuthorizationRule != null)
{
AuthorizationRule.ClaimType = value;
}
}
}
public string ClaimValue
{
get
{
return claimValue;
}
set
{
claimValue = value;
if (AuthorizationRule != null)
{
AuthorizationRule.ClaimValue = value;
}
}
}
public string IssuerName
{
get
{
return issuerName;
}
set
{
issuerName = value;
if (AuthorizationRule != null)
{
AuthorizationRule.IssuerName = value;
}
}
}
public DateTime CreatedTime { get; private set; }
public DateTime ModifiedTime { get; private set; }
public long Revision { get; private set; }
public AuthorizationRule AuthorizationRule { get; private set; }
public bool Manage
{
get
{
return manage;
}
set
{
manage = value;
if (!value)
{
return;
}
Send = true;
Listen = true;
if (AuthorizationRule != null &&
!AuthorizationRule.Rights.Contains(AccessRights.Manage))
{
AuthorizationRule.Rights = new[] {AccessRights.Manage, AccessRights.Send, AccessRights.Listen};
}
}
}
public bool Send
{
get
{
return send;
}
set
{
send = value;
if (!value && manage)
{
Manage = false;
}
if (AuthorizationRule == null || AuthorizationRule.Rights.Contains(AccessRights.Send))
{
return;
}
var list = AuthorizationRule.Rights.ToList();
list.Add(AccessRights.Send);
AuthorizationRule.Rights = list;
}
}
public bool Listen
{
get
{
return listen;
}
set
{
listen = value;
if (!value && manage)
{
Manage = false;
}
if (AuthorizationRule == null || AuthorizationRule.Rights.Contains(AccessRights.Listen))
{
return;
}
var list = AuthorizationRule.Rights.ToList();
list.Add(AccessRights.Listen);
AuthorizationRule.Rights = list;
}
}
#endregion
}
}
/// <summary>将一个 <see cref="T:System.Web.Configuration.AuthorizationRule" /> 对象添加到集合中。</summary>
/// <param name="rule">要添加到集合的 <see cref="T:System.Web.Configuration.AuthorizationRule" /> 对象。</param>
public void AddRule(AuthorizationRule rule)
{
this.InnerList.Add((object) rule);
}
/// <summary>将该集合的内容复制到数组。</summary>
/// <param name="rules">将集合内容复制到的目标数组。</param>
/// <param name="index">从零开始的索引,从此处开始复制。</param>
public void CopyTo(AuthorizationRule[] rules, int index)
{
this.CopyTo((Array) rules, index);
}
Project:DotNetReferenceSource
File:AuthorizationRuleCollection.cs
Examples:6
// Protected Overrides
protected override ConfigurationElement CreateNewElement() {
return new AuthorizationRule();
}
protected override Object GetElementKey(ConfigurationElement element) {
AuthorizationRule rule = (AuthorizationRule)element;
return rule._ActionString;
}
// public methods
public void Add(AuthorizationRule rule) {
BaseAdd(-1, rule); // add to the end of the list and dont overwrite dups!
}
public AuthorizationRule Get(int index) {
return (AuthorizationRule)BaseGet(index);
}
public void Set(int index, AuthorizationRule rule) {
BaseAdd(index, rule);
}
public int IndexOf(AuthorizationRule rule) {
for (int x = 0; x < Count; x++) {
if (Object.Equals(Get(x), rule)) {
return x;
}
}
return -1;
}
Project:dotnet-src-all
File:AuthorizationRuleCollection.cs
Examples:6
// Protected Overrides
protected override ConfigurationElement CreateNewElement() {
return new AuthorizationRule();
}
protected override Object GetElementKey(ConfigurationElement element) {
AuthorizationRule rule = (AuthorizationRule)element;
return rule._ActionString;
}
// public methods
public void Add(AuthorizationRule rule) {
BaseAdd(-1, rule); // add to the end of the list and dont overwrite dups!
}
public AuthorizationRule Get(int index) {
return (AuthorizationRule)BaseGet(index);
}
public void Set(int index, AuthorizationRule rule) {
BaseAdd(index, rule);
}
public int IndexOf(AuthorizationRule rule) {
for (int x = 0; x < Count; x++) {
if (Object.Equals(Get(x), rule)) {
return x;
}
}
return -1;
}
Project:TMS
File:AuthorizationRuleRepo.cs
Examples:2
public AuthorizationRule FindByPK(int id)
{
return context.AuthorizationRule.Where(d => d.Id == id).FirstOrDefault();
}
public void delete(AuthorizationRule dbitem)
{
context.AuthorizationRule.Remove(dbitem);
var auditrail = new Auditrail { Actionnya = "Delete", EventDate = DateTime.Now, Modulenya = "General Setting", QueryDetail = "Delete " + dbitem.Id, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1 };
context.Auditrail.Add(auditrail);
context.SaveChanges();
}
Project:CodeAnalyzer
File:AuthorizationRuleTest.cs
Examples:2
[Test]
public void Defaults()
{
AuthorizationRule a = new AuthorizationRule(AuthorizationRuleAction.Deny);
Assert.AreEqual (AuthorizationRuleAction.Deny, a.Action, "A1");
Assert.IsNotNull (a.Roles, "A2");
Assert.IsNotNull (a.Users, "A3");
Assert.IsNotNull (a.Verbs, "A4");
}
[Test]
public void Test_EqualsAndHashCode ()
{
AuthorizationRule a = new AuthorizationRule (AuthorizationRuleAction.Deny);
AuthorizationRule b = new AuthorizationRule (AuthorizationRuleAction.Deny);
a.Users.Add ("toshok");
a.Roles.Add ("Admin");
a.Verbs.Add ("reboot");
b.Users.Add ("toshok");
b.Roles.Add ("Admin");
b.Verbs.Add ("reboot");
Assert.AreEqual (a, b, "A1");
Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "A2");
}
Project:playscript
File:AuthorizationRuleTest.cs
Examples:1
//
// AuthorizationRuleTest.cs
// - unit tests for System.Web.Configuration.AuthorizationRule
//
// Author:
// Chris Toshok <[email protected]>
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using NUnit.Framework;
using System;
using System.Configuration;
using System.Web.Configuration;
using System.Web;
using System.Web.Security;
using System.IO;
using System.Xml;
using System.Reflection;
namespace MonoTests.System.Web.Configuration {
[TestFixture]
public class AuthorizationRuleTest {
[Test]
public void Defaults()
{
AuthorizationRule a = new AuthorizationRule(AuthorizationRuleAction.Deny);
Assert.AreEqual (AuthorizationRuleAction.Deny, a.Action, "A1");
Assert.IsNotNull (a.Roles, "A2");
Assert.IsNotNull (a.Users, "A3");
Assert.IsNotNull (a.Verbs, "A4");
}
[Test]
public void Test_EqualsAndHashCode ()
{
AuthorizationRule a = new AuthorizationRule (AuthorizationRuleAction.Deny);
AuthorizationRule b = new AuthorizationRule (AuthorizationRuleAction.Deny);
a.Users.Add ("toshok");
a.Roles.Add ("Admin");
a.Verbs.Add ("reboot");
b.Users.Add ("toshok");
b.Roles.Add ("Admin");
b.Verbs.Add ("reboot");
Assert.AreEqual (a, b, "A1");
Assert.AreEqual (a.GetHashCode (), b.GetHashCode (), "A2");
}
[Test]
public void SerializeElement ()
{
StringWriter sw;
XmlWriter writer;
AuthorizationRule rule;
MethodInfo mi = typeof (AuthorizationRule).GetMethod ("SerializeElement", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
object[] parms = new object[2];
bool failed;
/* 1 */
failed = true;
try {
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
parms[0] = writer;
parms[1] = false;
mi.Invoke (rule, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A1");
failed = false;
}
Assert.IsFalse (failed, "A1");
/* 2 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
parms[0] = writer;
parms[1] = false;
mi.Invoke (rule, parms);
Assert.AreEqual ("<allow users=\"toshok\" />", sw.ToString(), "A2");
/* 2 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
parms[0] = writer;
parms[1] = true;
mi.Invoke (rule, parms);
Assert.AreEqual ("<allow users=\"toshok\" />", sw.ToString(), "A2");
/* 3-4 */
sw = new StringWriter ();
writer = new XmlTextWriter (sw);
rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Users.Add ("chris");
rule.Roles.Add ("admin");
rule.Roles.Add ("wheel");
rule.Verbs.Add ("GET");
rule.Verbs.Add ("PUT");
parms[0] = writer;
parms[1] = true;
bool b = (bool)mi.Invoke (rule, parms);
Assert.AreEqual ("<deny roles=\"admin,wheel\" users=\"toshok,chris\" verbs=\"GET,PUT\" />", sw.ToString(), "A3");
Assert.IsTrue (b, "A4");
}
[Test]
public void PostDeserialize ()
{
AuthorizationRule rule;
MethodInfo mi = typeof (AuthorizationRule).GetMethod ("PostDeserialize", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
object[] parms = new object[0];
bool failed;
/* 1 */
failed = true;
try {
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
mi.Invoke (rule, parms);
}
catch (TargetInvocationException e) {
Assert.AreEqual (typeof (ConfigurationErrorsException), e.InnerException.GetType (), "A1");
failed = false;
}
Assert.IsFalse (failed, "A1");
/* 2 */
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
mi.Invoke (rule, parms);
/* 2 */
rule = new AuthorizationRule (AuthorizationRuleAction.Allow);
rule.Users.Add ("toshok");
mi.Invoke (rule, parms);
/* 3-4 */
rule = new AuthorizationRule (AuthorizationRuleAction.Deny);
rule.Users.Add ("toshok");
rule.Users.Add ("chris");
rule.Roles.Add ("admin");
rule.Roles.Add ("wheel");
rule.Verbs.Add ("GET");
rule.Verbs.Add ("PUT");
mi.Invoke (rule, parms);
}
}
}
#endif
Project:aws-sdk-net
File:AuthorizationRuleUnmarshaller.cs
Examples:1
/// <summary>
/// Unmarshaller error response to exception.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public AuthorizationRule Unmarshall(JsonUnmarshallerContext context)
{
return null;
}
Project:DotNetReferenceSource
File:AuthorizationRuleCollection.cs
Examples:6
// Protected Overrides
protected override ConfigurationElement CreateNewElement() {
return new AuthorizationRule();
}
protected override Object GetElementKey(ConfigurationElement element) {
AuthorizationRule rule = (AuthorizationRule)element;
return rule._ActionString;
}
// public methods
public void Add(AuthorizationRule rule) {
BaseAdd(-1, rule); // add to the end of the list and dont overwrite dups!
}
public AuthorizationRule Get(int index) {
return (AuthorizationRule)BaseGet(index);
}
public void Set(int index, AuthorizationRule rule) {
BaseAdd(index, rule);
}
public int IndexOf(AuthorizationRule rule) {
for (int x = 0; x < Count; x++) {
if (Object.Equals(Get(x), rule)) {
return x;
}
}
return -1;
}
Project:NET-Reference-Source
File:AuthorizationRuleCollection.cs
Examples:6
// Protected Overrides
protected override ConfigurationElement CreateNewElement() {
return new AuthorizationRule();
}
protected override Object GetElementKey(ConfigurationElement element) {
AuthorizationRule rule = (AuthorizationRule)element;
return rule._ActionString;
}
// public methods
public void Add(AuthorizationRule rule) {
BaseAdd(-1, rule); // add to the end of the list and dont overwrite dups!
}
public AuthorizationRule Get(int index) {
return (AuthorizationRule)BaseGet(index);
}
public void Set(int index, AuthorizationRule rule) {
BaseAdd(index, rule);
}
public int IndexOf(AuthorizationRule rule) {
for (int x = 0; x < Count; x++) {
if (Object.Equals(Get(x), rule)) {
return x;
}
}
return -1;
}
Azure.Messaging.ServiceBus.Administration.AuthorizationRule : IEquatable
Methods :
public abstract String get_ClaimType()public abstract List<AccessRights> get_Rights()
public abstract Void set_Rights(List<AccessRights> value = )
public abstract String get_KeyName()
public abstract Void set_KeyName(String value = )
public DateTimeOffset get_CreatedTime()
public DateTimeOffset get_ModifiedTime()
public abstract Boolean Equals(AuthorizationRule other = )
public abstract Boolean Equals(Object obj = )
public Int32 GetHashCode()
public Type GetType()
public String ToString()