Skip to content

Commit 455aebe

Browse files
committed
PLINK-487: clean up
1 parent c41ce60 commit 455aebe

File tree

1 file changed

+2
-101
lines changed
  • modules/federation/src/main/java/org/picketlink/identity/federation/web/filters

1 file changed

+2
-101
lines changed

modules/federation/src/main/java/org/picketlink/identity/federation/web/filters/IDPFilter.java

Lines changed: 2 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,8 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
204204
return;
205205
}
206206

207-
// first, we populate all required parameters sent into session for later retrieval. If they exists.
208-
//populateSessionWithSAMLParameters(httpServletRequest);
209-
210207
// get an authenticated user or tries to authenticate if this is a authentication request
211-
Principal userPrincipal = getUserPrincipal(httpServletRequest, httpServletResponse);
208+
Principal userPrincipal = httpServletRequest.getUserPrincipal();
212209

213210
// we only handle SAML messages for authenticated users.
214211
if (userPrincipal != null) {
@@ -275,39 +272,6 @@ private void handleSAMLMessage(HttpServletRequest request, HttpServletResponse r
275272
} else {
276273
chain.doFilter(request, response);
277274
}
278-
279-
/*HttpSession session = request.getSession();
280-
281-
String samlRequestMessage = (String) session.getAttribute(GeneralConstants.SAML_REQUEST_KEY);
282-
String samlResponseMessage = (String) session.getAttribute(GeneralConstants.SAML_RESPONSE_KEY);
283-
284-
*//**
285-
* Since the container has finished the authentication, we can retrieve the original saml message as well as any
286-
* relay state from the SP
287-
*//*
288-
String relayState = (String) session.getAttribute(GeneralConstants.RELAY_STATE);
289-
String signature = (String) session.getAttribute(GeneralConstants.SAML_SIGNATURE_REQUEST_KEY);
290-
String sigAlg = (String) session.getAttribute(GeneralConstants.SAML_SIG_ALG_REQUEST_KEY);
291-
292-
if (logger.isTraceEnabled()) {
293-
StringBuilder builder = new StringBuilder();
294-
builder.append("Retrieved saml messages and relay state from session");
295-
builder.append("saml Request message=").append(samlRequestMessage);
296-
builder.append("::").append("SAMLResponseMessage=");
297-
builder.append(samlResponseMessage).append(":").append("relay state=").append(relayState);
298-
299-
builder.append("Signature=").append(signature).append("::sigAlg=").append(sigAlg);
300-
logger.trace(builder.toString());
301-
}
302-
303-
if (isNotNull(samlRequestMessage)) {
304-
processSAMLRequestMessage(request, response);
305-
} else if (isNotNull(samlResponseMessage)) {
306-
processSAMLResponseMessage(request, response);
307-
} else if (request.getRequestURI().equals(request.getContextPath() + "/")) {
308-
// no SAML processing and the request is asking for /.
309-
forwardHosted(request, response);
310-
}*/
311275
}
312276
}
313277

@@ -356,48 +320,6 @@ private void forwardHosted(HttpServletRequest request, HttpServletResponse respo
356320
private void includeResource(ServletRequest request, HttpServletResponse response, RequestDispatcher dispatch)
357321
throws ServletException, IOException {
358322
dispatch.include(request, response);
359-
360-
// we need to re-configure the content length because Tomcat will truncate the output with the size of the welcome page
361-
// (eg.: index.html).
362-
//response.setContentLength(response.g.getContentCount());
363-
}
364-
365-
/**
366-
* <p>
367-
* SAML parameters are also populated into session if they are present in the request. This allows the IDP to retrieve them
368-
* later when handling a specific SAML request or response.
369-
* </p>
370-
*
371-
* @param request
372-
* @return
373-
* @throws IOException
374-
*/
375-
private void populateSessionWithSAMLParameters(HttpServletRequest request) throws IOException {
376-
String samlRequestMessage = request.getParameter(GeneralConstants.SAML_REQUEST_KEY);
377-
String samlResponseMessage = request.getParameter(GeneralConstants.SAML_RESPONSE_KEY);
378-
379-
boolean containsSAMLRequestMessage = isNotNull(samlRequestMessage);
380-
boolean containsSAMLResponseMessage = isNotNull(samlResponseMessage);
381-
382-
String signature = request.getParameter(GeneralConstants.SAML_SIGNATURE_REQUEST_KEY);
383-
String sigAlg = request.getParameter(GeneralConstants.SAML_SIG_ALG_REQUEST_KEY);
384-
String relayState = request.getParameter(GeneralConstants.RELAY_STATE);
385-
386-
HttpSession session = request.getSession();
387-
388-
if (containsSAMLRequestMessage || containsSAMLResponseMessage) {
389-
logger.trace("Storing the SAMLRequest/SAMLResponse and RelayState in session");
390-
if (isNotNull(samlRequestMessage))
391-
session.setAttribute(GeneralConstants.SAML_REQUEST_KEY, samlRequestMessage);
392-
if (isNotNull(samlResponseMessage))
393-
session.setAttribute(GeneralConstants.SAML_RESPONSE_KEY, samlResponseMessage);
394-
if (isNotNull(relayState))
395-
session.setAttribute(GeneralConstants.RELAY_STATE, relayState.trim());
396-
if (isNotNull(signature))
397-
session.setAttribute(GeneralConstants.SAML_SIGNATURE_REQUEST_KEY, signature.trim());
398-
if (isNotNull(sigAlg))
399-
session.setAttribute(GeneralConstants.SAML_SIG_ALG_REQUEST_KEY, sigAlg.trim());
400-
}
401323
}
402324

403325
/**
@@ -442,27 +364,6 @@ private boolean isUnauthorized(HttpServletResponse response) {
442364
return response.getStatus() == HttpServletResponse.SC_FORBIDDEN;
443365
}
444366

445-
/**
446-
* <p>
447-
* Returns the authenticated principal. If there is no principal associated with the {@link javax.servlet.http.HttpServletRequest}, null is returned.
448-
* </p>
449-
*
450-
* @param request
451-
* @param response
452-
* @return
453-
* @throws IOException
454-
* @throws ServletException
455-
*/
456-
private Principal getUserPrincipal(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
457-
Principal userPrincipal = request.getUserPrincipal();
458-
459-
if (userPrincipal == null) {
460-
userPrincipal = request.getUserPrincipal();
461-
}
462-
463-
return userPrincipal;
464-
}
465-
466367
protected void handleSAML11(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
467368
try {
468369
IDPWebRequestUtil webRequestUtil = new IDPWebRequestUtil(request, idpConfiguration, keyManager);
@@ -1423,4 +1324,4 @@ private void configureConfigurationProvider() throws ServletException {
14231324
public SAMLConfigurationProvider getConfigProvider() {
14241325
return this.configProvider;
14251326
}
1426-
}
1327+
}

0 commit comments

Comments
 (0)