Created
July 24, 2014 08:07
-
-
Save agonist/26bbf630f2200049a396 to your computer and use it in GitHub Desktop.
auth
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
@Component | |
@Provides | |
@Instantiate | |
public class MyAuthenticator implements Authenticator { | |
/** | |
* The famous {@link org.slf4j.Logger} | |
*/ | |
private static final Logger logger = LoggerFactory.getLogger(MyAuthenticator.class); | |
@Override | |
public String getName() { | |
return "my-authenticator"; | |
} | |
/** | |
* just check if the current user is logged in | |
* @param context | |
* @return | |
*/ | |
@Override | |
public String getUserName(Context context) { | |
Subject currentUser = SecurityUtils.getSubject(); | |
if (currentUser.isAuthenticated()) { | |
return currentUser.toString(); | |
} | |
return null; | |
} | |
@Override | |
public Result onUnauthorized(Context context) { | |
return Results.ok("Your are not authenticated !"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment