Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.certificateservices.messages.saml2.assertion;
import org.apache.xml.security.utils.XMLUtils;
import org.certificateservices.messages.*;
import org.certificateservices.messages.csmessages.DefaultCSMessageParser;
import org.certificateservices.messages.saml2.BaseSAMLMessageParser;
import org.certificateservices.messages.saml2.assertion.jaxb.*;
import org.certificateservices.messages.utils.MessageGenerateUtils;
import org.certificateservices.messages.utils.XMLEncrypter;
import org.certificateservices.messages.utils.XMLSigner;
import org.certificateservices.messages.xenc.jaxb.EncryptedDataType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.List;
import java.util.Properties;
/**
* MessageParser for generating generate SAML 2.0 Assertions. This should be used when generating SAML Assertions
* that is not connected to CSMessages. For CSMessage related assertions use AssertionPayloadParser.
*
* Created by philip on 02/01/17.
*/
public class SAMLAssertionMessageParser extends BaseSAMLMessageParser{
private static final String BASE_JAXB_CONTEXT = "org.certificateservices.messages.saml2.assertion.jaxb:org.certificateservices.messages.saml2.protocol.jaxb:org.certificateservices.messages.xenc.jaxb:org.certificateservices.messages.xmldsig.jaxb";
EncryptedAssertionXMLConverter encryptedAssertionXMLConverter = new EncryptedAssertionXMLConverter();
@Override
public String getNameSpace() {
return ASSERTION_NAMESPACE;
}
@Override
public String getJAXBPackages() {
return BASE_JAXB_CONTEXT;
}
@Override
public String[] getDefaultSchemaLocations() throws SAXException {
return new String[] {DefaultCSMessageParser.XMLDSIG_XSD_SCHEMA_RESOURCE_LOCATION,
DefaultCSMessageParser.XMLENC_XSD_SCHEMA_RESOURCE_LOCATION,
ASSERTION_XSD_SCHEMA_2_0_RESOURCE_LOCATION,
SAMLP_XSD_SCHEMA_2_0_RESOURCE_LOCATION};
}
@Override
public XMLSigner.SignatureLocationFinder getSignatureLocationFinder(){
return assertionSignatureLocationFinder;
}
@Override
public XMLSigner.OrganisationLookup getOrganisationLookup(){
return null;
}
@Override
protected String lookupSchemaForElement(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
if(namespaceURI != null){
if(namespaceURI.equals(DefaultCSMessageParser.XMLDSIG_NAMESPACE)){
return DefaultCSMessageParser.XMLDSIG_XSD_SCHEMA_RESOURCE_LOCATION;
}
if(namespaceURI.equals(DefaultCSMessageParser.XMLENC_NAMESPACE)){
return DefaultCSMessageParser.XMLENC_XSD_SCHEMA_RESOURCE_LOCATION;
}
if(namespaceURI.equals(PROTOCOL_NAMESPACE)){
return BaseSAMLMessageParser.SAMLP_XSD_SCHEMA_2_0_RESOURCE_LOCATION;
}
if(namespaceURI.equals(ASSERTION_NAMESPACE)){
return BaseSAMLMessageParser.ASSERTION_XSD_SCHEMA_2_0_RESOURCE_LOCATION;
}
}
return null;
}
/**
* Method for generating a simple assertion data structure.
* @param issuer the name if the issuer, set as NameIDType
* @param notBefore the not before date
* @param notOnOrAfter the expiration date
* @param subjectId the name of the subject the assertion is related to.
* @param attributes a list of attributes or encrypted attributes to add to the assertion.
* @return a simply assertion.
* @throws MessageProcessingException if internal problems occurred generating the assertion.
*/
public JAXBElement generateSimpleAssertion(String issuer, Date notBefore, Date notOnOrAfter, String subjectId, List