best grammar app

Grails MongoDB Spring Security Getting Started

Submitted by Abhishek on Tue, 2013-09-17 17:38
mongodb.org/grails.org
classBootStrap {

definit = { servletContext ->
		defuserRole = newcom.numahub.Role(authority:"ROLE_USER").save(flush:true)
		def user = newcom.numahub.User()
		user.username = "abhishek"
		user.password = "password"
		user.email = "contact@constonline.com"
		user.firstName= "Abhishek"
		user.lastName="Mishra"
		user.enabled = true
		user.accountExpired = false
		user.accountLocked = false
		user.passwordExpired = false
		user.validate();
user.save(flush:true)
		newcom.numahub.UserRole(user: user, role: userRole).save(flush: true, 
insert: true);
		
		
    }
defdestroy = {
    }
}

Step 10: Add a Handler in index.jsp

To see if the Login functionality is working, I added the code below in index.gsp page:


You are now Logged in as

	
Login Here
	

Step 11: Start Mongo Server

Then I started the Mongo Server on my machine. You can find the instructions on the MongoDb site for the same.

Step 12: Launch the App

And then I launched the App:

Configuring Spring Security Core ...
... finished configuring Spring Security Core
| Server running. Browse to http://localhost:8080/NumaHub

Verifying The Details

http://localhost:8080/NumaHub

image

Clicked on 'Login here', entered username and password as specified in the BootStrap.groovy:

image

And saw a message like this:

image

Using a Utility that lets you see the Database, you can verify the how it gets saved.

The following Collections were created

image

The contents of the collections were:

The Role

{
  "_id": { "$oid" : "5235aebdc2e6b9cd860aa951" },
  "authority": "ROLE_USER",
  "version": 0
}

The User

{
  "_id": { "$oid" : "5235aec4c2e6b9cd860aa953" },
  "accountExpired": false,
  "accountLocked": false,
  "email": "contact@constonline.com",
  "enabled": true,
  "firstName": "Abhishek",
  "lastName": "Mishra",
  "password": "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8",
  "passwordExpired": false,
  "username": "abhishek",
  "version": 0
}

And the User Role

{
  "_id": { "$oid" : "5235b0e3c2e6b107f99c44a0" },
  "role": { "$oid" : "5235b0e1c2e6b107f99c449e" },
  "user": { "$oid" : "5235b0e3c2e6b107f99c449f" }
}

Hope this is helpful for anyone getting started. Questions are suggestions are welcome. If you would like to see more articles on Grails, do let me know.


Abhishek Mishra
Good experience in working with BPM technologies like Savvion, JBPM. Founder and Chief Editor of BPMGeek.com. Founder of Savvion Business Manager Mobility Framework Savmobify| View my BPMGeek Profile
|
best grammar app

About BPMGeek

BPMGeek is an initiative to collaborate and communicate with the growing Business process management community out there. The goal is to help developers connect with experts, ask questions, post their learning and get understanding of BPM Concepts. Often tool specific knowledge of niche areas end up developers perplexed and confused - especially when there are very less number of resources available. We will be coming up several several new features. Have a look at our Roadmap here

BPMGeek is an independent entity not associated with any Product. All BPM product professionals are invited to contribute. The Logos and Names used across the site belong to their respective owners. The viewpoints mentioned by Individual contributors are their own. BPMgeek cannot be held liable for any issues arising out of it.


BPMgeek is promoting the Nounshoun English Grammar App - developed by Constellation Software.