-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified and use service as Google login
- Loading branch information
Tim Niblett
committed
Oct 16, 2012
1 parent
f939e5d
commit 21deb2d
Showing
32 changed files
with
409 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/cilogi/shiro/googlegae/GoogleGAEAuthenticationInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2012 Tim Niblett. All Rights Reserved. | ||
// | ||
// File: GoogleGAEAuthenticationInfo.java (16-Oct-2012) | ||
// Author: tim | ||
// | ||
// Copyright in the whole and every part of this source file belongs to | ||
// Tim Niblett (the Author) and may not be used, sold, licenced, | ||
// transferred, copied or reproduced in whole or in part in | ||
// any manner or form or in or on any media to any person other than | ||
// in accordance with the terms of The Author's agreement | ||
// or otherwise without the prior written consent of The Author. All | ||
// information contained in this source file is confidential information | ||
// belonging to The Author and as such may not be disclosed other | ||
// than in accordance with the terms of The Author's agreement, or | ||
// otherwise, without the prior written consent of The Author. As | ||
// confidential information this source file must be kept fully and | ||
// effectively secure at all times. | ||
// | ||
|
||
|
||
package com.cilogi.shiro.googlegae; | ||
|
||
import org.apache.shiro.authc.AuthenticationInfo; | ||
import org.apache.shiro.subject.PrincipalCollection; | ||
import org.apache.shiro.subject.SimplePrincipalCollection; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
||
public class GoogleGAEAuthenticationInfo implements AuthenticationInfo { | ||
static final Logger LOG = Logger.getLogger(GoogleGAEAuthenticationInfo.class.getName()); | ||
|
||
private final String principal; | ||
|
||
public GoogleGAEAuthenticationInfo(String principal) { | ||
this.principal = principal; | ||
} | ||
|
||
@Override | ||
public Object getCredentials() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public PrincipalCollection getPrincipals() { | ||
return new SimplePrincipalCollection(principal, "GoogleGAE"); | ||
} | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/com/cilogi/shiro/googlegae/GoogleGAEAuthenticationToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2012 Tim Niblett. All Rights Reserved. | ||
// | ||
// File: GoogleGAEAuthenticationToken.java (16-Oct-2012) | ||
// Author: tim | ||
// | ||
// Copyright in the whole and every part of this source file belongs to | ||
// Tim Niblett (the Author) and may not be used, sold, licenced, | ||
// transferred, copied or reproduced in whole or in part in | ||
// any manner or form or in or on any media to any person other than | ||
// in accordance with the terms of The Author's agreement | ||
// or otherwise without the prior written consent of The Author. All | ||
// information contained in this source file is confidential information | ||
// belonging to The Author and as such may not be disclosed other | ||
// than in accordance with the terms of The Author's agreement, or | ||
// otherwise, without the prior written consent of The Author. As | ||
// confidential information this source file must be kept fully and | ||
// effectively secure at all times. | ||
// | ||
|
||
|
||
package com.cilogi.shiro.googlegae; | ||
|
||
import org.apache.shiro.authc.HostAuthenticationToken; | ||
import org.apache.shiro.authc.RememberMeAuthenticationToken; | ||
|
||
public class GoogleGAEAuthenticationToken implements HostAuthenticationToken, RememberMeAuthenticationToken { | ||
|
||
private final String principal; | ||
private final String host; | ||
|
||
public GoogleGAEAuthenticationToken(String principal, String host) { | ||
this.principal = principal; | ||
this.host = host; | ||
} | ||
|
||
@Override | ||
public Object getPrincipal() { | ||
return principal; | ||
} | ||
|
||
@Override | ||
public Object getCredentials() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean isRememberMe() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getHost() { | ||
return host; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/cilogi/shiro/googlegae/GoogleGAECredentialsMatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2012 Tim Niblett. All Rights Reserved. | ||
// | ||
// File: GoogleGAECredentialsMatcher.java (16-Oct-2012) | ||
// Author: tim | ||
// | ||
// Copyright in the whole and every part of this source file belongs to | ||
// Tim Niblett (the Author) and may not be used, sold, licenced, | ||
// transferred, copied or reproduced in whole or in part in | ||
// any manner or form or in or on any media to any person other than | ||
// in accordance with the terms of The Author's agreement | ||
// or otherwise without the prior written consent of The Author. All | ||
// information contained in this source file is confidential information | ||
// belonging to The Author and as such may not be disclosed other | ||
// than in accordance with the terms of The Author's agreement, or | ||
// otherwise, without the prior written consent of The Author. As | ||
// confidential information this source file must be kept fully and | ||
// effectively secure at all times. | ||
// | ||
|
||
|
||
package com.cilogi.shiro.googlegae; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.apache.shiro.authc.AuthenticationInfo; | ||
import org.apache.shiro.authc.AuthenticationToken; | ||
import org.apache.shiro.authc.credential.CredentialsMatcher; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
||
public class GoogleGAECredentialsMatcher implements CredentialsMatcher { | ||
static final Logger LOG = Logger.getLogger(GoogleGAECredentialsMatcher.class.getName()); | ||
|
||
public GoogleGAECredentialsMatcher() {} | ||
|
||
@Override | ||
public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) { | ||
Preconditions.checkNotNull(info); | ||
Preconditions.checkNotNull(token); | ||
|
||
Object primary = info.getPrincipals().getPrimaryPrincipal(); | ||
return token instanceof GoogleGAEAuthenticationToken && token.getPrincipal().equals(primary); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/cilogi/shiro/googlegae/GoogleGAERealm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright (c) 2012 Tim Niblett. All Rights Reserved. | ||
// | ||
// File: GoogleGAERealm.java (16-Oct-2012) | ||
// Author: tim | ||
// | ||
// Copyright in the whole and every part of this source file belongs to | ||
// Tim Niblett (the Author) and may not be used, sold, licenced, | ||
// transferred, copied or reproduced in whole or in part in | ||
// any manner or form or in or on any media to any person other than | ||
// in accordance with the terms of The Author's agreement | ||
// or otherwise without the prior written consent of The Author. All | ||
// information contained in this source file is confidential information | ||
// belonging to The Author and as such may not be disclosed other | ||
// than in accordance with the terms of The Author's agreement, or | ||
// otherwise, without the prior written consent of The Author. As | ||
// confidential information this source file must be kept fully and | ||
// effectively secure at all times. | ||
// | ||
|
||
|
||
package com.cilogi.shiro.googlegae; | ||
|
||
import com.cilogi.shiro.gae.MemcacheManager; | ||
import org.apache.shiro.authc.AuthenticationException; | ||
import org.apache.shiro.authc.AuthenticationInfo; | ||
import org.apache.shiro.authc.AuthenticationToken; | ||
import org.apache.shiro.realm.AuthenticatingRealm; | ||
|
||
import java.util.logging.Logger; | ||
|
||
|
||
public class GoogleGAERealm extends AuthenticatingRealm { | ||
static final Logger LOG = Logger.getLogger(GoogleGAERealm.class.getName()); | ||
|
||
public GoogleGAERealm() { | ||
super(new MemcacheManager(), new GoogleGAECredentialsMatcher()); | ||
setAuthenticationTokenClass(GoogleGAEAuthenticationToken.class); | ||
} | ||
|
||
@Override | ||
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { | ||
if (token != null && token instanceof GoogleGAEAuthenticationToken) { | ||
GoogleGAEAuthenticationToken authToken = (GoogleGAEAuthenticationToken)token; | ||
return new GoogleGAEAuthenticationInfo((String)authToken.getPrincipal()); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.