I have a problem in configurting :
<sec:global-method-security secured-annotations="enabled" />
the following error:
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.getLocalName(Lorg/w3c/dom/Node;)Ljava/lang/String
There are some incompitable jar files with schema security
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
I am using the following security jar:
spring-security-core-tiger-2.0.4
spring-2.5
It looks like you may not have the required spring-security dependency (spring-security-tiger-xxx.jar).
As per the spring-security-2.0.2 xsd, secured-annotations is available.
Related
I have configured Spring security 4.2.3 in jsf 2.0.1 successfully in a Mavennised project. I also, added Spring security taglib as a dependency but <sec:authorize access="hasRole('ROLE_ADMIN')"> is not functioning as expected.
security.xml:
<beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">
<http auto-config="true"><intercept-url pattern="/" access="permitAll" /><intercept-url pattern="/home" access="permitAll" /><intercept-url pattern="/secured**" access="hasRole('ADMIN')" /><intercept-url pattern="/dba**" access="hasRole('ADMIN') and hasRole('DBA')" /><form-login login-page="/login" username-parameter="ssoId" password-parameter="password" authentication-failure-url="/unsecured" /></http> <authentication-manager><authentication-provider><user-service><user name="bill" password="abc123" authorities="ROLE_USER" /><user name="admin" password="root123" authorities="ROLE_ADMIN" /><user name="dba" password="root123" authorities="ROLE_ADMIN,ROLE_DBA" /></user-service></authentication-provider></authentication-manager>
</beans:beans>
web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<context-param> <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name> <param-value>true</param-value> </context-param>
<context-param><param-name>javax.faces.STATE_SAVING_METHOD</param-name><param-value>client</param-value></context-param>
<context-param><param-name>contextConfigLocation</param-name><param-value>classpath*:META-INF/spring/app*.xml</param-value></context-param>
<context-param><param-name>com.sun.faces.injectionProvider</param-name><param-value>com.sun.faces.vendor.WebContainerInjectionProvider</param-value></context-param>
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
<context-param><param-name>contextConfigLocation</param-name><param-value>/WEB-INF/spring/*.xml</param-value></context-param>
<filter><filter-name>springSecurityFilterChain</filter-name><filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class></filter>
<filter-mapping><filter-name>springSecurityFilterChain</filter-name><url-pattern>/*</url-pattern></filter-mapping>
<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener>
<servlet><servlet-name>Faces Servlet</servlet-name><servlet-class>javax.faces.webapp.FacesServlet</servlet-class><load-on-startup>1</load-on-startup></servlet>
<servlet-mapping><servlet-name>Faces Servlet</servlet-name><url-pattern>*.jsf</url-pattern></servlet-mapping>
<servlet-mapping><servlet-name>Faces Servlet</servlet-name><url-pattern>*.faces</url-pattern></servlet-mapping>
<filter><display-name>RichFaces Filter</display-name><filter-name>richfaces</filter-name><filter-class>org.ajax4jsf.Filter</filter-class></filter>
<filter-mapping><filter-name>richfaces</filter-name><servlet-name>Faces Servlet</servlet-name><dispatcher>REQUEST</dispatcher><dispatcher>FORWARD</dispatcher><dispatcher>INCLUDE</dispatcher></filter-mapping>
<welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list> <session-config><session-timeout>-1</session-timeout></session-config>
</web-app>
pom.xml dependencies:
<!-- START: Spring Security JARS -->
<dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-web</artifactId><version>${springsecurity.version}</version></dependency>
<dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-config</artifactId><version>${springsecurity.version}</version></dependency>
<dependency><groupId>org.springframework.security</groupId><artifactId>spring-security-taglibs</artifactId><version>4.2.3.RELEASE</version>dependency>
I am upgrading spring versions of our OSGi project to spring 4.2.x.
I have removed Spring DM dependencies and add Gemini Blueprint dependencies (org.eclipse.gemini.blueprint.core,org.eclipse.gemini.blueprint.extender,org.eclipse.gemini.blueprint.io) and those are in ACTIVE state in Virgo RT server.
I have added spring-security-config dependency and it is also in ACTIVE state.
But I am facing following issue
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] Offending resource: URL [bundleentry://157.fwk1212103909/META-INF/spring/applicationContext-security.xml]
my applicationContext-security.xml file is like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<security:global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager"
secured-annotations="enabled">
<security:expression-handler ref="expressionHandler" />
</security:global-method-security>
...
</beans>
I have used the xsd with versions. same result.
any idea what is causing this issue?
It would help if you stated which version of Virgo you are using. Are you aware of the fact that Virgo 3.7.0 includes Spring 4?
I had to add following line to META-INF/spring.handlers file in my project.
http\://www.springframework.org/schema/security=org.springframework.security.config.SecurityNamespaceHandler
I am trying t integrate apache camel with spring security. I am following the documentation http://camel.apache.org/spring-security.html . I have used spring DSL mode for routing configuration.
Following is my incomplete routing configuration with imported commonDecurity.xml.
camel.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring-security="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/spring-security http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">
<!-- import the spring security configuration -->
<import resource="classpath:org/apache/camel/component/spring/security/commonSecurity.xml"/>
<camelContext id="myCamelContext" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<!-- The exchange should be authenticated with the role of ADMIN before it is send to mock:endpoint -->
</route>
</camelContext>
</beans>
commonSecurity.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:spring-security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<bean id="accessDecisionManager" class="org.springframework.security.access.vote.AffirmativeBased">
<constructor-arg index="0">
<bean class="org.springframework.security.access.vote.RoleVoter"/>
</constructor-arg>
<property name="allowIfAllAbstainDecisions" value="true"/>
</bean>
<spring-security:authentication-manager alias="authenticationManager">
<spring-security:authentication-provider user-service-ref="userDetailsService"/>
</spring-security:authentication-manager>
<spring-security:user-service id="userDetailsService">
<spring-security:user name="jim" password="jimspassword" authorities="ROLE_USER, ROLE_ADMIN"/>
<spring-security:user name="bob" password="bobspassword" authorities="ROLE_USER"/>
</spring-security:user-service>
</beans>
However, when I deploy the bundle in servicemix it throws following ClassNotFoundException.
Exception in thread "SpringOsgiExtenderThread-2"
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class [org.springframework.security.vote.AffirmativeBased] for
bean with name 'accessDecisionManager' defined in OSGi
resource[classpath:spring-security/commonSecurity.xml|bnd.id=337|bnd.sym=com.genix.casegenix.esb];
nested exception is java.lang.ClassNotFoundException:
org.springframework.security.vote.AffirmativeBased not found from
bundle [com.genix.casegenix.esb] at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1278)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1347)
at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:913)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:617)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:934)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at
org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.lang.ClassNotFoundException:
org.springframework.security.vote.AffirmativeBased not found from
bundle [com.genix.casegenix.esb] at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:103)
at
org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
org.springframework.util.ClassUtils.forName(ClassUtils.java:265) at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:419)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1299)
at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1270)
... 11 more Caused by: java.lang.ClassNotFoundException:
org.springframework.security.vote.AffirmativeBased not found by
com.genix.casegenix.esb [337] at
org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
at
org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
at
org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at
org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1925) at
org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:978)
at
org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
... 17 more
I have already installed following features.
spring-security/3.1.4
camel-spring-security/2.16.3
I am using
sevicemix-7.0.0.M2
apache-camel-2.16.3
Any kind help appreciated. Thanks
I get following ClassNotFoundException when I try with https://github.com/apache/camel/tree/master/examples/camel-example-spring-security example.
Exception in thread "SpringOsgiExtenderThread-2"
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':
Cannot resolve reference to bean 'userDetailsService' while setting
bean property 'userDetailsService'; nested exception is
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class
[org.springframework.security.provisioning.InMemoryUserDetailsManager]
for bean with name 'userDetailsService' defined in null; nested
exception is java.lang.ClassNotFoundException:
org.springframework.security.provisioning.InMemoryUserDetailsManager
not found from bundle [com.xxxx.yyyyy.esb]
Have this as a configuration but it fails to build in netbeans please what am I missing. I using wicket
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-3.0.xsd">
<security:authentication-manager alias="authenticationManager">
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource" users-by-username-query="select username,password from registration where username=? and Password = ?" />
</authentication-provider>
</security:authentication-manager>
<security:global-method-security secured-annotations="enabled" />
</beans>
I have upgraded my application from faces 2.1 to 2.2.The following error showing up when I am accessing my application in browser.Using javax.faces-2.2.4 jar, primefaces-4.0 jar
and primefaces-extensions-1.2.0 jar in my application
java.lang.NullPointerException
at org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
at org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:28)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:665)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:70)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
This is my faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
My problem got solved by not exporting (Properties->Java Build Path->Order and Export->Uncheck primefaces and extension jar checkbox)
primefaces-4.0 jar and primefaces-extensions-1.2.0 jar.
These two jars are present in application's WEB-INF/lib folder.
This error appeared when informed hibernate.cfg.xml in the address of the packet in the class map.
Make notes of all the configuration files if you are not wrong addresses.