package at.gv.egovernment.moa.id.auth.builder;
import java.text.MessageFormat;
import at.gv.egovernment.moa.util.Constants;
/**
* Builder for the <CreateXMLSignatureRequest>
structure
* used for requesting a signature under the authentication block from the
* security layer implementation.
*
* @author Paul Ivancsics
* @version $Id$
*/
public class CreateXMLSignatureRequestBuilder implements Constants {
/** private static String nl contains the NewLine representation in Java*/
private static final String nl = "\n";
/**
* XML template for the <moa:CreateXMLSignatureRequest>
to be built
*/
private static final String CREATE_XML_SIGNATURE_REQUEST =
"" + nl +
"" + nl +
" {1}" + nl +
" " + nl +
" " + nl +
"{2}" +
" " + nl +
" " + nl +
" " + nl +
" {0}" + nl +
" " + nl +
" /saml:Assertion" + nl +
" " + nl +
"";
/**
* Constructor for CreateXMLSignatureRequestBuilder.
*/
public CreateXMLSignatureRequestBuilder() {
super();
}
/**
* Builds the <CreateXMLSignatureRequest>
.
*
* @param authBlock String representation of XML authentication block
* @param keyBoxIdentfier the key box identifier which will be used (e.g. CertifiedKeypair)
* @return String representation of <CreateXMLSignatureRequest>
*/
public String build(String authBlock, String keyBoxIdentifier, String[] dsigTransformInfos) {
String dsigTransformInfosString = "";
for (int i = 0; i < dsigTransformInfos.length; i++)
dsigTransformInfosString += dsigTransformInfos[i];
String request = MessageFormat.format(
CREATE_XML_SIGNATURE_REQUEST, new Object[] { authBlock, keyBoxIdentifier, dsigTransformInfosString });
return request;
}
}