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

<channel>
	<title>JotaDeveloper &#187; spring</title>
	<atom:link href="http://blog.jotadeveloper.com/tag/spring/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jotadeveloper.com</link>
	<description>Programacion y algo más</description>
	<lastBuildDate>Wed, 20 Jan 2010 09:28:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Cómo crear el schema de la base datos con Anotaciones de Hibernate y Spring</title>
		<link>http://blog.jotadeveloper.com/2009/10/23/como-crear-el-schema-de-la-base-datos-con-anotaciones-de-hibernate-y-spring/</link>
		<comments>http://blog.jotadeveloper.com/2009/10/23/como-crear-el-schema-de-la-base-datos-con-anotaciones-de-hibernate-y-spring/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 04:46:31 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[bases de datos]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2963</guid>
		<description><![CDATA[A veces es necesario hacer cambios a nuestra base de datos, y siempre estaremos lidiando con las herramientas gráficas o desde la consola, con los cambios en la base de datos, pero existen formas de hacer este trabajo &#8220;sucio&#8221; mucho más rapido y ahorrando tiempo.
En nuestro caso, usaremos Spring 2.5 y Hibernate 3.3 y MySQL, [...]]]></description>
			<content:encoded><![CDATA[<p>A veces <strong>es necesario hacer cambios a nuestra base de datos</strong>, y siempre estaremos lidiando con las herramientas gráficas o desde la consola, con los cambios en la base de datos, pero existen formas de hacer este trabajo &#8220;sucio&#8221; <strong>mucho más rapido y ahorrando tiempo</strong>.</p>
<p>En nuestro caso, usaremos Spring 2.5 y Hibernate 3.3 y MySQL, donde es necesario ya tengas armado los beans de conexión a la base de datos. El siguiente código es un array de cadenas, si en nuestro caso tenemos segmentado los xml de spring, los añadiremos de la siguiente manera.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// array de string para agregar todos tus archivos de configuración de spring</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> SPRING_CONFIG_FILES <span style="color: #339933;">=</span>
<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;source/spring/config/xxxxxx-db-context.xml&quot;</span>, <span style="color: #0000ff;">&quot;source/spring/config/xxxxxxx-param-context.xml&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>A continuación, el código necesario para generar nuestra base de datos, el <strong>FileSystemXmlApplicationContext</strong> carga el Contexto de la Aplicación, y una vez teniendo el contexto obtenemos el SessionFactory, que en nuestro caso usamos Anotaciones, creamos el bean en base a la clase <strong>AnnotationSessionFactoryBean</strong> , esto es importante pues en base a esta clase usaremos los metodos <strong>dropDatabaseSchema();</strong> para borrar el actual schema (tablas, relaciones , etc) y luego ejecutamos <strong>createDatabaseSchema();</strong> para crear el nuevo schema.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// carga el application context de Spring</span>
 FileSystemXmlApplicationContext appContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FileSystemXmlApplicationContext<span style="color: #009900;">&#40;</span>SPRING_CONFIG_FILES<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Obtiene el bean del session factory</span>
 AnnotationSessionFactoryBean annotationSF <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AnnotationSessionFactoryBean<span style="color: #009900;">&#41;</span>  appContext.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;sessionFactory&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// si quieres eliminar el schema de la base de datos</span>
 annotationSF.<span style="color: #006633;">dropDatabaseSchema</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// para crear nuevamente el schema de la base de datos</span>
 annotationSF.<span style="color: #006633;">createDatabaseSchema</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Los archivos de configuración de <strong>Spring</strong>, deben lucir de la siguiente manera, hay que destacar el <strong>hibernate.dialect</strong> donde indicamos el dialecto que usaremos para crear el schema,  en el caso de MySQL puede ser MySAM o InnoDB, luego el parametro  <strong>hibernate.hbm2ddl.delimiter</strong> que también indicamos el tipo de tablas que usaremos en mi caso usaré <strong>type=InnoDB</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataSource&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;driverClassName&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${datasource.classname}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${datasource.urldb}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${datasource.userbd}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${datasource.pass}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;sessionFactory&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dataSource&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;dataSource&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;annotatedClasses&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Clase1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
              <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Clase2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hibernateProperties&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
           <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #808080; font-style: italic;">&lt;!-- &lt;prop key=&quot;hibernate.hbm2ddl.auto&quot;&gt;update&lt;/prop&gt; --&gt;</span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;hibernate.dialect&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>${datasource.dialect}
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;hibernate.show_sql&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>${datasource.showsql}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;prop</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;hibernate.hbm2ddl.delimiter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>${datasource.delimited}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/prop<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/props<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=2963" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/10/23/como-crear-el-schema-de-la-base-datos-con-anotaciones-de-hibernate-y-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lo Nuevo de Spring 3.0 RC1</title>
		<link>http://blog.jotadeveloper.com/2009/10/05/lo-nuevo-de-spring-3-0-rc1/</link>
		<comments>http://blog.jotadeveloper.com/2009/10/05/lo-nuevo-de-spring-3-0-rc1/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 03:45:12 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2930</guid>
		<description><![CDATA[
Hace poco el equipo de Spring Source liberó Spring 3.0 RC1 y viene con muchas nuevas características interesantes, para mi una de las mas interesantes es que ya viene con soporte para Java 6 y completamente basado en Java 5, ya era hora !. Me tomado el permiso de pegar la traducción que hizo Dos [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDgvc3ByaW5nc291cmNlLnBuZw=="><img class="size-full wp-image-2723 alignnone" style="margin: 5px;" title="springsource" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/08/springsource.png" alt="springsource" width="224" height="92" /></a></p>
<p>Hace poco <strong>el equipo de Spring Source</strong> liberó <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2UuY29tL2Rvd25sb2Fk" target=\"_blank\">Spring 3.0 RC1</a> y viene con muchas nuevas características interesantes, para mi una de las mas interesantes es que ya viene con soporte para Java 6 y completamente basado en Java 5, ya era hora !. Me tomado el permiso de pegar l<a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5kb3NpZGVhcy5jb20vamF2YS83MzYtc2UtdmllbmUtc3ByaW5nLTMwLWl5YS1jYXNpLmh0bWw=" target=\"_blank\">a traducción que hizo Dos Ideas</a>.</p>
<ul>
<li><strong>Completamente basado en Java 5</strong>. Esta la primer versión de Spring que necesita Java 5 o superior para funcionar, y que utiliza la sintáxis de Java 5 en todo el API de Spring, y también en su implementación. Por ejemplo, el API del BeanFactory retorna instancias tipadas con generics cuando es posible, y un ApplicationListener puede declarar tipos de eventos específicos con generics. En comparación, Spring 2.5 (la versión actual de Spring) todavía es compatible con el JDK 1.4, aunque mucha funcionalidad de alto nivel se construía en Java 5.</li>
<li><strong>Lenguaje de expresiones de Spring (SpEL &#8211; Spring Expression Language)</strong>. Un parser de expresiones para usar en la definición de los beans, que permite referenciar a estructuras anidadas (por ejemplo, propiedades de otros beans), y también a estructuras del sistema (por ejemplo, variables de entorno) usando la sintáxis común <span style="font-family: Courier New;">#{&#8230;}</span> en el valor de las propiedaes de un bean. Esto también sirve como base para otras características basadas en expresiones en otros proyectos de Spring.</li>
<li><strong>Soporte extendido para componentes basados en anotaciones</strong>. Se incluye el concepto de clases de configuración y métodos de factory anotados &#8211; ¡las características fundamentales del proyecto Spring JavaConfig finalmente están disponibles en Spring!. Sprint también permite inyectar valores de configuración a través de expresiones <span style="font-family: Courier New;">@Value</span>, y referirse a valores de la configuración usando expresiones dinámicas <span style="font-family: Courier New;">#{&#8230;}</span> o estáticas <span style="font-family: Courier New;">${&#8230;}.</span></li>
<li><strong>Modelo de estereotipos</strong>. Permite crear anotaciones &#8220;de atajo&#8221; a través del uso de meta-anotaciones. Por ejemplo, para determinar scopes predeterminados o características de transacción predeterminadas en estereotipos propios. Imaginen una anotación propia <span style="font-family: Courier New;">@MiServicio</span> que indica <span style="font-family: Courier New;">@Service</span>, <span style="font-family: Courier New;">@Scope(&#8220;request&#8221;)</span> y <span style="font-family: Courier New;">@Transactional(readOnly=true)</span> usando una única anotación. Este es el principio de No Repetirse aplicado al uso de anotaciones de componentes.</li>
<li><strong>Anotaciones de inyección de dependencias estándar</strong>. Spring 3.0 provee un soporte inicial para el <a onclick=\"javascript:urchinTracker('/outbound/www.jcp.org');\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5qY3Aub3JnL2VuL2pzci9zdW1tYXJ5P2lkPTMzMA==">JSR-330 specification for Dependency Injection in Java</a>- inyección a través de anotaciones usando <span style="font-family: Courier New;">javax.inject.Inject</span> y sus calificadores asociados y modelo de proveedores, como una forma alternativa a la anotación <span style="font-family: Courier New;">@Autowired</span> propia de Spring. Tengan en cuenta que el JSR-330 todavía no está terminado; el soporte para <span style="font-family: Courier New;">javax.inject</span> en Spring se irá completando a medida que madure la especificación.</li>
<li><strong>Modelo de validaciones declarativo basado en anotaciones de restricciones</strong>. Configuración al estilo de Spring de un proveedor de <a onclick=\"javascript:urchinTracker('/outbound/www.jcp.org');\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5qY3Aub3JnL2VuL2pzci9zdW1tYXJ5P2lkPTMwMw==">JSR-303 Bean Validation</a> (como ser, Hibernate Validator 4.0). Spring 3.0 viene con una opción para hacer validaciones basadas en anotaciones en Spring MVC, exponiendo una vista unificada cuando no se cumplen las restricciones. Tengan en cuenta que el JSR-303 está próximo a terminarse, aunque todavía puede tener modificaciones.</li>
<li><strong>Soporte para REST extendido</strong>. Soporte nativo para REST en Spring MVC, como ser mapeos de peticiones REST, extracción de variables URI a través de parámetros <span style="font-family: Courier New;">@PathVariable</span>, y resolución de vistas guiadas por la negociación del contenido. Imaginen Spring MVC 2.5 con soporte de primera clase para REST &#8211; y manteniendo en enfoque de MVC. Hay soporte para el lado del cliente de REST a través de la clase <span style="font-family: Courier New;">RestTemplate</span>.</li>
<li><strong>Mapeo Objeto/XML (OXM)</strong>. Tal como se usaba en Spring Web Services, ahora dentro del núcleo de Spring Framework. Abstracciones para el marshalling y unmarshalling con soporte directo para JAXB 2, Castor, etc. Se provee opciones de integración para soporte de contenidos XML en Spring MVC y Spring JMS.</li>
<li><strong>Soporte para Portlet 2.0</strong>. Spring MVC soporta completamente los entorno de Portlet 2.0 y el nuevo modelo de recursos y eventos de Portlet 2.0. Se incluyen facilidades de mapeo para peticiones de portlet típicas: <span style="font-family: Courier New;">@ActionMapping, @RenderMapping, @ResourceMapping, @EventMapping</span>.</li>
<li><strong>Nuevo sistema de scheduling</strong>. Nuevos mecanismos de TaskScheduler y Trigger con soporte estilo cron, alineados con el mecanismo de Spring TaskExecutor. Spring 3.0 provee un namespace que soporta anotaciones <span style="font-family: Courier New;">@Async</span> y <span style="font-family: Courier New;">@Scheduled</span>. Esto se puede ejecutar sobre pooles nativos de hilos o en pooles manejados por Servidores de Aplicaciones, incluyendo soporte para los servidores de aplicaciones Java EE más populares.</li>
<li><strong>Y por último, soporte inicial para Java EE 6</strong>. Spring 3.0 soporte el uso de JSF 2.0 y JPA 2.0 dentro de Spring, junto al soporte de JSR-303 y JSR-330. Se irá incluyendo soporte para otras tecnologías de Java EE 6 (como Servlet 3.0) a medida que se vayan concretando los productos.</li>
</ul>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=2930" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/10/05/lo-nuevo-de-spring-3-0-rc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VMware compra SpringSource</title>
		<link>http://blog.jotadeveloper.com/2009/08/21/vmware-compra-springsource/</link>
		<comments>http://blog.jotadeveloper.com/2009/08/21/vmware-compra-springsource/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 04:28:50 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Noticias]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[springsource]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2722</guid>
		<description><![CDATA[VMWare ha anunciado la adquisición de SpringSource, un proveedor de desarrollo de aplicaciones web y servicios de gestión. El acuerdo se ha valorado en 420 millones de dólares, 362 de los mismos en efectivo y unos 58 millones en acciones.
Con la compra de la compañía SpringSource, dedicada a la creación de aplicaciones y desarrollador de [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDgvc3ByaW5nc291cmNlLnBuZw=="><img class="alignleft size-full wp-image-2723" style="margin: 5px;" title="springsource" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/08/springsource.png" alt="springsource" width="224" height="92" /></a><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5vam9pbnRlcm5ldC5jb20vc29icmUvdm13YXJlLw==">VMWare</a> ha anunciado la adquisición de <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2UuY29tLw==">SpringSource</a>, un proveedor de desarrollo de aplicaciones web y servicios de gestión. <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy50ZWNoY3J1bmNoaXQuY29tLzIwMDkvMDgvMTAvdm13YXJlLWFjcXVpcmVzLXNwcmluZ3NvdXJjZS8=">El acuerdo se ha valorado en 420 millones de dólares</a>, 362 de los mismos en efectivo y unos 58 millones en acciones.</p>
<p>Con la compra de la compañía SpringSource, dedicada a la creación de aplicaciones y desarrollador de java,<strong> VMware planea crear una arquitectura de cloud computing y extender su soporte de código abierto</strong>.</p>
<p>Por sí sola, <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2UuY29tLw==" target=\"_blank\">SpringSource </a>desarrolla aplicaciones basada en tecnología de código abierto, y la compañía está al frente de varias comunidades &#8216;open-source&#8217;. Entre las aplicaciones destaca <strong>Spring Framework</strong>, un modelo de programación Java para empresa que VMware dice que ofrece soporte a a cerca de la mitad de todos los proyectos Java empresariales. <strong>El Spring Framework lo utilizan cerca de dos millones de desarrolladores de todo el mundo</strong> como un entorno de programación ligero para realizar portabilidad de aplicaciones entre entornos de código abierto y aplicaciones comerciales.</p>
<p>Via <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL211eWNvbXB1dGVycHJvLmNvbS9BY3R1YWxpZGFkL05vdGljaWFzL1ZNd2FyZS1jb21wcmEtU3ByaW5nU291cmNlL193RTlFUmsyWHhEQTJiTEJNa1FmZ041bC1kM1EzOW1vQkZwYTA0aFJCTzEzeW1WQUwwUTZ2anRkUDJBczlfeGpt" target=\"_blank\">MuyComputerPro</a> y <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5vam9pbnRlcm5ldC5jb20vbm90aWNpYXMvdm13YXJlLWFkcXVpZXJlLXNwcmluZ3NvdXJjZS8=">OjoInternet</a></p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=2722" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/08/21/vmware-compra-springsource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring conquista Python con su primera liberación</title>
		<link>http://blog.jotadeveloper.com/2009/07/04/spring-conquista-python-con-su-primera-liberacion/</link>
		<comments>http://blog.jotadeveloper.com/2009/07/04/spring-conquista-python-con-su-primera-liberacion/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 15:28:53 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Noticias]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2272</guid>
		<description><![CDATA[
El equipo de Spring coronó hace unos años Java, .NET y ahora la siguiente cúspide es Python, el día 1 de Julio se liberó la primera versíon del framework para Python de Spring.
El comunicado dice lo siguiente

Estoy complacido de anunciar que la GA de Spring Python 1.0.0 está disponible. Spring Python toma los conceptos implementados [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDcvc3ByaW5nX3B5dGhvbl93aGl0ZS5wbmc="><img class="alignnone size-full wp-image-2273" title="spring_python_white" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/07/spring_python_white.png" alt="spring_python_white" width="265" height="90" /></a></p>
<p>El equipo de Spring<strong> coronó hace unos años Java, .NET</strong> y ahora la siguiente cúspide es <strong>Python</strong>, <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2Uub3JnL25vZGUvMTY3Ng==" target=\"_blank\">el día 1 de Julio se liberó la primera versíon</a> del framework para Python de Spring.</p>
<p>El comunicado dice lo siguiente</p>
<blockquote>
<p style="margin-top: 0.6em; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px;" align="justify">Estoy complacido de <strong>anunciar que la GA de Spring Python 1.0.0 está disponible</strong>. Spring Python toma los conceptos implementados por el Framework Spring y los aplica a Python.</p>
<p style="margin-top: 0.6em; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px;" align="justify">Esta es una <strong>ocasión histórica</strong> ya que la primera extensión en vivo de SpringSource ha alcanzado un lanzamiento 1.0 estable. El trunk ha sido actualizado para soportar nuevas características, mientras que también se prepara para cualquier actualización portada.</p>
<p style="margin-top: 0.6em; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px;" align="justify">Desde que la concepción de este proyecto <strong>comenzó en 2006</strong>, la comunidad nos ha proporcionado con excelente retroalimentación mediante el proceso de desarrollo. Aliento a cualquier interesado a involucrarse probando la nueva funcionalidad y proporcionándonos retroalimentación en el foro de la comunidad y en el JIRA mientras nos movemos hacia la nueva funcionalidad de <strong>objetivo para la versión 1.1</strong>.</p>
<p style="margin-top: 0.6em; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding: 0px;" align="justify"><strong>Greg Turnquist<br />
<span style="font-weight: normal;"> Líder del proyecto Spring Python</span></strong></p></blockquote>
<p><a style=\"text-decoration: none; font-weight: bold;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zcHJpbmdzb3VyY2UuY29tL2Rvd25sb2FkL2NvbW11bml0eT9wcm9qZWN0PVNwcmluZyUyMFB5dGhvbg=="><span style="color: #000000;">Descarga el Codigo</span></a><span style="color: #000000;"> | </span><a style=\"text-decoration: none; font-weight: bold;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NwcmluZ3B5dGhvbi53ZWJmYWN0aW9uYWwuY29tL3JlZmVyZW5jZS9odG1sLw=="><span style="color: #000000;">Documentación</span></a><span style="color: #000000;"> | </span><a style=\"text-decoration: none; font-weight: bold;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3NwcmluZ3B5dGhvbi53ZWJmYWN0aW9uYWwuY29tL3B5ZG9jL3NwcmluZ3B5dGhvbi5odG1s"><span style="color: #000000;">Python API Doc</span></a><span style="color: #000000;"> | </span><a style=\"text-decoration: none; font-weight: bold;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuc3ByaW5ncHl0aG9uLndlYmZhY3Rpb25hbC5jb20v"><span style="color: #000000;">Blog</span></a></p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=2272" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/07/04/spring-conquista-python-con-su-primera-liberacion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Security 2, la configuración a la medida con DAO Hibernate IV</title>
		<link>http://blog.jotadeveloper.com/2009/06/23/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iv/</link>
		<comments>http://blog.jotadeveloper.com/2009/06/23/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iv/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 16:08:12 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[filtros]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=2143</guid>
		<description><![CDATA[Más filtros de los que explicamos en el artículo anterior se puede usar en Spring Security, donde vimos los filtros esenciales para la configuración de nuestra capa de seguridad.
AnonymousProcessingFilter
Este filtro es muy util, nos permite darle acceso a un usuarios anónimos a secciones del sistema, digamos que la pagina de registro debe ser de acceso [...]]]></description>
			<content:encoded><![CDATA[<p>Más filtros de los que explicamos en el <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOS8wNS8yNS9zcHJpbmctc2VjdXJpdHktMi1sYS1jb25maWd1cmFjaW9uLWEtbGEtbWVkaWRhLWNvbi1kYW8taGliZXJuYXRlLWlpaS8=" target=\"_blank\">artículo anterior</a> se puede usar en Spring Security, donde vimos los filtros esenciales para la configuración de nuestra capa de seguridad.</p>
<h2>AnonymousProcessingFilter</h2>
<p>Este filtro es muy util, nos permite darle acceso a un usuarios anónimos a secciones del sistema, digamos que la pagina de registro debe ser de acceso anónimo, en el <strong>FilterChainProxy</strong>  agregamos otra linea donde colocamos el recurso y le asignamos el filtro, ese recurso sera accesible siempre y cuando en el <strong>FilterSecurityInterceptor </strong> también podemos hacer uso del Rol que indicamos que seran Roles para identificar al usuario anónimo.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;anonymousProcessingFilter&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.providers.anonymous.AnonymousProcessingFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;key&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MU7kyU0he1MvXEDZ9Mdj7MVvkXOXJ8uRgtg/Xb/3eJyW0HZa3csBoyvinGEC4vmi<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;userAttribute&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>anonymousUser,ENCUESTAME_ANONYMOUS
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2> ExceptionTranslationFilter </h2>
<p>Maneja cualquier <strong>AccessDeniedException </strong>y <strong>AuthenticationException </strong> arrojados dentro de la cadena de filtro. Este filtro es necesario, ya que proporciona el puente entre las excepciones de Java y las respuestas HTTP.  Sólo se ocupan de mantener la interfaz de usuario. Este filtro no hace ninguna garantía real de la ejecución. Para utilizar este filtro, es necesario especificar las siguientes propiedades:</p>
<ul>
<li><strong>authenticationEntryPoint </strong>indica que el controlador debe comenzar el proceso de autenticación si un AuthenticationException se detecta. Tenga en cuenta que esto también puede cambiar el actual protocolo de http a https para un inicio de sesión SSL.</li>
<li><strong>portResolver</strong> (opcional) Se utiliza para determinar el &#8220;verdadero&#8221; puerto por la que fue recibida la petición.</li>
<ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;exceptionTranslationFilter&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.ExceptionTranslationFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationEntryPoint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">local</span>=<span style="color: #ff0000;">&quot;authenticationEntryPoint&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2> BasicProcessingFilterEntryPoint</h2>
<p>Este filtro es responsable de la tramitación de cualquier solicitud que tiene un encabezado de petición HTTP Authorization con un sistema de autenticación Basica y una codificación username:password simbólico. Por ejemplo, para autenticar el usuario &#8220;Aladdin&#8221;, con contraseña &#8220;ábrete Sésamo&#8221; el siguiente encabezado se mostrara como el siguiente ejemplo, (<strong>Autorización: Básica QWxhZGRpbjpvcGVuIHNlc2FtZQ == </strong> ). Si la autorización es satisfactoria, el objeto<strong>Authentication </strong>se colocará en el <strong>SecurityContextHolder.</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;authenticationEntryPoint&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.basicauth.BasicProcessingFilterEntryPoint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;realmName&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>EmForge<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>LogoutFilter</h2>
<p>Se necesita una forma de cerrar sesión, el <strong>LogoutFilter</strong> es la solución perfecta, indicamos en el constructor del bean el lugar donde seremos dirigidos cuando cerremos la sesión, y una lista de beans o manejadores de Cerrar sesión, por defecto se debe usar el SecurityContextLogoutHandler, aunque puedes personalizar el tuyo propio.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;logoutFilter&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.logout.LogoutFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/pages/index.me&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #808080; font-style: italic;">&lt;!--  &lt;ref bean=&quot;rememberMeServices&quot;/&gt;  --&gt;</span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span></span>
<span style="color: #009900;">					<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.logout.SecurityContextLogoutHandler&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>AuthenticationProcessingFilterEntryPoint</h2>
<p>AuthenticationProcessingFilterEntryPoint, es el bean que nos redirecionará a la pantalla de la aplicación donde se inicia sesión, o a donde nosotros queramos por eso la propiedad <strong>loginFormUrl</strong>. En el caso en que los credenciales no sean correctos se utliza el objeto <strong>AccessDeniedHandlerImpl</strong>, y en su propiedad errorPage se le especifica a que camino se debe dirigir la aplicación en caso de error.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;formEntryPoint&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;loginFormUrl&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/login.faces&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Estos son los filtros más usados y que podemos aplicar a nuestra seguridad, junto con los explicados anteriormente son una <strong>magnifica opción</strong> para crear nuestra seguridad, y como ven, con muy poca programación. En el <strong>siguiente artícul</strong>o veremos la integración del <strong>OPENID</strong> en Spring Security.</p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=2143" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/06/23/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iv/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Integrando Flex con Spring</title>
		<link>http://blog.jotadeveloper.com/2009/05/26/integrando-flex-con-spring/</link>
		<comments>http://blog.jotadeveloper.com/2009/05/26/integrando-flex-con-spring/#comments</comments>
		<pubDate>Tue, 26 May 2009 00:55:53 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1735</guid>
		<description><![CDATA[Presentacion en SpringLive2009 en el aula magna de la UNMSM en Lima, Perú, excelente introducción a las dos tecnologías.
Integrando Flex  Y Spring
View more OpenOffice presentations from ricdex.

 ]]></description>
			<content:encoded><![CDATA[<p>Presentacion en SpringLive2009 en el aula magna de la UNMSM en Lima, Perú, excelente introducción a las dos tecnologías.</p>
<div id="__ss_1447714" style="width: 425px; text-align: left;"><a style=\"font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;\" title=\"Integrando Flex  Y Spring\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zbGlkZXNoYXJlLm5ldC9yaWNkZXgvaW50ZWdyYW5kby1mbGV4LXktc3ByaW5nP3R5cGU9cHJlc2VudGF0aW9u">Integrando Flex  Y Spring</a><object width="425" height="355" data="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=integrandoflexyspring-090517102531-phpapp01&amp;stripped_title=integrando-flex-y-spring" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=integrandoflexyspring-090517102531-phpapp01&amp;stripped_title=integrando-flex-y-spring" /><param name="allowfullscreen" value="true" /></object></p>
<div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;">View more <a style=\"text-decoration:underline;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zbGlkZXNoYXJlLm5ldC8=">OpenOffice presentations</a> from <a style=\"text-decoration:underline;\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL3d3dy5zbGlkZXNoYXJlLm5ldC9yaWNkZXg=">ricdex</a>.</div>
</div>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1735" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/05/26/integrando-flex-con-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Security 2, la configuración a la medida con DAO Hibernate III</title>
		<link>http://blog.jotadeveloper.com/2009/05/25/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iii/</link>
		<comments>http://blog.jotadeveloper.com/2009/05/25/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iii/#comments</comments>
		<pubDate>Mon, 25 May 2009 15:32:11 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[filtros]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1723</guid>
		<description><![CDATA[El dia de hoy vamos a continuar con los Filtros, es la parte central de la seguridad de Spring, y por eso la hace tan flexible, porque esta completamente separada del modelo de Negocio, eso es lo que lo hace tan genial, pues si el dia de mañana se te ocurre cambiar toda la seguridad, [...]]]></description>
			<content:encoded><![CDATA[<p>El dia de hoy vamos a continuar con los Filtros, es la parte central de la <strong>seguridad de Spring</strong>, y por eso la hace tan flexible, porque esta completamente separada del modelo de Negocio, eso es lo que lo hace tan genial, pues si el dia de mañana se te ocurre cambiar toda la seguridad, tu sistema no sufrirá grandes cambios.</p>
<p><strong>Los filtros se encargan de la seguridad de la aplicación</strong>. Existen tres filtros fundamentales se <strong>encadenan</strong> juntos mediante un objeto llamado &#8220;filterChainProxy&#8221;, que crea e inicializa los tres filtros; como se ve en el siguiente diagrama.
</p>
<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDUvZmlsdHJvc2FjZWdpLmpwZw=="><img class="size-full wp-image-1724 alignnone" title="filtrosacegi" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/05/filtrosacegi.jpg" alt="filtrosacegi" width="592" height="324" /></a></p>
<ol>
<li> El filtro <strong>AuthenticationProcessingFilter</strong> maneja la petición o requerimiento (request) que chequea la autenticación -Authentication Request Check- (&#8220;el login de la aplicación&#8221;). Para ello usa el <strong>AuthenticationManager </strong>que vimos en el articulo anterior.</li>
<li> El filtro <strong>HttpSessionContextIntegrationFilter </strong>mantiene el objeto Authentication entre varios requests y se lo pasa al <strong>AuthenticationManager</strong> y al <strong>AccessDecisionManager </strong>cuando sea necesario.</li>
<li> El filtro <strong>ExceptonTranslationFilter</strong> verifica la existencia de autenticación , maneja las excepciones de seguridad y ejecuta la acción apropiada. El ExceptonTranslationFilter depende del filtro siguiente, <strong>FilterSecurityInterceptor.</strong></li>
<li> <strong>FilterSecurityInterceptor </strong>controla el acceso restricto a recursos determinados , y el chequeo de autorización.  Conoce <em>qué recursos son seguros y qué roles tienen acceso a ellos</em>.  FilterSecurityInterceptor usa el <strong>AuthenticationManager </strong>y el  <strong>AccessDecisionManager </strong>para hacer su trabajo.</li>
</ol>
<p>Cuando inicias, todo esto es una maraña de filtros sin sentido, pero vamos a profundizar un poco para que te quede más claro la funcion y configuración de cada uno de ellos.</p>
<h2>AuthenticationProcessingFilter</h2>
<p>El primer filtro donde pasa el RequestHTTP. Este filtro se especializa en manejar el request de autentificación, valida el usuario y la contraseña, más alla de esto solo debes conocer otros parametros imporantes.</p>
<ul>
<li> <strong>authenticationFailureUrl: </strong> En el caso de fallo, algún lugar debe de ir cuando no se logea el usuario.</li>
<li> <strong>defaultTargetUrl:</strong> Es el URL por defecto, generalmente es la raiz.</li>
<li> <strong>filterProcessesUrl:</strong> Es a quien le encarga la responsbilidad de verificar si el usuario se logea o no..</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;authenticationProcessingFilter&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.webapp.AuthenticationProcessingFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationFailureUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/login.me<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;defaultTargetUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;filterProcessesUrl&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/j_spring_security_check<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>HttpSessionContextIntegrationFilter</h2>
<p>El HttpSessionContextIntegrationFilter es fácil de configurar. Su única función, es propagar por el Contexto de Seguridad la autenticación a través de todas las solicitudes. No necesita propiedades ni nada en especial.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;httpSessionContextIntegrationFilter&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.context.HttpSessionContextIntegrationFilter&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<h2>ExceptionTranslationFilter</h2>
<p>El filtro ExceptionTranslationFilter  intercepta cualquier error de autenticación o autorización, por ejemplo <strong>UsernameNotFoundException</strong> o <strong>DataAccessException</strong>.</p>
<p>Si la excepción fue causada por una excepción de autorización lanzada por el filtro FilterSecurityInterceptor (puede ser porque no tiene permisos para acceder a un Recurso Web, una imagen o un URL), el filtro lanzará un HTTP 403 al navegador, el cual mostrará una página de acceso no autorizado.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;formExceptionTranslationFilter&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.ExceptionTranslationFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationEntryPoint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">local</span>=<span style="color: #ff0000;">&quot;formEntryPoint&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;formEntryPoint&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;loginFormUrl&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/login.me&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>FilterSecurityInterceptor</h2>
<p>El FilterSecurityInterceptor, es donde protegeremos todos nuestros recursos, donde decidimos que ROL entra a ciertos recursos, cuales pueden ser accedido por usuarios anónimos, todo esto se configura en el <strong>objectDefinitionSource</strong>. Necesitamos 2 referencias para configurar este Filtro, el <strong>authenticationManager</strong> y el bean <strong>accessDecisionManager</strong> que miraremos en el siguiente artículo.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;filterInvocationInterceptor&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.intercept.web.FilterSecurityInterceptor&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;accessDecisionManager&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;voteAccessDecisionManager&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;objectDefinitionSource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
				PATTERN_TYPE_APACHE_ANT
				/=ENCUESTAME_ANONYMOUS
				/pages/**=ENCUESTAME_USER
				/pages/admon/**=ENCUESTAME_ADMIN
				/user/**=ENCUESTAME_ANONYMOUS,ENCUESTAME_USER,ENCUESTAME_ADMIN				           
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>FilterChainProxy</h2>
<p>El filtro inicializador, su función principal es indicar o personalizar, que recursos ejecutaran los filtros deseados en <strong>filterInvocationDefinitionSource</strong>, por ejemplo, si tenemos un sevlet<strong> /uploadFile</strong> y solo nos interesa aplicar algunos filtros</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;springSecurityFilterChain&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.security.util.FilterChainProxy&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;filterInvocationDefinitionSource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		   CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
		    PATTERN_TYPE_APACHE_ANT
               /**=httpSessionContextIntegrationFilter,logoutFilter,basicProcessingFilter,authenticationProcessingFilter....
              /uploadFile= basicProcessingFilter,OtroFiltroPersonalizado
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>En el siguiente artículo, veremos una extensión de los diferentes filtros opcionales que podemos integrar en nuestra seguridad, <strong>¿preguntas?</strong></p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1723" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/05/25/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-iii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Security 2, la configuración a la medida con DAO Hibernate II</title>
		<link>http://blog.jotadeveloper.com/2009/05/13/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-ii/</link>
		<comments>http://blog.jotadeveloper.com/2009/05/13/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-ii/#comments</comments>
		<pubDate>Wed, 13 May 2009 06:24:10 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[filtros]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1649</guid>
		<description><![CDATA[Siguiendo con el articulo anterior, voy a explicar los diferentes Filtros de Seguridad y las Configuraciones Personales que podemos aplicar en nuestra Seguridad. El siguiente gráfico explica el ciclo de vida de la autentificación en Spring.
En el post anterior, vimos el Bean del Formulario de logeo, donde se creo el objeto Authentication que se pasa [...]]]></description>
			<content:encoded><![CDATA[<p>Siguiendo con el articulo anterior, voy a explicar los diferentes <strong>Filtros de Seguridad y las Configuraciones Personales </strong>que podemos aplicar en nuestra Seguridad. El siguiente gráfico explica el ciclo de vida de la autentificación en Spring.</p>
<p>En el post anterior, vimos el Bean del Formulario de logeo, donde se creo el objeto <strong>Authentication </strong>que se pasa al <strong>AuthenticationManager</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">UsernamePasswordAuthenticationToken authReq <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UsernamePasswordAuthenticationToken<span style="color: #009900;">&#40;</span>userName, password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
.......
<span style="color: #006633;">Authentication</span> auth <span style="color: #339933;">=</span> getAuthenticationManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">authenticate</span><span style="color: #009900;">&#40;</span>authReq<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDUvc3ByaW5nX2V4Y2VwdGlvbl9maWx0ZXIuZ2lm"><img class="alignnone size-full wp-image-1650" title="spring_exception_filter" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/05/spring_exception_filter.gif" alt="spring_exception_filter" width="637" height="400" /></a></p>
<h3>AuthenticationManager</h3>
<p>El bean AuthenticationManager es del tipo <strong>ProviderManager</strong>, lo que significa que actúa de proxy con AuthenticationProvider. En Spring, el <strong>AuthenticationProvider es el encargado de validar la combinación nombre de usuario/contraseña por medio del objeto Authentication  y retornar los roles asociados a dicho usuario.</strong> Esta clase tan sólo delega la autenticación en una lista de proveedores configurable, cada uno de los cuales implementa el interfaz AuthenticationProvider. Hay muchos tipos de AuthenticationProvider( JDBC, Hibernate,  LDAP, RememberMe, OpenID). Usted puede indicar cuales quiere usar son los proveedores de autentificación que desee usar, en nuestro caso, <strong>usaremos un DAO Hibernate personalizado</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>bean id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;authenticationManager&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;paquete.MiAuthenticationManager&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;providerString&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userDaoProvider&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>bean<span style="color: #339933;">&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MiAuthenticationManager <span style="color: #000000; font-weight: bold;">extends</span> ProviderManager <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">String</span> providerString<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setProviderString<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> providerString<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">providerString</span> <span style="color: #339933;">=</span> providerString<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
 <span style="color: #008000; font-style: italic; font-weight: bold;">/**
  * Agrega al Manejador de Proveedores un listado
  */</span> 
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> afterPropertiesSet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>providerString <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>			
			List<span style="color: #339933;">&lt;</span>authenticationprovider<span style="color: #339933;">&gt;</span> providers <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">LinkedList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> names <span style="color: #339933;">=</span> providerString.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> providerUnit <span style="color: #339933;">:</span> names<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				AuthenticationProvider provider <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AuthenticationProvider<span style="color: #009900;">&#41;</span> applicationContext
						.<span style="color: #006633;">getBean</span><span style="color: #009900;">&#40;</span>providerUnit.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>provider <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> EnMeExpcetion<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AuthenticationProvider &quot;</span>
							<span style="color: #339933;">+</span> providerUnit <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; don't exist&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>				
				providers.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>provider<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			setProviders<span style="color: #009900;">&#40;</span>providers<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">afterPropertiesSet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>authenticationprovider<span style="color: #339933;">&gt;</span></pre></div></div>

<h3>DaoAuthenticationProvider </h3>
<p>DaoAuthenticationProvider, es el comúnmente usado puesto que es el que permite acceder a la información almacenada en una base de datos. El proveedor DaoAuthenticationProvider merece una mención especial. Esta implementación delega a su vez en un objeto de tipo <strong>UserDetailsService</strong>, un interfaz que define un objeto de acceso a datos con un único método <strong>loadUserByUsername </strong>que permite obtener la información de un usuario a partir de su nombre de usuario.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>bean id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userDaoProvider&quot;</span>
		<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;org.springframework.security.providers.dao.DaoAuthenticationProvider&quot;</span><span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userDetailsService&quot;</span> ref<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dbUserService&quot;</span> <span style="color: #339933;">/&gt;</span>		
	<span style="color: #339933;">&lt;/</span>bean<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Si deseas agregarle encriptación a la contraseña del usuario, agregale una propiedad más al userDaoProvider, <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMS8yOS9lbmNyaXB0YWNpb24tamFweXN0LXNwcmluZy1zZWMtMi8=">este artículo que escribi tiempo atrás te ayudará a poner una mejor seguridad que el tipico MD5</a>. </p>
<h3>UserDetailsService, un Dao Personalizado</h3>
<p>Si no queremos que Spring acceda a la bases de datos directamente podemos configurar un Dao personalizado por medio de una Implementación UserDetailsService, , un interfaz que define un objeto de acceso a datos con un único método loadUserByUsername que permite obtener la información de un usuario a partir de su nombre de usuario.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">&lt;</span>bean id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dbUserService&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;paquete.MiUserServiceImp&quot;</span><span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>property name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userDao&quot;</span> ref<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;userDao&quot;</span> <span style="color: #339933;">/&gt;</span>		
	<span style="color: #339933;">&lt;/</span>bean<span style="color: #339933;">&gt;</span></pre></div></div>

<p><!-- Un Dao Cualquiera para Hibernate --><br />
<bean id="userDao" class="paquete.dao.UserDaoImp"></p>
<property name="hibernateTemplate">
			<ref bean="hibernateTemplate" />
		</property>
</bean></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MiUserServiceImp <span style="color: #000000; font-weight: bold;">implements</span> UserDetailsService <span style="color: #009900;">&#123;</span>
         ......
        <span style="color: #000000; font-weight: bold;">public</span> UserDetails loadUserByUsername<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> UsernameNotFoundException, DataAccessException <span style="color: #009900;">&#123;</span>		
		SecUsers user <span style="color: #339933;">=</span> userDao.<span style="color: #006633;">getUser</span><span style="color: #009900;">&#40;</span>username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>user <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;no encontrado...&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> UsernameNotFoundException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>		
		<span style="color: #000000; font-weight: bold;">return</span> convertToUserDetails<span style="color: #009900;">&#40;</span>user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
         ......
&nbsp;
    <span style="color: #000000; font-weight: bold;">protected</span> UserDetails convertToUserDetails<span style="color: #009900;">&#40;</span>SecUsers user<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #666666; font-style: italic;">//lista de permisos, </span>
         List<span style="color: #339933;">&lt;</span>string<span style="color: #339933;">&gt;</span> listPermissions <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;&lt;</span>string<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ...........
        <span style="color: #006633;">GrantedAuthority</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> authorities <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GrantedAuthority<span style="color: #009900;">&#91;</span>listPermissions
				.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> permission <span style="color: #339933;">:</span> listPermissions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			authorities<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GrantedAuthorityImpl<span style="color: #009900;">&#40;</span>permission.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		User userDetails <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #009900;">&#40;</span>user.<span style="color: #006633;">getUsername</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, user.<span style="color: #006633;">getPassword</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
				user.<span style="color: #006633;">isStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">false</span> <span style="color: #339933;">:</span> user.<span style="color: #006633;">isStatus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000066; font-weight: bold;">true</span>, 
				<span style="color: #000066; font-weight: bold;">true</span>, 
				<span style="color: #000066; font-weight: bold;">true</span>,
				authorities<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		log.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;userDetails &quot;</span><span style="color: #339933;">+</span>userDetails<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> userDetails<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>string<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Vamos a dejar la explicación de los Filtros, para una tercera parte, ya se hizo largo <img src='http://blog.jotadeveloper.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1649" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/05/13/spring-security-2-la-configuracion-a-la-medida-con-dao-hibernate-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spring Security 2, la configuración a la medida con DAO Hibernate I</title>
		<link>http://blog.jotadeveloper.com/2009/05/11/spring-security-2-hibernate-dao-part/</link>
		<comments>http://blog.jotadeveloper.com/2009/05/11/spring-security-2-hibernate-dao-part/#comments</comments>
		<pubDate>Mon, 11 May 2009 15:38:48 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[filtros]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[jsf]]></category>
		<category><![CDATA[Seguridad]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1617</guid>
		<description><![CDATA[Uno de los aspectos que toda aplicación debe considerar es la seguridad, entendiendo como tal la necesidad de saber que el usuario es quien dice ser (autenticación), y permitirle acceso sólo a aquellos recursos necesarios (autorización). En un princio el framework  se llamaba Acegi Security e inicio en el 2003, 5 años después en Abril [...]]]></description>
			<content:encoded><![CDATA[<p>Uno de los aspectos que toda aplicación debe considerar es la seguridad, entendiendo como tal la necesidad de saber que el usuario es quien dice ser (autenticación), y permitirle acceso sólo a aquellos recursos necesarios (autorización). En un princio el framework  se llamaba Acegi Security e inicio en el 2003, 5 años después en Abril del 2008 se incorporó al portafolio de Spring Framework como un súbmodulo. Spring trae por defecto ciertas caracteristicas que a la hora de querer integrarlas en nuestros sistemas avanzados no encajan a la perfección y por lo general se necesitan modificaciones a las clases principales.</p>
<p>Anteriormente hemos visto configuraciones mucho más sencillas :</p>
<ul>
<li> <a title=\"Permanent Link to Configuración Spring Security 2.0 con JDBC\" rel=\"bookmark\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMS8yMS9jb25maWd1cmFjaW9uLXNwcmluZy1zZWN1cml0eS0yMC1jb24tamRiYy8=">Configuración Spring Security 2.0 con JDBC</a></li>
<li> <a title=\"Permanent Link to Configuración Spring Security 2.04 para LDAP\" rel=\"bookmark\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMS8xNy9jb25maWd1cmFjaW9uLXNwcmluZy1zZWN1cml0eS0yMDQtcGFyYS1sZGFwLw==">Configuración Spring Security 2.04 para LDAP</a></li>
<li> <a title=\"Permanent Link to La Seguridad Perfecta con Spring y el dropDownMenu de RichFaces\" rel=\"bookmark\" href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMi8wNy9sYS1zZWd1cmlkYWQtcGVyZmVjdGEtY29uLXNwcmluZy15LWVsLWRyb3Bkb3dubWVudS1kZS1yaWNoZmFjZXMv">La Seguridad Perfecta con Spring y el dropDownMenu de RichFaces</a></li>
</ul>
<p>Creo que una de las configuraciones más complejas es fusionando con el framework Hibernate y esto nos permite no anclarnos a las tablas que ya Spring Security trae por defecto, asi poder personalizar nuestra seguridad de una mejor manera.</p>
<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDkvMDUvdW1sLnBuZw=="><img class="size-full wp-image-1625 alignnone" title="uml" src="http://blog.jotadeveloper.com/wp-content/uploads/2009/05/uml.png" alt="uml" width="520" height="326" /></a></p>
<p>En nuestro caso vamos a trabajar con Spring Framework, y lo ideal es separar nuestra aplicación en 3 capas:</p>
<ul>
<li><strong>Capa de Presentación: </strong>En esta capa vamos a programar el formulario, el típico formulario con el nombre de usuario y la contraseña, podemos integrar OPEN ID, e incluso la funcionalidad de Recordar la Sessión por medio de un Cookie.</li>
<li><strong>Filtros de Seguridad: </strong>Aqui aplicaremos toda la configuración de Spring Security, aplicaremos todos los filtros y las clases que vamos a modificar algunas clases de Spring que se comuniquen con nuestros servicios en la capa de negocio.</li>
<li><strong>Servicios en la Capa de Negocio</strong>: En esta capa colocaremos nuestros Beans de Spring que a su vez acceden a otra capa en la cual no vamos a entrar en detalle, la de acceso a datos.</li>
</ul>
<p>Iniciemos con la capa de presentación y el formulario para logearse, en su forma más sencilla, aqui se pueden agregar validadores y mensajes de error, etc.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h</span> :inputText <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;j_username&quot;</span>  <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{loginForm.userName}&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h</span> :inputSecret <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;j_password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{loginForm.userPassword}&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;40&quot;</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h</span> :commandButton <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;#{loginForm.login}&quot;</span>  <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Iniciar Sesión&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Ahora necesitamos nuestro Bean LoginForm, este puedes colocarlo como un ManageBean o un Bean de Spring, como mas te parezca, en mi caso use Spring.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LoginForm<span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//Bean Personalizado del Manejador de Autentificación</span>
	<span style="color: #000000; font-weight: bold;">private</span> AuthenticationManager authenticationManager<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> userName<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> userPassword<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Application app<span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> userName<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUserName<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userName</span> <span style="color: #339933;">=</span> userName<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getUserPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> userPassword<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setUserPassword<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userPassword<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">userPassword</span> <span style="color: #339933;">=</span> userPassword<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> AuthenticationManager getAuthenticationManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> authenticationManager<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAuthenticationManager<span style="color: #009900;">&#40;</span>
			AuthenticationManager authenticationManager<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">authenticationManager</span> <span style="color: #339933;">=</span> authenticationManager<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * 
&nbsp;
	/**
	 * Ejecuta un envio a un url definido por la navegación JSF
	 * @param viewId
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> forward<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> viewId<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	ViewHandler viewHandler <span style="color: #339933;">=</span> getApplication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getViewHandler</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    FacesContext facesCtx <span style="color: #339933;">=</span> getFacesContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    UIViewRoot view <span style="color: #339933;">=</span> viewHandler.<span style="color: #006633;">createView</span><span style="color: #009900;">&#40;</span>facesCtx, viewId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    facesCtx.<span style="color: #006633;">setViewRoot</span><span style="color: #009900;">&#40;</span>view<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    facesCtx.<span style="color: #006633;">renderResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Obtiene el contexto de la Aplicación
	 * @return
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> Application getApplication<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>app <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ApplicationFactory appFactory <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ApplicationFactory<span style="color: #009900;">&#41;</span> FactoryFinder.<span style="color: #006633;">getFactory</span><span style="color: #009900;">&#40;</span>FactoryFinder.<span style="color: #006633;">APPLICATION_FACTORY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        app <span style="color: #339933;">=</span> appFactory.<span style="color: #006633;">getApplication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> 
		<span style="color: #000000; font-weight: bold;">return</span> app<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Obtiene el Contexto de JSF
	 * @return
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> FacesContext getFacesContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> FacesContext.<span style="color: #006633;">getCurrentInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Obtiene la Petición del HttpServletRequest
	 * @return
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> HttpServletRequest getRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ExternalContext context <span style="color: #339933;">=</span> 
			FacesContext.<span style="color: #006633;">getCurrentInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getExternalContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    HttpServletRequest request <span style="color: #339933;">=</span> 
	    	<span style="color: #009900;">&#40;</span>HttpServletRequest<span style="color: #009900;">&#41;</span> context.<span style="color: #006633;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	    
	    <span style="color: #000000; font-weight: bold;">return</span> request<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Obtiene la Respuesta del HttpServletResponse	
	 * @return
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> HttpServletResponse getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ExternalContext context <span style="color: #339933;">=</span> 
			FacesContext.<span style="color: #006633;">getCurrentInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getExternalContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		HttpServletResponse response <span style="color: #339933;">=</span> 
	    	<span style="color: #009900;">&#40;</span>HttpServletResponse<span style="color: #009900;">&#41;</span> context.<span style="color: #006633;">getResponse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #000000; font-weight: bold;">return</span> response<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> login<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		HttpServletRequest request <span style="color: #339933;">=</span> getRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
&nbsp;
               <span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Obtenemos del Formulario los Datos, por mayor seguridad podriamos agregar filtros contra XSS e Inyección HQL
                 * Creamos un token para Spring
                 */</span>
	    	<span style="color: #003399;">String</span> userName <span style="color: #339933;">=</span> getUserName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	<span style="color: #003399;">String</span> password <span style="color: #339933;">=</span> getUserPassword<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Creamos un token para Spring
                 */</span>
	    	UsernamePasswordAuthenticationToken authReq <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UsernamePasswordAuthenticationToken<span style="color: #009900;">&#40;</span>userName, password<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
               <span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Le agregamos al token el request de HttpServletRequest
                 */</span>
	    	authReq.<span style="color: #006633;">setDetails</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> WebAuthenticationDetails<span style="color: #009900;">&#40;</span>request<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>			    	
	    	HttpSession session <span style="color: #339933;">=</span> request.<span style="color: #006633;">getSession</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
               <span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Asignamos la sesión el atributo UserName
                 * Obtenemos el manager auth y le asignamos el token
                 */</span>
	    	session.<span style="color: #006633;">setAttribute</span><span style="color: #009900;">&#40;</span>AuthenticationProcessingFilter.<span style="color: #006633;">SPRING_SECURITY_LAST_USERNAME_KEY</span>, userName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	Authentication auth <span style="color: #339933;">=</span> getAuthenticationManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">authenticate</span><span style="color: #009900;">&#40;</span>authReq<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	    	
&nbsp;
                  <span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Obtenemos el Contexto de Spring Security
                 * Le asignamos el Autentication Manager al Contexto de Seguridad
                 */</span>	
&nbsp;
	    	SecurityContext secCtx <span style="color: #339933;">=</span> SecurityContextHolder.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	    	
	    	secCtx.<span style="color: #006633;">setAuthentication</span><span style="color: #009900;">&#40;</span>auth<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	session.<span style="color: #006633;">setAttribute</span><span style="color: #009900;">&#40;</span>HttpSessionContextIntegrationFilter.<span style="color: #006633;">SPRING_SECURITY_CONTEXT_KEY</span>, secCtx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   			    	
&nbsp;
	    	<span style="color: #003399;">String</span> urlKey <span style="color: #339933;">=</span> AbstractProcessingFilter.<span style="color: #006633;">SPRING_SECURITY_SAVED_REQUEST_KEY</span><span style="color: #339933;">;</span>	   
	    	SavedRequest savedRequest <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SavedRequest<span style="color: #009900;">&#41;</span>session.<span style="color: #006633;">getAttribute</span><span style="color: #009900;">&#40;</span>urlKey<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	session.<span style="color: #006633;">removeAttribute</span><span style="color: #009900;">&#40;</span>urlKey<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    	<span style="color: #003399;">String</span> target <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/index.jsf&quot;</span><span style="color: #339933;">;</span>
	    	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
                  * Si perdiste la sesión en una página en particular, este parametro te ayudara a regresar a donde perdiste la sesión
                 */</span>
	    	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>savedRequest <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	    		
		    	<span style="color: #003399;">String</span> targetUrl <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	    		targetUrl <span style="color: #339933;">=</span> savedRequest.<span style="color: #006633;">getFullRequestUrl</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	    		
	    		FacesContext.<span style="color: #006633;">getCurrentInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getExternalContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">redirect</span><span style="color: #009900;">&#40;</span>targetUrl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	    		
	    		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>	    		
	    	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
	    		.................		  
	    	<span style="color: #009900;">&#125;</span>
	    	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
                 * Si no existiera un SavedRequest, entonces te enviaria a la pagina de inicio
                  */</span>
	    	forward<span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>BadCredentialsException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	...............	    	
	    	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">AuthenticationException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	............
	    	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> ioException<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	       ..............
	    <span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;index&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y como lo vamos a integrar con Spring, la declaración del Bean en el contexto</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginForm&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.xxx.LoginForm&quot;</span> <span style="color: #000066;">scope</span>=<span style="color: #ff0000;">&quot;request&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;authenticationManager&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>En la <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOS8wNS8xMy9zcHJpbmctc2VjdXJpdHktMi1sYS1jb25maWd1cmFjaW9uLWEtbGEtbWVkaWRhLWNvbi1kYW8taGliZXJuYXRlLWlpLw==">parte II miraremos los Filtros de Seguridad.</a></p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1617" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2009/05/11/spring-security-2-hibernate-dao-part/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>La Seguridad Perfecta con Spring y el dropDownMenu de RichFaces</title>
		<link>http://blog.jotadeveloper.com/2008/12/07/la-seguridad-perfecta-con-spring-y-el-dropdownmenu-de-richfaces/</link>
		<comments>http://blog.jotadeveloper.com/2008/12/07/la-seguridad-perfecta-con-spring-y-el-dropdownmenu-de-richfaces/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 13:04:17 +0000</pubDate>
		<dc:creator>Jota</dc:creator>
				<category><![CDATA[Articulos]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jbug]]></category>
		<category><![CDATA[RichFaces]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[spring security]]></category>

		<guid isPermaLink="false">http://blog.jotadeveloper.com/?p=1088</guid>
		<description><![CDATA[Bueno, sigo con la seguridad de Spring 2.0 o el conocido como el antiguo Acegi Security, ahora voy a proponer una alternativa para generar una seguridad con un componente de RichFaces, el dropDownMenu. ToolBar y menuItem.
Primero te recomiendo sigas la configuración de Spring con JDBC, o con LDAP, como tu lo desees, porque de todas [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vd3AtY29udGVudC91cGxvYWRzLzIwMDgvMTIvZHJvcGRvd25tZW51LmpwZw=="><img class="alignleft size-full wp-image-1089" style="margin: 6px;" title="dropdownmenu" src="http://blog.jotadeveloper.com/wp-content/uploads/2008/12/dropdownmenu.jpg" alt="" width="143" height="115" /></a>Bueno, sigo con la seguridad de Spring 2.0 o el conocido como el antiguo Acegi Security, ahora voy a proponer una alternativa para generar una seguridad con un componente de <strong>RichFaces, el dropDownMenu. ToolBar y menuItem</strong>.</p>
<p>Primero te recomiendo sigas <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMS8yMS9jb25maWd1cmFjaW9uLXNwcmluZy1zZWN1cml0eS0yMC1jb24tamRiYy8=">la configuración de Spring con JDBC</a>, o con <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMS8xNy9jb25maWd1cmFjaW9uLXNwcmluZy1zZWN1cml0eS0yMDQtcGFyYS1sZGFwLw==">LDAP</a>, como tu lo desees, porque de todas formas todos los Roles ( o Permisos) quedan almacenados en la misma variable de Spring. También <a href="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?url=aHR0cDovL2Jsb2cuam90YWRldmVsb3Blci5jb20vMjAwOC8xMC8yMC9pbnRlZ3JhbmRvLWpzZi1mYWNlbGV0cy1zcHJpbmctc2VjdXJpdHktMjAv">si deseas integrarlo con Facelest, aqui tenes los pasos a seguir</a>.</p>
<p>Lo <strong>primero</strong> que hay que hacer, es construir el menú, para eso usamos un Tool Bar:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:toolBar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:dropDownMenu</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:facet</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;label&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:panelGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:graphicImage</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{initParam['rootimages']}/images/icons/contexthelp.png&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:outputText</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;JotaDeveloper&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:panelGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/f:facet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Articulos&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Tutoriales&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Ayuda&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:dropDownMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:toolBar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>El código es bien sencillo, no hace falta explicar mucho, solo que para poder colocar un dropDownMenu , es necesario el toolBar, y para el menuItem , debe estar dentro de un dropDownMenu.</p>
<p>Depues de esto, y <strong>espero que hayas leido los 3 articulos que sugerí anteriormente</strong>, vamos a crear un Bean, donde tendremos la logica de nuestra seguridad con el dropDownMenu.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Date</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.logging.Log</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.logging.LogFactory</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.security.Authentication</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.security.GrantedAuthority</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.security.context.SecurityContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.security.context.SecurityContextHolder</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.springframework.security.ui.WebAuthenticationDetails</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> JotaDeveloperMenuBean <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Un objeto Booleano por cada elemento del Menu</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> rootJotaDeveloper<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> rootTutoriales<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> rootArticulos<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> rootAyuda<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Objetos Spring Security</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span> seguridadAcegi<span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// El GrantedAuthority es un Array con todos los Roles que recupera de la BD</span>
	<span style="color: #000000; font-weight: bold;">private</span> GrantedAuthority<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> listaAutoridades<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> SecurityContext contexto<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> Authentication autenticacion<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> ListAutoridades <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> nombreUsuario<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> estaAutenticado<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> WebAuthenticationDetails webAu<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Constructor que accede a toda la información de Spring Security
	 */</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> JotaDeveloperMenuBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">seguridadAcegi</span> <span style="color: #339933;">=</span> SecurityContextHolder.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
				.<span style="color: #006633;">getAuthentication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPrincipal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">contexto</span> <span style="color: #339933;">=</span> SecurityContextHolder.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">autenticacion</span> <span style="color: #339933;">=</span> SecurityContextHolder.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
				.<span style="color: #006633;">getAuthentication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">listaAutoridades</span> <span style="color: #339933;">=</span> SecurityContextHolder.<span style="color: #006633;">getContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
				.<span style="color: #006633;">getAuthentication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getAuthorities</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		convertirArrayAuthoritiesToListAuthorities<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">nombreUsuario</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">autenticacion</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">estaAutenticado</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">autenticacion</span>.<span style="color: #006633;">isAuthenticated</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Este metodo convierte el Array de Roles poco manejable en un List
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> convertirArrayAuthoritiesToListAuthorities<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> it_cont<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>it_cont <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> it_cont <span style="color: #339933;">&lt;</span> listaAutoridades.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> it_cont<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">String</span> ROL <span style="color: #339933;">=</span> listaAutoridades<span style="color: #009900;">&#91;</span>it_cont<span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ListAutoridades.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>ROL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Comprueba si existe determinado Rol en la Lista de Autoridades del
	 * Usuario Logeado
	 * 
	 * @param cadena
	 *            ROL
	 * @return El resultado de la Busqueda
	 */</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Boolean</span> comprobarRol<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> cadena<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">Integer</span> id <span style="color: #339933;">=</span> ListAutoridades.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span>cadena<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Si el Id es -1, el valor no fue encontrado.</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>id <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Los Getters que va leer cada elemento del Menu
	 */</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> getRootJotaDeveloper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rootJotaDeveloper <span style="color: #339933;">=</span> comprobarRol<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ROLE_ROOT_JOTADEVELOPER&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> getRootTutoriales<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rootTutoriales <span style="color: #339933;">=</span> comprobarRol<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ROLE_ROOT_TUTORIALES&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> getRootAyuda<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rootArticulos <span style="color: #339933;">=</span> comprobarRol<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ROLE_ROOT_AYUDA&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> getRootArticulos<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> rootAyuda <span style="color: #339933;">=</span> comprobarRol<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ROLE_ROOT_ARTICULOS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Despues de esto y <strong>incluir el Bean el el ManageBean de faces-config.xml</strong>, solo agregamos a la propiedad disabled del MenuItem el get del Bean.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:toolBar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;acegijsf:authorize</span> <span style="color: #000066;">ifAllGranted</span>=<span style="color: #ff0000;">&quot;ROLE_ROOT_JOTADEVELOPER&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:dropDownMenu</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:facet</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;label&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:panelGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:graphicImage</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{initParam['rootimages']}/images/icons/contexthelp.png&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:outputText</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;JotaDeveloper&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:panelGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/f:facet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Articulos&quot;</span> <span style="color: #000066;">disabled</span>=<span style="color: #ff0000;">&quot;#{jotaDeveloperMenuBean.rootArticulos}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Tutoriales&quot;</span> <span style="color: #000066;">disabled</span>=<span style="color: #ff0000;">&quot;#{jotaDeveloperMenuBean.rootTutoriales}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rich:menuItem</span> <span style="color: #000066;">submitMode</span>=<span style="color: #ff0000;">&quot;ajax&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Ayuda&quot;</span> <span style="color: #000066;">disabled</span>=<span style="color: #ff0000;">&quot;#{jotaDeveloperMenuBean.rootAyuda}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/rich:menuItem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:dropDownMenu<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/acegijsf:authorize<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rich:toolBar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>El <strong>resultado </strong>de todo esto, es que cuando inices sesión, el GrantedAuthority que genera en la sesión del usuario Spring Security, lo convertimos en un List, luego cada elemente del menu que tu crees, va preguntarle al List si existe, si Existe, regresa <strong>True</strong>, sino, <strong>False</strong>, y apareceran los menus cuales el usuario no tenga permiso desactivados, ademas de eso, no podra acceder via URL, si has configurado correctamente el security.xml del Spring Security.</p>
 <img src="http://blog.jotadeveloper.com/wp-content/plugins/feed-statistics.php?view=1&post_id=1088" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.jotadeveloper.com/2008/12/07/la-seguridad-perfecta-con-spring-y-el-dropdownmenu-de-richfaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
