public ConversationID findCorrespondingHTMLFormConversation(ConversationID samlId) { ConversationModel conversationModel = this.model.getConversationModel(); HttpUrl samlHttpUrl = conversationModel.getRequestUrl(samlId); int samlConversationIndex = conversationModel.getIndexOfConversation(samlId); for (int conversationIndex = samlConversationIndex - 1; conversationIndex >= 0; conversationIndex--) { ConversationID id = conversationModel.getConversationAt(conversationIndex); Response response = conversationModel.getResponse(id); HttpUrl httpUrl = conversationModel.getRequestUrl(id); Object parsedContent = Parser.parse(httpUrl, response); if (null == parsedContent) { continue; } if (false == parsedContent instanceof org.htmlparser.util.NodeList) { continue; } org.htmlparser.util.NodeList htmlNodeList = (org.htmlparser.util.NodeList) parsedContent; org.htmlparser.util.NodeList forms = htmlNodeList.searchFor(FormTag.class); try { for (NodeIterator ni = forms.elements(); ni.hasMoreNodes(); ) { FormTag form = (FormTag) ni.nextNode(); String formAction = form.getAttribute("action"); HttpUrl formActionHttpUrl = new HttpUrl(formAction); if (samlHttpUrl.equals(formActionHttpUrl)) { return id; } } } catch (ParserException ex) { this._logger.log(Level.WARNING, "Looking for forms, got ''{0}''", ex); } catch (MalformedURLException ex) { this._logger.log(Level.WARNING, "Malformed action url: {0}", ex.getMessage()); } } return null; }
public byte[] getResponseContent(ConversationID id) { ConversationModel conversationModel = this.model.getConversationModel(); Response response = conversationModel.getResponse(id); byte[] content = response.getContent(); return content; }