use of org.gluu.oxauth.client.authentication.SimplePrincipal in project oxTrust by GluuFederation.
the class HttpServletRequestWrapperFilter method retrievePrincipalFromSessionOrRequest.
protected SimplePrincipal retrievePrincipalFromSessionOrRequest(final ServletRequest servletRequest) {
final HttpServletRequest request = (HttpServletRequest) servletRequest;
final HttpSession session = request.getSession(false);
final OAuthData oAuthData = (OAuthData) (session == null ? request.getAttribute(Configuration.SESSION_OAUTH_DATA) : session.getAttribute(Configuration.SESSION_OAUTH_DATA));
if (oAuthData == null) {
log.trace("There is no OAuthData in session");
return null;
}
SimplePrincipal principanl = new SimplePrincipal(oAuthData.getUserUid());
return principanl;
}
use of org.gluu.oxauth.client.authentication.SimplePrincipal in project oxTrust by GluuFederation.
the class HttpServletRequestWrapperFilter method doFilter.
/**
* Wraps the HttpServletRequest in a wrapper class that delegates
* <code>request.getRemoteUser</code> to the underlying OAuthData object
* stored in the user session.
*/
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
final SimplePrincipal principal = retrievePrincipalFromSessionOrRequest(servletRequest);
if (principal == null) {
log.trace("There is no principal");
filterChain.doFilter(servletRequest, servletResponse);
} else {
filterChain.doFilter(new OAuthHttpServletRequestWrapper((HttpServletRequest) servletRequest, principal), servletResponse);
}
}
Aggregations