/** * Parse the attributes that are common to all SAML Request Types * * @param startElement * @param request * @throws ParsingException */ protected void parseBaseAttributes(StartElement startElement, RequestAbstractType request) throws ParsingException { Attribute destinationAttr = startElement.getAttributeByName(new QName(JBossSAMLConstants.DESTINATION.get())); if (destinationAttr != null) request.setDestination(URI.create(StaxParserUtil.getAttributeValue(destinationAttr))); Attribute consent = startElement.getAttributeByName(new QName(JBossSAMLConstants.CONSENT.get())); if (consent != null) request.setConsent(StaxParserUtil.getAttributeValue(consent)); }
protected void parseCommonElements( StartElement startElement, XMLEventReader xmlEventReader, RequestAbstractType request) throws ParsingException { if (startElement == null) throw new IllegalArgumentException(ErrorCodes.NULL_START_ELEMENT); String elementName = StaxParserUtil.getStartElementName(startElement); if (JBossSAMLConstants.ISSUER.get().equals(elementName)) { startElement = StaxParserUtil.getNextStartElement(xmlEventReader); NameIDType issuer = new NameIDType(); issuer.setValue(StaxParserUtil.getElementText(xmlEventReader)); request.setIssuer(issuer); } else if (JBossSAMLConstants.SIGNATURE.get().equals(elementName)) { request.setSignature(StaxParserUtil.getDOMElement(xmlEventReader)); } }
/** * Sign an RequestType at the root * * @param request * @param keypair Key Pair * @param digestMethod (Example: DigestMethod.SHA1) * @param signatureMethod (Example: SignatureMethod.DSA_SHA1) * @return * @throws ParserConfigurationException * @throws IOException * @throws SAXException * @throws XMLSignatureException * @throws MarshalException * @throws GeneralSecurityException */ public Document sign(RequestAbstractType request, KeyPair keypair) throws SAXException, IOException, ParserConfigurationException, GeneralSecurityException, MarshalException, XMLSignatureException { SAML2Request saml2Request = new SAML2Request(); Document doc = saml2Request.convert(request); doc.normalize(); Node theSibling = getNextSiblingOfIssuer(doc); if (theSibling != null) { this.sibling = theSibling; } return sign(doc, request.getID(), keypair); }