appendix-namespace.xml 140 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <appendix version="5.0" xml:id="appendix-namespace" xmlns="http://docbook.org/ns/docbook"
  3. xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <info>
  5. <title>The Security Namespace</title>
  6. </info>
  7. <para> This appendix provides a reference to the elements available in the security namespace
  8. and information on the underlying beans they create (a knowledge of the individual classes
  9. and how they work together is assumed - you can find more information in the project Javadoc
  10. and elsewhere in this document). If you haven't used the namespace before, please read the
  11. <link xlink:href="#ns-config">introductory chapter</link> on namespace configuration, as
  12. this is intended as a supplement to the information there. Using a good quality XML editor
  13. while editing a configuration based on the schema is recommended as this will provide
  14. contextual information on which elements and attributes are available as well as comments
  15. explaining their purpose. The namespace is written in <link
  16. xlink:href="http://www.relaxng.org/">RELAX NG</link> Compact format and later converted into
  17. an XSD schema. If you are familiar with this format, you may wish to examine the <link
  18. xlink:href="https://fisheye.springsource.org/browse/spring-security/config/src/main/resources/org/springframework/security/config/spring-security-3.1.rnc"
  19. >schema file</link> directly.</para>
  20. <section xml:id="nsa-web">
  21. <title>Web Application Security</title>
  22. <section xml:id="nsa-debug">
  23. <title><literal>&lt;debug&gt;</literal></title>
  24. <para>Enables Spring Security debugging infrastructure. This will provide human-readable (multi-line)
  25. debugging information to monitor requests coming into the security filters. This may include sensitive
  26. information, such as request parameters or headers, and should only be used in a development
  27. environment.</para>
  28. </section>
  29. <section xml:id="nsa-http">
  30. <title><literal>&lt;http&gt;</literal></title>
  31. <para> If you use an <literal>&lt;http&gt;</literal> element within your application, a
  32. <classname>FilterChainProxy</classname> bean named "springSecurityFilterChain" is
  33. created and the configuration within the element is used to build a filter chain within
  34. <classname>FilterChainProxy</classname>. As of Spring Security 3.1, additional
  35. <literal>http</literal> elements can be used to add extra filter chains <footnote>
  36. <para>See the <link xlink:href="#ns-web-xml">introductory chapter</link> for how to set
  37. up the mapping from your <literal>web.xml</literal></para>
  38. </footnote>. Some core filters are always created in a filter chain and others will be
  39. added to the stack depending on the attributes and child elements which are present. The
  40. positions of the standard filters are fixed (see <link xlink:href="#filter-stack">the
  41. filter order table</link> in the namespace introduction), removing a common source of
  42. errors with previous versions of the framework when users had to configure the filter
  43. chain explicitly in the <classname>FilterChainProxy</classname> bean. You can, of course,
  44. still do this if you need full control of the configuration. </para>
  45. <para> All filters which require a reference to the
  46. <interfacename>AuthenticationManager</interfacename> will be automatically injected with
  47. the internal instance created by the namespace configuration (see the <link
  48. xlink:href="#ns-auth-manager">introductory chapter</link> for more on the
  49. <interfacename>AuthenticationManager</interfacename>). </para>
  50. <para> Each <literal>&lt;http&gt;</literal> namespace block always creates an
  51. <classname>SecurityContextPersistenceFilter</classname>, an
  52. <classname>ExceptionTranslationFilter</classname> and a
  53. <classname>FilterSecurityInterceptor</classname>. These are fixed and cannot be replaced
  54. with alternatives. </para>
  55. <section xml:id="nsa-http-attributes">
  56. <title><literal>&lt;http&gt;</literal> Attributes</title>
  57. <para> The attributes on the <literal>&lt;http&gt;</literal> element control some of the
  58. properties on the core filters. </para>
  59. <section xml:id="nsa-http-access-decision-manager-ref">
  60. <title><literal>access-decision-manager-ref</literal></title>
  61. <para> Optional attribute specifying the ID of the
  62. <interfacename>AccessDecisionManager</interfacename> implementation which should
  63. be used for authorizing HTTP requests. By default an
  64. <classname>AffirmativeBased</classname> implementation is used for with a
  65. <classname>RoleVoter</classname> and an
  66. <classname>AuthenticatedVoter</classname>. </para>
  67. </section>
  68. <section xml:id="nsa-http-access-denied-page">
  69. <title><literal>access-denied-page</literal></title>
  70. <para> Deprecated in favour of the <link xlink:href="#nsa-access-denied-handler">access-denied-handler</link>
  71. child element.</para>
  72. </section>
  73. <section xml:id="nsa-http-authentication-manager-ref">
  74. <title><literal>authentication-manager-ref</literal></title>
  75. <para>A reference to the <interfacename>AuthenticationManager</interfacename> used for the
  76. <classname>FilterChain</classname> created by this http element.</para>
  77. </section>
  78. <section xml:id="nsa-http-auto-config">
  79. <title><literal>auto-config</literal></title>
  80. <para>Automatically registers a login form, BASIC authentication, anonymous authentication, logout
  81. services, remember-me and servlet-api-integration. If set to "true", all of these capabilities are added
  82. (although you can still customize the configuration of each by providing the respective element). If
  83. unspecified, defaults to "false".</para>
  84. </section>
  85. <section xml:id="nsa-http-create-session">
  86. <title><literal>create-session</literal></title>
  87. <para>Controls the eagerness with which an HTTP session is created by Spring Security classes.
  88. Options include:
  89. <itemizedlist>
  90. <listitem>
  91. <literal>always</literal> - Spring Security will proactively create a session if one
  92. does not exist.
  93. </listitem>
  94. <listitem>
  95. <literal>ifRequired</literal> - Spring Security will only create a session only if one
  96. is required (default value).
  97. </listitem>
  98. <listitem>
  99. <literal>never</literal> - Spring Security will never create a session, but will
  100. make use of one if the application does.</listitem>
  101. <listitem>
  102. <literal>stateless</literal> - Spring Security will not create a session and ignore the
  103. session for obtaining a Spring <interfacename>Authentication</interfacename>.
  104. </listitem>
  105. </itemizedlist>
  106. </para>
  107. </section>
  108. <section xml:id="nsa-http-disable-url-rewriting">
  109. <title><literal>disable-url-rewriting</literal></title>
  110. <para>Prevents session IDs from being appended to URLs in the application. Clients
  111. must use cookies if this attribute is set to <literal>true</literal>. The default is
  112. <literal>false</literal>.</para>
  113. </section>
  114. <section xml:id="nsa-http-entry-point-ref">
  115. <title><literal>entry-point-ref</literal></title>
  116. <para> Normally the <interfacename>AuthenticationEntryPoint</interfacename> used
  117. will be set depending on which authentication mechanisms have been configured.
  118. This attribute allows this behaviour to be overridden by defining a customized
  119. <interfacename>AuthenticationEntryPoint</interfacename> bean which will start
  120. the authentication process.</para>
  121. </section>
  122. <section xml:id="nsa-http-jaas-api-provision">
  123. <title><literal>jaas-api-provision</literal></title>
  124. <para>If available, runs the request as the <literal>Subject</literal> acquired from
  125. the <classname>JaasAuthenticationToken</classname> which is implemented by
  126. adding a <classname>JaasApiIntegrationFilter</classname> bean to the stack.
  127. Defaults to <literal>false</literal>.</para>
  128. </section>
  129. <section xml:id="nsa-http-name">
  130. <title><literal>name</literal></title>
  131. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  132. </section>
  133. <section xml:id="nsa-http-once-per-request">
  134. <title><literal>once-per-request</literal></title>
  135. <para>Corresponds to the <literal>observeOncePerRequest</literal> property of
  136. <classname>FilterSecurityInterceptor</classname>. Defaults to <literal>true</literal>.</para>
  137. </section>
  138. <section xml:id="nsa-http-path-type">
  139. <title><literal>path-type</literal></title>
  140. <para>Deprecated in favor of <link xlink:href="#nsa-http-request-matcher">request-matcher</link>.
  141. </para>
  142. </section>
  143. <section xml:id="nsa-http-pattern">
  144. <title><literal>pattern</literal></title>
  145. <para>Defining a pattern for the <link xlink:href="#nsa-http">http</link> element controls the
  146. requests which will be filtered through the list of filters which it defines.
  147. The interpretation is dependent on the configured <link
  148. xlink:href="#nsa-http-request-matcher">request-matcher</link>. If no pattern is defined,
  149. all requests will be matched, so the most specific patterns should be declared
  150. first.</para>
  151. </section>
  152. <section xml:id="nsa-http-realm">
  153. <title><literal>realm</literal></title>
  154. <para>Sets the realm name used for basic authentication (if enabled). Corresponds
  155. to the <literal>realmName</literal> property on
  156. <classname>BasicAuthenticationEntryPoint</classname>.</para>
  157. </section>
  158. <section xml:id="nsa-http-request-matcher">
  159. <title><literal>request-matcher</literal></title>
  160. <para>Defines the <interfacename>RequestMatcher</interfacename> strategy used in
  161. the <classname>FilterChainProxy</classname> and the beans created by the
  162. <literal>intercept-url</literal> to match incoming requests. Options are
  163. currently <literal>ant</literal>, <literal>regex</literal> and
  164. <literal>ciRegex</literal>, for ant, regular-expression and case-insensitive
  165. regular-expression repsectively. A separate instance is created for each
  166. <link xlink:href="#nsa-intercept-url">intercept-url</link> element using its
  167. <link xlink:href="#nsa-intercept-url-pattern">pattern</link> and
  168. <link xlink:href="#nsa-intercept-url-method">method</link> attributes. Ant paths
  169. are matched using an <classname>AntPathRequestMatcher</classname> and regular expressions
  170. are matched using a <classname>RegexRequestMatcher</classname>. See the Javadoc
  171. for these classes for more details on exactly how the matching is preformed. Ant
  172. paths are the default strategy.</para>
  173. </section>
  174. <section xml:id="nsa-http-request-matcher-ref">
  175. <title><literal>request-matcher-ref</literal></title>
  176. <para>A referenece to a bean that implements <interfacename>RequestMatcher</interfacename> that
  177. will determine if this <classname>FilterChain</classname> should be used. This is a more
  178. powerful alternative to <link xlink:href="#nsa-http-pattern">pattern</link>.</para>
  179. </section>
  180. <section xml:id="nsa-http-security">
  181. <title><literal>security</literal></title>
  182. <para>A request pattern can be mapped to an empty filter chain, by setting this
  183. attribute to <literal>none</literal>. No security will be applied and none of
  184. Spring Security's features will be available.</para>
  185. </section>
  186. <section xml:id="nsa-http-security-context-repository-ref">
  187. <title><literal>security-context-repository-ref</literal></title>
  188. <para>Allows injection of a custom
  189. <interfacename>SecurityContextRepository</interfacename> into the
  190. <classname>SecurityContextPersistenceFilter</classname>.</para>
  191. </section>
  192. <section xml:id="nsa-http-servlet-api-provision">
  193. <title><literal>servlet-api-provision</literal></title>
  194. <para>Provides versions of <literal>HttpServletRequest</literal> security methods
  195. such as <literal>isUserInRole()</literal> and <literal>getPrincipal()</literal>
  196. which are implemented by adding a
  197. <classname>SecurityContextHolderAwareRequestFilter</classname> bean to the
  198. stack. Defaults to <literal>true</literal>.</para>
  199. </section>
  200. <section xml:id="nsa-http-use-expressions">
  201. <title><literal>use-expressions</literal></title>
  202. <para>Enables EL-expressions in the <literal>access</literal> attribute, as
  203. described in the chapter on <link xlink:href="#el-access-web">expression-based
  204. access-control</link>.</para>
  205. </section>
  206. </section>
  207. <section xml:id="nsa-http-children">
  208. <title>Child Elements of &lt;http&gt;</title>
  209. <itemizedlist>
  210. <listitem><link xlink:href="#nsa-access-denied-handler">access-denied-handler</link></listitem>
  211. <listitem><link xlink:href="#nsa-anonymous">anonymous</link></listitem>
  212. <listitem><link xlink:href="#nsa-custom-filter">custom-filter</link></listitem>
  213. <listitem><link xlink:href="#nsa-expression-handler">expression-handler</link></listitem>
  214. <listitem><link xlink:href="#nsa-form-login">form-login</link></listitem>
  215. <listitem><link xlink:href="#nsa-http-basic">http-basic</link></listitem>
  216. <listitem><link xlink:href="#nsa-intercept-url">intercept-url</link></listitem>
  217. <listitem><link xlink:href="#nsa-jee">jee</link></listitem>
  218. <listitem><link xlink:href="#nsa-logout">logout</link></listitem>
  219. <listitem><link xlink:href="#nsa-openid-login">openid-login</link></listitem>
  220. <listitem><link xlink:href="#nsa-port-mappings">port-mappings</link></listitem>
  221. <listitem><link xlink:href="#nsa-remember-me">remember-me</link></listitem>
  222. <listitem><link xlink:href="#nsa-request-cache">request-cache</link></listitem>
  223. <listitem><link xlink:href="#nsa-session-management">session-management</link></listitem>
  224. <listitem><link xlink:href="#nsa-x509">x509</link></listitem>
  225. </itemizedlist>
  226. </section>
  227. </section>
  228. <section xml:id="nsa-access-denied-handler">
  229. <title><literal>&lt;access-denied-handler&gt;</literal></title>
  230. <para>This element allows you to set the <literal>errorPage</literal> property for the
  231. default <interfacename>AccessDeniedHandler</interfacename> used by the
  232. <classname>ExceptionTranslationFilter</classname>, using the
  233. <link xlink:href="#nsa-access-denied-handler-error-page">error-page</link> attribute, or
  234. to supply your own implementation using the
  235. <link xlink:href="#nsa-access-denied-handler-ref">ref</link> attribute. This is discussed
  236. in more detail in the section on the <link xlink:href="#access-denied-handler">
  237. <classname>ExceptionTranslationFilter</classname></link>.</para>
  238. <section xml:id="nsa-access-denied-handler-parents">
  239. <title>Parent Elements of <literal>&lt;access-denied-handler&gt;</literal></title>
  240. <itemizedlist>
  241. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  242. </itemizedlist>
  243. </section>
  244. <section xml:id="nsa-access-denied-handler-attributes">
  245. <title><literal>&lt;access-denied-handler&gt;</literal> Attributes</title>
  246. <section xml:id="nsa-access-denied-handler-error-page">
  247. <title><literal>error-page</literal></title>
  248. <para>The access denied page that an authenticated user will be redirected to if they request a
  249. page which they don't have the authority to access.</para>
  250. </section>
  251. <section xml:id="nsa-access-denied-handler-ref">
  252. <title><literal>ref</literal></title>
  253. <para>Defines a reference to a Spring bean of type <interfacename>AccessDeniedHandler
  254. </interfacename>.</para>
  255. </section>
  256. </section>
  257. </section>
  258. <section xml:id="nsa-anonymous">
  259. <title><literal>&lt;anonymous&gt;</literal></title>
  260. <para>Adds an <classname>AnonymousAuthenticationFilter</classname> to the stack and an
  261. <classname>AnonymousAuthenticationProvider</classname>. Required if you are using
  262. the <literal>IS_AUTHENTICATED_ANONYMOUSLY</literal> attribute.</para>
  263. <section xml:id="nsa-anonymous-parents">
  264. <title>Parent Elements of <literal>&lt;anonymous&gt;</literal></title>
  265. <itemizedlist>
  266. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  267. </itemizedlist>
  268. </section>
  269. <section xml:id="nsa-anonymous-attributes">
  270. <title><literal>&lt;anonymous&gt;</literal> Attributes</title>
  271. <section xml:id="nsa-anonymous-enabled">
  272. <title><literal>enabled</literal></title>
  273. <para>With the default namespace setup, the anonymous "authentication" facility is automatically
  274. enabled. You can disable it using this property.</para>
  275. </section>
  276. <section xml:id="nsa-anonymous-granted-authority">
  277. <title><literal>granted-authority</literal></title>
  278. <para>The granted authority that should be assigned to the anonymous request. Commonly this is used
  279. to assign the anonymous request particular roles, which can subsequently be used in authorization
  280. decisions. If unset, defaults to <literal>ROLE_ANONYMOUS</literal>.</para>
  281. </section>
  282. <section xml:id="nsa-anonymous-key">
  283. <title><literal>key</literal></title>
  284. <para>The key shared between the provider and filter. This generally does not need to be set. If
  285. unset, it will default to a secure randomly generated value. This means setting this value can
  286. improve startup time when using the anonymous functionality since secure random values can take
  287. a while to be generated.</para>
  288. </section>
  289. <section xml:id="nsa-anonymous-username">
  290. <title><literal>username</literal></title>
  291. <para>The username that should be assigned to the anonymous request. This allows the principal to
  292. be identified, which may be important for logging and auditing. if unset, defaults to
  293. <literal>anonymousUser</literal>.</para>
  294. </section>
  295. </section>
  296. </section>
  297. <section xml:id="nsa-custom-filter">
  298. <title><literal>&lt;custom-filter&gt;</literal></title>
  299. <para>This element is used to add a filter to the filter chain. It doesn't create any
  300. additional beans but is used to select a bean of type
  301. <interfacename>javax.servlet.Filter</interfacename> which is already defined in the
  302. application context and add that at a particular position in the filter chain
  303. maintained by Spring Security. Full details can be found in the <link xlink:href="#ns-custom-filters">
  304. namespace chapter</link>.</para>
  305. <section xml:id="nsa-custom-filter-parents">
  306. <title>Parent Elements of <literal>&lt;custom-filter&gt;</literal></title>
  307. <itemizedlist>
  308. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  309. </itemizedlist>
  310. </section>
  311. <section xml:id="nsa-custom-filter-attributes">
  312. <title><literal>&lt;custom-filter&gt;</literal> Attributes</title>
  313. <section xml:id="nsa-custom-filter-after">
  314. <title><literal>after</literal></title>
  315. <para>The filter immediately after which the custom-filter should be placed in the chain. This
  316. feature will only be needed by advanced users who wish to mix their own filters into the
  317. security filter chain and have some knowledge of the standard Spring Security filters. The
  318. filter names map to specific Spring Security implementation filters.</para>
  319. </section>
  320. <section xml:id="nsa-custom-filter-before">
  321. <title><literal>before</literal></title>
  322. <para>The filter immediately before which the custom-filter should be placed in the chain</para>
  323. </section>
  324. <section xml:id="nsa-custom-filter-position">
  325. <title><literal>position</literal></title>
  326. <para>The explicit position at which the custom-filter should be placed in the chain. Use if you
  327. are replacing a standard filter.</para>
  328. </section>
  329. <section xml:id="nsa-custom-filter-ref">
  330. <title><literal>ref</literal></title>
  331. <para>Defines a reference to a Spring bean that implements <interfacename>Filter</interfacename>.</para>
  332. </section>
  333. </section>
  334. </section>
  335. <section xml:id="nsa-expression-handler">
  336. <title><literal>&lt;expression-handler&gt;</literal></title>
  337. <para>Defines the <interfacename>SecurityExpressionHandler</interfacename> instance which will be used if
  338. expression-based access-control is enabled. A default implementation (with no ACL support) will be used
  339. if not supplied.</para>
  340. <section xml:id="nsa-expression-handler-parents">
  341. <title>Parent Elements of <literal>&lt;expression-handler&gt;</literal></title>
  342. <itemizedlist>
  343. <listitem><link xlink:href="#nsa-global-method-security">global-method-security</link></listitem>
  344. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  345. </itemizedlist>
  346. </section>
  347. <section xml:id="nsa-expression-handler-attributes">
  348. <title><literal>&lt;expression-handler&gt;</literal> Attributes</title>
  349. <section xml:id="nsa-expression-handler-ref">
  350. <title><literal>ref</literal></title>
  351. <para>Defines a reference to a Spring bean that implements <interfacename>SecurityExpressionHandler</interfacename>.</para>
  352. </section>
  353. </section>
  354. </section>
  355. <section xml:id="nsa-form-login">
  356. <title><literal>&lt;form-login&gt;</literal></title>
  357. <para>Used to add an <classname>UsernamePasswordAuthenticationFilter</classname> to the
  358. filter stack and an <classname>LoginUrlAuthenticationEntryPoint</classname> to the
  359. application context to provide authentication on demand. This will always take
  360. precedence over other namespace-created entry points. If no attributes are supplied,
  361. a login page will be generated automatically at the URL "/spring_security_login" <footnote>
  362. <para>This feature is really just provided for convenience and is not intended for
  363. production (where a view technology will have been chosen and can be used to
  364. render a customized login page). The class
  365. <classname>DefaultLoginPageGeneratingFilter</classname> is responsible for
  366. rendering the login page and will provide login forms for both normal form login
  367. and/or OpenID if required.</para>
  368. </footnote> The behaviour can be customized using the <link xlink:href="#nsa-form-login-attributes">
  369. <literal>&lt;form-login&gt;</literal> Attributes</link>.</para>
  370. <section xml:id="nsa-form-login-parents">
  371. <title>Parent Elements of <literal>&lt;form-login&gt;</literal></title>
  372. <itemizedlist>
  373. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  374. </itemizedlist>
  375. </section>
  376. <section xml:id="nsa-form-login-attributes">
  377. <title><literal>&lt;form-login&gt;</literal> Attributes</title>
  378. <section xml:id="nsa-form-login-always-use-default-target">
  379. <title><literal>always-use-default-target</literal></title>
  380. <para>If set to <literal>true</literal>, the user will always start at the value given by
  381. <link xlink:href="#nsa-form-login-default-target-url">default-target-url</link>, regardless
  382. of how they arrived at the login page. Maps to the <literal>alwaysUseDefaultTargetUrl</literal>
  383. property of <classname>UsernamePasswordAuthenticationFilter</classname>. Default value is
  384. <literal>false</literal>.</para>
  385. </section>
  386. <section xml:id="nsa-form-login-authentication-details-source-ref">
  387. <title><literal>authentication-details-source-ref</literal></title>
  388. <para>Reference to an <interfacename>AuthenticationDetailsSource</interfacename> which will be used
  389. by the authentication filter</para>
  390. </section>
  391. <section xml:id="nsa-form-login-authentication-failure-handler-ref">
  392. <title><literal>authentication-failure-handler-ref</literal></title>
  393. <para>Can be used as an alternative to
  394. <link xlink:href="#nsa-form-login-authentication-failure-url">authentication-failure-url</link>,
  395. giving you full control over the navigation flow after an authentication failure. The value
  396. should be he name of an <interfacename>AuthenticationFailureHandler</interfacename> bean in the
  397. application context.</para>
  398. </section>
  399. <section xml:id="nsa-form-login-authentication-failure-url">
  400. <title><literal>authentication-failure-url</literal></title>
  401. <para>Maps to the <literal>authenticationFailureUrl</literal> property of
  402. <classname>UsernamePasswordAuthenticationFilter</classname>. Defines the URL the
  403. browser will be redirected to on login failure. Defaults to
  404. <literal>/spring_security_login?login_error</literal>, which will be automatically handled by
  405. the automatic login page generator, re-rendering the login page with an error message.</para>
  406. </section>
  407. <section xml:id="nsa-form-login-authentication-success-handler-ref">
  408. <title><literal>authentication-success-handler-ref</literal></title>
  409. <para>This can be used as an alternative to
  410. <link xlink:href="#nsa-form-login-default-target-url">default-target-url</link>
  411. and <link xlink:href="#nsa-form-login-always-use-default-target">always-use-default-target</link>,
  412. giving you full control over the navigation flow after a successful authentication. The value
  413. should be the name of an <interfacename>AuthenticationSuccessHandler</interfacename> bean in
  414. the application context. By default, an implementation of
  415. <classname>SavedRequestAwareAuthenticationSuccessHandler</classname> is used and
  416. injected with the <link xlink:href="#nsa-form-login-default-target-url">default-target-url
  417. </link>.</para>
  418. </section>
  419. <section xml:id="nsa-form-login-default-target-url">
  420. <title><literal>default-target-url</literal></title>
  421. <para>Maps to the <literal>defaultTargetUrl</literal> property of
  422. <classname>UsernamePasswordAuthenticationFilter</classname>. If not set, the
  423. default value is "/" (the application root). A user will be taken to this URL
  424. after logging in, provided they were not asked to login while attempting to
  425. access a secured resource, when they will be taken to the originally requested
  426. URL.</para>
  427. </section>
  428. <section xml:id="nsa-form-login-login-page">
  429. <title><literal>login-page</literal></title>
  430. <para> The URL that should be used to render the login page. Maps to the
  431. <literal>loginFormUrl</literal> property of the
  432. <classname>LoginUrlAuthenticationEntryPoint</classname>. Defaults to
  433. "/spring_security_login".</para>
  434. </section>
  435. <section xml:id="nsa-form-login-login-processing-url">
  436. <title><literal>login-processing-url</literal></title>
  437. <para> Maps to the <literal>filterProcessesUrl</literal> property of
  438. <classname>UsernamePasswordAuthenticationFilter</classname>. The default value
  439. is "/j_spring_security_check".</para>
  440. </section>
  441. <section xml:id="nsa-form-login-password-parameter">
  442. <title><literal>password-parameter</literal></title>
  443. <para>The name of the request parameter which contains the password. Defaults to "j_password".</para>
  444. </section>
  445. <section xml:id="nsa-form-login-username-parameter">
  446. <title><literal>username-parameter</literal></title>
  447. <para>The name of the request parameter which contains the username. Defaults to "j_username".</para>
  448. </section>
  449. </section>
  450. </section>
  451. <section xml:id="nsa-http-basic">
  452. <title><literal>&lt;http-basic&gt;</literal></title>
  453. <para>Adds a <classname>BasicAuthenticationFilter</classname> and
  454. <classname>BasicAuthenticationEntryPoint</classname> to the configuration. The
  455. latter will only be used as the configuration entry point if form-based login is not
  456. enabled.</para>
  457. <section xml:id="nsa-http-basic-parents">
  458. <title>Parent Elements of <literal>&lt;http-basic&gt;</literal></title>
  459. <itemizedlist>
  460. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  461. </itemizedlist>
  462. </section>
  463. <section xml:id="nsa-http-basic-attributes">
  464. <title><literal>&lt;http-basic&gt;</literal> Attributes</title>
  465. <section xml:id="nsa-http-basic-authentication-details-source-ref">
  466. <title><literal>authentication-details-source-ref</literal></title>
  467. <para>Reference to an <interfacename>AuthenticationDetailsSource</interfacename> which will be used
  468. by the authentication filter</para>
  469. </section>
  470. <section xml:id="nsa-http-basic-entry-point-ref">
  471. <title><literal>entry-point-ref</literal></title>
  472. <para>Sets the <interfacename>AuthenticationEntryPoint</interfacename> which is used by the
  473. <classname>BasicAuthenticationFilter</classname>.</para>
  474. </section>
  475. </section>
  476. </section>
  477. <section xml:id="nsa-http-firewall">
  478. <title><literal>&lt;http-firewall></literal> Element</title>
  479. <para>This is a top-level element which can be used to inject a custom implementation of
  480. <interfacename>HttpFirewall</interfacename> into the
  481. <classname>FilterChainProxy</classname> created by the namespace. The default
  482. implementation should be suitable for most applications.</para>
  483. <section xml:id="nsa-http-firewall-attributes">
  484. <title><literal>&lt;http-firewall&gt;</literal> Attributes</title>
  485. <section xml:id="nsa-http-firewall-ref">
  486. <title><literal>ref</literal></title>
  487. <para>Defines a reference to a Spring bean that implements <interfacename>HttpFirewall</interfacename>.</para>
  488. </section>
  489. </section>
  490. </section>
  491. <section xml:id="nsa-intercept-url">
  492. <title><literal>&lt;intercept-url&gt;</literal></title>
  493. <para>This element is used to define the set of URL patterns that the application is
  494. interested in and to configure how they should be handled. It is used to construct
  495. the <interfacename>FilterInvocationSecurityMetadataSource</interfacename> used by
  496. the <classname>FilterSecurityInterceptor</classname>. It is also responsible for
  497. configuring a <classname>ChannelProcessingFilter</classname> if particular URLs
  498. need to be accessed by HTTPS, for example. When matching the specified patterns
  499. against an incoming request, the matching is done in the order in which the elements
  500. are declared. So the most specific matches patterns should come first and the most
  501. general should come last.</para>
  502. <section xml:id="nsa-intercept-url-parents">
  503. <title>Parent Elements of <literal>&lt;intercept-url&gt;</literal></title>
  504. <itemizedlist>
  505. <listitem><link xlink:href="#nsa-filter-invocation-definition-source">filter-invocation-definition-source</link></listitem>
  506. <listitem><link xlink:href="#nsa-filter-security-metadata-source">filter-security-metadata-source</link></listitem>
  507. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  508. </itemizedlist>
  509. </section>
  510. <section xml:id="nsa-intercept-url-attributes">
  511. <title><literal>&lt;intercept-url&gt;</literal> Attributes</title>
  512. <section xml:id="nsa-intercept-url-access">
  513. <title><literal>access</literal></title>
  514. <para>Lists the access attributes which will be stored in the
  515. <interfacename>FilterInvocationSecurityMetadataSource</interfacename> for the
  516. defined URL pattern/method combination. This should be a comma-separated list of
  517. the security configuration attributes (such as role names).</para>
  518. </section>
  519. <section xml:id="nsa-intercept-url-filters">
  520. <title><literal>filters</literal></title>
  521. <para>Can only take the value <quote>none</quote>. This will cause any matching
  522. request to bypass the Spring Security filter chain entirely. None of the rest of
  523. the <literal>&lt;http&gt;</literal> configuration will have any effect on the
  524. request and there will be no security context available for its duration. Access
  525. to secured methods during the request will fail.</para>
  526. </section>
  527. <section xml:id="nsa-intercept-url-method">
  528. <title><literal>method</literal></title>
  529. <para>The HTTP Method which will be used in combination with the pattern to match
  530. an incoming request. If omitted, any method will match. If an identical pattern
  531. is specified with and without a method, the method-specific match will take
  532. precedence.</para>
  533. </section>
  534. <section xml:id="nsa-intercept-url-pattern">
  535. <title><literal>pattern</literal></title>
  536. <para>The pattern which defines the URL path. The content will depend on the
  537. <literal>request-matcher</literal> attribute from the containing http element,
  538. so will default to ant path syntax.</para>
  539. </section>
  540. <section xml:id="nsa-intercept-url-requires-channel">
  541. <title><literal>requires-channel</literal></title>
  542. <para>Can be <quote>http</quote> or <quote>https</quote> depending on whether a
  543. particular URL pattern should be accessed over HTTP or HTTPS respectively.
  544. Alternatively the value <quote>any</quote> can be used when there is no
  545. preference. If this attribute is present on any
  546. <literal>&lt;intercept-url&gt;</literal> element, then a
  547. <classname>ChannelProcessingFilter</classname> will be added to the filter
  548. stack and its additional dependencies added to the application
  549. context.<!--See the chapter on <link
  550. xlink:href="#channel-security-config">channel security</link> for an example
  551. configuration using traditional beans. --></para>
  552. <para>If a <literal>&lt;port-mappings&gt;</literal> configuration is added, this
  553. will be used to by the <classname>SecureChannelProcessor</classname> and
  554. <classname>InsecureChannelProcessor</classname> beans to determine the ports
  555. used for redirecting to HTTP/HTTPS. </para>
  556. </section>
  557. </section>
  558. </section>
  559. <section xml:id="nsa-jee">
  560. <title><literal>&lt;jee&gt;</literal></title>
  561. <para>Adds a J2eePreAuthenticatedProcessingFilter to the filter chain to provide integration with container
  562. authentication.</para>
  563. <section xml:id="nsa-jee-parents">
  564. <title>Parent Elements of <literal>&lt;jee&gt;</literal></title>
  565. <itemizedlist>
  566. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  567. </itemizedlist>
  568. </section>
  569. <section xml:id="nsa-jee-attributes">
  570. <title><literal>&lt;jee&gt;</literal> Attributes</title>
  571. <section xml:id="nsa-jee-mappable-roles">
  572. <title><literal>mappable-roles</literal></title>
  573. <para>A comma-separate list of roles to look for in the incoming HttpServletRequest.</para>
  574. </section>
  575. <section xml:id="nsa-jee-user-service-ref">
  576. <title><literal>user-service-ref</literal></title>
  577. <para>A reference to a user-service (or UserDetailsService bean) Id</para>
  578. </section>
  579. </section>
  580. </section>
  581. <section xml:id="nsa-logout">
  582. <title><literal>&lt;logout&gt;</literal></title>
  583. <para>Adds a <classname>LogoutFilter</classname> to the filter stack. This is
  584. configured with a <classname>SecurityContextLogoutHandler</classname>.</para>
  585. <section xml:id="nsa-logout-parents">
  586. <title>Parent Elements of <literal>&lt;logout&gt;</literal></title>
  587. <itemizedlist>
  588. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  589. </itemizedlist>
  590. </section>
  591. <section xml:id="nsa-logout-attributes">
  592. <title><literal>&lt;logout&gt;</literal> Attributes</title>
  593. <section xml:id="nsa-logout-delete-cookies">
  594. <title>The <literal>delete-cookies</literal> attribute</title>
  595. <para>A comma-separated list of the names of cookies which should be deleted when the user logs out.
  596. </para>
  597. </section>
  598. <section xml:id="nsa-logout-invalidate-session">
  599. <title>The <literal>invalidate-session</literal> attribute</title>
  600. <para> Maps to the <literal>invalidateHttpSession</literal> of the
  601. <classname>SecurityContextLogoutHandler</classname>. Defaults to "true", so the
  602. session will be invalidated on logout.</para>
  603. </section>
  604. <section xml:id="nsa-logout-logout-success-url">
  605. <title>The <literal>logout-success-url</literal> attribute</title>
  606. <para>The destination URL which the user will be taken to after logging out.
  607. Defaults to "/". </para>
  608. <para>Setting this attribute will inject the <classname>SessionManagementFilter</classname>
  609. with a <classname>SimpleRedirectInvalidSessionStrategy</classname> configured with
  610. the attribute value. When an invalid session ID is submitted, the strategy will be invoked,
  611. redirecting to the configured URL.</para>
  612. </section>
  613. <section xml:id="nsa-logout-logout-url">
  614. <title>The <literal>logout-url</literal> attribute</title>
  615. <para> The URL which will cause a logout (i.e. which will be processed by the
  616. filter). Defaults to "/j_spring_security_logout". </para>
  617. </section>
  618. <section xml:id="nsa-logout-success-handler-ref">
  619. <title>The <literal>success-handler-ref</literal> attribute</title>
  620. <para>May be used to supply an instance of <interfacename>LogoutSuccessHandler</interfacename>
  621. which will be invoked to control the navigation after logging out.
  622. </para>
  623. </section>
  624. </section>
  625. </section>
  626. <section xml:id="nsa-openid-login">
  627. <title><literal>&lt;openid-login&gt;</literal></title>
  628. <para> Similar to <literal>&lt;form-login&gt;</literal> and has the same attributes. The
  629. default value for <literal>login-processing-url</literal> is
  630. "/j_spring_openid_security_check". An
  631. <classname>OpenIDAuthenticationFilter</classname> and
  632. <classname>OpenIDAuthenticationProvider</classname> will be registered. The latter
  633. requires a reference to a <interfacename>UserDetailsService</interfacename>. Again,
  634. this can be specified by <literal>id</literal>, using the <literal>user-service-ref</literal>
  635. attribute, or will be located automatically in the application context. </para>
  636. <section xml:id="nsa-openid-login-parents">
  637. <title>Parent Elements of <literal>&lt;openid-login&gt;</literal></title>
  638. <itemizedlist>
  639. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  640. </itemizedlist>
  641. </section>
  642. <section xml:id="nsa-openid-login-attributes">
  643. <title><literal>&lt;openid-login&gt;</literal> Attributes</title>
  644. <section xml:id="nsa-openid-login-always-use-default-target">
  645. <title><literal>always-use-default-target</literal></title>
  646. <para>Whether the user should always be redirected to the default-target-url after login.</para>
  647. </section>
  648. <section xml:id="nsa-openid-login-authentication-details-source-ref">
  649. <title><literal>authentication-details-source-ref</literal></title>
  650. <para>Reference to an AuthenticationDetailsSource which will be used by the authentication filter</para>
  651. </section>
  652. <section xml:id="nsa-openid-login-authentication-failure-handler-ref">
  653. <title><literal>authentication-failure-handler-ref</literal></title>
  654. <para>Reference to an AuthenticationFailureHandler bean which should be used to handle a failed
  655. authentication request. Should not be used in combination with authentication-failure-url as the
  656. implementation should always deal with navigation to the subsequent destination</para>
  657. </section>
  658. <section xml:id="nsa-openid-login-authentication-failure-url">
  659. <title><literal>authentication-failure-url</literal></title>
  660. <para>The URL for the login failure page. If no login failure URL is specified, Spring Security will
  661. automatically create a failure login URL at /spring_security_login?login_error and a corresponding
  662. filter to render that login failure URL when requested.</para>
  663. </section>
  664. <section xml:id="nsa-openid-login-authentication-success-handler-ref">
  665. <title><literal>authentication-success-handler-ref</literal></title>
  666. <para>Reference to an AuthenticationSuccessHandler bean which should be used to handle a successful
  667. authentication request. Should not be used in combination with
  668. <link xlink:href="#nsa-openid-login-default-target-url">default-target-url</link> (or
  669. <link xlink:href="#nsa-openid-login-always-use-default-target">
  670. always-use-default-target</link>) as the implementation should always deal with navigation
  671. to the subsequent destination</para>
  672. </section>
  673. <section xml:id="nsa-openid-login-default-target-url">
  674. <title><literal>default-target-url</literal></title>
  675. <para>The URL that will be redirected to after successful authentication, if the user's previous action
  676. could not be resumed. This generally happens if the user visits a login page without having first requested a
  677. secured operation that triggers authentication. If unspecified, defaults to the root of the application.</para>
  678. </section>
  679. <section xml:id="nsa-openid-login-login-page">
  680. <title><literal>login-page</literal></title>
  681. <para>The URL for the login page. If no login URL is specified, Spring Security will automatically
  682. create a login URL at /spring_security_login and a corresponding filter to render that login URL when requested.
  683. </para>
  684. </section>
  685. <section xml:id="nsa-openid-login-login-processing-url">
  686. <title><literal>login-processing-url</literal></title>
  687. <para>The URL that the login form is posted to. If unspecified, it defaults to /j_spring_security_check.</para>
  688. </section>
  689. <section xml:id="nsa-openid-login-password-parameter">
  690. <title><literal>password-parameter</literal></title>
  691. <para>The name of the request parameter which contains the password. Defaults to "j_password".</para>
  692. </section>
  693. <section xml:id="nsa-openid-login-user-service-ref">
  694. <title><literal>user-service-ref</literal></title>
  695. <para>A reference to a user-service (or UserDetailsService bean) Id</para>
  696. </section>
  697. <section xml:id="nsa-openid-login-username-parameter">
  698. <title><literal>username-parameter</literal></title>
  699. <para>The name of the request parameter which contains the username. Defaults to "j_username".</para>
  700. </section>
  701. </section>
  702. <section xml:id="nsa-openid-login-children">
  703. <title>Child Elements of &lt;openid-login&gt;</title>
  704. <itemizedlist>
  705. <listitem><link xlink:href="#nsa-attribute-exchange">attribute-exchange</link></listitem>
  706. </itemizedlist>
  707. </section>
  708. </section>
  709. <section xml:id="nsa-attribute-exchange">
  710. <title><literal>&lt;attribute-exchange&gt;</literal></title>
  711. <para>The <literal>attribute-exchange</literal> element defines the list of
  712. attributes which should be requested from the identity provider. An example can be found
  713. in the <link xlink:href="#ns-openid">OpenID Support</link> section of the namespace configuration
  714. chapter. More than one can be used, in which case each must have an <literal>identifier-match</literal>
  715. attribute, containing a regular expression which is matched against the supplied
  716. OpenID identifier. This allows different attribute lists to be fetched from
  717. different providers (Google, Yahoo etc).</para>
  718. <section xml:id="nsa-attribute-exchange-parents">
  719. <title>Parent Elements of <literal>&lt;attribute-exchange&gt;</literal></title>
  720. <itemizedlist>
  721. <listitem><link xlink:href="#nsa-openid-login">openid-login</link></listitem>
  722. </itemizedlist>
  723. </section>
  724. <section xml:id="nsa-attribute-exchange-attributes">
  725. <title><literal>&lt;attribute-exchange&gt;</literal> Attributes</title>
  726. <section xml:id="nsa-attribute-exchange-identifier-match">
  727. <title><literal>identifier-match</literal></title>
  728. <para>A regular expression which will be compared against the claimed identity, when deciding which
  729. attribute-exchange configuration to use during authentication.</para>
  730. </section>
  731. </section>
  732. <section xml:id="nsa-attribute-exchange-children">
  733. <title>Child Elements of <literal>&lt;attribute-exchange&gt;</literal></title>
  734. <itemizedlist>
  735. <listitem><link xlink:href="#nsa-openid-attribute">openid-attribute</link></listitem>
  736. </itemizedlist>
  737. </section>
  738. </section>
  739. <section xml:id="nsa-openid-attribute">
  740. <title><literal>&lt;openid-attribute&gt;</literal></title>
  741. <para>Attributes used when making an OpenID AX
  742. <link xlink:href="http://openid.net/specs/openid-attribute-exchange-1_0.html#fetch_request">
  743. Fetch Request</link></para>
  744. <section xml:id="nsa-openid-attribute-parents">
  745. <title>Parent Elements of <literal>&lt;openid-attribute&gt;</literal></title>
  746. <itemizedlist>
  747. <listitem><link xlink:href="#nsa-attribute-exchange">attribute-exchange</link></listitem>
  748. </itemizedlist>
  749. </section>
  750. <section xml:id="nsa-openid-attribute-attributes">
  751. <title><literal>&lt;openid-attribute&gt;</literal> Attributes</title>
  752. <section xml:id="nsa-openid-attribute-count">
  753. <title><literal>count</literal></title>
  754. <para>Specifies the number of attributes that you wish to get back. For example, return 3 emails.
  755. The default value is 1.</para>
  756. </section>
  757. <section xml:id="nsa-openid-attribute-name">
  758. <title><literal>name</literal></title>
  759. <para>Specifies the name of the attribute that you wish to get back. For example, email.</para>
  760. </section>
  761. <section xml:id="nsa-openid-attribute-required">
  762. <title><literal>required</literal></title>
  763. <para>Specifies if this attribute is required to the OP, but does not error out if the OP does not
  764. return the attribute. Default is false.</para>
  765. </section>
  766. <section xml:id="nsa-openid-attribute-type">
  767. <title><literal>type</literal></title>
  768. <para>Specifies the attribute type. For example, http://axschema.org/contact/email. See your OP's
  769. documentation for valid attribute types.</para>
  770. </section>
  771. </section>
  772. </section>
  773. <section xml:id="nsa-port-mappings">
  774. <title><literal>&lt;port-mappings&gt;</literal></title>
  775. <para> By default, an instance of <classname>PortMapperImpl</classname> will be added to
  776. the configuration for use in redirecting to secure and insecure URLs. This element
  777. can optionally be used to override the default mappings which that class defines.
  778. Each child <literal>&lt;port-mapping&gt;</literal> element defines a pair of
  779. HTTP:HTTPS ports. The default mappings are 80:443 and 8080:8443. An example of
  780. overriding these can be found in the <link xlink:href="#ns-requires-channel"
  781. >namespace introduction</link>. </para>
  782. <section xml:id="nsa-port-mappings-parents">
  783. <title>Parent Elements of <literal>&lt;port-mappings&gt;</literal></title>
  784. <itemizedlist>
  785. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  786. </itemizedlist>
  787. </section>
  788. <section xml:id="nsa-port-mappings-children">
  789. <title>Child Elements of <literal>&lt;port-mappings&gt;</literal></title>
  790. <itemizedlist>
  791. <listitem><link xlink:href="#nsa-port-mapping">port-mapping</link></listitem>
  792. </itemizedlist>
  793. </section>
  794. </section>
  795. <section xml:id="nsa-port-mapping">
  796. <title><literal>&lt;port-mapping&gt;</literal></title>
  797. <para>Provides a method to map http ports to https ports when forcing a redirect.</para>
  798. <section xml:id="nsa-port-mapping-parents">
  799. <title>Parent Elements of <literal>&lt;port-mapping&gt;</literal></title>
  800. <itemizedlist>
  801. <listitem><link xlink:href="#nsa-port-mappings">port-mappings</link></listitem>
  802. </itemizedlist>
  803. </section>
  804. <section xml:id="nsa-port-mapping-attributes">
  805. <title><literal>&lt;port-mapping&gt;</literal> Attributes</title>
  806. <section xml:id="nsa-port-mapping-http">
  807. <title><literal>http</literal></title>
  808. <para>The http port to use.</para>
  809. </section>
  810. <section xml:id="nsa-port-mapping-https">
  811. <title><literal>https</literal></title>
  812. <para>The https port to use.</para>
  813. </section>
  814. </section>
  815. </section>
  816. <section xml:id="nsa-remember-me">
  817. <title><literal>&lt;remember-me&gt;</literal></title>
  818. <para> Adds the <classname>RememberMeAuthenticationFilter</classname> to the stack. This
  819. in turn will be configured with either a
  820. <classname>TokenBasedRememberMeServices</classname>, a
  821. <classname>PersistentTokenBasedRememberMeServices</classname> or a user-specified
  822. bean implementing <interfacename>RememberMeServices</interfacename> depending on the
  823. attribute settings. </para>
  824. <section xml:id="nsa-remember-me-parents">
  825. <title>Parent Elements of <literal>&lt;remember-me&gt;</literal></title>
  826. <itemizedlist>
  827. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  828. </itemizedlist>
  829. </section>
  830. <section xml:id="nsa-remember-me-attributes">
  831. <title><literal>&lt;remember-me&gt;</literal> Attributes</title>
  832. <section xml:id="nsa-remember-me-authentication-success-handler-ref">
  833. <title><literal>authentication-success-handler-ref</literal></title>
  834. <para>Sets the <code>authenticationSuccessHandler</code> property on the
  835. <classname>RememberMeAuthenticationFilter</classname> if custom navigation is required.
  836. The value should be the name of a <interfacename>AuthenticationSuccessHandler</interfacename>
  837. bean in the application context. </para>
  838. </section>
  839. <section xml:id="nsa-remember-me-data-source-ref">
  840. <title><literal>data-source-ref</literal></title>
  841. <para>A reference to a <interfacename>DataSource</interfacename> bean. If this is set,
  842. <classname>PersistentTokenBasedRememberMeServices</classname> will be used and configured with a
  843. <classname>JdbcTokenRepositoryImpl</classname> instance. </para>
  844. </section>
  845. <section xml:id="nsa-remember-me-key">
  846. <title><literal>key</literal></title>
  847. <para>Maps to the "key" property of
  848. <classname>AbstractRememberMeServices</classname>. Should be set to a unique
  849. value to ensure that remember-me cookies are only valid within the one
  850. application <footnote>
  851. <para>This doesn't affect the use of
  852. <classname>PersistentTokenBasedRememberMeServices</classname>, where the
  853. tokens are stored on the server side.</para>
  854. </footnote>. If this is not set a secure random value will be generated. Since generating secure
  855. random values can take a while, setting this value explicitly can help improve startup times when
  856. using the remember me functionality.</para>
  857. </section>
  858. <section xml:id="nsa-remember-me-services-alias">
  859. <title><literal>services-alias</literal></title>
  860. <para>Exports the internally defined <interfacename>RememberMeServices</interfacename> as a bean alias,
  861. allowing it to be used by other beans in the application context.</para>
  862. </section>
  863. <section xml:id="nsa-remember-me-services-ref">
  864. <title><literal>services-ref</literal></title>
  865. <para> Allows complete control of the
  866. <interfacename>RememberMeServices</interfacename> implementation that will be
  867. used by the filter. The value should be the <literal>id</literal> of a bean in the application
  868. context which implements this interface. Should also implement
  869. <interfacename>LogoutHandler</interfacename> if a logout filter is in use.</para>
  870. </section>
  871. <section xml:id="nsa-remember-me-token-repository-ref">
  872. <title><literal>token-repository-ref</literal></title>
  873. <para> Configures a <classname>PersistentTokenBasedRememberMeServices</classname>
  874. but allows the use of a custom
  875. <interfacename>PersistentTokenRepository</interfacename> bean. </para>
  876. </section>
  877. <section xml:id="nsa-remember-me-token-validity-seconds">
  878. <title><literal>token-validity-seconds</literal></title>
  879. <para> Maps to the <literal>tokenValiditySeconds</literal> property of
  880. <classname>AbstractRememberMeServices</classname>. Specifies the period in
  881. seconds for which the remember-me cookie should be valid. By default it will be
  882. valid for 14 days. </para>
  883. </section>
  884. <section xml:id="nsa-remember-me-use-secure-cookie">
  885. <title><literal>use-secure-cookie</literal></title>
  886. <para>It is recommended that remember-me cookies are only submitted over HTTPS and thus should
  887. be flagged as <quote>secure</quote>. By default, a secure cookie will be used if the
  888. connection over which the login request is made is secure (as it should be).
  889. If you set this property to <literal>false</literal>, secure cookies will not be used.
  890. Setting it to <literal>true</literal> will always set the secure flag on the cookie.
  891. This attribute maps to the <literal>useSecureCookie</literal> property of
  892. <classname>AbstractRememberMeServices</classname>.
  893. </para>
  894. </section>
  895. <section xml:id="nsa-remember-me-user-service-ref">
  896. <title><literal>user-service-ref</literal></title>
  897. <para> The remember-me services implementations require access to a
  898. <interfacename>UserDetailsService</interfacename>, so there has to be one
  899. defined in the application context. If there is only one, it will be selected
  900. and used automatically by the namespace configuration. If there are multiple
  901. instances, you can specify a bean <literal>id</literal> explicitly using this attribute. </para>
  902. </section>
  903. </section>
  904. </section>
  905. <section xml:id="nsa-request-cache">
  906. <title><literal>&lt;request-cache></literal> Element</title>
  907. <para>Sets the <interfacename>RequestCache</interfacename> instance which will be used
  908. by the <classname>ExceptionTranslationFilter</classname> to store request
  909. information before invoking an
  910. <interfacename>AuthenticationEntryPoint</interfacename>. </para>
  911. <section xml:id="nsa-request-cache-parents">
  912. <title>Parent Elements of <literal>&lt;request-cache&gt;</literal></title>
  913. <itemizedlist>
  914. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  915. </itemizedlist>
  916. </section>
  917. <section xml:id="nsa-request-cache-attributes">
  918. <title><literal>&lt;request-cache&gt;</literal> Attributes</title>
  919. <section xml:id="nsa-request-cache-ref">
  920. <title><literal>ref</literal></title>
  921. <para>Defines a reference to a Spring bean that is a <interfacename>RequestCache</interfacename>.</para>
  922. </section>
  923. </section>
  924. </section>
  925. <section xml:id="nsa-session-management">
  926. <title><literal>&lt;session-management&gt;</literal></title>
  927. <para> Session-management related functionality is implemented by the addition of a
  928. <classname>SessionManagementFilter</classname> to the filter stack.</para>
  929. <section xml:id="nsa-session-management-parents">
  930. <title>Parent Elements of <literal>&lt;session-management&gt;</literal></title>
  931. <itemizedlist>
  932. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  933. </itemizedlist>
  934. </section>
  935. <section xml:id="nsa-session-management-attributes">
  936. <title><literal>&lt;session-management&gt;</literal> Attributes</title>
  937. <section xml:id="nsa-session-management-invalid-session-url">
  938. <title><literal>invalid-session-url</literal></title>
  939. <para>Setting this attribute will inject the <classname>SessionManagementFilter</classname>
  940. with a <classname>SimpleRedirectInvalidSessionStrategy</classname> configured with
  941. the attribute value. When an invalid session ID is submitted, the strategy will be invoked,
  942. redirecting to the configured URL.
  943. </para>
  944. </section>
  945. <section xml:id="nsa-session-management-session-authentication-error-url">
  946. <title><literal>session-authentication-error-url</literal></title>
  947. <para>Defines the URL of the error page which should be shown when the SessionAuthenticationStrategy
  948. raises an exception. If not set, an unauthorized (402) error code will be returned to the client.
  949. Note that this attribute doesn't apply if the error occurs during a form-based login, where the URL
  950. for authentication failure will take precedence.</para>
  951. </section>
  952. <section xml:id="nsa-session-management-session-authentication-strategy-ref">
  953. <title><literal>session-authentication-strategy-ref</literal></title>
  954. <para>Allows injection of the SessionAuthenticationStrategy instance used by the
  955. SessionManagementFilter</para>
  956. </section>
  957. <section xml:id="nsa-session-management-session-fixation-protection">
  958. <title><literal>session-fixation-protection</literal></title>
  959. <para> Indicates whether an existing session should be invalidated when a user
  960. authenticates and a new session started. If set to "none" no change will be
  961. made. "newSession" will create a new empty session. "migrateSession" will create
  962. a new session and copy the session attributes to the new session. Defaults to
  963. "migrateSession".</para>
  964. <para> If session fixation protection is enabled, the
  965. <classname>SessionManagementFilter</classname> is injected with an appropriately
  966. configured <classname>DefaultSessionAuthenticationStrategy</classname>. See the
  967. Javadoc for this class for more details. </para>
  968. </section>
  969. </section>
  970. <section xml:id="nsa-session-management-children">
  971. <title>Child elements of <literal>&lt;session-management&gt;</literal></title>
  972. <itemizedlist>
  973. <listitem><link xlink:href="#nsa-concurrency-control">concurrency-control</link></listitem>
  974. </itemizedlist>
  975. </section>
  976. </section>
  977. <section xml:id="nsa-concurrency-control">
  978. <title><literal>&lt;concurrency-control&gt;</literal></title>
  979. <para> Adds support for concurrent session control, allowing limits to be placed on the
  980. number of active sessions a user can have. A
  981. <classname>ConcurrentSessionFilter</classname> will be created, and a
  982. <classname>ConcurrentSessionControlStrategy</classname> will be used with the
  983. <classname>SessionManagementFilter</classname>. If a <literal>form-login</literal>
  984. element has been declared, the strategy object will also be injected into the
  985. created authentication filter. An instance of
  986. <interfacename>SessionRegistry</interfacename> (a
  987. <classname>SessionRegistryImpl</classname> instance unless the user wishes to use a
  988. custom bean) will be created for use by the strategy.</para>
  989. <section xml:id="nsa-concurrency-control-parents">
  990. <title>Parent Elements of <literal>&lt;concurrency-control&gt;</literal></title>
  991. <itemizedlist>
  992. <listitem><link xlink:href="#nsa-session-management">session-management</link></listitem>
  993. </itemizedlist>
  994. </section>
  995. <section xml:id="nsa-concurrency-control-attributes">
  996. <title><literal>&lt;concurrency-control&gt;</literal> Attributes</title>
  997. <section xml:id="nsa-concurrency-control-error-if-maximum-exceeded">
  998. <title><literal>error-if-maximum-exceeded</literal></title>
  999. <para>If set to "true" a
  1000. <exceptionname>SessionAuthenticationException</exceptionname> will be raised
  1001. when a user attempts to exceed the maximum allowed number of sessions. The
  1002. default behaviour is to expire the original session. </para>
  1003. </section>
  1004. <section xml:id="nsa-concurrency-control-expired-url">
  1005. <title><literal>expired-url</literal></title>
  1006. <para> The URL a user will be redirected to if they attempt to use a session which
  1007. has been "expired" by the concurrent session controller because the user has
  1008. exceeded the number of allowed sessions and has logged in again elsewhere.
  1009. Should be set unless <literal>exception-if-maximum-exceeded</literal> is set. If
  1010. no value is supplied, an expiry message will just be written directly back to
  1011. the response. </para>
  1012. </section>
  1013. <section xml:id="nsa-concurrency-control-max-sessions">
  1014. <title><literal>max-sessions</literal></title>
  1015. <para>Maps to the <literal>maximumSessions</literal> property of
  1016. <classname>ConcurrentSessionControlStrategy</classname>.</para>
  1017. </section>
  1018. <section xml:id="nsa-concurrency-control-session-registry-alias">
  1019. <title><literal>session-registry-alias</literal></title>
  1020. <para> It can also be useful to have a reference to the internal session registry
  1021. for use in your own beans or an admin interface. You can expose the internal bean
  1022. using the <literal>session-registry-alias</literal> attribute, giving it a name
  1023. that you can use elsewhere in your configuration. </para>
  1024. </section>
  1025. <section xml:id="nsa-concurrency-control-session-registry-ref">
  1026. <title><literal>session-registry-ref</literal></title>
  1027. <para> The user can supply their own <interfacename>SessionRegistry</interfacename>
  1028. implementation using the <literal>session-registry-ref</literal> attribute. The
  1029. other concurrent session control beans will be wired up to use it. </para>
  1030. </section>
  1031. </section>
  1032. </section>
  1033. <section xml:id="nsa-x509">
  1034. <title><literal>&lt;x509&gt;</literal></title>
  1035. <para> Adds support for X.509 authentication. An
  1036. <classname>X509AuthenticationFilter</classname> will be added to the stack and an
  1037. <classname>Http403ForbiddenEntryPoint</classname> bean will be created. The latter
  1038. will only be used if no other authentication mechanisms are in use (its only
  1039. functionality is to return an HTTP 403 error code). A
  1040. <classname>PreAuthenticatedAuthenticationProvider</classname> will also be created
  1041. which delegates the loading of user authorities to a
  1042. <interfacename>UserDetailsService</interfacename>. </para>
  1043. <section xml:id="nsa-x509-parents">
  1044. <title>Parent Elements of <literal>&lt;x509&gt;</literal></title>
  1045. <itemizedlist>
  1046. <listitem><link xlink:href="#nsa-http">http</link></listitem>
  1047. </itemizedlist>
  1048. </section>
  1049. <section xml:id="nsa-x509-attributes">
  1050. <title><literal>&lt;x509&gt;</literal> Attributes</title>
  1051. <section xml:id="nsa-x509-authentication-details-source-ref">
  1052. <title><literal>authentication-details-source-ref</literal></title>
  1053. <para>A reference to an <interfacename>AuthenticationDetailsSource</interfacename></para>
  1054. </section>
  1055. <section xml:id="nsa-x509-subject-principal-regex">
  1056. <title><literal>subject-principal-regex</literal></title>
  1057. <para> Defines a regular expression which will be used to extract the username from
  1058. the certificate (for use with the
  1059. <interfacename>UserDetailsService</interfacename>). </para>
  1060. </section>
  1061. <section xml:id="nsa-x509-user-service-ref">
  1062. <title><literal>user-service-ref</literal></title>
  1063. <para> Allows a specific <interfacename>UserDetailsService</interfacename> to be
  1064. used with X.509 in the case where multiple instances are configured. If not set,
  1065. an attempt will be made to locate a suitable instance automatically and use
  1066. that. </para>
  1067. </section>
  1068. </section>
  1069. </section>
  1070. <section xml:id="nsa-filter-chain-map">
  1071. <title><literal>&lt;filter-chain-map&gt;</literal></title>
  1072. <para>Used to explicitly configure a FilterChainProxy instance with a FilterChainMap</para>
  1073. <section xml:id="nsa-filter-chain-map-attributes">
  1074. <title><literal>&lt;filter-chain-map&gt;</literal> Attributes</title>
  1075. <section xml:id="nsa-filter-chain-map-path-type">
  1076. <title><literal>path-type</literal></title>
  1077. <para>Superseded by the
  1078. <link xlink:href="#nsa-filter-chain-map-request-matcher">request-matcher</link> attribute</para>
  1079. </section>
  1080. <section xml:id="nsa-filter-chain-map-request-matcher">
  1081. <title><literal>request-matcher</literal></title>
  1082. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1083. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1084. case-insensitive regular expressions.</para>
  1085. </section>
  1086. </section>
  1087. <section xml:id="nsa-filter-chain-map-children">
  1088. <title>Child Elements of <literal>&lt;filter-chain-map&gt;</literal></title>
  1089. <itemizedlist>
  1090. <listitem><link xlink:href="#nsa-filter-chain">filter-chain</link></listitem>
  1091. </itemizedlist>
  1092. </section>
  1093. </section>
  1094. <section xml:id="nsa-filter-chain">
  1095. <title><literal>&lt;filter-chain&gt;</literal></title>
  1096. <para>Used within to define a specific URL pattern and the list of filters which apply to the URLs matching
  1097. that pattern. When multiple filter-chain elements are assembled in a list in order to configure a FilterChainProxy,
  1098. the most specific patterns must be placed at the top of the list, with most general ones at the bottom.</para>
  1099. <section xml:id="nsa-filter-chain-parents">
  1100. <title>Parent Elements of <literal>&lt;filter-chain&gt;</literal></title>
  1101. <itemizedlist>
  1102. <listitem><link xlink:href="#nsa-filter-chain-map">filter-chain-map</link></listitem>
  1103. </itemizedlist>
  1104. </section>
  1105. <section xml:id="nsa-filter-chain-attributes">
  1106. <title><literal>&lt;filter-chain&gt;</literal> Attributes</title>
  1107. <section xml:id="nsa-filter-chain-filters">
  1108. <title><literal>filters</literal></title>
  1109. <para>A comma separated list of references to Spring beans that implement
  1110. <interfacename>Filter</interfacename>. The value "none" means that no
  1111. <interfacename>Filter</interfacename>'s should be used for this
  1112. <classname>FilterChain</classname>.</para>
  1113. </section>
  1114. <section xml:id="nsa-filter-chain-pattern">
  1115. <title><literal>pattern</literal></title>
  1116. <para>A-pattern that creates RequestMatcher in combination with the
  1117. <link xlink:href="#nsa-filter-chain-map-request-matcher">request-matcher</link></para>
  1118. </section>
  1119. <section xml:id="nsa-filter-chain-request-matcher-ref">
  1120. <title><literal>request-matcher-ref</literal></title>
  1121. <para>A reference to a <interfacename>RequestMatcher</interfacename> that will be used to determine if the
  1122. <interfacename>Filter</interfacename>'s from the <literal>filters</literal> attribute should be invoked.</para>
  1123. </section>
  1124. </section>
  1125. </section>
  1126. <section xml:id="nsa-filter-invocation-definition-source">
  1127. <title><literal>&lt;filter-invocation-definition-source&gt;</literal></title>
  1128. <para>Deprecated synonym for filter-security-metadata-source</para>
  1129. <section xml:id="nsa-filter-invocation-definition-source-attributes">
  1130. <title><literal>&lt;filter-invocation-definition-source&gt;</literal> Attributes</title>
  1131. <section xml:id="nsa-filter-invocation-definition-source-id">
  1132. <title><literal>id</literal></title>
  1133. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1134. </section>
  1135. <section xml:id="nsa-filter-invocation-definition-source-lowercase-comparisons">
  1136. <title><literal>lowercase-comparisons</literal></title>
  1137. <para>Compare after forcing to lowercase</para>
  1138. </section>
  1139. <section xml:id="nsa-filter-invocation-definition-source-path-type">
  1140. <title><literal>path-type</literal></title>
  1141. <para>Superseded by
  1142. <link xlink:href="#nsa-filter-invocation-definition-source-request-matcher">request-matcher</link></para>
  1143. </section>
  1144. <section xml:id="nsa-filter-invocation-definition-source-request-matcher">
  1145. <title><literal>request-matcher</literal></title>
  1146. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1147. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1148. case-insensitive regular expressions.</para>
  1149. </section>
  1150. <section xml:id="nsa-filter-invocation-definition-source-use-expressions">
  1151. <title><literal>use-expressions</literal></title>
  1152. <para>Enables the use of expressions in the 'access' attributes in &lt;intercept-url&gt; elements
  1153. rather than the traditional list of configuration attributes. Defaults to 'false'. If
  1154. enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true', access will be
  1155. granted.</para>
  1156. </section>
  1157. </section>
  1158. <section xml:id="nsa-filter-invocation-definition-source-children">
  1159. <title>Child Elements of <literal>&lt;filter-invocation-definition-source&gt;</literal></title>
  1160. <itemizedlist>
  1161. <listitem><link xlink:href="#nsa-intercept-url">intercept-url</link></listitem>
  1162. </itemizedlist>
  1163. </section>
  1164. </section>
  1165. <section xml:id="nsa-filter-security-metadata-source">
  1166. <title><literal>&lt;filter-security-metadata-source&gt;</literal></title>
  1167. <para>Used to explicitly configure a FilterSecurityMetadataSource bean for use with a FilterSecurityInterceptor. Usually
  1168. only needed if you are configuring a FilterChainProxy explicitly, rather than using the
  1169. &lt;http&gt; element. The intercept-url elements used should only contain pattern, method and access attributes. Any
  1170. others will result in a configuration error.</para>
  1171. <section xml:id="nsa-filter-security-metadata-source-attributes">
  1172. <title><literal>&lt;filter-security-metadata-source&gt;</literal> Attributes</title>
  1173. <section xml:id="nsa-filter-security-metadata-source-id">
  1174. <title><literal>id</literal></title>
  1175. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1176. </section>
  1177. <section xml:id="nsa-filter-security-metadata-source-lowercase-comparisons">
  1178. <title><literal>lowercase-comparisons</literal></title>
  1179. <para>Compare after forcing to lower case</para>
  1180. </section>
  1181. <section xml:id="nsa-filter-security-metadata-source-path-type">
  1182. <title><literal>path-type</literal></title>
  1183. <para>Superseded by
  1184. <link xlink:href="#nsa-filter-security-metadata-source-request-matcher">request-matcher</link>
  1185. </para>
  1186. </section>
  1187. <section xml:id="nsa-filter-security-metadata-source-request-matcher">
  1188. <title><literal>request-matcher</literal></title>
  1189. <para>Supersedes the 'path-type' attribute. Defines the strategy use for matching incoming requests.
  1190. Currently the options are 'ant' (for ant path patterns), 'regex' for regular expressions and 'ciRegex' for
  1191. case-insensitive regular expressions.</para>
  1192. </section>
  1193. <section xml:id="nsa-filter-security-metadata-source-use-expressions">
  1194. <title><literal>use-expressions</literal></title>
  1195. <para>Enables the use of expressions in the 'access' attributes in
  1196. &lt;intercept-url&gt; elements rather than the traditional list of configuration attributes. Defaults to 'false'. If
  1197. enabled, each attribute should contain a single boolean expression. If the expression evaluates to 'true',
  1198. access will be granted.</para>
  1199. </section>
  1200. </section>
  1201. <section xml:id="nsa-filter-security-metadata-source-children">
  1202. <title>Child Elements of <literal>&lt;filter-security-metadata-source&gt;</literal></title>
  1203. <itemizedlist>
  1204. <listitem><link xlink:href="#nsa-intercept-url">intercept-url</link></listitem>
  1205. </itemizedlist>
  1206. </section>
  1207. </section>
  1208. </section>
  1209. <section xml:id="nsa-authentication">
  1210. <title>Authentication Services</title>
  1211. <para> Before Spring Security 3.0, an <interfacename>AuthenticationManager</interfacename>
  1212. was automatically registered internally. Now you must register one explicitly using the
  1213. <literal>&lt;authentication-manager&gt;</literal> element. This creates an instance of
  1214. Spring Security's <classname>ProviderManager</classname> class, which needs to be
  1215. configured with a list of one or more
  1216. <interfacename>AuthenticationProvider</interfacename> instances. These can either be
  1217. created using syntax elements provided by the namespace, or they can be standard bean
  1218. definitions, marked for addition to the list using the
  1219. <literal>authentication-provider</literal> element. </para>
  1220. <section xml:id="nsa-authentication-manager">
  1221. <title><literal>&lt;authentication-manager&gt;</literal></title>
  1222. <para> Every Spring Security application which uses the namespace must have include this
  1223. element somewhere. It is responsible for registering the
  1224. <interfacename>AuthenticationManager</interfacename> which provides authentication
  1225. services to the application. All elements
  1226. which create <interfacename>AuthenticationProvider</interfacename> instances should
  1227. be children of this element.</para>
  1228. <section xml:id="nsa-authentication-manager-attributes">
  1229. <title><literal>&lt;authentication-manager&gt;</literal> Attributes</title>
  1230. <section xml:id="nsa-authentication-manager-alias">
  1231. <title><literal>alias</literal></title>
  1232. <para>This attribute allows you to define an alias name for the
  1233. internal instance for use in your own configuration. Its use is described in the
  1234. <link xlink:href="#ns-auth-manager">namespace introduction</link>.</para>
  1235. </section>
  1236. <section xml:id="nsa-authentication-manager-erase-credentials">
  1237. <title><literal>erase-credentials</literal></title>
  1238. <para>If set to true, the AuthenticationManger will attempt to clear any credentials data in the
  1239. returned Authentication object, once the user has been authenticated. Literally it maps to
  1240. the <literal>eraseCredentialsAfterAuthentication</literal> property of the
  1241. <classname>ProviderManager</classname>. This is discussed in the <link
  1242. xlink:href="#core-services-erasing-credentials">Core Services</link> chapter.</para>
  1243. </section>
  1244. <section xml:id="nsa-authentication-manager-id">
  1245. <title><literal>id</literal></title>
  1246. <para>This attribute allows you to define an id for the internal instance for use in your own
  1247. configuration. It is the same a the alias element, but provides a more consistent experience
  1248. with elements that use the id attribute.</para>
  1249. </section>
  1250. </section>
  1251. <section xml:id="nsa-authentication-manager-children">
  1252. <title>Child Elements of <literal>&lt;authentication-manager&gt;</literal></title>
  1253. <itemizedlist>
  1254. <listitem><link xlink:href="#nsa-authentication-provider">authentication-provider</link></listitem>
  1255. <listitem><link xlink:href="#nsa-ldap-authentication-provider">ldap-authentication-provider</link></listitem>
  1256. </itemizedlist>
  1257. </section>
  1258. </section>
  1259. <section xml:id="nsa-authentication-provider">
  1260. <title><literal>&lt;authentication-provider&gt;</literal></title>
  1261. <para> Unless used with a <literal>ref</literal> attribute, this element is
  1262. shorthand for configuring a <link xlink:href="#core-services-dao-provider"
  1263. ><classname>DaoAuthenticationProvider</classname></link>.
  1264. <classname>DaoAuthenticationProvider</classname> loads user information from a
  1265. <interfacename>UserDetailsService</interfacename> and compares the
  1266. username/password combination with the values supplied at login. The
  1267. <interfacename>UserDetailsService</interfacename> instance can be defined either
  1268. by using an available namespace element (<literal>jdbc-user-service</literal> or
  1269. by using the <literal>user-service-ref</literal> attribute to point to a bean
  1270. defined elsewhere in the application context). You can find examples of these
  1271. variations in the <link xlink:href="#ns-auth-providers">namespace
  1272. introduction</link>. </para>
  1273. <section xml:id="nsa-authentication-provider-parents">
  1274. <title>Parent Elements of <literal>&lt;authentication-provider&gt;</literal></title>
  1275. <itemizedlist>
  1276. <listitem><link xlink:href="#nsa-authentication-manager">authentication-manager</link></listitem>
  1277. </itemizedlist>
  1278. </section>
  1279. <section xml:id="nsa-authentication-provider-attributes">
  1280. <title><literal>&lt;authentication-provider&gt;</literal> Attributes</title>
  1281. <section xml:id="nsa-authentication-provider-ref">
  1282. <title><literal>ref</literal></title>
  1283. <para>Defines a reference to a Spring bean that implements <interfacename>AuthenticationProvider
  1284. </interfacename>.</para>
  1285. <para> If you have written your own
  1286. <interfacename>AuthenticationProvider</interfacename> implementation (or want to
  1287. configure one of Spring Security's own implementations as a traditional bean for
  1288. some reason, then you can use the following syntax to add it to the internal
  1289. <classname>ProviderManager</classname>'s list: <programlisting language="xml"><![CDATA[
  1290. <security:authentication-manager>
  1291. <security:authentication-provider ref="myAuthenticationProvider" />
  1292. </security:authentication-manager>
  1293. <bean id="myAuthenticationProvider" class="com.something.MyAuthenticationProvider"/>
  1294. ]]></programlisting></para>
  1295. </section>
  1296. <section xml:id="nsa-authentication-provider-user-service-ref">
  1297. <title><literal>user-service-ref</literal></title>
  1298. <para>A reference to a bean that implements UserDetailsService that may be created using the standard bean
  1299. element or the custom user-service element.</para>
  1300. </section>
  1301. </section>
  1302. <section xml:id="nsa-authentication-provider-children">
  1303. <title>Child Elements of <literal>&lt;authentication-provider&gt;</literal></title>
  1304. <itemizedlist>
  1305. <listitem><link xlink:href="#nsa-jdbc-user-service">jdbc-user-service</link></listitem>
  1306. <listitem><link xlink:href="#nsa-ldap-user-service">ldap-user-service</link></listitem>
  1307. <listitem><link xlink:href="#nsa-password-encoder">password-encoder</link></listitem>
  1308. <listitem><link xlink:href="#nsa-user-service">user-service</link></listitem>
  1309. </itemizedlist>
  1310. </section>
  1311. </section>
  1312. <section xml:id="nsa-jdbc-user-service">
  1313. <title><literal>&lt;jdbc-user-service&gt;</literal></title>
  1314. <para>Causes creation of a JDBC-based UserDetailsService.</para>
  1315. <section xml:id="nsa-jdbc-user-service-attributes">
  1316. <title><literal>&lt;jdbc-user-service&gt;</literal> Attributes</title>
  1317. <section xml:id="nsa-jdbc-user-service-authorities-by-username-query">
  1318. <title><literal>authorities-by-username-query</literal></title>
  1319. <para>An SQL statement to query for a user's granted authorities given a username.</para>
  1320. <para>The default is
  1321. <programlisting><![CDATA[select username, authority from authorities where username = ?]]></programlisting></para>
  1322. </section>
  1323. <section xml:id="nsa-jdbc-user-service-cache-ref">
  1324. <title><literal>cache-ref</literal></title>
  1325. <para>Defines a reference to a cache for use with a UserDetailsService.</para>
  1326. </section>
  1327. <section xml:id="nsa-jdbc-user-service-data-source-ref">
  1328. <title><literal>data-source-ref</literal></title>
  1329. <para>The bean ID of the DataSource which provides the required tables.</para>
  1330. </section>
  1331. <section xml:id="nsa-jdbc-user-service-group-authorities-by-username-query">
  1332. <title><literal>group-authorities-by-username-query</literal></title>
  1333. <para>An SQL statement to query user's group authorities given a username.</para>
  1334. <para>The default is
  1335. <programlisting><![CDATA[select
  1336. g.id, g.group_name, ga.authority
  1337. from
  1338. groups g, group_members gm, group_authorities ga
  1339. where
  1340. gm.username = ? and g.id = ga.group_id and g.id = gm.group_id]]></programlisting></para>
  1341. </section>
  1342. <section xml:id="nsa-jdbc-user-service-id">
  1343. <title><literal>id</literal></title>
  1344. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1345. </section>
  1346. <section xml:id="nsa-jdbc-user-service-role-prefix">
  1347. <title><literal>role-prefix</literal></title>
  1348. <para>A non-empty string prefix that will be added to role strings loaded from persistent
  1349. storage (default is "ROLE_"). Use the value "none" for no prefix in cases where the default is non-empty.</para>
  1350. </section>
  1351. <section xml:id="nsa-jdbc-user-service-users-by-username-query">
  1352. <title><literal>users-by-username-query</literal></title>
  1353. <para>An SQL statement to query a username, password, and enabled status given a username.</para>
  1354. <para>The default is
  1355. <programlisting><![CDATA[select username, password, enabled from users where username = ?]]></programlisting></para>
  1356. </section>
  1357. </section>
  1358. </section>
  1359. <section xml:id="nsa-password-encoder">
  1360. <title><literal>&lt;password-encoder&gt;</literal></title>
  1361. <para>Authentication providers can optionally be configured to use a password
  1362. encoder as described in the <link xlink:href="#ns-password-encoder"
  1363. >namespace introduction</link>. This will result in the bean being injected
  1364. with the appropriate <interfacename>PasswordEncoder</interfacename>
  1365. instance, potentially with an accompanying
  1366. <interfacename>SaltSource</interfacename> bean to provide salt values for
  1367. hashing. </para>
  1368. <section xml:id="nsa-password-encoder-parents">
  1369. <title>Parent Elements of <literal>&lt;password-encoder&gt;</literal></title>
  1370. <itemizedlist>
  1371. <listitem><link xlink:href="#nsa-authentication-provider">authentication-provider</link></listitem>
  1372. <listitem><link xlink:href="#nsa-password-compare">password-compare</link></listitem>
  1373. </itemizedlist>
  1374. </section>
  1375. <section xml:id="nsa-password-encoder-attributes">
  1376. <title><literal>&lt;password-encoder&gt;</literal> Attributes</title>
  1377. <section xml:id="nsa-password-encoder-base64">
  1378. <title><literal>base64</literal></title>
  1379. <para>Whether a string should be base64 encoded</para>
  1380. </section>
  1381. <section xml:id="nsa-password-encoder-hash">
  1382. <title><literal>hash</literal></title>
  1383. <para>Defines the hashing algorithm used on user passwords. We recommend strongly against using
  1384. MD4, as it is a very weak hashing algorithm.</para>
  1385. </section>
  1386. <section xml:id="nsa-password-encoder-ref">
  1387. <title><literal>ref</literal></title>
  1388. <para>Defines a reference to a Spring bean that implements <interfacename>PasswordEncoder
  1389. </interfacename>.</para>
  1390. </section>
  1391. </section>
  1392. <section xml:id="nsa-password-encoder-children">
  1393. <title>Child Elements of <literal>&lt;password-encoder&gt;</literal></title>
  1394. <itemizedlist>
  1395. <listitem><link xlink:href="#nsa-salt-source">salt-source</link></listitem>
  1396. </itemizedlist>
  1397. </section>
  1398. </section>
  1399. <section xml:id="nsa-salt-source">
  1400. <title><literal>&lt;salt-source&gt;</literal></title>
  1401. <para>Password salting strategy. A system-wide constant or a property from the UserDetails object
  1402. can be used.</para>
  1403. <section xml:id="nsa-salt-source-parents">
  1404. <title>Parent Elements of <literal>&lt;salt-source&gt;</literal></title>
  1405. <itemizedlist>
  1406. <listitem><link xlink:href="#nsa-password-encoder">password-encoder</link></listitem>
  1407. </itemizedlist>
  1408. </section>
  1409. <section xml:id="nsa-salt-source-attributes">
  1410. <title><literal>&lt;salt-source&gt;</literal> Attributes</title>
  1411. <section xml:id="nsa-salt-source-ref">
  1412. <title><literal>ref</literal></title>
  1413. <para>Defines a reference to a Spring bean Id.</para>
  1414. </section>
  1415. <section xml:id="nsa-salt-source-system-wide">
  1416. <title><literal>system-wide</literal></title>
  1417. <para>A single value that will be used as the salt for a password encoder.</para>
  1418. </section>
  1419. <section xml:id="nsa-salt-source-user-property">
  1420. <title><literal>user-property</literal></title>
  1421. <para>A property of the UserDetails object which will be used as salt by a password encoder.
  1422. Typically something like "username" might be used.</para>
  1423. </section>
  1424. </section>
  1425. </section>
  1426. <section xml:id="nsa-user-service">
  1427. <title><literal>&lt;user-service&gt;</literal></title>
  1428. <para>Creates an in-memory UserDetailsService from a properties file or a list of "user" child
  1429. elements. Usernames are converted to lower-case internally to allow for case-insensitive lookups, so
  1430. this should not be used if case-sensitivity is required.</para>
  1431. <section xml:id="nsa-user-service-attributes">
  1432. <title><literal>&lt;user-service&gt;</literal> Attributes</title>
  1433. <section xml:id="nsa-user-service-id">
  1434. <title><literal>id</literal></title>
  1435. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1436. </section>
  1437. <section xml:id="nsa-user-service-properties">
  1438. <title><literal>properties</literal></title>
  1439. <para>The location of a Properties file where each line is in the format of
  1440. <programlisting><![CDATA[username=password,grantedAuthority[,grantedAuthority][,enabled|disabled]]]></programlisting></para>
  1441. </section>
  1442. </section>
  1443. <section xml:id="nsa-user-service-children">
  1444. <title>Child Elements of <literal>&lt;user-service&gt;</literal></title>
  1445. <itemizedlist>
  1446. <listitem><link xlink:href="#nsa-user">user</link></listitem>
  1447. </itemizedlist>
  1448. </section>
  1449. </section>
  1450. <section xml:id="nsa-user">
  1451. <title><literal>&lt;user&gt;</literal></title>
  1452. <para>Represents a user in the application.</para>
  1453. <section xml:id="nsa-user-parents">
  1454. <title>Parent Elements of <literal>&lt;user&gt;</literal></title>
  1455. <itemizedlist>
  1456. <listitem><link xlink:href="#nsa-user-service">user-service</link></listitem>
  1457. </itemizedlist>
  1458. </section>
  1459. <section xml:id="nsa-user-attributes">
  1460. <title><literal>&lt;user&gt;</literal> Attributes</title>
  1461. <section xml:id="nsa-user-authorities">
  1462. <title><literal>authorities</literal></title>
  1463. <para>One of more authorities granted to the user. Separate authorities with a comma
  1464. (but no space). For example, "ROLE_USER,ROLE_ADMINISTRATOR"</para>
  1465. </section>
  1466. <section xml:id="nsa-user-disabled">
  1467. <title><literal>disabled</literal></title>
  1468. <para>Can be set to "true" to mark an account as disabled and unusable.</para>
  1469. </section>
  1470. <section xml:id="nsa-user-locked">
  1471. <title><literal>locked</literal></title>
  1472. <para>Can be set to "true" to mark an account as locked and unusable.</para>
  1473. </section>
  1474. <section xml:id="nsa-user-name">
  1475. <title><literal>name</literal></title>
  1476. <para>The username assigned to the user.</para>
  1477. </section>
  1478. <section xml:id="nsa-user-password">
  1479. <title><literal>password</literal></title>
  1480. <para>The password assigned to the user. This may be hashed if the corresponding
  1481. authentication provider supports hashing (remember to set the "hash" attribute of the
  1482. "user-service" element). This attribute be omitted in the case where the data will
  1483. not be used for authentication, but only for accessing authorities. If omitted, the
  1484. namespace will generate a random value, preventing its accidental use for
  1485. authentication. Cannot be empty.</para>
  1486. </section>
  1487. </section>
  1488. </section>
  1489. </section>
  1490. <section xml:id="nsa-method-security">
  1491. <title>Method Security</title>
  1492. <section xml:id="nsa-global-method-security">
  1493. <title><literal>&lt;global-method-security&gt;</literal></title>
  1494. <para> This element is the primary means of adding support for securing methods on
  1495. Spring Security beans. Methods can be secured by the use of annotations (defined at
  1496. the interface or class level) or by defining a set of pointcuts as child elements,
  1497. using AspectJ syntax. </para>
  1498. <section xml:id="nsa-global-method-security-attributes">
  1499. <title><literal>&lt;global-method-security&gt;</literal> Attributes</title>
  1500. <section xml:id="nsa-global-method-security-access-decision-manager-ref">
  1501. <title><literal>access-decision-manager-ref</literal></title>
  1502. <para>Method security uses the same <interfacename>AccessDecisionManager</interfacename>
  1503. configuration as web security, but this can be overridden using this attribute. By default
  1504. an AffirmativeBased implementation is used for with a RoleVoter and an AuthenticatedVoter. </para>
  1505. </section>
  1506. <section xml:id="nsa-global-method-security-authentication-manager-ref">
  1507. <title><literal>authentication-manager-ref</literal></title>
  1508. <para>A reference to an <interfacename>AuthenticationManager</interfacename>
  1509. that should be used for method security.</para>
  1510. </section>
  1511. <section xml:id="nsa-global-method-security-jsr250-annotations">
  1512. <title><literal>jsr250-annotations</literal></title>
  1513. <para>Specifies whether JSR-250 style attributes are to be used (for example "RolesAllowed"). This
  1514. will require the javax.annotation.security classes on the classpath. Setting this to true also
  1515. adds a <classname>Jsr250Voter</classname> to the
  1516. <interfacename>AccessDecisionManager</interfacename>, so you need to make sure you do this if
  1517. you are using a custom implementation and want to use these annotations.</para>
  1518. </section>
  1519. <section xml:id="nsa-global-method-security-metadata-source-ref">
  1520. <title><literal>&lt;metadata-source-ref&gt;</literal> Attribute</title>
  1521. <para> An external <interfacename>MethodSecurityMetadataSource</interfacename>
  1522. instance can be supplied which will take priority over other sources
  1523. (such as the default annotations).
  1524. </para>
  1525. </section>
  1526. <section xml:id="nsa-global-method-security-mode">
  1527. <title>The <literal>mode</literal> Attribute</title>
  1528. <para>This attribute can be set to <quote>aspectj</quote> to specify that AspectJ
  1529. should be used instead of the default Spring AOP. Secured methods must be woven
  1530. with the <classname>AnnotationSecurityAspect</classname> from the
  1531. <literal>spring-security-aspects</literal> module. </para>
  1532. </section>
  1533. <section xml:id="nsa-global-method-security-order">
  1534. <title><literal>order</literal></title>
  1535. <para>Allows the advice "order" to be set for the method security interceptor.</para>
  1536. </section>
  1537. <section xml:id="nsa-global-method-security-pre-post-annotations">
  1538. <title><literal>pre-post-annotations</literal></title>
  1539. <para>Specifies whether the use of Spring Security's pre and post invocation annotations (@PreFilter,
  1540. @PreAuthorize, @PostFilter, @PostAuthorize) should be enabled for this application context.
  1541. Defaults to "disabled".</para>
  1542. </section>
  1543. <section xml:id="nsa-global-method-security-proxy-target-class">
  1544. <title><literal>proxy-target-class</literal></title>
  1545. <para>If true, class based proxying will be used instead of interface based proxying.</para>
  1546. </section>
  1547. <section xml:id="nsa-global-method-security-run-as-manager-ref">
  1548. <title><literal>run-as-manager-ref</literal></title>
  1549. <para>A reference to an optional <interfacename>RunAsManager</interfacename> implementation which
  1550. will be used by the configured <classname>MethodSecurityInterceptor</classname></para>
  1551. </section>
  1552. <section xml:id="nsa-global-method-security-secured-annotations">
  1553. <title><literal>secured-annotations</literal></title>
  1554. <para>Specifies whether the use of Spring Security's @Secured annotations should be enabled for this
  1555. application context. Defaults to "disabled".</para>
  1556. </section>
  1557. </section>
  1558. <section xml:id="nsa-global-method-security-children">
  1559. <title>Child Elements of <literal>&lt;global-method-security&gt;</literal></title>
  1560. <itemizedlist>
  1561. <listitem><link xlink:href="#nsa-after-invocation-provider">after-invocation-provider</link></listitem>
  1562. <listitem><link xlink:href="#nsa-expression-handler">expression-handler</link></listitem>
  1563. <listitem><link xlink:href="#nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1564. <listitem><link xlink:href="#nsa-protect-pointcut">protect-pointcut</link></listitem>
  1565. </itemizedlist>
  1566. </section>
  1567. </section>
  1568. <section xml:id="nsa-after-invocation-provider">
  1569. <title><literal>&lt;after-invocation-provider&gt;</literal></title>
  1570. <para> This element can be used to decorate an
  1571. <interfacename>AfterInvocationProvider</interfacename> for use by the security
  1572. interceptor maintained by the <literal>&lt;global-method-security&gt;</literal>
  1573. namespace. You can define zero or more of these within the
  1574. <literal>global-method-security</literal> element, each with a
  1575. <literal>ref</literal> attribute pointing to an
  1576. <interfacename>AfterInvocationProvider</interfacename> bean instance within your
  1577. application context. </para>
  1578. <section xml:id="nsa-after-invocation-provider-parents">
  1579. <title>Parent Elements of <literal>&lt;after-invocation-provider&gt;</literal></title>
  1580. <itemizedlist>
  1581. <listitem><link xlink:href="#nsa-global-method-security">global-method-security</link></listitem>
  1582. </itemizedlist>
  1583. </section>
  1584. <section xml:id="nsa-after-invocation-provider-attributes">
  1585. <title><literal>&lt;after-invocation-provider&gt;</literal> Attributes</title>
  1586. <section xml:id="nsa-after-invocation-provider-ref">
  1587. <title><literal>ref</literal></title>
  1588. <para>Defines a reference to a Spring bean that implements <interfacename>
  1589. AfterInvocationProvider</interfacename>.</para>
  1590. </section>
  1591. </section>
  1592. </section>
  1593. <section xml:id="nsa-pre-post-annotation-handling">
  1594. <title><literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1595. <para>Allows the default expression-based mechanism for handling Spring Security's pre and post invocation
  1596. annotations (@PreFilter, @PreAuthorize, @PostFilter, @PostAuthorize) to be replace entirely. Only
  1597. applies if these annotations are enabled.</para>
  1598. <section xml:id="nsa-pre-post-annotation-handling-parents">
  1599. <title>Parent Elements of <literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1600. <itemizedlist>
  1601. <listitem><link xlink:href="#nsa-global-method-security">global-method-security</link></listitem>
  1602. </itemizedlist>
  1603. </section>
  1604. <section xml:id="nsa-pre-post-annotation-handling-children">
  1605. <title>Child Elements of <literal>&lt;pre-post-annotation-handling&gt;</literal></title>
  1606. <itemizedlist>
  1607. <listitem><link xlink:href="#nsa-invocation-attribute-factory">invocation-attribute-factory</link></listitem>
  1608. <listitem><link xlink:href="#nsa-post-invocation-advice">post-invocation-advice</link></listitem>
  1609. <listitem><link xlink:href="#nsa-pre-invocation-advice">pre-invocation-advice</link></listitem>
  1610. </itemizedlist>
  1611. </section>
  1612. </section>
  1613. <section xml:id="nsa-invocation-attribute-factory">
  1614. <title><literal>&lt;invocation-attribute-factory&gt;</literal></title>
  1615. <para>Defines the PrePostInvocationAttributeFactory instance which is used to generate pre and post
  1616. invocation metadata from the annotated methods.</para>
  1617. <section xml:id="nsa-invocation-attribute-factory-parents">
  1618. <title>Parent Elements of <literal>&lt;invocation-attribute-factory&gt;</literal></title>
  1619. <itemizedlist>
  1620. <listitem><link xlink:href="#nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1621. </itemizedlist>
  1622. </section>
  1623. <section xml:id="nsa-invocation-attribute-factory-attributes">
  1624. <title><literal>&lt;invocation-attribute-factory&gt;</literal> Attributes</title>
  1625. <section xml:id="nsa-invocation-attribute-factory-ref">
  1626. <title><literal>ref</literal></title>
  1627. <para>Defines a reference to a Spring bean Id.</para>
  1628. </section>
  1629. </section>
  1630. </section>
  1631. <section xml:id="nsa-post-invocation-advice">
  1632. <title><literal>&lt;post-invocation-advice&gt;</literal></title>
  1633. <para>Customizes the <classname>PostInvocationAdviceProvider</classname> with the ref as the
  1634. <classname>PostInvocationAuthorizationAdvice</classname> for the &lt;pre-post-annotation-handling&gt;
  1635. element.</para>
  1636. <section xml:id="nsa-post-invocation-advice-parents">
  1637. <title>Parent Elements of <literal>&lt;post-invocation-advice&gt;</literal></title>
  1638. <itemizedlist>
  1639. <listitem><link xlink:href="#nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1640. </itemizedlist>
  1641. </section>
  1642. <section xml:id="nsa-post-invocation-advice-attributes">
  1643. <title><literal>&lt;post-invocation-advice&gt;</literal> Attributes</title>
  1644. <section xml:id="nsa-post-invocation-advice-ref">
  1645. <title><literal>ref</literal></title>
  1646. <para>Defines a reference to a Spring bean Id.</para>
  1647. </section>
  1648. </section>
  1649. </section>
  1650. <section xml:id="nsa-pre-invocation-advice">
  1651. <title><literal>&lt;pre-invocation-advice&gt;</literal></title>
  1652. <para>Customizes the <classname>PreInvocationAuthorizationAdviceVoter</classname> with the ref as the
  1653. <classname>PreInvocationAuthorizationAdviceVoter</classname> for the
  1654. &lt;pre-post-annotation-handling&gt; element.</para>
  1655. <section xml:id="nsa-pre-invocation-advice-parents">
  1656. <title>Parent Elements of <literal>&lt;pre-invocation-advice&gt;</literal></title>
  1657. <itemizedlist>
  1658. <listitem><link xlink:href="#nsa-pre-post-annotation-handling">pre-post-annotation-handling</link></listitem>
  1659. </itemizedlist>
  1660. </section>
  1661. <section xml:id="nsa-pre-invocation-advice-attributes">
  1662. <title><literal>&lt;pre-invocation-advice&gt;</literal> Attributes</title>
  1663. <section xml:id="nsa-pre-invocation-advice-ref">
  1664. <title><literal>ref</literal></title>
  1665. <para>Defines a reference to a Spring bean Id.</para>
  1666. </section>
  1667. </section>
  1668. </section>
  1669. <section xml:id="nsa-protect-pointcut">
  1670. <title>Securing Methods using <literal>&lt;protect-pointcut&gt;</literal></title>
  1671. <para> Rather than defining security attributes on an individual method or class
  1672. basis using the <literal>@Secured</literal> annotation, you can define
  1673. cross-cutting security constraints across whole sets of methods and interfaces
  1674. in your service layer using the <literal>&lt;protect-pointcut&gt;</literal>
  1675. element. You can find an example in the <link
  1676. xlink:href="#ns-protect-pointcut">namespace introduction</link>.</para>
  1677. <section xml:id="nsa-protect-pointcut-parents">
  1678. <title>Parent Elements of <literal>&lt;protect-pointcut&gt;</literal></title>
  1679. <itemizedlist>
  1680. <listitem><link xlink:href="#nsa-global-method-security">global-method-security</link></listitem>
  1681. </itemizedlist>
  1682. </section>
  1683. <section xml:id="nsa-protect-pointcut-attributes">
  1684. <title><literal>&lt;protect-pointcut&gt;</literal> Attributes</title>
  1685. <section xml:id="nsa-protect-pointcut-access">
  1686. <title><literal>access</literal></title>
  1687. <para>Access configuration attributes list that applies to all methods matching the pointcut,
  1688. e.g. "ROLE_A,ROLE_B"</para>
  1689. </section>
  1690. <section xml:id="nsa-protect-pointcut-expression">
  1691. <title><literal>expression</literal></title>
  1692. <para>An AspectJ expression, including the 'execution' keyword. For example, 'execution(int
  1693. com.foo.TargetObject.countLength(String))' (without the quotes).</para>
  1694. </section>
  1695. </section>
  1696. </section>
  1697. <section xml:id="nsa-intercept-methods">
  1698. <title><literal>&lt;intercept-methods&gt;</literal></title>
  1699. <para>Can be used inside a bean definition to add a security interceptor to the bean and set up access
  1700. configuration attributes for the bean's methods</para>
  1701. <section xml:id="nsa-intercept-methods-attributes">
  1702. <title><literal>&lt;intercept-methods&gt;</literal> Attributes</title>
  1703. <section xml:id="nsa-intercept-methods-access-decision-manager-ref">
  1704. <title><literal>access-decision-manager-ref</literal></title>
  1705. <para>Optional AccessDecisionManager bean ID to be used by the created method security interceptor.</para>
  1706. </section>
  1707. </section>
  1708. <section xml:id="nsa-intercept-methods-children">
  1709. <title>Child Elements of <literal>&lt;intercept-methods&gt;</literal></title>
  1710. <itemizedlist>
  1711. <listitem><link xlink:href="#nsa-protect">protect</link></listitem>
  1712. </itemizedlist>
  1713. </section>
  1714. </section>
  1715. <section xml:id="nsa-method-security-metadata-source">
  1716. <title><literal>&lt;method-security-metadata-source&gt;</literal></title>
  1717. <para>Creates a MethodSecurityMetadataSource instance</para>
  1718. <section xml:id="nsa-method-security-metadata-source-attributes">
  1719. <title><literal>&lt;method-security-metadata-source&gt;</literal> Attributes</title>
  1720. <section xml:id="nsa-method-security-metadata-source-id">
  1721. <title><literal>id</literal></title>
  1722. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1723. </section>
  1724. <section xml:id="nsa-method-security-metadata-source-use-expressions">
  1725. <title><literal>use-expressions</literal></title>
  1726. <para>Enables the use of expressions in the 'access' attributes in
  1727. &lt;intercept-url&gt; elements rather than the traditional list of configuration attributes.
  1728. Defaults to 'false'. If enabled, each attribute should contain a single boolean expression.
  1729. If the expression evaluates to 'true', access will be granted.</para>
  1730. </section>
  1731. </section>
  1732. <section xml:id="nsa-method-security-metadata-source-children">
  1733. <title>Child Elements of <literal>&lt;method-security-metadata-source&gt;</literal></title>
  1734. <itemizedlist>
  1735. <listitem><link xlink:href="#nsa-protect">protect</link></listitem>
  1736. </itemizedlist>
  1737. </section>
  1738. </section>
  1739. <section xml:id="nsa-protect">
  1740. <title><literal>&lt;protect&gt;</literal></title>
  1741. <para>Defines a protected method and the access control configuration attributes that apply to it. We
  1742. strongly advise you NOT to mix "protect" declarations with any services provided "global-method-security".</para>
  1743. <section xml:id="nsa-protect-parents">
  1744. <title>Parent Elements of <literal>&lt;protect&gt;</literal></title>
  1745. <itemizedlist>
  1746. <listitem><link xlink:href="#nsa-intercept-methods">intercept-methods</link></listitem>
  1747. <listitem><link xlink:href="#nsa-method-security-metadata-source">method-security-metadata-source</link></listitem>
  1748. </itemizedlist>
  1749. </section>
  1750. <section xml:id="nsa-protect-attributes">
  1751. <title><literal>&lt;protect&gt;</literal> Attributes</title>
  1752. <section xml:id="nsa-protect-access">
  1753. <title><literal>access</literal></title>
  1754. <para>Access configuration attributes list that applies to the method, e.g. "ROLE_A,ROLE_B".</para>
  1755. </section>
  1756. <section xml:id="nsa-protect-method">
  1757. <title><literal>method</literal></title>
  1758. <para>A method name</para>
  1759. </section>
  1760. </section>
  1761. </section>
  1762. </section>
  1763. <section xml:id="nsa-ldap">
  1764. <title>LDAP Namespace Options</title>
  1765. <para> LDAP is covered in some details in <link xlink:href="#ldap">its own
  1766. chapter</link>. We will expand on that here with some explanation of how the
  1767. namespace options map to Spring beans. The LDAP implementation uses Spring LDAP
  1768. extensively, so some familiarity with that project's API may be useful. </para>
  1769. <section xml:id="nsa-ldap-server">
  1770. <title>Defining the LDAP Server using the <literal>&lt;ldap-server&gt;</literal>
  1771. Element</title>
  1772. <para> This element sets up a Spring LDAP
  1773. <interfacename>ContextSource</interfacename> for use by the other LDAP beans,
  1774. defining the location of the LDAP server and other information (such as a
  1775. username and password, if it doesn't allow anonymous access) for connecting to
  1776. it. It can also be used to create an embedded server for testing. Details of the
  1777. syntax for both options are covered in the <link xlink:href="#ldap-server">LDAP
  1778. chapter</link>. The actual <interfacename>ContextSource</interfacename>
  1779. implementation is <classname>DefaultSpringSecurityContextSource</classname>
  1780. which extends Spring LDAP's <classname>LdapContextSource</classname> class. The
  1781. <literal>manager-dn</literal> and <literal>manager-password</literal> attributes
  1782. map to the latter's <literal>userDn</literal> and <literal>password</literal>
  1783. properties respectively. </para>
  1784. <para> If you only have one server defined in your application context, the other
  1785. LDAP namespace-defined beans will use it automatically. Otherwise, you can give
  1786. the element an "id" attribute and refer to it from other namespace beans using
  1787. the <literal>server-ref</literal> attribute. This is actually the bean <literal>id</literal> of the
  1788. <literal>ContextSource</literal> instance, if you want to use it in other
  1789. traditional Spring beans. </para>
  1790. <section xml:id="nsa-ldap-server-attributes">
  1791. <title><literal>&lt;ldap-server&gt;</literal> Attributes</title>
  1792. <section xml:id="nsa-ldap-server-id">
  1793. <title><literal>id</literal></title>
  1794. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1795. </section>
  1796. <section xml:id="nsa-ldap-server-ldif">
  1797. <title><literal>ldif</literal></title>
  1798. <para>Explicitly specifies an ldif file resource to load into an embedded LDAP server. The ldiff
  1799. is should be a Spring resource pattern (i.e. classpath:init.ldiff). The default is
  1800. classpath*:*.ldiff</para>
  1801. </section>
  1802. <section xml:id="nsa-ldap-server-manager-dn">
  1803. <title><literal>manager-dn</literal></title>
  1804. <para>Username (DN) of the "manager" user identity which will be used to authenticate to a
  1805. (non-embedded) LDAP server. If omitted, anonymous access will be used.</para>
  1806. </section>
  1807. <section xml:id="nsa-ldap-server-manager-password">
  1808. <title><literal>manager-password</literal></title>
  1809. <para>The password for the manager DN. This is required if the manager-dn is specified.</para>
  1810. </section>
  1811. <section xml:id="nsa-ldap-server-port">
  1812. <title><literal>port</literal></title>
  1813. <para>Specifies an IP port number. Used to configure an embedded LDAP server, for example. The
  1814. default value is 33389.</para>
  1815. </section>
  1816. <section xml:id="nsa-ldap-server-root">
  1817. <title><literal>root</literal></title>
  1818. <para>Optional root suffix for the embedded LDAP server. Default is "dc=springframework,dc=org"
  1819. </para>
  1820. </section>
  1821. <section xml:id="nsa-ldap-server-url">
  1822. <title><literal>url</literal></title>
  1823. <para>Specifies the ldap server URL when not using the embedded LDAP server.</para>
  1824. </section>
  1825. </section>
  1826. </section>
  1827. <section xml:id="nsa-ldap-authentication-provider">
  1828. <title><literal>&lt;ldap-authentication-provider&gt;</literal></title>
  1829. <para> This element is shorthand for the creation of an
  1830. <classname>LdapAuthenticationProvider</classname> instance. By default this will
  1831. be configured with a <classname>BindAuthenticator</classname> instance and a
  1832. <classname>DefaultAuthoritiesPopulator</classname>. As with all namespace
  1833. authentication providers, it must be included as a child of the
  1834. <literal>authentication-provider</literal> element.</para>
  1835. <section xml:id="nsa-ldap-authentication-provider-parents">
  1836. <title>Parent Elements of <literal>&lt;ldap-authentication-provider&gt;</literal></title>
  1837. <itemizedlist>
  1838. <listitem><link xlink:href="#nsa-authentication-manager">authentication-manager</link></listitem>
  1839. </itemizedlist>
  1840. </section>
  1841. <section xml:id="nsa-ldap-authentication-provider-attributes">
  1842. <title><literal>&lt;ldap-authentication-provider&gt;</literal> Attributes</title>
  1843. <section xml:id="nsa-ldap-authentication-provider-group-role-attribute">
  1844. <title><literal>group-role-attribute</literal></title>
  1845. <para>The LDAP attribute name which contains the role name which will be used within Spring
  1846. Security. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  1847. <literal>groupRoleAttribute</literal> property. Defaults to "cn".</para>
  1848. </section>
  1849. <section xml:id="nsa-ldap-authentication-provider-group-search-base">
  1850. <title><literal>group-search-base</literal></title>
  1851. <para>Search base for group membership searches. Maps to the
  1852. <classname>DefaultLdapAuthoritiesPopulator</classname>'s <literal>groupSearchBase</literal>
  1853. constructor argument. Defaults to "" (searching from the root).</para>
  1854. </section>
  1855. <section xml:id="nsa-ldap-authentication-provider-group-search-filter">
  1856. <title><literal>group-search-filter</literal></title>
  1857. <para>Group search filter. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  1858. <literal>groupSearchFilter</literal> property. Defaults to (uniqueMember={0}).
  1859. The substituted parameter is the DN of the user.</para>
  1860. </section>
  1861. <section xml:id="nsa-ldap-authentication-provider-role-prefix">
  1862. <title><literal>role-prefix</literal></title>
  1863. <para>A non-empty string prefix that will be added to role strings loaded from persistent.
  1864. Maps to the <classname>DefaultLdapAuthoritiesPopulator</classname>'s
  1865. <literal>rolePrefix</literal> property. Defaults to "ROLE_". Use the value "none" for
  1866. no prefix in cases where the default is non-empty.</para>
  1867. </section>
  1868. <section xml:id="nsa-ldap-authentication-provider-server-ref">
  1869. <title><literal>server-ref</literal></title>
  1870. <para>The optional server to use. If omitted, and a default LDAP server is registered (using
  1871. &lt;ldap-server&gt; with no Id), that server will be used.</para>
  1872. </section>
  1873. <section xml:id="nsa-ldap-authentication-provider-user-context-mapper-ref">
  1874. <title><literal>user-context-mapper-ref</literal></title>
  1875. <para>Allows explicit customization of the loaded user object by specifying a
  1876. UserDetailsContextMapper bean which will be called with the context information
  1877. from the user's directory entry</para>
  1878. </section>
  1879. <section xml:id="nsa-ldap-authentication-provider-user-details-class">
  1880. <title><literal>user-details-class</literal></title>
  1881. <para>Allows the objectClass of the user entry to be specified. If set, the framework will
  1882. attempt to load standard attributes for the defined class into the returned UserDetails
  1883. object</para>
  1884. </section>
  1885. <section xml:id="nsa-ldap-authentication-provider-user-dn-pattern">
  1886. <title><literal>user-dn-pattern</literal></title>
  1887. <para>If your users are at a fixed location in the directory (i.e. you can work
  1888. out the DN directly from the username without doing a directory search), you
  1889. can use this attribute to map directly to the DN. It maps directly to the
  1890. <literal>userDnPatterns</literal> property of
  1891. <classname>AbstractLdapAuthenticator</classname>. The value is a specific pattern
  1892. used to build the user's DN, for example "uid={0},ou=people". The key
  1893. "{0}" must be present and will be substituted with the username.</para>
  1894. </section>
  1895. <section xml:id="nsa-ldap-authentication-provider-user-search-base">
  1896. <title><literal>user-search-base</literal></title>
  1897. <para>Search base for user searches. Defaults to "". Only used with a 'user-search-filter'.</para>
  1898. <para>If you need to perform a search to locate the user in the directory, then
  1899. you can set these attributes to control the search. The
  1900. <classname>BindAuthenticator</classname> will be configured with a
  1901. <classname>FilterBasedLdapUserSearch</classname> and the attribute values
  1902. map directly to the first two arguments of that bean's constructor. If these
  1903. attributes aren't set and no <literal>user-dn-pattern</literal> has been
  1904. supplied as an alternative, then the default search values of
  1905. <literal>user-search-filter="(uid={0})"</literal> and
  1906. <literal>user-search-base=""</literal> will be used. </para>
  1907. </section>
  1908. <section xml:id="nsa-ldap-authentication-provider-user-search-filter">
  1909. <title><literal>user-search-filter</literal></title>
  1910. <para>The LDAP filter used to search for users (optional). For example "(uid={0})". The
  1911. substituted parameter is the user's login name.</para>
  1912. <para>If you need to perform a search to locate the user in the directory, then
  1913. you can set these attributes to control the search. The
  1914. <classname>BindAuthenticator</classname> will be configured with a
  1915. <classname>FilterBasedLdapUserSearch</classname> and the attribute values
  1916. map directly to the first two arguments of that bean's constructor. If these
  1917. attributes aren't set and no <literal>user-dn-pattern</literal> has been
  1918. supplied as an alternative, then the default search values of
  1919. <literal>user-search-filter="(uid={0})"</literal> and
  1920. <literal>user-search-base=""</literal> will be used. </para>
  1921. </section>
  1922. </section>
  1923. <section xml:id="nsa-ldap-authentication-provider-children">
  1924. <title>Child Elements of <literal>&lt;ldap-authentication-provider&gt;</literal></title>
  1925. <itemizedlist>
  1926. <listitem><link xlink:href="#nsa-password-compare">password-compare</link></listitem>
  1927. </itemizedlist>
  1928. </section>
  1929. </section>
  1930. <section xml:id="nsa-password-compare">
  1931. <title><literal>&lt;password-compare&gt;</literal></title>
  1932. <para> This is used as child element to <literal>&lt;ldap-provider&gt;</literal>
  1933. and switches the authentication strategy from
  1934. <classname>BindAuthenticator</classname> to
  1935. <classname>PasswordComparisonAuthenticator</classname>.</para>
  1936. <section xml:id="nsa-password-compare-parents">
  1937. <title>Parent Elements of <literal>&lt;password-compare&gt;</literal></title>
  1938. <itemizedlist>
  1939. <listitem><link xlink:href="#nsa-ldap-authentication-provider">ldap-authentication-provider</link></listitem>
  1940. </itemizedlist>
  1941. </section>
  1942. <section xml:id="nsa-password-compare-attributes">
  1943. <title><literal>&lt;password-compare&gt;</literal> Attributes</title>
  1944. <section xml:id="nsa-password-compare-hash">
  1945. <title><literal>hash</literal></title>
  1946. <para>Defines the hashing algorithm used on user passwords. We recommend strongly against
  1947. using MD4, as it is a very weak hashing algorithm.</para>
  1948. </section>
  1949. <section xml:id="nsa-password-compare-password-attribute">
  1950. <title><literal>password-attribute</literal></title>
  1951. <para>The attribute in the directory which contains the user password. Defaults to "userPassword".
  1952. </para>
  1953. </section>
  1954. </section>
  1955. <section xml:id="nsa-password-compare-children">
  1956. <title>Child Elements of <literal>&lt;password-compare&gt;</literal></title>
  1957. <itemizedlist>
  1958. <listitem><link xlink:href="#nsa-password-encoder">password-encoder</link></listitem>
  1959. </itemizedlist>
  1960. </section>
  1961. </section>
  1962. <section xml:id="nsa-ldap-user-service">
  1963. <title><literal>&lt;ldap-user-service&gt;</literal></title>
  1964. <para> This element configures an LDAP
  1965. <interfacename>UserDetailsService</interfacename>. The class used is
  1966. <classname>LdapUserDetailsService</classname> which is a combination of a
  1967. <classname>FilterBasedLdapUserSearch</classname> and a
  1968. <classname>DefaultLdapAuthoritiesPopulator</classname>. The attributes it supports
  1969. have the same usage as in <literal>&lt;ldap-provider&gt;</literal>. </para>
  1970. <section xml:id="nsa-ldap-user-service-attributes">
  1971. <title><literal>&lt;ldap-user-service&gt;</literal> Attributes</title>
  1972. <section xml:id="nsa-ldap-user-service-cache-ref">
  1973. <title><literal>cache-ref</literal></title>
  1974. <para>Defines a reference to a cache for use with a UserDetailsService.</para>
  1975. </section>
  1976. <section xml:id="nsa-ldap-user-service-group-role-attribute">
  1977. <title><literal>group-role-attribute</literal></title>
  1978. <para>The LDAP attribute name which contains the role name which will be used within Spring
  1979. Security. Defaults to "cn".</para>
  1980. </section>
  1981. <section xml:id="nsa-ldap-user-service-group-search-base">
  1982. <title><literal>group-search-base</literal></title>
  1983. <para>Search base for group membership searches. Defaults to "" (searching from the root).</para>
  1984. </section>
  1985. <section xml:id="nsa-ldap-user-service-group-search-filter">
  1986. <title><literal>group-search-filter</literal></title>
  1987. <para>Group search filter. Defaults to (uniqueMember={0}). The substituted parameter is the DN of
  1988. the user.</para>
  1989. </section>
  1990. <section xml:id="nsa-ldap-user-service-id">
  1991. <title><literal>id</literal></title>
  1992. <para>A bean identifier, used for referring to the bean elsewhere in the context.</para>
  1993. </section>
  1994. <section xml:id="nsa-ldap-user-service-role-prefix">
  1995. <title><literal>role-prefix</literal></title>
  1996. <para>A non-empty string prefix that will be added to role strings loaded from persistent
  1997. storage (e.g. "ROLE_"). Use the value "none" for no prefix in cases where the default is
  1998. non-empty.</para>
  1999. </section>
  2000. <section xml:id="nsa-ldap-user-service-server-ref">
  2001. <title><literal>server-ref</literal></title>
  2002. <para>The optional server to use. If omitted, and a default LDAP server is registered (using
  2003. &lt;ldap-server&gt; with no Id), that server will be used.</para>
  2004. </section>
  2005. <section xml:id="nsa-ldap-user-service-user-context-mapper-ref">
  2006. <title><literal>user-context-mapper-ref</literal></title>
  2007. <para>Allows explicit customization of the loaded user object by specifying a
  2008. UserDetailsContextMapper bean which will be called with the context information from the
  2009. user's directory entry</para>
  2010. </section>
  2011. <section xml:id="nsa-ldap-user-service-user-details-class">
  2012. <title><literal>user-details-class</literal></title>
  2013. <para>Allows the objectClass of the user entry to be specified. If set, the framework will
  2014. attempt to load standard attributes for the defined class into the returned UserDetails object
  2015. </para>
  2016. </section>
  2017. <section xml:id="nsa-ldap-user-service-user-search-base">
  2018. <title><literal>user-search-base</literal></title>
  2019. <para>Search base for user searches. Defaults to "". Only used with a 'user-search-filter'.</para>
  2020. </section>
  2021. <section xml:id="nsa-ldap-user-service-user-search-filter">
  2022. <title><literal>user-search-filter</literal></title>
  2023. <para>The LDAP filter used to search for users (optional). For example "(uid={0})". The
  2024. substituted parameter is the user's login name.</para>
  2025. </section>
  2026. </section>
  2027. </section>
  2028. </section>
  2029. </appendix>