package at.gv.egovernment.moa.id.proxy.builder; import java.text.MessageFormat; import java.util.Calendar; import org.w3c.dom.Element; import at.gv.egovernment.moa.id.BuildException; import at.gv.egovernment.moa.util.Constants; import at.gv.egovernment.moa.util.DOMUtils; import at.gv.egovernment.moa.util.DateTimeUtils; /** * Builder for the <samlp:Request> used for querying * the authentication data <saml:Assertion>. * * @author Paul Ivancsics * @version $Id$ */ public class SAMLRequestBuilder implements Constants { /** samlp-Request template */ private static final String REQUEST = "" + "{2}" + ""; /** * Constructor for SAMLRequestBuilder. */ public SAMLRequestBuilder() { super(); } /** * Builds the <samlp:Request>. * @param requestID request ID * @param samlArtifactBase64 SAML artifact, encoded BASE64 * @return the DOM element */ public Element build(String requestID, String samlArtifactBase64) throws BuildException { try { String issueInstant = DateTimeUtils.buildDateTime(Calendar.getInstance()); String request = MessageFormat.format(REQUEST, new Object[] {requestID, issueInstant, samlArtifactBase64}); Element requestElem = DOMUtils.parseDocument(request, false, ALL_SCHEMA_LOCATIONS, null).getDocumentElement(); return requestElem; } catch (Throwable ex) { throw new BuildException( "builder.00", new Object[] {"samlp:Request", ex.toString()}, ex); } } }