minor tweaks to portlet support
This commit is contained in:
parent
918f7ca008
commit
e70f01c260
|
@ -223,14 +223,6 @@ public class PortletSessionContextIntegrationInterceptor
|
||||||
private boolean preHandle(PortletRequest request, PortletResponse response,
|
private boolean preHandle(PortletRequest request, PortletResponse response,
|
||||||
Object handler) throws Exception {
|
Object handler) throws Exception {
|
||||||
|
|
||||||
// make sure the holder is clear
|
|
||||||
if (SecurityContextHolder.getContext() != null) {
|
|
||||||
if (logger.isWarnEnabled())
|
|
||||||
logger.warn("SecurityContextHolder should have been null but contained: '"
|
|
||||||
+ SecurityContextHolder.getContext() + "'; setting to null now");
|
|
||||||
SecurityContextHolder.clearContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
PortletSession portletSession = null;
|
PortletSession portletSession = null;
|
||||||
boolean portletSessionExistedAtStartOfRequest = false;
|
boolean portletSessionExistedAtStartOfRequest = false;
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package org.acegisecurity.providers.portlet;
|
package org.acegisecurity.providers.portlet;
|
||||||
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.portlet.PortletRequest;
|
import javax.portlet.PortletRequest;
|
||||||
|
|
||||||
|
@ -130,19 +131,26 @@ public class PortletAuthenticationProvider
|
||||||
// build the resulting successful authentication token
|
// build the resulting successful authentication token
|
||||||
PortletAuthenticationToken result = new PortletAuthenticationToken(
|
PortletAuthenticationToken result = new PortletAuthenticationToken(
|
||||||
user, authentication.getCredentials(), user.getAuthorities());
|
user, authentication.getCredentials(), user.getAuthorities());
|
||||||
|
result.setAuthenticated(true);
|
||||||
|
|
||||||
// see if the detail property on the request is the PortletRequest
|
// see if the detail property on the request is the PortletRequest
|
||||||
if (authentication.getDetails() instanceof PortletRequest) {
|
if (authentication.getDetails() instanceof PortletRequest) {
|
||||||
// place the USER_INFO map into the details property of the result
|
// if available, place the USER_INFO map into the details property of the result
|
||||||
PortletRequest request = (PortletRequest)authentication.getDetails();
|
PortletRequest request = (PortletRequest)authentication.getDetails();
|
||||||
result.setDetails(request.getAttribute(PortletRequest.USER_INFO));
|
Map userInfo = null;
|
||||||
|
try {
|
||||||
|
userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("unable to retrieve USER_INFO map from portlet request", e);
|
||||||
|
}
|
||||||
|
result.setDetails(userInfo);
|
||||||
} else {
|
} else {
|
||||||
// copy any other details information forward
|
// copy any other details information forward
|
||||||
result.setDetails(authentication.getDetails());
|
result.setDetails(authentication.getDetails());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
logger.debug("portlet authentication succeeded: " + authentication);
|
logger.debug("portlet authentication succeeded: " + result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,7 +206,12 @@ public class PortletProcessingInterceptor implements
|
||||||
|
|
||||||
// last try entries in USER_INFO if any attributes were defined
|
// last try entries in USER_INFO if any attributes were defined
|
||||||
if (this.userNameAttributes != null) {
|
if (this.userNameAttributes != null) {
|
||||||
Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
|
Map userInfo = null;
|
||||||
|
try {
|
||||||
|
userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("unable to retrieve USER_INFO map from portlet request", e);
|
||||||
|
}
|
||||||
if (userInfo != null) {
|
if (userInfo != null) {
|
||||||
Iterator i = this.userNameAttributes.iterator();
|
Iterator i = this.userNameAttributes.iterator();
|
||||||
while(i.hasNext()) {
|
while(i.hasNext()) {
|
||||||
|
|
Loading…
Reference in New Issue