forked from spring-attic/spring-security-oauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SpringSource/master
Merging changes from master Spring security oauth repo
- Loading branch information
Showing
31 changed files
with
419 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
language: java | ||
|
||
install: mvn -U install --quiet -DskipTests=true -P bootstrap | ||
script: mvn clean test -P bootstrap | ||
|
||
|
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
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
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
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
63 changes: 43 additions & 20 deletions
63
...pringframework/security/oauth/consumer/rememberme/HttpSessionOAuthRememberMeServices.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 |
---|---|---|
@@ -1,34 +1,57 @@ | ||
package org.springframework.security.oauth.consumer.rememberme; | ||
|
||
import org.springframework.security.oauth.consumer.OAuthConsumerToken; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.servlet.http.HttpSession; | ||
import java.util.Map; | ||
|
||
import org.springframework.security.oauth.consumer.OAuthConsumerToken; | ||
|
||
/** | ||
* Default implementation of the OAuth2 rememberme services. Just stores everything in the session. | ||
* Default implementation of the OAuth2 rememberme services. Just stores everything in the session by default. Storing | ||
* access token can be suppressed to reduce long-term expose of these tokens in the underlying HTTP session. | ||
* | ||
* @author Ryan Heaton | ||
* @author Alex Rau | ||
*/ | ||
public class HttpSessionOAuthRememberMeServices implements OAuthRememberMeServices { | ||
|
||
public static final String REMEMBERED_TOKENS_KEY = HttpSessionOAuthRememberMeServices.class.getName() + "#REMEMBERED_TOKENS"; | ||
|
||
public Map<String, OAuthConsumerToken> loadRememberedTokens(HttpServletRequest request, HttpServletResponse response) { | ||
HttpSession session = request.getSession(false); | ||
Map<String, OAuthConsumerToken> rememberedTokens = null; | ||
if (session != null) { | ||
rememberedTokens = (Map<String, OAuthConsumerToken>) session.getAttribute(REMEMBERED_TOKENS_KEY); | ||
} | ||
return rememberedTokens; | ||
} | ||
|
||
public void rememberTokens(Map<String, OAuthConsumerToken> tokens, HttpServletRequest request, HttpServletResponse response) { | ||
HttpSession session = request.getSession(false); | ||
if (session != null) { | ||
session.setAttribute(REMEMBERED_TOKENS_KEY, tokens); | ||
} | ||
} | ||
public static final String REMEMBERED_TOKENS_KEY = HttpSessionOAuthRememberMeServices.class.getName() | ||
+ "#REMEMBERED_TOKENS"; | ||
|
||
private boolean storeAccessTokens = true; | ||
|
||
@SuppressWarnings("unchecked") | ||
public Map<String, OAuthConsumerToken> loadRememberedTokens(HttpServletRequest request, HttpServletResponse response) { | ||
|
||
HttpSession session = request.getSession(false); | ||
|
||
if (session != null) { | ||
return (Map<String, OAuthConsumerToken>) session.getAttribute(REMEMBERED_TOKENS_KEY); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public void rememberTokens(Map<String, OAuthConsumerToken> tokens, HttpServletRequest request, | ||
HttpServletResponse response) { | ||
|
||
HttpSession session = request.getSession(false); | ||
|
||
if (session == null) { | ||
return; | ||
} | ||
|
||
Map<String, OAuthConsumerToken> requestTokensOnly = new HashMap<String, OAuthConsumerToken>(); | ||
|
||
for (Map.Entry<String, OAuthConsumerToken> token : tokens.entrySet()) { | ||
if (storeAccessTokens && !token.getValue().isAccessToken()) | ||
requestTokensOnly.put(token.getKey(), token.getValue()); | ||
|
||
} | ||
|
||
session.setAttribute(REMEMBERED_TOKENS_KEY, requestTokensOnly); | ||
} | ||
} |
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.