Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Using Virgo Snaps and Spring Interceptors
icon4.gif  Using Virgo Snaps and Spring Interceptors [message #774809] Wed, 04 January 2012 16:59 Go to next message
Gabriel Afonso is currently offline Gabriel Afonso
Messages: 23
Registered: December 2011
Junior Member
Hi,

I have two Web Bundles, the first is the Host and the other is a snap. In the Host I have a login page and a home page (it shows when I enter mi username and password). My problem is, I need to validate the user is authenticated to access to the other pages of the snap (second web bundle).
I have a Interceptor in the Host and works fine (localhost:8080/host/home) it validates the user is authenticated to show the home page, but when I go to the snap (localhost:8080/host/snap) the Interceptor doesn't work (it doesn't validate anything and show the snap page).

How can I validate the other snaps bundles with a Interceptor in the Host bundle? Is it possible?

this is the code of the interceptor in Host bundle
<mvc:interceptors>		 
        <mvc:interceptor>
            <mvc:mapping path="/**"/>
            <bean class="LoginValidatorInterceptor">
            </bean>
        </mvc:interceptor>
    </mvc:interceptors> 


class
public class LoginValidatorInterceptor extends HandlerInterceptorAdapter {
        
        if (request.getSession().getAttribute("user") != null) {
            return true;
        }

        response.sendRedirect("/host/");
        return false;
    }
}


[Updated on: Wed, 04 January 2012 17:04]

Report message to a moderator

Re: Using Virgo Snaps and Spring Interceptors [message #774846 is a reply to message #774809] Wed, 04 January 2012 19:00 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
Gabriel,

HostFilter will execute before DispatcherServlet in Host wab and will "forward" request to the child snap thus bypassing your interceptor in host.

Take a look at using SpringSecurity or a Filter to deal with this requirements. Make sure that filter is defined before HostFilter in host web.xml

Dmitry
Re: Using Virgo Snaps and Spring Interceptors [message #774908 is a reply to message #774846] Wed, 04 January 2012 22:25 Go to previous messageGo to next message
Gabriel Afonso is currently offline Gabriel Afonso
Messages: 23
Registered: December 2011
Junior Member
Thanks for your answer Dmitry.

In this moment I'm working with SpringSecurity, but I have a problem, I can't deploy the bundles of SpringSecurity in Virgo. I downloaded the Spring Security library and I put the bundles in /Virgo-folder/repository/usr/ folder, then I create a plan file for this bundles and finnally I add a line in the org.eclipse.virgo.kernel.userregion.properties file, but when I start Virgo, it throws this errors:

Unable to install application from URI 'file:/home/gabrielafonso/Virgo/virgo-tomcat-server-3.0.2.RELEASE/./repository/usr/org.springframework.security.plan'. Cannot satisfy constraints for bundle 'org.springframework.security.config' version '3.1.0.RELEASE'. Cannot resolve: org.springframework.security.config
    Resolver report:
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.config_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.core; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.acls_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.context; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.aspects_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.access.intercept.aspectj; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.cas_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.authority; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.core_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.context.support; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.web_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.context.support; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.taglibs_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.authority; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.openid_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.web.authentication.rememberme; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.ldap_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.ldap; version="[1.3.0,1.4.0)">
. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'org.springframework.security.config' at version '3.1.0.RELEASE': Cannot resolve: org.springframework.security.config
    Resolver report:
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.config_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.core; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.acls_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.context; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.aspects_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.access.intercept.aspectj; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.cas_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.authority; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.core_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.context.support; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.web_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.context.support; version="[3.0.6.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.taglibs_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.core.authority; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.openid_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.security.web.authentication.rememberme; version="[3.1.0.RELEASE,3.2.0)">
        An Import-Package could not be resolved. Caused by missing constraint in bundle <org.springframework.security.ldap_3.1.0.RELEASE>
             constraint: <Import-Package: org.springframework.ldap; version="[1.3.0,1.4.0)">

	at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:45)
	at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessTree(StandardPipeline.java:62)
	at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessTree(CompensatingPipeline.java:72)
	at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
	at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessTree(StandardPipeline.java:62)
	at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:285)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:164)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:136)
	at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:203)
	at org.eclipse.virgo.kernel.userregion.internal.InitialArtifactDeployer$ArtifactDeployingRunnable.deployArtifacts(InitialArtifactDeployer.java:156)
	at org.eclipse.virgo.kernel.userregion.internal.InitialArtifactDeployer$ArtifactDeployingRunnable.run(InitialArtifactDeployer.java:146)
	at java.lang.Thread.run(Thread.java:662)

[2012-01-04 17:16:34.583] system-artifacts             <UR0002E> User region failed while deploying initial artifacts. Shutting down. 
[2012-01-04 17:16:34.585] System Bundle Shutdown       <KE0010I> Shutdown initiated. 
[2012-01-04 17:16:34.677] System Bundle Shutdown       <TC0002I> Stopping Tomcat. 
[2012-01-04 17:16:37.788] System Bundle Shutdown       <TC0003I> Stopped Tomcat.


What am I doing wrong?

How can I load the Spring Security Library in Virgo?
Re: Using Virgo Snaps and Spring Interceptors [message #775110 is a reply to message #774908] Thu, 05 January 2012 10:43 Go to previous messageGo to next message
Chris Frost is currently offline Chris Frost
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

You are using Spring Security 3.1.0, this requires Spring framework 3.1.0. Virgo currently ships with an older version of the Spring framework as 3.1.0 has only recently released. You would have to upgrade Virgo to the newer version of the Spring framework, use an older version of Spring security or wait for the next release of Virgo which will have moved up to the new version of the Spring framework.

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Using Virgo Snaps and Spring Interceptors [message #775184 is a reply to message #775110] Thu, 05 January 2012 14:17 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
Gabriel,

As Chris mentioned you will need to downgrade to spring-security 3.0.x version. Upgrading to 3.1 of spring framework will be really painful as Virgo 3.0.2 has a exclusion for 3.1, i.e. "[2.5.6,3.1)".

You also should not need to manually deploy spring-security with a plan. If your bundles/wabs have imports for spring-security, required bundles will be automatically provisioned from repository.

Regards,
Dmitry
Re: Using Virgo Snaps and Spring Interceptors [message #775854 is a reply to message #775184] Fri, 06 January 2012 19:51 Go to previous message
Gabriel Afonso is currently offline Gabriel Afonso
Messages: 23
Registered: December 2011
Junior Member
Thanks for your answers, I could do it with Spring Security and it works fine.

Regards,
Gabriel
Previous Topic:Load jsp from another bundle OSGi
Next Topic:How to develop Spring Session Scope Beans
Goto Forum:
  


Current Time: Thu Oct 23 06:02:04 GMT 2014

Powered by FUDForum. Page generated in 0.02960 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software