Blog entry from previous reply seeing as it is out in the ether now :) Sorry for spamming list
http://www.mrvoip.com.au/blog/tapestry-security-howto-notes Chris On Tue, Aug 5, 2014 at 12:27 PM, Chris Mylonas <ch...@opencsta.org> wrote: > And here's some notes from my wiki for a tapestry-security file based auth > and hibernate for entities. > I'm also in +10 timezone down in Sydney - so the replies will come later > in the day usually :) > > Skeleton > > - Create quickstart tapestry archetype > > [edit > <https://bondiwiki.mrvoip.com.au/index.php?title=Tapestry_Hibernate_Security&action=edit§ion=2> > ]Change dependencies > > - Add in these dependencies replacing tapestry-core > > <dependency> > <groupId>org.apache.tapestry</groupId> > <artifactId>tapestry-hibernate</artifactId> > <version>5.3.7</version> > </dependency> > <dependency> > <groupId>org.tynamo</groupId> > <artifactId>tapestry-security</artifactId> > <version>0.5.1</version> > </dependency> > <dependency> > <groupId>hsqldb</groupId> > <artifactId>hsqldb</artifactId> > <version>1.8.0.7</version> > </dependency> > <dependency> > <groupId>org.got5</groupId> > <artifactId>tapestry5-jquery</artifactId> > <version>3.3.7</version> > </dependency> > > > ... > <repository> > <id>devlab722-repo</id> > <url>http://nexus.devlab722.net/nexus/content/repositories/releases > </url> > <snapshots> > <enabled>false</enabled> > </snapshots> > </repository> > > <repository> > <id>devlab722-snapshot-repo</id> > <url>http://nexus.devlab722.net/nexus/content/repositories/snapshots > </url> > <releases> > <enabled>false</enabled> > </releases> > </repository> > ... > > > > > - Running in jetty at this stage will yield this error in the browser > > HTTP ERROR 500 > > Problem accessing /TapestryHibernateSecurity/. Reason: > > Exception constructing service 'WebSecurityManager': Error invoking > constructor public > org.tynamo.security.services.TapestryRealmSecurityManager(org.tynamo.security.Authenticator,org.apache.shiro.mgt.SubjectFactory,org.apache.shiro.mgt.RememberMeManager,java.util.Collection): > Realms collection argument cannot be empty. > > Caused by: > > java.lang.RuntimeException: Exception constructing service > 'WebSecurityManager': Error invoking constructor public > org.tynamo.security.services.TapestryRealmSecurityManager(org.tynamo.security.Authenticator,org.apache.shiro.mgt.SubjectFactory,org.apache.shiro.mgt.RememberMeManager,java.util.Collection): > Realms collection argument cannot be empty. > at > org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75) > > > Because Tapestry has an IoC container that does dependency injection, each > service tapetry uses needs to be configured within a module. The default > place for application specific services to be set up is in AppModule. > [edit > <https://bondiwiki.mrvoip.com.au/index.php?title=Tapestry_Hibernate_Security&action=edit§ion=3> > ]Add realm to security service > > So we need to contribute some web security manager realm info by adding a > realm. > > - Add websecuritymanager realm into AppModule > > ... > import org.tynamo.shiro.extension.realm.text.ExtendedPropertiesRealm; > import org.apache.shiro.realm.Realm; > import org.apache.shiro.web.mgt.WebSecurityManager; > ... > > @Contribute(WebSecurityManager.class) > public static void addRealms(Configuration<Realm> configuration) { > ExtendedPropertiesRealm realm = new > ExtendedPropertiesRealm("classpath:shiro-users.properties"); > configuration.add(realm); > } > > [edit > <https://bondiwiki.mrvoip.com.au/index.php?title=Tapestry_Hibernate_Security&action=edit§ion=4> > ]Shiro users properties > > And also add shiro-users.properties to the classpath (src/main/resources) > > touch srm/main/resources/shiro-users.properties > > > - Firing up application now yields hibernate errors. > > HTTP ERROR 500 > > Problem accessing /TapestryHibernateSecurity/. Reason: > > java.lang.RuntimeException: Exception constructing service > 'ValueEncoderSource': Error invoking service contribution method > org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, > boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, > LoggerSource): Exception constructing service 'HibernateSessionSource': Error > invoking constructor public > org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl(org.slf4j.Logger,java.util.List): > /hibernate.cfg.xml not found > > Caused by: > > org.apache.shiro.subject.ExecutionException: java.lang.RuntimeException: > Exception constructing service 'ValueEncoderSource': Error invoking service > contribution method > org.apache.tapestry5.hibernate.HibernateModule.contributeValueEncoderSource(MappedConfiguration, > boolean, HibernateSessionSource, Session, TypeCoercer, PropertyAccess, > LoggerSource): Exception constructing service 'HibernateSessionSource': Error > invoking constructor public > org.apache.tapestry5.internal.hibernate.HibernateSessionSourceImpl(org.slf4j.Logger,java.util.List): > /hibernate.cfg.xml not found > at > org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:382) > > > [edit > <https://bondiwiki.mrvoip.com.au/index.php?title=Tapestry_Hibernate_Security&action=edit§ion=5> > ]add in the hibernate configuration > > - Add hibernate configuration for derby db > > src/main/resources/hibernate.cfg.xml > <!DOCTYPE hibernate-configuration PUBLIC > "-//Hibernate/Hibernate Configuration DTD 3.0//EN" > "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> > <hibernate-configuration> > <session-factory> > <property > name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property> > <property > name="hibernate.connection.url">jdbc:hsqldb:./target/work/t5hibernatesecurity;shutdown=true</property> > <property > name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property> > <property name="hibernate.connection.username">sa</property> > <property name="hibernate.connection.password"></property> > <property name="hbm2ddl.auto">update</property> > <property name="hibernate.show_sql">true</property> > <property name="hibernate.format_sql">true</property> > </session-factory> > </hibernate-configuration> > > > > > > > > On Tue, Aug 5, 2014 at 12:19 PM, Chris Mylonas <ch...@opencsta.org> wrote: > >> Hi Tim, >> >> I had sample code in a repo I was making a variations project to split >> hairs on how to do the same thing using different ways. >> >> Unforch that repo was lost by a VPS provider although I have the latest >> got tree it is def not share-able ATM. >> >> Do a Google search for "github eloquentia Thiago tapestry" and you'll >> find thiago's excellent sample to get you going from a file based thing to >> database. >> >> Eloquentia may use nosql but you will be able to work it out - I did and >> I'm by far nowhere in the league of others on the list :) >> >> HTH >> Chris >> On 05/08/2014 11:43 am, "D Tim Cummings" <t...@triptera.com.au> wrote: >> >>> I am having a look at the tapestry-security guide at >>> http://tynamo.org/tapestry-security+guide and several of the links are >>> broken >>> >>> Hibernate-based entity realm (service) >>> <http://svn.codehaus.org/tynamo/trunk/tynamo-federatedaccounts/tynamo-federatedaccounts-core/src/test/java/org/tynamo/security/federatedaccounts/testapp/services/UserRealm.java> >>> points >>> to >>> http://svn.codehaus.org/tynamo/trunk/tynamo-federatedaccounts/tynamo-federatedaccounts-core/src/test/java/org/tynamo/security/federatedaccounts/testapp/services/UserRealm.java >>> (404 Not found) >>> >>> User entity used by the realm sample referred to above >>> <http://svn.codehaus.org/tynamo/trunk/tynamo-federatedaccounts/tynamo-federatedaccounts-core/src/test/java/org/tynamo/security/federatedaccounts/testapp/entities/User.java> >>> points >>> to >>> http://svn.codehaus.org/tynamo/trunk/tynamo-federatedaccounts/tynamo-federatedaccounts-core/src/test/java/org/tynamo/security/federatedaccounts/testapp/entities/User.java >>> (404 Not found) >>> >>> tapestry-exceptionpage <http://tynamo.org/tapestry-security+guide> points >>> to the tapestry-security guide page that we are reading. >>> >>> full-featured integration test web app >>> <http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/java/org/tynamo/security/testapp/> >>> should >>> probably point to github >>> https://github.com/tynamo/tapestry-security/tree/master/src/test/java/org/tynamo/security/testapp >>> >>> template >>> <http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/resources/org/tynamo/security/testapp/pages/Index.tml> >>> should >>> probably point to github >>> https://github.com/tynamo/tapestry-security/blob/master/src/test/resources/org/tynamo/security/testapp/pages/Index.tml >>> >>> class >>> <http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/java/org/tynamo/security/testapp/pages/Index.java> >>> should >>> probably point to github >>> https://github.com/tynamo/tapestry-security/blob/master/src/test/java/org/tynamo/security/testapp/pages/Index.java >>> >>> AlphaService >>> <http://svn.codehaus.org/tynamo/trunk/tapestry-security/src/test/java/org/tynamo/security/testapp/services/AlphaService.java> >>> should >>> probably point to github >>> https://github.com/tynamo/tapestry-security/blob/master/src/test/java/org/tynamo/security/testapp/services/AlphaService.java >>> >>> http://svn.codehaus.org/tynamo/trunk/tynamo-example-federatedaccounts should >>> probably point to github >>> https://github.com/tynamo/tynamo-example-federatedaccounts >>> >>> AppModule >>> <http://svn.codehaus.org/tynamo/trunk/tynamo-example-federatedaccounts/src/main/java/org/tynamo/examples/federatedaccounts/services/AppModule.java> >>> should >>> probably point to github >>> https://github.com/tynamo/tynamo-example-federatedaccounts/blob/master/src/main/java/org/tynamo/examples/federatedaccounts/services/AppModule.java >>> >>> >>> >>> I am really looking for sample code of an implementation of >>> tapestry-security with Cayenne (or Hibernate) using Tapestry 5.3.7, >>> tapestry-security 0.5.1. I don't need federated accounts at this stage. >>> >>> >>> >>> Regards >>> >>> Tim >>> >> >