introduction.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <chapter version="5.0" xml:id="introduction" xmlns="http://docbook.org/ns/docbook"
  3. xmlns:xlink="http://www.w3.org/1999/xlink">
  4. <title>Introduction</title>
  5. <section xml:id="what-is-acegi-security">
  6. <title>What is Spring Security?</title>
  7. <para>Spring Security provides comprehensive security services for J2EE-based enterprise
  8. software applications. There is a particular emphasis on supporting projects built using
  9. The Spring Framework, which is the leading J2EE solution for enterprise software
  10. development. If you're not using Spring for developing enterprise applications, we
  11. warmly encourage you to take a closer look at it. Some familiarity with Spring - and in
  12. particular dependency injection principles - will help you get up to speed with Spring
  13. Security more easily.</para>
  14. <para>People use Spring Security for many reasons, but most are drawn to the project after
  15. finding the security features of J2EE's Servlet Specification or EJB Specification lack
  16. the depth required for typical enterprise application scenarios. Whilst mentioning these
  17. standards, it's important to recognise that they are not portable at a WAR or EAR level.
  18. Therefore, if you switch server environments, it is typically a lot of work to
  19. reconfigure your application's security in the new target environment. Using Spring
  20. Security overcomes these problems, and also brings you dozens of other useful,
  21. customisable security features.</para>
  22. <para>As you probably know two major areas of application security are
  23. <quote>authentication</quote> and <quote>authorization</quote> (or
  24. <quote>access-control</quote>). These are the two main areas that Spring Security
  25. targets. <quote>Authentication</quote> is the process of establishing a principal is who
  26. they claim to be (a <quote>principal</quote> generally means a user, device or some
  27. other system which can perform an action in your application).
  28. <quote>Authorization</quote> refers to the process of deciding whether a principal is
  29. allowed to perform an action within your application. To arrive at the point where an
  30. authorization decision is needed, the identity of the principal has already been
  31. established by the authentication process. These concepts are common, and not at all
  32. specific to Spring Security. </para>
  33. <para>At an authentication level, Spring Security supports a wide range of authentication
  34. models. Most of these authentication models are either provided by third parties, or are
  35. developed by relevant standards bodies such as the Internet Engineering Task Force. In
  36. addition, Spring Security provides its own set of authentication features. Specifically,
  37. Spring Security currently supports authentication integration with all of these
  38. technologies:</para>
  39. <itemizedlist spacing="compact">
  40. <listitem>
  41. <para>HTTP BASIC authentication headers (an IETF RFC-based standard)</para>
  42. </listitem>
  43. <listitem>
  44. <para>HTTP Digest authentication headers (an IETF RFC-based standard)</para>
  45. </listitem>
  46. <listitem>
  47. <para>HTTP X.509 client certificate exchange (an IETF RFC-based standard)</para>
  48. </listitem>
  49. <listitem>
  50. <para>LDAP (a very common approach to cross-platform authentication needs,
  51. especially in large environments)</para>
  52. </listitem>
  53. <listitem>
  54. <para>Form-based authentication (for simple user interface needs)</para>
  55. </listitem>
  56. <listitem>
  57. <para>OpenID authentication</para>
  58. </listitem>
  59. <listitem>
  60. <para>Authentication based on pre-established request headers (such as Computer
  61. Associates Siteminder)</para>
  62. </listitem>
  63. <listitem>
  64. <para>JA-SIG Central Authentication Service (otherwise known as CAS, which is a
  65. popular open source single sign-on system)</para>
  66. </listitem>
  67. <listitem>
  68. <para>Transparent authentication context propagation for Remote Method Invocation
  69. (RMI) and HttpInvoker (a Spring remoting protocol)</para>
  70. </listitem>
  71. <listitem>
  72. <para>Automatic "remember-me" authentication (so you can tick a box to avoid
  73. re-authentication for a predetermined period of time)</para>
  74. </listitem>
  75. <listitem>
  76. <para>Anonymous authentication (allowing every unauthenticated call to automatically assume a
  77. particular security identity)</para>
  78. </listitem>
  79. <listitem>
  80. <para>Run-as authentication (which is useful if one call should proceed with a
  81. different security identity)</para>
  82. </listitem>
  83. <listitem>
  84. <para>Java Authentication and Authorization Service (JAAS)</para>
  85. </listitem>
  86. <listitem>
  87. <para>JEE container autentication (so you can still use Container Managed
  88. Authentication if desired)</para>
  89. </listitem>
  90. <listitem>
  91. <para>Kerberos</para>
  92. </listitem>
  93. <listitem>
  94. <para>Java Open Source Single Sign On (JOSSO) *</para>
  95. </listitem>
  96. <listitem>
  97. <para>OpenNMS Network Management Platform *</para>
  98. </listitem>
  99. <listitem>
  100. <para>AppFuse *</para>
  101. </listitem>
  102. <listitem>
  103. <para>AndroMDA *</para>
  104. </listitem>
  105. <listitem>
  106. <para>Mule ESB *</para>
  107. </listitem>
  108. <listitem>
  109. <para>Direct Web Request (DWR) *</para>
  110. </listitem>
  111. <listitem>
  112. <para>Grails *</para>
  113. </listitem>
  114. <listitem>
  115. <para>Tapestry *</para>
  116. </listitem>
  117. <listitem>
  118. <para>JTrac *</para>
  119. </listitem>
  120. <listitem>
  121. <para>Jasypt *</para>
  122. </listitem>
  123. <listitem>
  124. <para>Roller *</para>
  125. </listitem>
  126. <listitem>
  127. <para>Elastic Path *</para>
  128. </listitem>
  129. <listitem>
  130. <para>Atlassian Crowd *</para>
  131. </listitem>
  132. <listitem>
  133. <para>Your own authentication systems (see below)</para>
  134. </listitem>
  135. </itemizedlist>
  136. <para>(* Denotes provided by a third party</para>
  137. <!-- TODO: Reinstate web link to third-party integrations/users -->
  138. <para>Many independent software vendors (ISVs) adopt Spring Security because of this
  139. significant choice of flexible authentication models. Doing so allows them to quickly
  140. integrate their solutions with whatever their end clients need, without undertaking a
  141. lot of engineering or requiring the client to change their environment. If none of the
  142. above authentication mechanisms suit your needs, Spring Security is an open platform and
  143. it is quite simple to write your own authentication mechanism. Many corporate users of
  144. Spring Security need to integrate with "legacy" systems that don't follow any particular
  145. security standards, and Spring Security is happy to "play nicely" with such
  146. systems.</para>
  147. <para>Irrespective of the authentication mechanism, Spring Security provides a deep set
  148. of authorization capabilities. There are three main areas of interest
  149. - authorizing web requests, authorizing whether methods can be
  150. invoked, and authorizing access to individual domain object instances. To help you
  151. understand the differences, consider the authorization capabilities found in the Servlet
  152. Specification web pattern security, EJB Container Managed Security and file system
  153. security respectively. Spring Security provides deep capabilities in all of these
  154. important areas, which we'll explore later in this reference guide.</para>
  155. </section>
  156. <section xml:id="history">
  157. <title>History</title>
  158. <para>Spring Security began in late 2003 as <quote>The Acegi Security System for
  159. Spring</quote>. A question was posed on the Spring Developers' mailing list asking
  160. whether there had been any consideration given to a Spring-based security
  161. implementation. At the time the Spring community was relatively small (especially
  162. compared with the size today!), and indeed Spring itself had only existed as a
  163. SourceForge project from early 2003. The response to the question was that it was a
  164. worthwhile area, although a lack of time currently prevented its exploration.</para>
  165. <para>With that in mind, a simple security implementation was built and not released. A few
  166. weeks later another member of the Spring community inquired about security, and at the
  167. time this code was offered to them. Several other requests followed, and by January 2004
  168. around twenty people were using the code. These pioneering users were joined by others
  169. who suggested a SourceForge project was in order, which was duly established in March
  170. 2004.</para>
  171. <para>In those early days, the project didn't have any of its own authentication modules.
  172. Container Managed Security was relied upon for the authentication process, with Acegi
  173. Security instead focusing on authorization. This was suitable at first, but as more and
  174. more users requested additional container support, the fundamental limitation of
  175. container-specific authentication realm interfaces became clear. There was also a
  176. related issue of adding new JARs to the container's classpath, which was a common source
  177. of end user confusion and misconfiguration.</para>
  178. <para>Acegi Security-specific authentication services were subsequently introduced. Around a
  179. year later, Acegi Security became an official Spring Framework subproject. The 1.0.0
  180. final release was published in May 2006 - after more than two and a half years of active
  181. use in numerous production software projects and many hundreds of improvements and
  182. community contributions.</para>
  183. <para>Acegi Security became an official Spring Portfolio project towards the end of 2007 and
  184. was rebranded as <quote>Spring Security</quote>.</para>
  185. <para>Today Spring Security enjoys a strong and active open source community. There are
  186. thousands of messages about Spring Security on the support forums. There is an active
  187. core of developers who work on the code itself and an active community which also
  188. regularly share patches and support their peers.</para>
  189. </section>
  190. <section xml:id="release-numbering">
  191. <title>Release Numbering</title>
  192. <para>It is useful to understand how Spring Security release numbers work, as it will help
  193. you identify the effort (or lack thereof) involved in migrating to future releases of
  194. the project. Each release uses a standard triplet of integers: MAJOR.MINOR.PATCH. The
  195. intent is that MAJOR versions are incompatible, large-scale upgrades of the API. MINOR
  196. versions should largely retain source and binary compatibility with older minor
  197. versions, thought there may be some design changes and incompatible udates. PATCH level
  198. should be perfectly compatible, forwards and backwards, with the possible exception of
  199. changes which are to fix bugs and defects.</para>
  200. <para>The extent to which you are affected by changes will depend on how tightly integrated
  201. your code is. If you are doing a lot of customization you are more likely to be affected
  202. than if you are using a simple namespace configuration.</para>
  203. <para>You should always test your application thoroughly before rolling out a new
  204. version.</para>
  205. </section>
  206. <section xml:id="get-spring-security">
  207. <title>Getting Spring Security</title>
  208. <para>You can get hold of Spring Security in several ways. You can download a packaged
  209. distribution from the main Spring <link
  210. xlink:href="http://www.springsource.com/download/community?project=Spring%20Security"
  211. >download page</link>, download individual jars (and sample WAR files) from the Maven
  212. Central repository (or a SpringSource Maven repository for snapshot and milestone
  213. releases) or, alternatively, you can build the project from source yourself. See the
  214. project web site for more details. </para>
  215. <section xml:id="modules">
  216. <title>Project Modules</title>
  217. <para>In Spring Security 3.0, the codebase has been sub-divided into separate jars which
  218. more clearly separate different functionaltiy areas and third-party dependencies. If
  219. you are using Maven to build your project, then these are the modules you will add
  220. to your <filename>pom.xml</filename>. Even if you're not using Maven, we'd recommend
  221. that you consult the <filename>pom.xml</filename> files to get an idea of
  222. third-party dependencies and versions. Alternatively, a good idea is to examine the
  223. libraries that are included in the sample applications.</para>
  224. <section xml:id="spring-security-core">
  225. <title>Core - <literal>spring-security-core.jar</literal></title>
  226. <para>Contains core authentication and access-contol classes and interfaces,
  227. remoting support and basic provisioning APIs. Required by any application which
  228. uses Spring Security. Supports standalone applications, remote clients, method
  229. (service layer) security and JDBC user provisioning. Contains the top-level packages:<itemizedlist>
  230. <listitem>
  231. <para><literal>org.springframework.security.core</literal></para>
  232. </listitem>
  233. <listitem>
  234. <para><literal>org.springframework.security.access</literal></para>
  235. </listitem>
  236. <listitem>
  237. <para><literal>org.springframework.security.authentication</literal></para>
  238. </listitem>
  239. <listitem>
  240. <para><literal>org.springframework.security.provisioning</literal></para>
  241. </listitem>
  242. <listitem>
  243. <para><literal>org.springframework.security.remoting</literal></para>
  244. </listitem>
  245. </itemizedlist></para>
  246. </section>
  247. <section xml:id="spring-security-web">
  248. <title>Web - <literal>spring-security-web.jar</literal></title>
  249. <para>Contains filters and related web-security infrastructure code. Anything with a
  250. servlet API dependency. You'll need it if you require Spring Security web
  251. authentication services and URL-based access-control. The main package is
  252. <literal>org.springframework.security.web</literal>.</para>
  253. </section>
  254. <section xml:id="spring-security-config">
  255. <title>Config - <literal>spring-security-config.jar</literal></title>
  256. <para>Contains the security namespace parsing code. You need it if you are using the
  257. Spring Security XML namespace for configuration. The main package is
  258. <literal>org.springframework.security.config</literal>. None of the
  259. classes are intended for direct use in an application.</para>
  260. </section>
  261. <section xml:id="spring-security-ldap">
  262. <title>LDAP - <literal>spring-security-ldap.jar</literal></title>
  263. <para>LDAP authentication and provisioning code. Required if you need to use LDAP
  264. authentication or manage LDAP user entries. The top-level package is
  265. <literal>org.springframework.security.ldap</literal>.</para>
  266. </section>
  267. <section xml:id="spring-security-acl">
  268. <title>ACL - <literal>spring-security-acl.jar</literal></title>
  269. <para>Specialized domain object ACL implementation. Used to apply security to
  270. specific domain object instances within your application. The top-level package
  271. is <literal>org.springframework.security.acls</literal>.</para>
  272. </section>
  273. <section xml:id="spring-security-cas">
  274. <title>CAS - <literal>spring-security-cas-client.jar</literal></title>
  275. <para>Spring Security's CAS client integration. If you want to use Spring Security
  276. web authentication with a CAS single sign-on server. The top-level package is
  277. <literal>org.springframework.security.cas</literal>.</para>
  278. </section>
  279. <section xml:id="spring-security-openid">
  280. <title>OpenID - <literal>spring-security-openid.jar</literal></title>
  281. <para>OpenID web authentication support. Used to authenticate users against an
  282. external OpenID server. <literal>org.springframework.security.openid</literal>.
  283. Requires OpenID4Java.</para>
  284. </section>
  285. <section xml:id="spring-security-crypto">
  286. <title>Crypto - <literal>spring-security-crypto.jar</literal></title>
  287. <para>Contains cryptography utility functions which are used by other
  288. Spring projects. <literal>org.springframework.security.crypto</literal>.
  289. </para>
  290. </section>
  291. </section>
  292. <section xml:id="get-source">
  293. <title>Checking out the Source</title>
  294. <para> Since Spring Security is an Open Source project, we'd strongly encourage you to
  295. check out the source code using git. This will give you full access to all the
  296. sample applications and you can build the most up to date version of the project
  297. easily. Having the source for a project is also a huge help in debugging. Exception
  298. stack traces are no longer obscure black-box issues but you can get straight to the
  299. line that's causing the problem and work out what's happening. The source is the
  300. ultimate documentation for a project and often the simplest place to find out how
  301. something actually works. </para>
  302. <para>To obtain the source for the project, use the following git command:
  303. <programlisting language="txt">
  304. git clone git://git.springsource.org/spring-security/spring-security.git
  305. </programlisting>
  306. </para>
  307. <para>This will give you access to the entire project history (including all releases
  308. and branches) on your local machine.</para>
  309. </section>
  310. </section>
  311. </chapter>