[JBoss Seam] - Re: external authentication-any pointers for a beginner?
by mwkohout
Thanks for your continuing suggestions and patience, Shane.
I reimplemented by overriding getLoginContext() and it's still going boom.
here's my JAAS config factory method:
| @Factory(value="org.jboss.seam.security.configuration", autoCreate=true, scope=APPLICATION)
| public javax.security.auth.login.Configuration getConfiguration()
| {
| log.error("in my getConfiguration()");
| return new javax.security.auth.login.Configuration()
| {
|
| private AppConfigurationEntry[] aces = { new AppConfigurationEntry(
| X500LoginModule.class.getName(),
| LoginModuleControlFlag.REQUIRED,
| new HashMap<String,String>()
| ) };
|
| @Override
| public AppConfigurationEntry[] getAppConfigurationEntry(String name)
| {
| List<AppConfigurationEntry> entries = new ArrayList<AppConfigurationEntry>();
| for( AppConfigurationEntry entry : aces)
| {
| if( entry.getLoginModuleName().equals(name))
| entries.add(entry);
|
| }
| return entries.toArray(new AppConfigurationEntry[0]);
| }
|
|
| public String toString()
| {
| return "appConfigurationEntries="+Arrays.asList(aces);
| }
|
|
| };
| }
|
And my subclass of identity
| @Name(value = "org.jboss.seam.security.identity")
| @Scope(value = SESSION)
| //@BypassInterceptors
| @Startup
| public class X500Identity extends Identity {
|
| private static final LogProvider log = Logging.getLogProvider(X500Identity.class);
|
| @In(value="org.jboss.seam.security.configuration")
| Configuration config;
|
| @In(value="org.jboss.seam.core.expressions")
| Expressions expressionFactory;
|
| public X500Identity()
| {
| setJaasConfigName(X500LoginModule.class.getName());
| setAuthenticateEveryRequest(true);
| log.error("in X500Identity constructor. jaas config name = "+this.getJaasConfigName());
| }
| @Override
| protected LoginContext getLoginContext() throws LoginException {
| log.error("in my getLoginContext()");
|
| if (getJaasConfigName() == null) {
| throw new RuntimeException("In X500Identity. JAAS config name not set. Please set it up.");
| }
| if( config == null )
| throw new RuntimeException("In X500Identity. \"org.jboss.seam.security.configuration\" component not injected. Please set it up.");
|
| log.error( "new LoginContext(getJaasConfigName(), getSubject(), getDefaultCallbackHandler(), config)=+new LoginContext("+getJaasConfigName()+","+ getSubject()+","+ getDefaultCallbackHandler()+","+ config+")");
| return new LoginContext(getJaasConfigName(), getSubject(), getDefaultCallbackHandler(), config);
| }
|
| @Override
| public CallbackHandler getDefaultCallbackHandler() {
| log.error("in my getDefaultCallbackHandler()");
| return new CookieCallbackHandler();
| }
|
|
|
| @Override
| public void checkRestriction(String expr) {
| log.error("in my checkRestriction(String expr) expr=" + expr);
| if (!evaluateExpression(expr)) {
| if (!isLoggedIn()) {
| this.login();
| } else {
| Events.instance().raiseEvent("org.jboss.seam.notAuthorized");
| throw new AuthorizationException(String.format("Authorization check failed for expression [%s]", expr));
| }
| }
| }
|
| @Override
| public boolean isLoggedIn(boolean attemptLogin) {
| log.error("in my isLoggedIn(boolean attemptLogin) attemptLogin = " + attemptLogin);
| boolean isLoggedIn = super.isLoggedIn(attemptLogin);
| log.error("exiting isLoggedIn(boolean attemptLogin). isLoggedIn = " + isLoggedIn);
| return isLoggedIn;
| }
|
| @Override
| public Expressions.MethodExpression getAuthenticateMethod() {
| log.error("in my getAuthenticateMethod():"+expressionFactory.createMethodExpression("#{authBean.authenticate()}"));
| return expressionFactory.createMethodExpression("#{authBean.authenticate()}");
| }
|
|
| public static Identity instance() {
| if (!Contexts.isSessionContextActive()) {
| throw new IllegalStateException("No active session context");
| }
|
| Identity instance = (Identity) Component.getInstance(X500Identity.class, ScopeType.SESSION);
|
| if (instance == null) {
| throw new IllegalStateException("No Identity could be created");
| }
|
| return instance;
| }
| }
|
For some reason, it doesn't appear to be hitting my authenticateMethod anymore....ideas?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068365#4068365
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068365
18Â years, 9Â months
[JBoss Seam] - @DataModel on Stateful beans (broken?)
by sannegrinovero
I'll post a simple case confirming the problem but I think the stacktrace below, from our complete application, could be more helpfull.
Having a bean method returning a List annotated as @DataModel in a stateless bean is working as before (used before Seam 1.2.1)
@Name("brokenList")
//@Stateful
public class BrokenList implements BrokenListIfa {
public void someOtherMethod(){
}
@DataModel
public List getTestData() {
List l = new ArrayList();
l.add("ONE");
l.add("TWO");
return "testitem";
}
// @Remove @Destroy
public void destroy() {
}
}
The page used to test is something like this:
<h:dataTable value="#{brokenList.testData}" var="d">
<h:column>
<h:outputText value="#{d}" />
</h:column>
</h:dataTable>
When changing the bean to a Stateful bean (as above when enabling commented lines) Seam throws an exception:
javax.faces.FacesException: javax.el.PropertyNotFoundException: /index.xhtml @52,57 value="#{brokenList.testData}": Property 'testData' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_0
at javax.faces.component.UIData.getValue(UIData.java:585)
at javax.faces.component.UIData.getDataModel(UIData.java:1063)
at javax.faces.component.UIData.setRowIndex(UIData.java:417)
at com.sun.faces.renderkit.html_basic.TableRenderer.encodeBegin(TableRenderer.java:85)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
at javax.faces.component.UIData.encodeBegin(UIData.java:879)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:577)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:233)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:87)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:63)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:46)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:63)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.ja
Actually when looking at our application's stacktrace whe get some more information (don't really now why they are different):
Caused by: javax.el.ELException: /private/users/readerSearchResult.xhtml @53,44 value="#{readerSearch.codeSearchParm}": Error reading 'codeSearchParm' on type org.javassist.tmp.java.lang.Object_$$_javassist_90
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
... 33 more
Caused by: javax.ejb.EJBTransactionRolledbackException: could not set property value: readerSearch.readers
at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
at org.jboss.aspects.tx.TxInterceptor$Supports.invoke(TxInterceptor.java:148)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:83)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:204)
at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:100)
at $Proxy231.getCodeSearchParm(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
at org.jboss.seam.ejb.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:41)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
at org.javassist.tmp.java.lang.Object_$$_javassist_90.getCodeSearchParm(Object_$$_javassist_90.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
... 34 more
Caused by: java.lang.IllegalArgumentException: could not set property value: readerSearch.readers
at org.jboss.seam.Component.setPropertyValue(Component.java:1660)
at org.jboss.seam.Component.access$300(Component.java:134)
at org.jboss.seam.Component$BijectedMethod.set(Component.java:2361)
at org.jboss.seam.Component.injectDataModelSelection(Component.java:1378)
at org.jboss.seam.Component.injectDataModelSelections(Component.java:1364)
at org.jboss.seam.Component.inject(Component.java:1303)
at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.ConversationInterceptor.aroundInvoke(ConversationInterceptor.java:63)
at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
at
2007-07-27 21:44:06,453 ERROR [STDERR] org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:106)
at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:53)
at sun.reflect.GeneratedMethodAccessor147.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.ExtendedPersistenceContextPropagationInterceptor.invoke(ExtendedPersistenceContextPropagationInterceptor.java:57)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
... 76 more
Caused by: java.lang.IllegalArgumentException: Could not invoke method by reflection: ReaderSearchActionHibernate.getReaders() with parameters: (java.util.ArrayList) on: it.politecnicoinnovazione.uol2.controller.users.ReaderSearchActionHibernate
at org.jboss.seam.util.Reflections.invoke(Reflections.java:31)
at org.jboss.seam.Component.setPropertyValue(Component.java:1656)
... 102 more
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
... 103 more
Looking to Seam's source code it looks like it is calling the setter's method to get the value, as our method doesn't have any parameters. "List" should be the return type, not the argument.
Someone could tell mo more about this? It used to work on Seam 1.2.1
Should I open a JIRA?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4068362#4068362
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4068362
18Â years, 9Â months