Generating JAXB classes for SAML 2.0
Recently, I ran into a situation of generating JAXB classes for SAML 2.0 schema. So writing up my experience here.
Before starting make sure that you have the following.
1. JDK 1.6 or higher
2. SAML 2.0 schema files downloaded to your machine
If you computer is connected to internet, you doesn’t have to download the dependent schema. xjc (JDK command for generating JAXB classes) will automatically download for you. Otherwise please download the schema manually from other computer and copy it to your computer. These are the dependent schemas:
a. xenc-schema.xsd (http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd)
b. xml.xsd (http://www.w3.org/2001/xml.xsd)
c. xmldsig-core-schema.xsd (http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd)
Assuming that dependent schema were downloaded manually, please follow this procedure to generate the classes.
1. Copy the dependent schema file into same directory where SAML 2.0 schema files exist.
2. Correct the dependent schema files path in SAML 2.0 schema files to point to local directory
Below schema files in SAML 2.0 refer to dependent schema
Open those schema files and check all import tags with the name spaces of dependent files. Correct its “schemaLocation” attribute to point to local directory.
3. Run xjc to generate classes.
Run the below command from the xsd folder to generate classes for all SAML schemas.
See help of JAXB & xjc documentation for customization & more information about generating classes.
We are done. Enjoy🙂