Apache Shiro and Twitter4J demonstrating account setup and login with Twitter.
- A Bootique Shiro Demo Application
- A Custom Shiro Realm Example with Bootique
- Custom Role Filters with Bootique Shiro Web
- Using Encrypted Passwords in Shiro
The Bootique Shiro Demo uses MySQL which requires configuration. To configure
- Create a MySQL database and run
setup.mysql
located in install/sql - Update the Bootique JDBC Connection properties in
bootique.yml
The tests use H2 and require no configuration.
You'll need to register your application with Twitter at http://dev.twitter.com
. This demo uses localhost:9000
so your Application Twitter Callback URL should be http://localhost:9000/authorized.
Copy the sample4j.properties
in both /src/main/resources
and /src/test/resources
to twitter4j.properties
and populate all values listed. The application requires oauth.consumerKey and oauth.consumerSecret values.
# supply the following properties in /src/main/resource/twitter4j.properties
oauth.consumerKey=*********
oauth.consumerSecret=*******
The test twitter4j.properties
file requires the additional property values of oauth.accessToken and oauth.accessTokenSecret. To obtain those properties you will:
- RUN the application
- LOGIN with Twitter, and if all goes well you will see an accessToken and accessTokenSecret in the MySQL table
user_social
, fieldsaccess_token
andsecret.
- Enter these values in the accessToken/accessTokenSecret properties in your test
twitter4j.properties
file.
# enter all properties in /src/test/resource/twitter4j.properties
oauth.consumerKey=*********
oauth.consumerSecret=*******
oauth.accessToken=***********
oauth.accessTokenSecret=*********
Build the app in your IDE and go to
http://localhost:9000/
To use Maven:
mvn clean package
Enter the following to launch the app from your application root directory.
/project/root/$ java -jar target/shiro-twitter.jar
Two User Accounts are available for login and are listed on the web pages.
- bob - Password: password Roles: admin and user
- ken - Password: halo Roles: user