|
Secure Communication: Application
For finer control over applied security mechanisms, an application can use an application-level, token-based protection mechanism, abstract from the underlying transmission protocol. This approach has an advantage over channel blanket encryption by being smarter and protecting only sensitive data. For instance, web services (see later in this section) use this paradigm for message protection, where only particular details of messages are signed and encrypted.
As already explained, J2SE includes GSSAPI, which may be utilized on the application level to provide token-based protection using the Kerberos V 5. GSSAPI framework, is quite a thin wrapper, delegating all requests to the underlying mechanism providers. The Java GSS mechanisms do not perform user logins themselves -- they should be done using JAAS prior to invoking GSSAPI services, and the credentials should be stored in some cache accessible to the GSS mechanism provider. Using JAAS and Kerberos tickets in GSS provides not only transport-level security protection, but also a principal delegation mechanism over the network. See "Authentication" in Part 4 for more information about JAAS and delegation.
GSS classes reside in the org.ietf.jgss package; check the online documentation for details and code examples.
Overall, Java offers a choice of platform-level (JSSE) and application-level (GSS) protection services with similar security goals: client-server authentication and protection of transmitted data. Listed below are a few criteria that can help to decide which service is more appropriate for a particular application:
JSSE is very easy to use from client's code -- no action besides establishing the proper socket factory is needed. GSS setup and coding are significantly more involved.
Java's "Single Sign-On" mechanism is based on Kerberos V5, which is supported only by GSS.
JSSE implementations are socket-based and typically use TCP as the underlying protocol. GSS is token-based and can use any communication channel for token transmission -- the code is responsible for establishing the channel, though.
GSS is capable of client credential delegation.
JSSE encrypts all data sent through the socket. GSS, being token-based, can encrypt tokens selectively, thus significantly lowering computational load.
JSSE implements TLS 1.0 and SSL 3.0 communication protocols. GSS supports only the Kerberos V5 protocol (known as "SSPI with Kerberos" on Win32), and provides implementation of IETF's generic GSS-API framework.
Web services security specifications and toolkits also look at protecting individual messages, or tokens. This area has been rapidly evolving, and has not yet been fully standardized. Because of this lack of standards, both platforms provide only partial support for it via extensions or external products. However, since the topic of web services security alone warrants a whole separate book, it is not addressed here in any significant detail. Of all competing standards in this area, only SAML and WS-Security have been so far accepted for standardization by OASIS, with the latter still undergoing committee reviews.
For web services security, Microsoft is actively promoting its Web Service Architecture (WSA, formerly GXA), and adds support for all released up-to-date specifications via its Web Services Extension (WSE) pack for .NET. WSE is currently at 1.0 release, with 2.0 coming soon -- check the MSDN documentation for updates and new releases. Notably, WSE (and .NET in general) lacks support for SAML, even though the WS-Security specification does define binding for SAML assertions as one of the supported token types. In other areas, WSE provides relatively complete support of WS-Security and a number of other specifications. Additionally, WSE's certificate classes (located in the Microsoft.Web.Services.Security.X509 package) are much more convenient to deal with than .NET's original ones. The code sample below shows how to sign a request using WSE:
// Get SOAP context from the Web service proxy
SoapContext reqCxt =
serviceProxy.RequestSoapContext;
// Retrieve the certificate to be used for signing
Microsoft.Web.Services.Security.X509.X509Certificate crt = ...;
// Create a X509 security token
X509SecurityToken token =
new X509SecurityToken(crt);
// Sign the request by adding
//a signature to the request
reqCxt.Security.Tokens.Add(token);
reqCxt.Security.Elements.Add(
new Signature(token));
// Use the signed request to call the service...
serviceProxy.Hello();
The extensible architecture of .NET's Remoting has allowed for the development of quite interesting approaches to transport security, whereas Remoting's RPC-style invocations are transmitted and protected by the means of SOAP-based web service messages. In principle, this is not very different from the Microsoft solution described earlier, but it allows applying WSA-family protection (in particular, WS-Security) to individual messages, which ensures standard-based authentication, integrity, and authorization at the message level, as opposed to the non-standard approach of blank encryption of the former solution. For explanations and code samples, read the excellent publications at the CodeProject web site, in particular ""Remoting over Internet"" and related articles.
The Java platform does not provide direct support for web services security yet. Currently, there are two web services security-related JSRs at work: JSR 155 "Web Services Security Assertions", and JSR 183 "Web Services Message Security APIs". When accepted (although they have been in review stage for over a year now), these specifications should provide assertions support and transport-level security to web services written in Java. Although not a standard part of Java platform, IBM's Emerging Technologies Toolkit v1.2 (ETTK), formerly known as Web Services Development Kit, or WSTK, adds support for the current draft of WS-Security and some other specifications from the WSA family, of which IBM is a co-author.
Note: The .NET platform stays very current with the latest developments in web services security, while their support in Java is not standardized and is limited to offerings from individual vendors. |
|