<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rantings in the dark &#187; programming</title>
	<atom:link href="http://kinsey.no/blog/index.php/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://kinsey.no/blog</link>
	<description>Because I want to be like the cool kids too</description>
	<lastBuildDate>Fri, 09 Jul 2010 17:11:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to set up an AD backed OpenID Provider without direct communication</title>
		<link>http://kinsey.no/blog/index.php/2010/07/09/how-to-set-up-an-ad-backed-openid-provider-without-direct-communication/</link>
		<comments>http://kinsey.no/blog/index.php/2010/07/09/how-to-set-up-an-ad-backed-openid-provider-without-direct-communication/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 17:11:41 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[easyXDM]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[active-directory]]></category>
		<category><![CDATA[ad]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=290</guid>
		<description><![CDATA[I&#8217;ve currently got a project where I need to provide an OpenID Provider (OP) to authenticate users using Active Directory (AD), something that shouldn&#8217;t be to much of a hassle. But there is a catch: the OP needs to be outside the firewall in order to talk to the Relying Parties (RP) and is unable [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2010%252F07%252F09%252Fhow-to-set-up-an-ad-backed-openid-provider-without-direct-communication%252F%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2Fddm8l5%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20set%20up%20an%20AD%20backed%20OpenID%20Provider%20without%20direct%20communication%22%20%7D);"></div>
<p>I&#8217;ve currently got a project where I need to provide an <a href="http://openid.net/specs/openid-authentication-2_0.html#terminology" target="_blank">OpenID Provider</a> (OP) to authenticate users using Active Directory (AD), something that shouldn&#8217;t be to much of a hassle.<br />
<b>But there is a catch:</b> the OP needs to be <i>outside</i> the firewall in order to talk to the <a href="http://openid.net/specs/openid-authentication-2_0.html#terminology" target="_blank">Relying Parties</a> (RP) and is unable to communicate directly with AD. <b>So what can you do?</b><br />
<span id="more-290"></span><br />
<img class="size-medium wp-image-292 alignright" title="easyxdm-openid" src="http://kinsey.no/blog/wp-content/uploads/2010/07/easyxdm-openid-300x225.png" alt="" width="300" height="225" />Well, in this case the OP is only going to be used by users that are sitting <i>behind</i> the firewall, and who have access to both internal resources and external resources over port 80, and what this means is that we can use the client (the browser) to relay messages between the OP and the asserting party. In order to make the communication going via the browser trusted, we can use a challenge combined with symmetric encryption to verify authenticity.</p>
<p>This means that the chain of trust needed for the identity assertion looks like the following</p>
<ul>
<li>The RP trust the assertion from the OP
<ul>
<li>The RP and the OP shares can communicate directly and uses a shared secret to verify the authenticity of the message passed through the browser</li>
</ul>
</li>
<li>The RP trusts the assertion from the Internal Webserver (IW)
<ul>
<li>The RP and the IW has a pre-shared encryption key that together with a challenge serves to verify the authenticity of the messages passed through the browser</li>
</ul>
</li>
</ul>
<p><b>In the following code <a href="dotnetopenauth.net/" target="_blank">DotNetOpenAuth </a>is used to provide support for OpenID, and <a href="http://easyxdm.net/" target="_blank">easyXDM</a> is used to provide the Cross-Document Communication.</b><br/><br />
Codewise, it all starts once the OpenID request hits the OP, and at this point we only store away the request and render a blank page containing the following JavaScript<br/></p>
<pre class="brush: jscript;">
// server.aspx
// This is called by ASP.NET Ajax once the page is ready
function pageLoad() {
    // Set up a new easyXDM.Rpc object
    var rpc = new easyXDM.Rpc({
        remote: &quot;http://localhost:55192/Endpoint.aspx&quot;
    }, {
        remote: {
            authenticate: {}
        }
    });

    // Retrieve a challenge from the server
    PageMethods.GetChallenge(function (challenge) {
        // Relay the challenge to the internal webserver
        rpc.authenticate(challenge, function (response) {
            // Relay the response back to the server
            PageMethods.VerifyResponse(response, function (verified) {
                // If the response was verified, we redirect to the page that will complete the OpenID assertion
                if (verified) {
                    location.href = &quot;complete.aspx&quot;;
                } else {
                    alert(&quot;not authenticated&quot;);
                }
            });
        });
    });
}
</pre>
<p>As you can see this uses PageMethods to talk to the server side code for retrieving the challenge, and for delivering the response</p>
<pre class="brush: vb;">
'server.aspx
&lt;WebMethod()&gt; _
Public Shared Function GetChallenge() As Utilities.Challenge
    ' This method is called to create a challenge, and to get access to the claimed identifier that the internal webserver will have to verify
    ' Create and store away a challenge
    Dim challenge As New Utilities.Challenge
    challenge.Guid = System.Guid.NewGuid().ToString()
    HttpContext.Current.Session(&quot;guid&quot;) = challenge.Guid

    If providerEndpoint.PendingAuthenticationRequest IsNot Nothing Then
        challenge.Identifier = providerEndpoint.PendingAuthenticationRequest.ClaimedIdentifier.OriginalString
    End If
    ' Return a Plain Old CRL Object (POCO). This will be serialized into JSON
    Return challenge
End Function

&lt;WebMethod()&gt; _
Public Shared Function VerifyResponse(ByVal response As String) As Boolean
    ' This method will be called after the response returns from the internal webserver
    If providerEndpoint.PendingAuthenticationRequest IsNot Nothing Then
        Dim enc = New Utilities.SymmetricEncryption(&quot;my secret&quot;)
        ' Encrypt the claimed identity and the stored challenge, and see if it matches the response from the internal server
        If enc.Encrypt(providerEndpoint.PendingAuthenticationRequest.ClaimedIdentifier.OriginalString &amp; &quot;_&quot; &amp; HttpContext.Current.Session(&quot;guid&quot;)) = response Then
            ' If it matches we issue an authentication token
            FormsAuthentication.SetAuthCookie(providerEndpoint.PendingAuthenticationRequest.ClaimedIdentifier, False)
            Return True
        End If
    End If
    Return False
End Function
</pre>
<p>On the internal server the setup is similar, we accept the claimed identity, verify it against the identity of the authenticated user, and return a signed response.<br />
Here we expose a method whose only purpose is to relay the challenge back to the serverside code</p>
<pre class="brush: jscript;">
// Endpoint.aspx
// This is called by ASP.NET Ajax once the page is ready
function pageLoad() {
    // Set up a new easyXDM.Rpc object
    var rpc = new easyXDM.Rpc({}, {
        local: {
            authenticate: function (challenge, fn) {
                // Relay the challenge to the serverside code
                PageMethods.Authenticate(challenge, function (response) {
                    // Relay the response back to the OP
                    fn(response);
                });
            }
        }
    });
}
</pre>
<p>Here we extract the username from the claimed identifier and compare it to the known one. If it matches we return an encrypted response </p>
<pre class="brush: vb;">
'Endpoint.aspx
&lt;WebMethod()&gt; _
Public Shared Function Authenticate(ByVal challenge As Utilities.Challenge) As String
    ' This is called to check wether the claimed identifier matches the known one
    Dim claimedUserName As String = New Uri(challenge.Identifier).Query.Substring(4)

    If HttpContext.Current.User.Identity.IsAuthenticated Then
        Dim username As String = HttpContext.Current.User.Identity.Name
        username = username.Substring(username.IndexOf(&quot;\&quot;) + 1)
        If username = claimedUserName Then
            ' If it matches we encrypt the identifier and the challenge, and return the result as the response
            Dim enc = New Utilities.SymmetricEncryption(&quot;my secret&quot;)
            Return enc.Encrypt(challenge.Identifier &amp; &quot;_&quot; &amp; challenge.Guid)
        End If
    End If

    Return String.Empty
End Function
</pre>
<p>One of the interesting things here is how the instances of <code>Utilities.Challenge</code> is serialized and deserialized going from the OP&#8217;s server side code to the client side code, and again serialized and deserialized going from the internal webservers client side code to the internal webservers server side code. Like magic right?</p>
<p>(Of course, we could easily have used a couple of redirects instead of the server-client-client-server communication, but that wouldn&#8217;t have been as fun now would it <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2010/07/09/how-to-set-up-an-ad-backed-openid-provider-without-direct-communication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jsContract &#8211; Code contracts for Javascript</title>
		<link>http://kinsey.no/blog/index.php/2010/02/03/jscontract-code-contracts-for-javascript/</link>
		<comments>http://kinsey.no/blog/index.php/2010/02/03/jscontract-code-contracts-for-javascript/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 21:01:10 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[jsContract]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[code contracts]]></category>
		<category><![CDATA[design by contract]]></category>
		<category><![CDATA[instrumentation]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=214</guid>
		<description><![CDATA[I have recently started using code contracts in one of my .net projects and I came to think that since most of the code I produce these days are in Javascript, why don&#8217;t I try it there to! Well, easier said than done &#8211; there just is no decent frameworks for this. During my searching [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2010%252F02%252F03%252Fjscontract-code-contracts-for-javascript%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22jsContract%20-%20Code%20contracts%20for%20Javascript%22%20%7D);"></div>
<p>I have recently started using <a href="http://en.wikipedia.org/wiki/Design_by_contract" target="_blank">code contract</a>s in one of my .net projects and I came to think that since most of the code I produce these days are in Javascript, why don&#8217;t I try it there to!</p>
<p>Well, easier said than done &#8211; there just is no decent frameworks for this.</p>
<p>During my searching I found some references to libraries such as <a href="http://www.cerny-online.com/cerny.js/documentation/guides/contracts" target="_blank">Cerny.js</a> and <a href="http://weblogs.mozillazine.org/weirdal/archives/016921.html" target="_blank">ecmaDebug</a>, but these just didn&#8217;t make the cut  - they all required heavy (and hard to follow) restructuring of your code to make them work.</p>
<p>So what did I do? Well I made <a href="http://kinsey.no/projects/jsContract/" target="_blank">jsContract</a>, a library that is clean and .. wait for it .. extremely easy to use!<span id="more-214"></span></p>
<p style="padding-left: 30px;"><strong>If you want a quick view on what Code Contracts can give you, take a look at </strong><a href="http://kinsey.no/projects/jsContract/test2.html" target="_blank"><strong>this example</strong></a><strong>!</strong></p>
<p>The following method comes from the sample code in the link above</p>
<pre class="brush: jscript;">    function _internalMethod(a, b){
        Contract.expectNumber(a);
        Contract.expectNumber(b);
        Contract.expectWhen(config.mode === &quot;divide&quot;, b &gt; 0, &quot;Divisor cannot be 0&quot;);
        Contract.expectWhen(config.mode === &quot;multiply&quot;, a &gt; 0 &amp;&amp; b &gt; 0, &quot;The multiplicands cannot be 0&quot;);
        Contract.guaranteesNumber();
        Contract.guarantees(function(result){
            return result &gt; 0;
        }, &quot;Result must be &gt; 0&quot;);

        if (config.mode == &quot;divide&quot;) {
            return a / b;
        }
        // At this point config.mode must be &quot;multiply&quot;
        return a * b;
    }
</pre>
<p>As you can see, the contract statements does not ruin the flow of the code, rather, it helps to document it.<br />
By looking at the contract at the start of the method, you can instantly see what the method expects and what it will return.<br />
This also helps you reduce code since you do not need to check for conditions that are not allowed according to the contract.</p>
<h2>Postconditions</h2>
<p>So, you might be wondering about how the <code>Contract.guarantees</code> methods work? How can a statement placed in the head of the method possibly check the return value of the method?<br />
Well, the above code will actually not check the return value when run, but by running it through  <code>Contract.instrument</code> we can get code that will!<br />
This is the output created by <code>Contract.instrument </code>for the above code</p>
<pre class="brush: jscript;">
    function _internalMethod(a, b){
        arguments.callee.isInstrumented = true;
        /*preconditions*/
        Contract.expectNumber(a);
        Contract.expectNumber(b);
        Contract.expectWhen(config.mode === &quot;divide&quot;, b &gt; 0, &quot;Divisor cannot be 0&quot;);
        Contract.expectWhen(config.mode === &quot;multiply&quot;, a &gt; 0 &amp;&amp; b &gt; 0, &quot;The multiplicands cannot be 0&quot;);
        var __return = (function(a, b){
            if (config.mode == &quot;divide&quot;) {
                return a / b;
            }
            // At this point config.mode must be &quot;multiply&quot;
            return a * b;
        }(a, b));
        /*postconditions*/
        Contract.guaranteesNumber(__return);
        Contract.guarantees(__return, function(result){
            return result &gt; 0;
        }, &quot;Result must be &gt; 0&quot;);
        return __return;
    }
</pre>
<p>As you can see the code block has been wrapped in an anonymous function, the postconditions has been moved below this and has been rewritten so that they take the result as an argument.</p>
<p><strong>We now have both pre- and postconditions checking our code!</strong></p>
<p>The framework handles nested functions just as you would expect it to and the only real change to your code is the extra anonymous function that is inserted when the parser finds a postcondition in use.</p>
<p>But now you might be wondering, how do we get the instrumented code in to our applications?</p>
<p>For this you have several options</p>
<ul>
<li>Use tools like <a href="http://kinsey.no/projects/jsContract/" target="_blank">this</a> to convert the code for you before pasting it into a js file</li>
<li>Use it as a part of you build process for automated generation
<ul>
<li>a commandline tool will be available shortly</li>
</ul>
</li>
<li>Use dynamic loading and instrumentation at runtime</li>
</ul>
<p>The last option is only viable for development scenarios, but that is mainly when code contracts are needed anyways.<br />
To load scripts dynamically you can either use your own AJAX code, or use the built in Contract.load method</p>
<p>The following code is taken from the  <a href="http://kinsey.no/projects/jsContract/test.html" target="_blank">example </a>available with the framework</p>
<pre class="brush: jscript;">
var instrument = (location.search &amp;&amp; location.search.indexOf(&quot;instrument=true&quot;) !== -1);
Contract.load(&quot;MyClass.js&quot;, instrument, function(){
    try {
        var myClass = new MyClass({
            mode: &quot;multiply&quot;
        });

        var result = myClass.publicMethod(34, 5, 3);
    }
    catch (ex) {
        alert(ex.message);
    }
});
</pre>
<p>This code loads regular or instrumented code depending on the query string.</p>
<p>Doesn&#8217;t it look cool?</p>
<p>Its available at <a href="http://github.com/oyvindkinsey/jsContract" target="_blank">github</a> and will most likely be licensed with an MIT style license.</p>
<p>Anybody want to join in, maybe help with some documentation etc?</p>
<p>Drop me a note if so!</p>
<p><strong>Note:</strong> This is the first draft, I started this project today.</p>
<p>The parser is quite naive and strings matching &#8216;function(&#8216; etc and unmatched { and } in comments  will break it. But this is a work in progress <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Update 1 04.02:</strong> { and } in comments are now safely handled, and several small issues has been corrected.</p>
<p>Now I only need to validate that the functions the parser finds are not part of a comment.</p>
<p><strong>Update 2 04.02:</strong> The parser has now been fixed, it now completely ignores anything in the comments. As far as I know this means that as long as the code validates the parser should be solid as a rock!</p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2010/02/03/jscontract-code-contracts-for-javascript/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>easyXDM just became even easier to use!</title>
		<link>http://kinsey.no/blog/index.php/2010/01/02/easyxdm-just-became-even-easier-to-use/</link>
		<comments>http://kinsey.no/blog/index.php/2010/01/02/easyxdm-just-became-even-easier-to-use/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 19:56:04 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[easyXDM]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[easyxdm]]></category>
		<category><![CDATA[rpc]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=201</guid>
		<description><![CDATA[To accommodate older browsers that does not implement the postMessage interface, easyXDM is able to fall back to using the URI fragment trick, and until now this has meant that the provided hash.html file had to be uploaded to the local domain (the &#8216;calling&#8217; domain). This seems to be a dealbreaker for many as they [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2010%252F01%252F02%252Feasyxdm-just-became-even-easier-to-use%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22easyXDM%20just%20became%20even%20easier%20to%20use%21%20%22%20%7D);"></div>
<p>To accommodate older browsers that does not implement the postMessage interface, easyXDM is able to fall back to using the URI fragment trick, and until now this has meant that the provided hash.html file had to be uploaded to the local domain (the &#8216;calling&#8217; domain).</p>
<p>This seems to be a dealbreaker for many as they are unable to upload files to the server, either due to special systems, or because they just want to present an API in the form of &#8216;just include this javascript file&#8217; etc..</p>
<p>With the new <a href="https://www.ohloh.net/p/easyXDM/packages" target="_blank">1.5.5</a> release, this has all changed.</p>
<p>For scenarios where you do not want to upload the hash.html file, you can now point the local attribute to any file present on the local domain, like robots.txt or favicon.ico, and supply a readyAfter attribute with the number of milliseconds to wait before assuming the local file to be loaded and the library to be ready for interaction.</p>
<pre class="brush: jscript;">
{
local: &quot;/robots.txt&quot;,
readyAfter: 1000,
remote: &quot;http://.........&quot;,
...
}
</pre>
<p><strong>Update</strong>: Just released <a href="https://www.ohloh.net/p/easyXDM/packages" target="_blank">1.6.0</a> which makes it possible to utilize the current document instead of loading a new one from the local domain. This makes it very easy to integrate, but does mean that you will be modifying the documents location when falling back to the HashTransport &#8211; and this might interfere with for instance history managers etc.</p>
<pre class="brush: jscript;">
{
local: window,
remote: &quot;http://.........&quot;,
...
}
</pre>
<p>The hash.html file is still the recommended approach for stable<br />
implementations as it is unobtrusive and it guarantees that the library is indeed ready<br />
when transitioning into a ready state.<br />
Using hash.html also shortens the time needed to initialize easyXDM<br />
as there is no need for the delay to give the local file time to<br />
properly load.</p>
<p>All the different ways to set up easyXDM can now be viewed at <a href="http://easyxdm.net/wiki/Documentation.ashx">http://easyxdm.net/wiki/Documentation.ashx</a></p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2010/01/02/easyxdm-just-became-even-easier-to-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modifying privileges stored binary using ExtJs</title>
		<link>http://kinsey.no/blog/index.php/2009/11/17/modifying-privileges-stored-binary-using-extjs/</link>
		<comments>http://kinsey.no/blog/index.php/2009/11/17/modifying-privileges-stored-binary-using-extjs/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 18:37:03 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[bitwise]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[privileges]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=180</guid>
		<description><![CDATA[In an earlier post I showed you how to use binary operators to store multiple privileges/settings in a single integer field. Now I will present to you a simple control for visualizing and modifying such a value. Ext.namespace(&#34;Ext.ux&#34;); Ext.ux.Privileges = function(config){ var _formPanel = this; var items = []; for (var key in config.privileges) { [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F11%252F17%252Fmodifying-privileges-stored-binary-using-extjs%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Modifying%20privileges%20stored%20binary%20using%20ExtJs%22%20%7D);"></div>
<p>In an <a href="http://kinsey.no/blog/index.php/2009/11/17/storing-multiple-privilegessettings-in-a-single-integer/">earlier post</a> I showed you how to use binary operators to store multiple privileges/settings in a single integer field. Now I will present to you a simple control for visualizing and modifying such a value.</p>
<p><span id="more-180"></span></p>
<pre class="brush: jscript;">
Ext.namespace(&quot;Ext.ux&quot;);
Ext.ux.Privileges = function(config){
    var _formPanel = this;
    var items = [];

    for (var key in config.privileges) {
        if (config.privileges.hasOwnProperty(key)) {
            items.push({
                name: &quot;privilege_&quot; + config.privileges[key],
                fieldLabel: key
            });
        }
    }

    Ext.apply(config, {
        defaultType: &quot;checkbox&quot;,
        items: items,
		/**
		 * Updates the form according to the current privileges
		 * @param {Integer} p The integer containing all set privileges
		 */
        setValue: function(p){
            var field, values = {}, privilege;
			for (var key in config.privileges) {
				// Loop over all the privileges, set the value to true if set
                if (config.privileges.hasOwnProperty(key)) {
                    privilege = config.privileges[key];
                    values[&quot;privilege_&quot; + privilege] = (p == (p | privilege));
                }
            }
			// Update the form
            _formPanel.form.setValues(values);
        },
		/**
		 * Returns an integer representing all set privileges
		 * @return Integer
		 */
        getValue: function(){
            var p = 0, field, privilege;
			for (var key in config.privileges) {
				// Loop over all the privileges and see if it is set
                if (config.privileges.hasOwnProperty(key)) {
                    privilege = config.privileges[key];
                    field = _formPanel.form.findField(&quot;privilege_&quot; + privilege);
                    if (field.getValue()) {
						// The privilege is set, lets add it to p
                        p = p | privilege;
                    }
                }
            }
            return p;
        },
		/**
		 * Resets the form
		 */
        clear: function(){
            _formPanel.form.reset();
        }
    });
    Ext.ux.Privileges.superclass.constructor.call(this, config);
};
Ext.extend(Ext.ux.Privileges, Ext.form.FormPanel);
</pre>
<p>Using the following code</p>
<pre class="brush: jscript;">
var _pnlPrivileges= new Ext.ux.Privileges({
	height: 180,
	privileges: {
	    Read: 1,
	    Write: 2,
	    Create: 4,
	    Delete: 8,
	    List: 16,
	    SetPrivileges: 32,
	    Publish: 64
	}
});
</pre>
<p>you end up with something like this</p>
<p><img class="size-full wp-image-183 alignnone" title="privileges" src="http://kinsey.no/blog/wp-content/uploads/2009/11/privileges.png" alt="privileges" width="414" height="196" /></p>
<p>The controll exposes its functionality in two methods, setValue and getValue &#8211; both of these should be easy to understand <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/11/17/modifying-privileges-stored-binary-using-extjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Storing multiple privileges/settings in a single integer</title>
		<link>http://kinsey.no/blog/index.php/2009/11/17/storing-multiple-privilegessettings-in-a-single-integer/</link>
		<comments>http://kinsey.no/blog/index.php/2009/11/17/storing-multiple-privilegessettings-in-a-single-integer/#comments</comments>
		<pubDate>Tue, 17 Nov 2009 18:20:10 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[binary]]></category>
		<category><![CDATA[bitwise]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[privileges]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=168</guid>
		<description><![CDATA[In many applications you have the need to set users privileges , and while there are many ways to do so, I prefer to using a single integer value to store a users privileges on any single entity. This has many advantages, you only have a single value representing all privileges you can add and [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F11%252F17%252Fstoring-multiple-privilegessettings-in-a-single-integer%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Storing%20multiple%20privileges%2Fsettings%20in%20a%20single%20integer%22%20%7D);"></div>
<p>In many applications you have the need to set users privileges , and while there are many ways to do so, I prefer to using a single integer value to store a users privileges on any single entity.</p>
<p>This has many advantages,</p>
<ul>
<li>you only have a single value representing all privileges</li>
<li>you can add and remove available privileges without altering the schema/entity model/storage logic</li>
<li>checking for privileges are very simple</li>
</ul>
<p><span id="more-168"></span></p>
<p>Now you might be wondering, how is it possible to store any number of privileges in a single integer?<br />
One of the keys to doing this are the values that you assign each privilege, these must each be twice the previous value.</p>
<p>For example</p>
<ul>
<li>Read = 1</li>
<li>Write = 2</li>
<li>Delete = 4</li>
<li>&#8230; = 8</li>
</ul>
<p>To understand why we do it like this we need to take a look at the individual integers binary representation</p>
<pre>1 = 00000001
2 = 00000010
4 = 00000100
8 = 00001000
</pre>
<p>Anyone see the pattern?</p>
<p>And if you were to sum some of these, say Write (2) + Delete(4)</p>
<pre>00000010
+
00000100
=
00000110
</pre>
<p>Again, you see the pattern?</p>
<p>Each privilege is being stored as a single bit in the integer, and each bit can be checked against even if you add multiple values together.</p>
<p>So, now that we have some of the theory covered, how do we utilize this?</p>
<p>If you have an integer you can easily check for any fraction using a simple statement</p>
<p>In JavaScript</p>
<pre class="brush: jscript;">
var allPrivileges = 6;
var hasWrite = (allPrivileges  == (allPrivileges  | 2));
</pre>
<p>In VB.net</p>
<pre class="brush: vb;">
Dim allPrivileges As Integer = 6
Dim hasWrite As Boolean = allPrivileges = (allPrivileges Or 2)
</pre>
<p>Here we are using the bitwise operator | (<strong>or</strong>) to check that allPrivileges (6) binary <strong>or</strong>&#8216;ed with 2 equals 6, meaning that 2 is a contained fraction of 6.</p>
<p>Now if you want to add a new privilege (or existing one) you just binary <strong>or </strong>the current integer with the new integer<br />
In JavaScript</p>
<pre class="brush: jscript;">
var allPrivileges = 4;
allPrivileges = allprivileges | 2;
// allPrivileges equals 6
allPrivileges= allprivileges | 2;
// allPrivileges still equals 6
</pre>
<p>In VB.net</p>
<pre class="brush: vb;">
Dim allPrivileges As Integer = 4
allPrivileges = (allPrivileges Or 2)
' allPrivileges equals 6
allPrivileges = (allPrivileges Or 2)
' allPrivileges still equals 6
</pre>
<p>Wasn&#8217;t that easy?</p>
<p>In an <a href="http://kinsey.no/blog/index.php/2009/11/17/modifying-privileges-stored-binary-using-extjs/#more-180"> upcoming post</a> I will show you a simple ExtJs control for visualizing and modifying a users privileges.</p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/11/17/storing-multiple-privilegessettings-in-a-single-integer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to restrict your web app to a single instance</title>
		<link>http://kinsey.no/blog/index.php/2009/11/15/how-to-restrict-your-web-app-to-a-single-instance/</link>
		<comments>http://kinsey.no/blog/index.php/2009/11/15/how-to-restrict-your-web-app-to-a-single-instance/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:37:07 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Single instance]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=157</guid>
		<description><![CDATA[When building complex web applications it is often necessarry to restrict the user to keeping only a single instance open, and to do this you need to check for the precense of an existing instance, either directly or indirectly. One way of doing this indirectly would be to set a cookie using javascript when the [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F11%252F15%252Fhow-to-restrict-your-web-app-to-a-single-instance%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22How%20to%20restrict%20your%20web%20app%20to%20a%20single%20instance%22%20%7D);"></div>
<p>When building complex web applications it is often necessarry to restrict the user to keeping only a single instance open, and to do this you need to check for the precense of an existing instance, either directly or indirectly.</p>
<p><span id="more-157"></span></p>
<p>One way of doing this indirectly would be to set a cookie using javascript when the page loads and then use the unload event to remove the cookie. This means that as long as there is an instance open, the cookie will be set, and this can be tested for when the page loads.</p>
<pre class="brush: jscript;">
window.onload = function(){
    if (document.cookie.indexOf(&quot;_instance=true&quot;) === -1) {
        document.cookie = &quot;_instance=true&quot;;
        // Set the onunload function
        window.onunload = function(){
            document.cookie =&quot;_instance=true;expires=Thu, 01-Jan-1970 00:00:01 GMT&quot;;
        };
        // Load the application
    }
    else {
        // Notify the user
    }
};
</pre>
<p>The disadvantage of doing it this way is that you increase the amount of data being sent to the server with each request as all cookies are being sent, but the cookie could be restricted to the documents path so that it would not be sent with non-matching requests.</p>
<p>The direct way would be to try to get a reference to the existing window using its name, but this does involve using window.open, which means the method could be blocked and rendered unreliable by popup blockers. But then again, complex application often need popups to be enabled and one could use this to check for and alert the user about the popup blocker.</p>
<pre class="brush: jscript;">
window.onload = function(){
    var doLoad = false, name = &quot;unique_name&quot;, existing = window.open(&quot;&quot;, name, &quot;&quot;);
    if (!existing) {
        // Notify the user about allowing popups
        alert(&quot;Popup blocker detected\nPlease allow popups for this domain.&quot;);
        return;
    }
    if (window === existing) {
        doLoad = true;
    }
    else {
        if (existing.document.title !== window.document.title) {
            // The referenced window is not an existing instance
            doLoad = true;
            existing.close();
            window.name = name;
        }
    }
    if (doLoad) {
        // Load the application
    }
    else {
        // Notify user
    }
};
</pre>
<p>Which way you choose is entirely up to you.<br />
If you know any other ways, feel free to add it in the comments <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/11/15/how-to-restrict-your-web-app-to-a-single-instance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upcoming book review &#8211; &#8220;Ext JS 3.0 Cookbook&#8221;</title>
		<link>http://kinsey.no/blog/index.php/2009/11/11/upcoming-book-review-ext-js-3-0-cookbook/</link>
		<comments>http://kinsey.no/blog/index.php/2009/11/11/upcoming-book-review-ext-js-3-0-cookbook/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 14:03:35 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[extjs]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=143</guid>
		<description><![CDATA[The nice people at Packt Publishing has asked me to do a book review of  Jorge Ramons &#8220;Ext JS 3.0 Cookbook&#8220;. According to the book description the following subjects will be covered Work with different browsers, platforms, and the DOM, as well as determine and understand the different ExtJS data types Create your own custom [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F11%252F11%252Fupcoming-book-review-ext-js-3-0-cookbook%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Upcoming%20book%20review%20-%20%5C%22Ext%20JS%203.0%20Cookbook%5C%22%20%22%20%7D);"></div>
<p><img class="size-thumbnail wp-image-145 alignright" title="Ext JS 3.0 Cookbook" src="http://kinsey.no/blog/wp-content/uploads/2009/11/1847198708-150x150.jpg" alt="Ext JS 3.0 Cookbook" width="150" height="150" />The nice people at <a href="http://www.packtpub.com/" target="_blank">Packt Publishing</a> has asked me to do a book review of  <a href="http://miamicoder.com/" target="_blank">Jorge Ramons</a> &#8220;<a href="http://www.packtpub.com/ext-js-3-0-cookbook/book" target="_blank">Ext JS 3.0 Cookbook</a>&#8220;.</p>
<p>According to the book description the following subjects will be covered</p>
<ul>
<li>Work with different browsers, platforms, and the DOM, as well as determine and understand the different ExtJS data types</li>
<li>Create your own custom Ext JS data types as you extend their functionality</li>
<li>Build great-looking and friendly forms by using client and server-side field validation, form loading, submission, field customization, and layout techniques</li>
<li>Explore the different layouts provided by the Ext JS library as well as create your own, and understand their common uses</li>
<li>Display, edit, and group tabular data generated by the server using Grid Panels</li>
<li>Explore the advantages and the efficiency tradeoffs of widgets such as Combo boxes</li>
<li>Use the drag and drop features of the grid component, data editing with the new RowEditor Class, and the new lightweight ListView component</li>
<li>Explore multiple ways of displaying master-details relationships</li>
<li>Group components or information under the same container to build hierarchical views of information by using TabPanel components</li>
<li>Use patterns to build a solid and flexible application architecture and implement additional design patterns such as auto-saving form elements, component state management, and code modules to build robust and flexible applications with Ext JS</li>
<li>Build your own custom components on top of the Ext framework and enhance the custom components created by the Ext JS users&#8217; community</li>
</ul>
<p>I&#8217;m looking forward to this as Ext and JavaScript are two things that I am quite passionate about <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/11/11/upcoming-book-review-ext-js-3-0-cookbook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Widget support added to easyXDM!</title>
		<link>http://kinsey.no/blog/index.php/2009/09/06/119/</link>
		<comments>http://kinsey.no/blog/index.php/2009/09/06/119/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 14:37:39 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[easyXDM]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[easyxdm]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=119</guid>
		<description><![CDATA[The newest version of easyXDM (v1.5.3) now includes two new classes, the easyXDM.WidgetManager, and easyXDM.Widget. These make it extremely easy to make mashups based on the subscribe/publish architecture. To read more about easyXDM check out this blog post. The widget demo can be found at http://consumer.easyxdm.net/example/widgets.html,  and if you want to, just copy the code [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F09%252F06%252F119%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Widget%20support%20added%20to%20easyXDM%21%22%20%7D);"></div>
<p>The newest version of easyXDM (v1.5.3) now includes two new classes, the easyXDM.WidgetManager, and easyXDM.Widget.</p>
<p>These make it extremely easy to make mashups based on the subscribe/publish architecture.<br />
<span id="more-119"></span><br />
To read more about easyXDM check out <a href="http://kinsey.no/blog/index.php/2009/08/20/easyxdm/" target="_blank">this blog post</a>.</p>
<p>The widget demo can be found at <a href="http://consumer.easyxdm.net/example/widgets.html" target="_blank">http://consumer.easyxdm.net/example/widgets.html</a>,  and if you want to, just copy the code for the widget found <a href="http://easyxdm.net/example/widget.html" target="_blank">here</a>, modify the src for the scripts and save it to your own domain &#8211; you should now be able to add it from the WidgetManager!</p>
<h2>The WidgetManager</h2>
<p>To set up a page to contain widgets we need an instance of the WidgetManager:</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var _widgetManager = new easyXDM.WidgetManager({
    local: &quot;../hash.html&quot;,
    container: document.getElementById(&quot;widgets&quot;)
 });
</pre>
<p>And with the widgetmanager set up we continue by adding widgets by their url</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
_widgetManager.addWidget(&quot;http://provider.easyxdm.net/example/widget.html&quot;,{});
</pre>
<p>And thats it <img src='http://kinsey.no/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>The widgets</h2>
<p>Creating a widget isn&#8217;t much more work</p>
<p>The following is a skeleton widget</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var widget = new easyXDM.Widget({
    subscriptions: [&quot;testtopic&quot;],
    initialize: function(widget, widgetManager){
        // Set up the widget

        // Render the UI

        // Register the handler for incoming messages
        widget.registerMessageHandler(function(url, topic, data){
            // Do something
        });
    },
    initialized: function(widget, widgetManager){
        //This is called after the widget has been initialized by the widgetmanager
    }
});
</pre>
<p>To create a custom widget you only need to select the topics to subscribe to, build the UI, and handle the incoming messages the way you see fit.</p>
<p>To publish your own messages you simply use widget.publish  like this</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
widget.publish(&quot;position&quot;, {
    latitude: &quot;60.378776&quot;,
    longitude: &quot;5.337811&quot;
});
</pre>
<p>and all subscribers will get this.</p>
<p>It&#8217;s that easy!</p>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/09/06/119/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>easyXDM &#8211; extremely easy cross-domain scripting</title>
		<link>http://kinsey.no/blog/index.php/2009/08/20/easyxdm/</link>
		<comments>http://kinsey.no/blog/index.php/2009/08/20/easyxdm/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 15:03:02 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[easyXDM]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[easyxdm]]></category>
		<category><![CDATA[easyxss]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[rpc]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=84</guid>
		<description><![CDATA[easyXDM is a javascript library that uses available techniques to provide a means of transporting messages and/or method calls between windows in different domains, in short, by-passing the same-origin policy and letting you call methods across the domain boundry. This is perfect if you plan to provide a client-side API (e.g Facebook Connect) on your [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F08%252F20%252Feasyxdm%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22easyXDM%20-%20extremely%20easy%20cross-domain%20scripting%22%20%7D);"></div>
<p><a href="http://easyxdm.net/">easyXDM </a>is a javascript library that uses available techniques to provide a means of transporting messages and/or method calls between windows in different domains, in short, <span style="text-decoration: underline;">by-passing the same-origin policy and letting you call methods across the domain boundry</span>.</p>
<p>This is perfect if you plan to provide a client-side API (e.g Facebook Connect) on your web site as you can expose a method in as little as 7 lines of code.</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var remote = new easyXDM.Interface({}, {
    local: {
        doMagic:{
            method: _privateMethod
        }
    }
});
</pre>
<p>This can be consumed by a client by using</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var remote = new easyXDM.Interface({
   local: &quot;../hash.html&quot;,
   remote: &quot;http://apiprovidersdomain.com/api.html&quot;
},{
    remote: {
        doMagic: {}
    }
});
</pre>
<p>and can then be called by using</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
remote.doMagic('argument1',2,function(result){
    alert(result)
}
</pre>
<p>In this <a href="http://www.codeproject.com/KB/scripting/easyXDM.aspx">CodeProject</a> article I present an example on how easy it is to do this, and in the extensive <a href="http://easyxdm.net/docs/">documentation </a>there are links to several demos showing everything from sending simple strings to letting two applications from different domains send arbitrary objects back and forth, even using older browsers like IE6.</p>
<p>The demos are repeated here</p>
<ul>
<li> <a href="http://consumer.easyxdm.net/example/data.html">Sending data (objects)  using the easyXDM.Channel class</a></li>
<li> <a href="http://consumer.easyxdm.net/example/methods.html">Exposing and invoking methods using the easyXDM.Interface class</a></li>
<li> <a href="http://consumer.easyxdm.net/example/xhr.html">Calling an ajax method from the remote domain</a></li>
<li><a href="http://consumer.easyxdm.net/example/widgets.html">Simple widget page with broadcasting</a></li>
<li> <a href="http://consumer.easyxdm.net/example/index.html">Bridging two web applications</a></li>
</ul>
<p><span id="more-84"></span>This library was earlier on called easyXSS, but due to the name being kinda ambiguous (someone say vulnerability), I decided to change it to easyXDM, short for easy cross domain messaging.</p>
<p>If you want to sneak a peek at the sourcecode, you can see the fully documented debug version <a href="http://easyxdm.net/docs/source/easyXDM.html#cls-easyXDM">here</a>. The <a href="http://easyxdm.net/easyXDM.min.js">minified version</a> weighs in at only 1.46KB gzipped.</p>
<p>The library is very flexible, allowing you you choose exactly how much of the work you want to handle yourself, the base functionality is transferring string messages.</p>
<h3>Some of the features are</h3>
<ul>
<li>transport classes for transmitting strings
<ul>
<li>postMessage where supported OR</li>
<li>hash fragment using the resize event for invisible iframes</li>
<li>hash fragment using polling for visible frames</li>
</ul>
</li>
<li>channel class for transmitting aribitrary data</li>
<li>interface class for setting up methods to be exposed/consumed</li>
<li>debug build with extensive logging for easy debugging</li>
<li>works in all browser (<a href="http://easyxdm.net/tests/">run the test suite</a>)</li>
</ul>
<p>The library also support both visible and invisible iframes, so you can either access the remote domain transparently, or you can expose the remote domains document for direct interaction (sign in etc.).</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 133px; width: 1px; height: 1px;">&lt;ul&gt;<br />
&lt;li&gt;<br />
&lt;a href=&#8221;http://consumer.easyxdm.net/example/transport.html&#8221;&gt;Sending plain string messages using the easyXDM.Transport.BestAvailableTransport class&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;<br />
&lt;a href=&#8221;http://consumer.easyxdm.net/example/data.html&#8221;&gt;Sending data (objects)  using the easyXDM.Channel class&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;<br />
&lt;a href=&#8221;http://consumer.easyxdm.net/example/methods.html&#8221;&gt;Exposing and invoking methods using the easyXDM.Interface class&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;<br />
&lt;a href=&#8221;http://consumer.easyxdm.net/example/xhr.html&#8221;&gt;Calling an ajax method from the remote domain&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;li&gt;<br />
&lt;a href=&#8221;http://consumer.easyxdm.net/example/index.html&#8221;&gt;Bridging two web applications&lt;/a&gt;<br />
&lt;/li&gt;<br />
&lt;/ul&gt;</div>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/08/20/easyxdm/feed/</wfw:commentRss>
		<slash:comments>46</slash:comments>
		</item>
		<item>
		<title>easyXSS</title>
		<link>http://kinsey.no/blog/index.php/2009/06/24/easyxss/</link>
		<comments>http://kinsey.no/blog/index.php/2009/06/24/easyxss/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:39:38 +0000</pubDate>
		<dc:creator>oyvind.kinsey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[easyXDM]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[cross-site]]></category>
		<category><![CDATA[easyxss]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://kinsey.no/blog/?p=44</guid>
		<description><![CDATA[Please see easyXDM for updated info! I&#8217;ve just completed the first version of my cross-site scripting library easyXSS. It is available at http://code.google.com/p/easyxss/ under a MIT-license. As it is now it supports simple messaging between windows of different domains, but it also supports proxying method calls and results between them making it well-suited for creating [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fkinsey.no%252Fblog%252Findex.php%252F2009%252F06%252F24%252Feasyxss%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22easyXSS%22%20%7D);"></div>
<p>Please see <a href="http://kinsey.no/blog/index.php/2009/08/20/easyxdm/">easyXDM </a>for updated info!</p>
<p>I&#8217;ve just completed the first version of my cross-site scripting library easyXSS. It is available at <a href="http://code.google.com/p/easyxss/">http://code.google.com/p/easyxss/</a> under a MIT-license.</p>
<p>As it is now it supports simple messaging between windows of different domains, but it also supports proxying method calls and results between them making it well-suited for creating API&#8217;s.</p>
<p>I&#8217;ve prepared several examples and demo&#8217;s at <a href="http://code.google.com/p/easyxss/">http://code.google.com/p/easyxss/</a> and look forward to getting feedback!<br />
<span id="more-44"></span><br />
To show you a quick example, here is the code needed to have a method &#8216;doMagic&#8217; that is located on domainA available in a window from domainB.</p>
<p>This is placed in the document api.html at domainA</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var channel = easyXSS.createChannel({
onReady: function(){
remote = easyXSS.createInterface(channel, {
local: {
doMagic: _privateMethodDoingMagic
}
});
}
});
</pre>
<p>and this is placed in the document at domainB</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
var remote;
var channel = easyXSS.createChannel({
local: &amp;quot;/hash.html&amp;quot;,
remote: &amp;quot;http://domaina.com/api.html&amp;quot;,
onReady: function(){
remote = easyXSS.createInterface(channel, {
remote: {
doMagic: {}
}
});
}
});
</pre>
<p>The medhod doMagic can now be called from domainB using</p>
<pre class="brush: jscript; smart-tabs: true; tab-size: 4;">
remote.doMagic('argument1',2,'three',function(result){
// Consume the result
});
</pre>

]]></content:encoded>
			<wfw:commentRss>http://kinsey.no/blog/index.php/2009/06/24/easyxss/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
