You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Peter Liu <ti...@gmail.com> on 2009/07/29 01:50:11 UTC

Using Shiro with Google App Engine

Hi,

My name is Peter and I am working on a webapp using Google App Engine
(Java).
I am trying to add a custom authentication method in additional to the
Google accounts.
After searching around the web I found Shiro and I want to try it out. 

I just checked out the source with SVN and built with Maven and able to run
the Quickstart program.
However I am not sure where should I go next, seems like there are couple
paths I can take but there's little documentation about them.

Here are my questions:

1. With a servlet environment, I should use the filter approach right?

2. Seems like I need to build my custom Realm to store credentials to
Google's datastore "bigtable". How do I define, config a custom Realm to be
used? What are the methods that I should customize?

3. Also, seems like I need to build my custom "CachingRealm" to use Google's
memcache. How do I define, config a caching realm to be used? 


Thanks!
-- 
View this message in context: http://n2.nabble.com/Using-Shiro-with-Google-App-Engine-tp3346759p3346759.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Using Shiro with Google App Engine

Posted by Peter Liu <ti...@gmail.com>.
This should be enough to get me started. Thanks!

On Tue, Jul 28, 2009 at 5:08 PM, Les Hazlewood-2 (via Nabble) <
ml-user+51627-824409545@n2.nabble.com<ml...@n2.nabble.com>
> wrote:

> Hi Peter,
>
> > I am trying to add a custom authentication method in additional to the
> > Google accounts.
> > After searching around the web I found Shiro and I want to try it out.
>
> Very cool!  I hope you find the answers you're looking for on this list.
>
> > I just checked out the source with SVN and built with Maven and able to
> run
> > the Quickstart program.
> > However I am not sure where should I go next, seems like there are couple
>
> > paths I can take but there's little documentation about them.
> >
> > Here are my questions:
> >
> > 1. With a servlet environment, I should use the filter approach right?
>
> Yep, this is the way to go.
>
> > 2. Seems like I need to build my custom Realm to store credentials to
> > Google's datastore "bigtable". How do I define, config a custom Realm to
> be
> > used? What are the methods that I should customize?
>
> Yep, you would need a custom Realm to do this.  Once you've created
> it, you can specify it in the ShiroFilter's 'config' init-param:
>
> [main]
> googleRealm = com.company.shiro.GoogleRealm
> gogoleRealm.property1 = someValue
> googleRealm.property2 = anotherValue
> etc...
>
> Shiro picks up any realms defined in this section and automatically
> enables them in the Shiro SecurityManager that will be used to 'talk'
> to the Realms at runtime.
>
> You store data in Google however you like - only the Realm
> implementation needs to know how to look up data using Google's APIs.
> If you subclass the AuthorizingRealm, you can override the
> 'doGetAuthenticationInfo' method to do this and return that data in
> the form of an AuthenticationInfo instance.
>
> > 3. Also, seems like I need to build my custom "CachingRealm" to use
> Google's
> > memcache. How do I define, config a caching realm to be used?
>
> You will need to implement the org.apache.shiro.cache.CacheManager
> interface to talk to Google's cache mechanism.  Then you need to tell
> the SecurityManager about this CacheManager instance so it can be used
> at runtime:
>
> [main]
> cacheManager = com.company.pkg.shiro.GoogleCacheManager
> #set any other properties here as necessary.
> #cacheManager.property1 = value
> #cacheManager.property2 = $reference
> #etc.
>
> #Now set it on the security manager by using
> # an object reference ($ marker):
> securityManager.cacheManager = $cacheManager
>
> # define your realms here, they will be picked
> # up automatically and given to the SecurityManager
> # no need to set them on the securityManager directly:
> myRealm = com.company.pkg.shiro.BigtableRealm
>
> Almost all of the Shiro Realms are cache-enabled by default - you just
> need to configure the CacheManager on the SecurityManager as shown
> above.  If you subclass the AuthenticatingRealm or AuthorizingRealm
> class depending on your needs, the SecurityManager will automatically
> provide the Realm instance with the CacheManager that was configured.
>
> I hope that helps!
>
> Cheers,
>
> Les
>
>
> ------------------------------
>  View message @
> http://n2.nabble.com/Using-Shiro-with-Google-App-Engine-tp3346759p3346820.html
> To unsubscribe from Using Shiro with Google App Engine, click here< (link removed) =>.
>
>
>

-- 
View this message in context: http://n2.nabble.com/Using-Shiro-with-Google-App-Engine-tp3346759p3346873.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Using Shiro with Google App Engine

Posted by Les Hazlewood <lh...@apache.org>.
Hi Peter,

> I am trying to add a custom authentication method in additional to the
> Google accounts.
> After searching around the web I found Shiro and I want to try it out.

Very cool!  I hope you find the answers you're looking for on this list.

> I just checked out the source with SVN and built with Maven and able to run
> the Quickstart program.
> However I am not sure where should I go next, seems like there are couple
> paths I can take but there's little documentation about them.
>
> Here are my questions:
>
> 1. With a servlet environment, I should use the filter approach right?

Yep, this is the way to go.

> 2. Seems like I need to build my custom Realm to store credentials to
> Google's datastore "bigtable". How do I define, config a custom Realm to be
> used? What are the methods that I should customize?

Yep, you would need a custom Realm to do this.  Once you've created
it, you can specify it in the ShiroFilter's 'config' init-param:

[main]
googleRealm = com.company.shiro.GoogleRealm
gogoleRealm.property1 = someValue
googleRealm.property2 = anotherValue
etc...

Shiro picks up any realms defined in this section and automatically
enables them in the Shiro SecurityManager that will be used to 'talk'
to the Realms at runtime.

You store data in Google however you like - only the Realm
implementation needs to know how to look up data using Google's APIs.
If you subclass the AuthorizingRealm, you can override the
'doGetAuthenticationInfo' method to do this and return that data in
the form of an AuthenticationInfo instance.

> 3. Also, seems like I need to build my custom "CachingRealm" to use Google's
> memcache. How do I define, config a caching realm to be used?

You will need to implement the org.apache.shiro.cache.CacheManager
interface to talk to Google's cache mechanism.  Then you need to tell
the SecurityManager about this CacheManager instance so it can be used
at runtime:

[main]
cacheManager = com.company.pkg.shiro.GoogleCacheManager
#set any other properties here as necessary.
#cacheManager.property1 = value
#cacheManager.property2 = $reference
#etc.

#Now set it on the security manager by using
# an object reference ($ marker):
securityManager.cacheManager = $cacheManager

# define your realms here, they will be picked
# up automatically and given to the SecurityManager
# no need to set them on the securityManager directly:
myRealm = com.company.pkg.shiro.BigtableRealm

Almost all of the Shiro Realms are cache-enabled by default - you just
need to configure the CacheManager on the SecurityManager as shown
above.  If you subclass the AuthenticatingRealm or AuthorizingRealm
class depending on your needs, the SecurityManager will automatically
provide the Realm instance with the CacheManager that was configured.

I hope that helps!

Cheers,

Les