{"id":52550,"date":"2010-07-14T16:26:28","date_gmt":"2010-07-14T13:26:28","guid":{"rendered":"https:\/\/www.altoros.com\/blog\/?p=52550"},"modified":"2020-05-10T20:22:26","modified_gmt":"2020-05-10T17:22:26","slug":"unity-and-aop-cross-cutting-security-functionality","status":"publish","type":"post","link":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/","title":{"rendered":"Unity and AOP: Cross-Cutting Security Functionality"},"content":{"rendered":"<p>With the release of <a href=\"https:\/\/github.com\/unitycontainer\/unity\" rel=\"noreferrer noopener\" target=\"_blank\">Unity 2.0<\/a>, a dependency injection container, the team at Altoros explored how to implement the capabilities of aspect-oriented programming with the help of the framework. In this post, we demonstrate how the paradigm works on the example of cross-cutting security functionality injection.<\/p>\n<p>&nbsp;<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#Challenge\" >Challenge<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#How_Unity_can_help\" >How Unity can help<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#About_the_author\" >About the author<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#Further_reading\" >Further reading<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Challenge\"><\/span>Challenge<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>In our example, there is a set of repositories that we can access from domain objects\u2014<code style=\"color: black; background-color: #e6e6e6;\">Employees<\/code>, <code style=\"color: black; background-color: #e6e6e6;\">Orders<\/code>, and <code style=\"color: black; background-color: #e6e6e6;\">Devices<\/code>. These objects are placed in different types of storage\u2014Active Directory, external ERP, or a locally stored XML file accordingly. Each repository has different underlying storage, so it is difficult to control user permissions. In our case, we also enable only users with admin roles to perform the <code style=\"color: black; background-color: #e6e6e6;\">create<\/code>\/<code style=\"color: black; background-color: #e6e6e6;\">edit<\/code>\/<code style=\"color: black; background-color: #e6e6e6;\">delete<\/code> operations for domain objects, while all the other users are limited to the read operations<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/repository.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/repository.jpg\" alt=\"\" width=\"600\" height=\"320\" class=\"alignnone size-full wp-image-52563\" \/><\/a><small>Performing key operations for domain objects in a repository<\/small><\/center><\/p>\n<p>With the help of <a href=\"https:\/\/nunit.org\/\" rel=\"noreferrer noopener\" target=\"_blank\">NUnit<\/a>, we have formulated these requirements in the following unit tests.<\/p>\n<p>1. Users with the admin role have the <code style=\"color: black; background-color: #e6e6e6;\">Save<\/code> functionality access. We also ran the same test for <code style=\"color: black; background-color: #e6e6e6;\">Delete<\/code>.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">  \r\n   &#x5B;Test]\r\n       public void CheckThatAdminHaveSaveAccess()\r\n       {\r\n           \/\/ init\r\n           Thread.CurrentPrincipal = new Principal(&quot;Admin&quot;);\r\n           \/\/ action\r\n           var result = employeeRepository.Save(new List&amp;lt;Employee&amp;gt;() {&lt;span&gt;new &lt;span&gt;Employee()});\r\n           \/\/ assert\r\n           Assert.AreEqual(result, 1);\r\n       }\r\n<\/pre>\n<p>2. Users with the user role do not have the <code style=\"color: black; background-color: #e6e6e6;\">Save<\/code> functionality access (the same for <code style=\"color: black; background-color: #e6e6e6;\">Delete<\/code>).<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">       \r\n &#x5B;Test]\r\n        &#x5B;ExpectedException(typeof(MethodAccessSecurityException))]\r\n        public void CheckThatUserHaveNotSaveAccess()\r\n        {\r\n            \/\/ init\r\n            Thread.CurrentPrincipal = new Principal(&quot;User&quot;);\r\n            \/\/ action\r\n            var result = employeeRepository.Save(new List&amp;lt;Employee&amp;gt;() {new Employee()});\r\n            \/\/ assert\r\n            Assert.AreEqual(result, 1);\r\n        }\r\n<\/pre>\n<p>3. Users with the user role have the <code style=\"color: black; background-color: #e6e6e6;\">Get<\/code> functionality access (the same for the admin role).<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">      \r\n&#x5B;Test]\r\n       public void CheckThatUserHaveGetAccess()\r\n       {\r\n            \/\/ init\r\n            Thread.CurrentPrincipal = new Principal(&quot;User&quot;);\r\n            \/\/ action\r\n            var result = employeeRepository.Get();\r\n            \/\/ assert\r\n            Assert.AreNotEqual(result.Count, 0);\r\n       }\r\n<\/pre>\n<p>The performed unit tests work for each type of the repositories mentioned above.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_Unity_can_help\"><\/span>How Unity can help<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>With cross-cut functionality injection, Unity provides possibility to intercept method calls by using call handlers (e.g., the <code style=\"color: black; background-color: #e6e6e6;\">ICallHandler<\/code> interface). This interface includes the <code style=\"color: black; background-color: #e6e6e6;\">invoke<\/code >method, which contains required functionality that should be executed before actual method execution. In our example, it will be permission to check functionality. In addition, this interface defines the <code style=\"color: black; background-color: #e6e6e6;\">Orders<\/code> property, which should return the call handler order number. This is useful in case of using several call handlers (we can specify the order of their execution).<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/the-unity-interseption-process.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/the-unity-interseption-process.jpg\" alt=\"\" width=\"600\" height=\"250\" class=\"alignnone size-full wp-image-52564\" \/><\/a><small>The Unity interception process (<a href=\"http:\/\/unitycontainer.org\/index.html\" rel=\"noreferrer noopener\" target=\"_blank\">Image credit<\/a>)<\/small><\/center><\/p>\n<p>After having our custom call handlers implemented, we should specify when and where they should be executed. Unity allows for several ways to do it. With the attribute approach, we should mark methods with custom attributes inherited from <code style=\"color: black; background-color: #e6e6e6;\">HandlerAttribute<\/code>. These attributes are responsible for appropriate call handler creation by overriding the <code style=\"color: black; background-color: #e6e6e6;\">CreateHandler<\/code> factory method.<\/p>\n<p>&nbsp;<br \/>\n<strong>Step 1<\/strong> <\/p>\n<p>First of all, we will create a call handler that should contain permission check logic.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">   \r\npublic class MethodAccessCallHandler : ICallHandler\r\n    {\r\n        private readonly string&#x5B;] roles;\r\n\r\n        public MethodAccessCallHandler(params string&#x5B;] roles)\r\n        {\r\n            this.roles = roles;\r\n        }\r\n\r\n        public IMethodReturn Invoke(IMethodInvocation input, GetNextHandlerDelegate\r\n                                                                                 getNext)\r\n        {\r\n            IPrincipal principal = Thread.CurrentPrincipal;\r\n            bool allowed = roles.Any(principal.IsInRole);\r\n            if (!allowed)\r\n                return input.CreateExceptionMethodReturn(new\r\n                                             Exceptions.MethodAccessSecurityException());\r\n            return getNext()(input, getNext);\r\n        }\r\n\r\n        public int Order { get; set; }\r\n    }\r\n<\/pre>\n<p>Our call handler throws <code style=\"color: black; background-color: #e6e6e6;\">MethodAccessSecurityException<\/code>, a custom exception inherited from <code style=\"color: black; background-color: #e6e6e6;\">ApplicationException<\/code>, in case of a permission check failure.<\/p>\n<p>&nbsp;<br \/>\n<strong>Step 2<\/strong> <\/p>\n<p>After that, we will create a custom attribute inherited from <code style=\"color: black; background-color: #e6e6e6;\">HandlerAttribute<\/code> that should override the <code style=\"color: black; background-color: #e6e6e6;\">CreateHandler<\/code> factory method for the appropriate call handler creation (see Step 1).<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">    \r\npublic class MethodAccessAttribute : HandlerAttribute\r\n    {\r\n        private readonly string&#x5B;] roles;\r\n\r\n        public MethodAccessAttribute(params string&#x5B;] roles)\r\n        {\r\n            this.roles = roles;\r\n        }\r\n\r\n        public override ICallHandler CreateHandler(IUnityContainer container)\r\n        {\r\n            return newMethodAccessCallHandler(roles);\r\n        }\r\n    }\r\n<\/pre>\n<p>&nbsp;<br \/>\n<strong>Step 3<\/strong> <\/p>\n<p>Then, we will mark the IRepository interface methods (permission to which should be controlled) with the attribute created during Step 2.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">    \r\npublic interface IRepository\r\n    {\r\n        &#x5B;MethodAccess(Roles.AdminRole, Roles.UserRole)]\r\n        IList&amp;lt;T&amp;gt; Get();\r\n\r\n        &#x5B;MethodAccess(Roles.AdminRole)]\r\n        int Save(IList&amp;lt;T&amp;gt; entities);\r\n\r\n        &#x5B;MethodAccess(Roles.AdminRole)]\r\n        int Delete(IList&amp;lt;Guid&amp;gt; ids);\r\n    }\r\n<\/pre>\n<p>By marking these methods, we actually add permission check functionality to all classes that will implement this interface. Now, you can run unit tests.<\/p>\n<p>Unity allows us to inject cross-cutting functionality with minimal efforts across such areas as domain object changes tracking, automatic <code style=\"color: black; background-color: #e6e6e6;\">PropertyChanged<\/code> event rising for all domain object properties, etc.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"About_the_author\"><\/span>About the author<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div>\n<div style=\"float: right;\"><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/Aliaksei-Yenzhyieuski.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/Aliaksei-Yenzhyieuski.png\" alt=\"\" width=\"120\" class=\"alignnone size-full wp-image-53179\" \/><\/a><\/div>\n<div style=\"width: 600px;\"><small><strong>Aliaksei Yenzhyieuski<\/strong> is Senior Software Engineer at Altoros with 16+ years of experience in software development. He is responsible for project management and team leading. Aliaksei can boast of solid expertise in computer science. Along with broad experience in implementation and maintenance of large-scale web, desktop, and mobile applications, he has strong object-oriented design and programming skills. In addition, Aliaksei is experienced in Agile and Scrum methodologies.<\/small><\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Further_reading\"><\/span>Further reading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/running-capybara-tests-for-ruby-applications-in-remote-browsers\/\">How to Run Capybara Tests for Ruby Applications in Remote Browsers<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/speeding-up-ruby-tests\/\">Speeding up Ruby Tests<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/linq-to-sql-alternative-to-the-where-in-expression\/\">Linq-To-Sql: Alternative to the \u2018WHERE IN\u2019 Expression<\/a><\/li>\n<p>&nbsp;<\/p>\n<hr\/>\n<p><small>This blog post was written by Aliaksei Yenzhyieuski; edited by <a href=\"https:\/\/www.altoros.com\/blog\/author\/olga\/\">Olga Belokurdkaya<\/a> and <a href=\"https:\/\/www.altoros.com\/blog\/author\/alex\/\">Alex Khizhniak<\/a>.<\/small><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the release of Unity 2.0, a dependency injection container, the team at Altoros explored how to implement the capabilities of aspect-oriented programming with the help of the framework. In this post, we demonstrate how the paradigm works on the example of cross-cutting security functionality injection.<\/p>\n<p>&nbsp;<\/p>\n<p>Challenge<\/p>\n<p>In our example, there is [&#8230;]<\/p>\n","protected":false},"author":5,"featured_media":52565,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[7],"tags":[895],"class_list":["post-52550","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news-and-opinion","tag-research-and-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Unity and AOP: Cross-Cutting Security Functionality | Altoros<\/title>\n<meta name=\"description\" content=\"Learn how to use Unity to inject custom security functionality to a target object with minimal efforts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Unity and AOP: Cross-Cutting Security Functionality | Altoros\" \/>\n<meta property=\"og:description\" content=\"With the release of Unity 2.0, a dependency injection container, the team at Altoros explored how to implement the capabilities of aspect-oriented programming with the help of the framework. In this post, we demonstrate how the paradigm works on the example of cross-cutting security functionality injection. &nbsp; Challenge In our example, there is [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/\" \/>\n<meta property=\"og:site_name\" content=\"Altoros\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-14T13:26:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-10T17:22:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/gif\" \/>\n<meta name=\"author\" content=\"Alex Khizhniak\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alex Khizhniak\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/\",\"name\":\"Unity and AOP: Cross-Cutting Security Functionality | Altoros\",\"isPartOf\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif\",\"datePublished\":\"2010-07-14T13:26:28+00:00\",\"dateModified\":\"2020-05-10T17:22:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3d914db6ad1b2908c32c0dc5dcabc420\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif\",\"width\":640,\"height\":360},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.altoros.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Unity and AOP: Cross-Cutting Security Functionality\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\",\"url\":\"https:\/\/www.altoros.com\/blog\/\",\"name\":\"Altoros\",\"description\":\"Insight\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.altoros.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3d914db6ad1b2908c32c0dc5dcabc420\",\"name\":\"Alex Khizhniak\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/06\/druzya-edit1-150x150.jpg\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/06\/druzya-edit1-150x150.jpg\",\"caption\":\"Alex Khizhniak\"},\"description\":\"Alex Khizhniak is Director of Technical Content Strategy at Altoros and a cofounder of a local Java User Group. Managing distributed teams since 2004, he has gained experience as a journalist, an editor-in-chief, a technical writer, a technology evangelist, a project manager, and a product owner. Alex is obsessed with AI\/ML, data science, data integration, ETL\/DWH, data quality, databases (SQL\/NoSQL), big data, IoT, and BI. The articles and industry reports he created or helped to publish reached out to 3,000,000+ tech-savvy readers. Some of the pieces were covered on TechRepublic, ebizQ, NetworkWorld, CIO.com, etc. Find him on Twitter at @alxkh.\",\"sameAs\":[\"https:\/\/x.com\/https:\/\/twitter.com\/alxkh\"],\"url\":\"https:\/\/www.altoros.com\/blog\/author\/alex\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Unity and AOP: Cross-Cutting Security Functionality | Altoros","description":"Learn how to use Unity to inject custom security functionality to a target object with minimal efforts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/","og_locale":"en_US","og_type":"article","og_title":"Unity and AOP: Cross-Cutting Security Functionality | Altoros","og_description":"With the release of Unity 2.0, a dependency injection container, the team at Altoros explored how to implement the capabilities of aspect-oriented programming with the help of the framework. In this post, we demonstrate how the paradigm works on the example of cross-cutting security functionality injection. &nbsp; Challenge In our example, there is [...]","og_url":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/","og_site_name":"Altoros","article_published_time":"2010-07-14T13:26:28+00:00","article_modified_time":"2020-05-10T17:22:26+00:00","og_image":[{"width":640,"height":360,"url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif","type":"image\/gif"}],"author":"Alex Khizhniak","twitter_misc":{"Written by":"Alex Khizhniak","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/","url":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/","name":"Unity and AOP: Cross-Cutting Security Functionality | Altoros","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage"},"image":{"@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif","datePublished":"2010-07-14T13:26:28+00:00","dateModified":"2020-05-10T17:22:26+00:00","author":{"@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3d914db6ad1b2908c32c0dc5dcabc420"},"breadcrumb":{"@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#primaryimage","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2010\/07\/unity-aop-featured-image.gif","width":640,"height":360},{"@type":"BreadcrumbList","@id":"https:\/\/www.altoros.com\/blog\/unity-and-aop-cross-cutting-security-functionality\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.altoros.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Unity and AOP: Cross-Cutting Security Functionality"}]},{"@type":"WebSite","@id":"https:\/\/www.altoros.com\/blog\/#website","url":"https:\/\/www.altoros.com\/blog\/","name":"Altoros","description":"Insight","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.altoros.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/3d914db6ad1b2908c32c0dc5dcabc420","name":"Alex Khizhniak","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/06\/druzya-edit1-150x150.jpg","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2017\/06\/druzya-edit1-150x150.jpg","caption":"Alex Khizhniak"},"description":"Alex Khizhniak is Director of Technical Content Strategy at Altoros and a cofounder of a local Java User Group. Managing distributed teams since 2004, he has gained experience as a journalist, an editor-in-chief, a technical writer, a technology evangelist, a project manager, and a product owner. Alex is obsessed with AI\/ML, data science, data integration, ETL\/DWH, data quality, databases (SQL\/NoSQL), big data, IoT, and BI. The articles and industry reports he created or helped to publish reached out to 3,000,000+ tech-savvy readers. Some of the pieces were covered on TechRepublic, ebizQ, NetworkWorld, CIO.com, etc. Find him on Twitter at @alxkh.","sameAs":["https:\/\/x.com\/https:\/\/twitter.com\/alxkh"],"url":"https:\/\/www.altoros.com\/blog\/author\/alex\/"}]}},"_links":{"self":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/52550","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/comments?post=52550"}],"version-history":[{"count":14,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/52550\/revisions"}],"predecessor-version":[{"id":54426,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/52550\/revisions\/54426"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media\/52565"}],"wp:attachment":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media?parent=52550"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/categories?post=52550"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/tags?post=52550"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}