<?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>Gridshore &#187; web service</title>
	<atom:link href="http://www.gridshore.nl/tag/web-service/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gridshore.nl</link>
	<description>A weblog about software engineering, Architecture, Technology an other things we like.</description>
	<lastBuildDate>Tue, 13 Dec 2011 15:36:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Feeling secure with Web Services &#8211; Part 3 &#8211; Digital Signature</title>
		<link>http://www.gridshore.nl/2008/06/01/feeling-secure-with-web-services-part-3-digital-signature/</link>
		<comments>http://www.gridshore.nl/2008/06/01/feeling-secure-with-web-services-part-3-digital-signature/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 15:10:55 +0000</pubDate>
		<dc:creator>Allard</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[signing]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/06/01/feeling-secure-with-web-services-part-3-digital-signature/</guid>
		<description><![CDATA[<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your data, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p> <p>In [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your data, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p>
<p>In my introductory post I&#8217;ve elaborated on what type of security we&#8217;d typically want on Web Services.</p>
<p>In <a href="http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/">part 1</a> , I&#8217;ve dealt with Username Token authentication, an easy to use way to provide an authentication mechanism for your web service.</p>
<p>In <a href="http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/">part 2</a> , I have described Transport Layer Security (TLS) -formerly known as Secure Socket Layer- and message encryption.</p>
<p>In this part, the last one in this series, I will explain how the the digital signature can provide some form of security in web services.</p>
<p><span id="more-135"></span></p>
<p>Lets recap the security requirements I have discussed in my <a href="http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/">introduction</a> .</p>
<ol>
<li>The client must be sure it sends it messages to the correct provider;</li>
<li>The provider wants to be sure that the client is authorized to;</li>
<li>The provider wants to be sure that the client is who it says it is;</li>
<li>Both the consumer and provider want to be sure that the messages can only be interpreted by each other;</li>
<li>Both parties want to be sure that the message sent is received unchanged.</li>
</ol>
<p>So far, we have dealt with the first four requirements by implementing Encryption or TLS/SSL or by requiring a UsernameToken from the client. But until now, we are still not the guaranteed that the messages are unmodified since we&#8217;ve sent them.</p>
<p>Encryption will prevent modification during the transport between the sender and the final recipient, the one with the private key to decrypt the message. However, once decrypted, the message is free to be modified.</p>
<p>Digital invoices are an example of documents that should be digitally signed. In some countries (in The Netherlands in any case) the Belastingdienst (Tax authority) requires that all digital invoices are digitally signed by the company sending the invoice. This way, the Belastingdienst is able to verify who sent the invoice -the one who signed it- and be sure that it hasn&#8217;t been tampered with in the meantime. Of course, the company receiving this invoice wouldn&#8217;t really mind to have these guarantees too, I suppose.</p>
<p>Now that we have a real valid use case and are really convinces of the need of the digital signature, let&#8217;s have a look at how it works.</p>
<p>Actually, it is almost identical to encryption, but then in the opposite way. With encryption, the message is encrypted using the public key. Only the one with access to the private key can decrypt it. When signing, the private key is used to sign the message, and the public key is used to check the signature. Since access to the private key is limited to authorized people/machines, only they can sign the message. Anyone can access the public part of the key -hence &#8220;public&#8221;-, meaning that anyone can check the signature.</p>
<p>When a message is signed, the actual message itself is not encrypted. That wouldn&#8217;t be very meaningful, because that would mean that anyone would have to decrypt the message, even though they might not really care about the signature. Instead, a hash is creating from all the parts that have to be signed. That hash is then encrypted using the private key. The encrypted has is then inserted in (the header of) the message. Typically, one would also include the public key, to allow anyone to check your signature. That&#8217;s it.</p>
<p>To check a signature, the hash is recreated the same way as it was done originally and the encrypted hash from the signer is decrypted. If the message has not been tampered with, the newly generated hash and the decrypted original hash are identical. If they are different, you know the message has been tampered with.</p>
<p>The signature on the message will ensure the reader that the message has not been modified since it has signed sent and that the contents were created by, or created with the consent of, the user who signed it. If you want to see it in action, you can download the example code from the <a href="http://code.google.com/p/gridshore/source/checkout">Gridshore google code repository</a>. The demo uses all three forms of security described in this series.</p>
<p>This concludes this three-part article about web service security. The type of security you would choose for your web service clearly depends on the needs of your specific service. UsernameToken provides for an easy to use authentication mechanism, while TLS or message encryption prevents a third party from reading the messages. Finally, the digital signature will ensure that a message is not modified after it is signed.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F06%2F01%2Ffeeling-secure-with-web-services-part-3-digital-signature%2F&amp;title=Feeling%20secure%20with%20Web%20Services%20-%20Part%203%20-%20Digital%20Signature&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/06/01/feeling-secure-with-web-services-part-3-digital-signature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feeling secure with Web Services &#8211; Part 2</title>
		<link>http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/</link>
		<comments>http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/#comments</comments>
		<pubDate>Mon, 26 May 2008 19:23:04 +0000</pubDate>
		<dc:creator>Allard</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/</guid>
		<description><![CDATA[<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your data, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p> <p>In [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your data, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p>
<p>In my <a href="http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/">introductory post</a> I&#8217;ve elaborated on what type of security we&#8217;d typically want on Web Services.</p>
<p>In <a href="http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/">part 1</a> , I&#8217;ve dealt with Username Token authentication.</p>
<p>In this article, I will describe Transport Level Security (TLS), formerly known as Secure Socket Layer and message encryption.</p>
<p><span id="more-134"></span></p>
<p>Lets recap the security requirements I have discussed in my introduction.</p>
<ol>
<li>
<div>The client must be sure it sends it messages to the correct provider;</div>
</li>
<li>
<div>The provider wants to be sure that the client is authorized to;</div>
</li>
<li>
<div>The provider wants to be sure that the client is who it says it is;</div>
</li>
<li>
<div>Both the consumer and provider want to be sure that the messages can only be interpreted by each other;</div>
</li>
<li>
<div>Both parties want to be sure that the message sent is received unchanged.</div>
</li>
</ol>
<p><em><span style="text-decoration: underline;">Transport Level Security</span></em></p>
<p>Using &#8220;Transport Level Security&#8221; (TLS), formerly known as Secure Socket Layer (SSL), and also referred to as HTTPS, will take care of requirements 1 and 4.</p>
<p>TLS is a technically very complex algorithm, with a lot of varieties. Fortunately, the general concept is not as hard to grasp. It works as follows:</p>
<ol>
<li>
<div>The client will send a &#8220;Hello&#8221; to the server.</div>
</li>
<li>
<div>The server will response with a &#8220;Hello&#8221;, and send a certificate to the client</div>
</li>
<li>
<div>The client will decide whether it trusts the server&#8217;s certificate</div>
</li>
<li>
<div>The client will use the servers certificate to encrypt its own certificate and send it back to the server</div>
</li>
<li>
<div>Depending on the exact algorithm chosen, the client and server will exchange some more encryption information to make the communication &#8220;water tight&#8221;.</div>
</li>
</ol>
<p>If you really want to know the technical details of TLS, have a look at this page: <a href="http://an.wikipedia.org/wiki/Secure_Sockets_Layer">http://an.wikipedia.org/wiki/Secure_Sockets_Layer</a>. For the typical Web Service developer, these details are not really important. However, knowledge of how the first three steps work can help you prevent a lot of problems.</p>
<p>Especially step 3 is of great importance. The client has received a certificate from the server, and has to decide whether it is safe. This decision is based on a few factors.</p>
<p>First of all, the certificate has to have been issued for the domain that has been requested. So if you access a service on http://somecompany.com/service and get a certificate issued for someothercompany.org, the client will reject the certificate. Some clients, such as web browsers allow the users to override this decision and accept the certificate anyway. A web service client doesn&#8217;t typically have a user, so there is no room for second chances.</p>
<p>Secondly, the certificates timestamp has to be valid, meaning that it hasn&#8217;t reached it&#8217;s expiry date yet. Depending of the type of certificate, it is valid from 1 to tens of years.</p>
<p>The third requirement can sometimes give some problems: the client has to <em>trust</em> the certificate. This can best be explained using a real life example. Imagine yourself at the border control on a foreign airport. If you show them a paper with your name and a signature on it, chances are small that they let you through? Why? Because they can&#8217;t trust a self-signed certificate, or one that is signed by a relative. However, if that same name is written on a legal passport, given and signed by your country&#8217;s authority, border control will trust it, because they trust them. In TLS, it is exactly the same.</p>
<p>If you order a certificate from a certificate authority (CA), nobody will actually know that you have that certificate. And you don&#8217;t trust what you don&#8217;t know. However, you have paid the CA to sign your certificate. And maybe the CA certificate has been signed with yet another certificate. Now, if you trust the CA, you will automatically trust all certificates that have been signed with that CA. Back to our border control. If you trust the US government to issue correct passports to people, you will automatically trust all passports of US citizens, even if you don&#8217;t know that person.</p>
<p>To mark a certificate as trusted, the certificate has to be stored in a so-called &#8220;trust store&#8221;. Your browser has a truststore that includes the large CA certificates by default. Just look around in the configuration of your browser. You&#8217;ll be able to install other certificates if you like. For example, one that you have created and signed yourself.</p>
<p>You can also configure a truststore for your web service client. By default, your JVM will probably include the large CA certificates, such as Verisign and Thawte. If you&#8217;re running on an application server, chances are big there is a trust store configured in them, too. Of course, you can override the truststore by defining your own.</p>
<p>Ok, now that we&#8217;ve seen a lot of misery on the client side, let&#8217;s have a look at what has to happen on the server side. Well, luckily, not all that much. All you have to do is configure your web server to use SSL. Somewhere along the line it will require you configure a certificate to use. And since you probably want to be trusted, make sure to have your certificate signed by a large CA.</p>
<p>The good part is that all communication between client and server is encrypted in such a way, that only these parties are able to read the messages. And, as a bonus, the client is ensured that it is really talking to the server it was expecting to communicate with.</p>
<p><em><span style="text-decoration: underline;">Message encryption</span></em></p>
<p>TLS is nice, but if you have a message that will pass a few endpoints, or has to be logged in the mean time, it doesn&#8217;t really help you. If you have to keep your data secure after is has arrived at your first endpoint, message encryption could be your solution.</p>
<p>Let&#8217;s start off with an example. Let&#8217;s image we have a service where consumers can place orders. Just for the sake of the example, the request will first be processed by an endpoint that checks the stocks. If the stocks are sufficient, the payment is processed. If TLS were used between the consumer and the first endpoint, the message would be sent unencrypted. Of course it is possible to encrypt that communication too, but that would probably be a performance hit.</p>
<p>The idea behind encryption is not really complex. The entire message, or part of it is encrypted using the public key part of the certificate. Since the private key is required to decrypt it, only the recipient (or at least only systems with access to the private key) will be able to so. Even if a message is stored for future reference, the contents will be unreadable to any third party.</p>
<p>Typically, only parts of messages are encrypted. You could think of elements containing payment information or other private contents, such as social security numbers. The <a href="http://code.google.com/p/gridshore/source/checkout" target="_blank">example project in go ogle code </a>shows an example of a message where an ID is encrypted. Not a really powerful use case, but it shows how the technology works.</p>
<p>As with TLS, message encryption will deal with items 1 and 4. However, it will only do so for the parts of the message that have been encrypted.</p>
<p><em><span style="text-decoration: underline;">Conclusion</span></em></p>
<p>Both TLS and message encryption give the communication between consumer and provider some form or privacy and protection against eavesdropping. If configured correctly, they can work transparently to the implementation of both the client and the consumer, but will claim some of your performance.</p>
<p>My next and last article in this series will discuss message signing, which will deal with the security item that hasn&#8217;t been covered yet: &#8220;Both parties want to be sure that the message is received unchanged&#8221;.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F05%2F26%2Ffeeling-secure-with-web-services-part-2%2F&amp;title=Feeling%20secure%20with%20Web%20Services%20-%20Part%202&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Feeling secure with Web Services &#8211; Part 1 &#8211; The UsernameToken</title>
		<link>http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/</link>
		<comments>http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/#comments</comments>
		<pubDate>Tue, 20 May 2008 19:25:59 +0000</pubDate>
		<dc:creator>Allard</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/</guid>
		<description><![CDATA[<p>Recently, I&#8217;ve been helping a customer with some Web Service issues. One of the problems was their limited knowledge of security in that area. He asked me to explain, in Jip and Janneke language [1] how SSL works and what it actually secures.</p> <p>There seems to be a lot of misunderstanding about Web Service [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been helping a customer with some Web Service issues. One of the problems was their limited knowledge of security in that area. He asked me to explain, in Jip and Janneke language [1] how SSL works and what it actually secures.</p>
<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your services, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p>
<p>In my <a href="http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/">introductory post</a> I&#8217;ve elaborated on what type of security we&#8217;d typically want on Web Services.</p>
<p>This article will go more in-depth in the Username Token authentication.</p>
<p><span id="more-133"></span></p>
<p>First, I&#8217;ll list the 5 security requirements we usually have to feel really secured. These have been treated in the introductory post in this series.</p>
<ol>
<li>
<div>The client must be sure it sends it messages to the correct provider;</div>
</li>
<li>
<div>The provider wants to be sure that the client is authorized to;</div>
</li>
<li>
<div>The provider wants to be sure that the client is who it says it is;</div>
</li>
<li>
<div>Both the consumer and provider want to be sure that the messages can only be interpreted by eachother;</div>
</li>
<li>
<div>Both parties want to be sure that the message sent is received unchanged.</div>
</li>
</ol>
<p>The username token will take care of items 2 and 3. The username token is typically a security header in the soap message from the client towards the server. This header contains a username and a password, in one form or another.</p>
<p>In the simplest form, a UsernameToken authentication header contains an element with a username and one with a password. This is the &#8220;PasswordText&#8221; option of the UsernameToken. When you send this message unencrypted, anyone would be able to read your username and password, an log in on your behalf. Encrypting the communication will solve this risk. However, if the message has to pass several endpoints and one of the connections in unencrypted, your password is open again, despite effort to secure it.</p>
<p>To prevent giving away the username and password combination for free, it is possible to use the &#8220;PasswordDigest&#8221; version of the UsernameToken. This will actually pass a hash of your password, instead of the password itself. This prevents malicious ears from plucking you password off the wire.</p>
<p>However, although the password is encrypted and unknown to any third party, that third party could log log in by copying the entire security header. After all, if one client can get in using that header, any client could. To prevent this, a Nonce and/or a Timestamp are made part of the hash too. The Nonce is a random value, chosen by the client. The Timestamp is the date and time the password was hashed.</p>
<p>So how does this prevent another user from replicating your authentication header? Well, if a Timestamp is used, the server could require that that timestamp may not be older than for example 5 minutes. This still gives the third party a 5 minute window to abuse your password. That&#8217;s where the Nonce comes in. The server can (and should) require that the Nonce may be used at most one time. If the same header -and thus the same nonce- is sent again, the UsernameToken is refused based on a duplicate nonce.</p>
<p>In the end, the security header could look like this:</p>
<p>&lt;wsse:Security xmlns:wsse=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221; SOAP-ENV:mustUnderstand=&#8221;1&#8243;&gt; &lt;wsse:UsernameToken xmlns:wsu=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&#8221; wsu:Id=&#8221;UsernameToken-33083972&#8243; xmlns:wsse=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221;&gt; &lt;wsse:Username xmlns:wsse=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221;&gt;username&lt;/wsse:username&gt; &lt;wsse:Password Type=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest&#8221; xmlns:wsse=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221;&gt;Zb5nkZdaXM3hH/bVPQRdMdYSbdo=&lt;/wsse:password&gt; &lt;wsse:Nonce xmlns:wsse=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd&#8221;&gt;hHDHOSh3akTwwZFs+6o13A==&lt;/wsse:nonce&gt; &lt;wsu:Created xmlns:wsu=&#8221;http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd&#8221;&gt;2008-05-20T19:00:06.937Z&lt;/wsu:created&gt; &lt;/wsse:UsernameToken&gt; &lt;/wsse:Security&gt;</p>
<p>So, does this make us absolutely secured from any attacks? Well, the likelyhood of anyone abusing your security header is very slim, but nowhere near to zero. Hackers keep lists of commonly used passwords and can use these lists to guess your password. They will see which passwords will create the given hash using the Nonce and Timestamp you have provided. It is therefore very important to generate a password instead of choosing one which is easy to remember. Why would you anyway, a client is usually a piece of software that doesn&#8217;t really have difficulties remembering any password. It is of course still not water tight, but it is more likely that the service won&#8217;t exist anymore by the time the password has been guessed.</p>
<p>Another way to minimize the chance of abuse of your credentials is by encrypting the messages, or parts of it. This shall be treated in my next post in this series.</p>
<p>The configuration of UsernameToken security in your WebService is fairly simple. Both in client and server only little configuration is needed. There are libraries that can assist you in setting up security, such as <a href="http://ws.apache.org/wss4j/" target="_blank">Apache&#8217;s WSS4J</a> and <a href="https://xwss.dev.java.net/" target="_blank">Sun&#8217;s XWSS</a>. If you want to see these libraries at work, make sure you download the code samples for this series on the Gridshore code repository: <a href="http://code.google.com/p/gridshore/source/checkout">http://code.google.com/p/gridshore/source/checkout</a> [1].</p>
<p>If you want to go into a little (or a lot) more technical depth of the UsernameToken specification, make sure you read the OASIS WSS specification from <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss#technical">http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wss#technical</a>.</p>
<p>This concludes this post about the UsernameToken. In my <a href="http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/">next post </a>in this series, I will shed some light on Transport Level Security and Message Encryption.</p>
<hr />[1] Make sure you checkout the code in the /trunk/feeling-secure-with-webservices/ folder. If you check out the entire trunk, you&#8217;ll have to deal with lots of samples.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F05%2F20%2Ffeeling-secure-with-web-services-part-1-the-usernametoken%2F&amp;title=Feeling%20secure%20with%20Web%20Services%20-%20Part%201%20-%20The%20UsernameToken&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Feeling secure with Web Services &#8211; Introduction</title>
		<link>http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/</link>
		<comments>http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/#comments</comments>
		<pubDate>Sat, 17 May 2008 13:45:27 +0000</pubDate>
		<dc:creator>Allard</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorization]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/</guid>
		<description><![CDATA[<p>Recently, I&#8217;ve been helping a customer with some Web Service issues. One of the problems was their limited knowledge of security in that area. He asked me to explain, in Jip and Janneke language [1] how SSL works and what it actually secures.</p> <p>There seems to be a lot of misunderstanding about Web Service [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been helping a customer with some Web Service issues. One of the problems was their limited knowledge of security in that area. He asked me to explain, in Jip and Janneke language [1] how SSL works and what it actually secures.</p>
<p>There seems to be a lot of misunderstanding about Web Service security. Using password authentication doesn&#8217;t prevent unauthorized users to access your data, while SSL / HTTPS doesn&#8217;t give you any information about who is trying to access your services. And did you ever think of signing you messages with a digital signature?</p>
<p>In this article, I&#8217;ll explain the different methods of securing your Web Services, how each of the methods work and what you actually secure by applying each method.</p>
<p><span id="more-132"></span></p>
<p>First, let&#8217;s start with a definition of security. Wikipedia describes it as: &#8220;Security is the condition of being protected against danger or loss&#8221; [2]. This just means that you don&#8217;t want anyone stealing your data (expecially during transportation) or doing something unwanted with it. To feel secure in the Web Services area, we want to be assured of the following:</p>
<ol>
<li>
<div>The client must be sure it sends it messages to the correct provider;</div>
</li>
<li>
<div>The provider wants to be sure that the client is authorized to;</div>
</li>
<li>
<div>The provider wants to be sure that the client is who it says it is;</div>
</li>
<li>
<div>Both the consumer and provider want to be sure that the messages can only be interpreted by eachother;</div>
</li>
<li>
<div>Both parties want to be sure that the message sent is received unchanged.</div>
</li>
</ol>
<p>I will briefly explain each of these items.</p>
<p>Let&#8217;s start with the first item. The client is the one initiating the connection. Typically by accessing a URL. For example, http://services.somecompany.com/someService. However, messages towards this endpoint are routed through many routers, switches and proxy servers around the internet. How can you be sure that your messages don&#8217;t end up in the servers of &#8220;some competiting company&#8221;?</p>
<p>On the other side of the connection we want a similar kind of ensurance. How can you be sure that the message comes from a client that has been authorized to access that service? And how do you know the message really comes from that client and not from someone pretending to be an authorized client? Quite often, the use of services is paid for, and you&#8217;d want to be sure that nobody is using your services without paying for it.</p>
<p>Regarding the fourth item, just imagine sending a request to a web service provider with an order. That order will probably contain some order items, an address and payment information. If anyone can read that information, it is only a matter of minutes before the credit card number has been abused. We want to be absolutely sure that only the client and the server are aware of the contents of the messages.</p>
<p>And finally, if a message has been tampered with, we want both the client and the server to be able to reject that message. After all, when sending the order again, we wouldn&#8217;t want our competitor to intercept the message, change the delivery address to their own (although that would be really easy to trace for law enforcement) and forward the message to the service provider. In some countries, at least in The Netherlands, the tax authority requires that digital invoices are signed by the sender using a trusted digital certificate.</p>
<p>There are several tools, methods and libraries available to achieve one or more of these goals. In my next articles, I will elaborate more on the following topics:</p>
<ol>
<li>
<div><a href="http://www.gridshore.nl/2008/05/20/feeling-secure-with-web-services-part-1-the-usernametoken/">Username Token authentication</a>,</div>
</li>
<li>
<div><a href="http://www.gridshore.nl/2008/05/26/feeling-secure-with-web-services-part-2/">Transport Level Security and Message encryption</a>,</div>
</li>
<li>
<div><a href="http://www.gridshore.nl/2008/06/01/feeling-secure-with-web-services-part-3-digital-signature/">Digital signing</a></div>
</li>
</ol>
<hr />[1] Jip and Janneke are two very popular cartoon characters for small children. You might just recognize them: <a href="http://images.google.nl/images?q=jip+and+janneke&amp;hl=nl&amp;um=1&amp;ie=UTF-8&amp;sa=X&amp;oi=images&amp;ct=title">http://images.google.nl/images?q=jip+and+janneke&amp;hl=nl&amp;um=1&amp;ie=UTF-8&amp;sa=X&amp;oi=images&amp;ct=title</a></p>
<p>[2]http://en.wikipedia.org/wiki/Security</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F05%2F17%2Ffeeling-secure-with-web-services-introduction%2F&amp;title=Feeling%20secure%20with%20Web%20Services%20-%20Introduction&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/05/17/feeling-secure-with-web-services-introduction/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Why are web services so different from an HTML user interface?</title>
		<link>http://www.gridshore.nl/2008/02/13/why-are-web-services-so-different-from-an-html-user-interface/</link>
		<comments>http://www.gridshore.nl/2008/02/13/why-are-web-services-so-different-from-an-html-user-interface/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 18:41:35 +0000</pubDate>
		<dc:creator>Allard</dc:creator>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[SOA]]></category>
		<category><![CDATA[user interface]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://www.gridshore.nl/2008/02/13/why-are-web-services-so-different-from-an-html-user-interface/</guid>
		<description><![CDATA[<p>We all know how a typical web application is usually built up. The image at the side rougly displays the different layers that are to be found in an application. Typically, the user interface layer receives HTTP requests, calls one or more methods in the Business logic layer, and responds with an HTTP message [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gridshore.nl/wp-content/gui-application-layout.gif" alt="Typical architecture of a GUI application" align="right" height="155" width="222" />We all know how a typical web application is usually built up. The image at the side rougly displays the different layers that are to be found in an application. Typically, the user interface layer receives HTTP requests, calls one or more methods in the Business logic layer, and responds with an HTTP message containing HTML.</p>
<p>Nowadays, SOA has come along, and suddenly all enterprise architects want XML web services everywhere. For some reason, many think of SOA as a synonym for &#8220;everything must be a web service&#8221;. What SOA really is, is not the topic of this article. I want to discuss the position these web services get in the overall picture.</p>
<p><img src="http://www.gridshore.nl/wp-content/gui-and-ws-separated.gif" alt="Application design when GUI and WS are separated" align="left" height="296" width="220" />The &#8220;Business logic&#8221; layer could contain business services that are useful to other applications too. In that case, it might be an option to provide these business services to the &#8220;outside world&#8221; as XML Web Services. So, the user interface is separated from the rest of the application and replaced with a Web Services interface layer. The business logic is now available to all applications that need it. The user interface that had just been removed is now considered another application that uses the business logic layer through a web services layer.</p>
<p>On paper, it might not even look that ugly. There are, however several major downsides to this approach.</p>
<p>First of all, performance is decreased, as XML Web Service calls cost a lot of processing time. Not only marshalling the request and the response take a lot of time, but HTTP communication takes its toll too.</p>
<p>Something developers will notice, especially after the first release, is that this choice of architecture is difficult to maintain. Most changes that have been requested involve the user interface; a little more information here, something else there, etc. However, to get this information to the front-end, changes have to be made in the business logic, domain model and or the Web Service interface.</p>
<p>The third downside is that the &#8220;Business Logic&#8221; layer and the &#8220;User interface&#8221; layer are (often) functionally coupled. The main functions exposed in the view have almost a one-to-one mapping to business services. Splitting these two layers into different application would then sound inappropriate.</p>
<p>So why is this apparently homogeneous application split up into different components?</p>
<p>One thing I have heard is that this is the way SOA prescribes it should be done. I&#8217;ve read many documents and specifications, but I have never found a single one that says so. It might be obvious that I disagree.</p>
<p>Another excuse is &#8220;versioning&#8221;. For some reason, people think more of versioning as a problem than as an opportunity. When done right, versioning of a web service should be a big problem. But a more important question is: why should you version a service? Probably because the business rules in the business logic layer have changed. If that is the case, why keep the old version alive? It uses a deprecated business logic layer. Another reason to version is because the request/response model of the web service doesn&#8217;t provide all available information. That can be easily solved by adding either a new service, or an optional parameter to the existing request indicating an extended response is wanted. In my article about <a href="http://www.gridshore.nl/blog/index.php?/archives/68-Web-service-versioning-in-the-java-world.html" title="Web Service versioning in the Java world">Web Service versioning in Java</a>, I go more in-depth on ways services can be versioned (limiting to Java).</p>
<p>However, the most common excuse for the separation is reuse. &#8220;Maybe, in the future, more application might want to use this functionality too&#8221; is a sentence I have heard more than once too often. Will the business logic ever be used by another application? If that is the case, will the request/response model chosen sufficient for that application? Big chance that the answers are respectively &#8220;Most probably not&#8221; and &#8220;Very little chance&#8221;.</p>
<p>It is obvious that I am not fond of this solution. Not because I don&#8217;t think it really sounds right, but because I have dealt with this structure in my day to day work. Not somehting I would want to wish you.</p>
<p>I prefer to see the analogy between the User Interface (UI) layer and the Web Services (WS) layer. The UI presents an Business Logic interface to human users. HTML is usually the format of choice. A Web Service layer is exactly that, but then presents the same functionality in another format. For example as SOAP/XML messages. Or as JMS messages on a queue. And let&#8217;s not forget REST.</p>
<p><img src="http://www.gridshore.nl/wp-content/gui-and-ws-combined.gif" alt="GUI-and-WS-combined" align="right" height="148" width="211" />When you see the analogy between the UI and the WS interface, an architectural layout as the image on your right is a good option. In this picture, I have drawn a single &#8220;WS&#8221; box, but there could be more, depending on the types of services you would like to expose. I have, however, never seen more than one WS interface type in an application, and it usually is a SOAP based web service.</p>
<p>The application is still usable by other applications, accessible for other users and a lot easier to develop. There really aren&#8217;t any concessions to be made compared to the completely separated variant. Furthermore, the Web Service only has to be added at the point in time another application actualy needs it. This allows the request/response model to be designed in such a way that external application can take full advantage of the business logic.</p>
<p>I am conviced that the last option provides the most possibilities with the least concessions. And isn&#8217;t that exactly what we want? Or did I really miss something? In that case, please leave a comment and let me know.</p>
<div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><iframe src='http://widgets.dzone.com/links/widgets/zoneit.html?url=http%3A%2F%2Fwww.gridshore.nl%2F2008%2F02%2F13%2Fwhy-are-web-services-so-different-from-an-html-user-interface%2F&amp;title=Why%20are%20web%20services%20so%20different%20from%20an%20HTML%20user%20interface%3F&amp;t=2' height='25' width='155' frameborder='0' scrolling='no'></iframe></div></div><div style='clear:both'></div></div><!-- Social Buttons Generated by Digg Digg plugin v4.5.3.4, 
    Author : Yong Mook Kim
    Website : http://www.diggdigg2u.com -->]]></content:encoded>
			<wfw:commentRss>http://www.gridshore.nl/2008/02/13/why-are-web-services-so-different-from-an-html-user-interface/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

