package at.gv.egovernment.moa.id.auth.builder; import java.text.MessageFormat; import at.gv.egovernment.moa.util.Constants; /** * Builder for the authentication block <saml:Assertion> * to be included in a <CreateXMLSignatureResponse>. * * @author Paul Ivancsics * @version $Id$ */ public class AuthenticationBlockAssertionBuilder implements Constants { /** the NewLine representation in Java*/ private static String nl = "\n"; /** template for the Auth-Block */ private static String AUTH_BLOCK = "" + nl + " " + nl + " " + nl + " {3}" + nl + " " + nl + "{4}" + " " + nl + " {5}" + nl + " " + nl + " " + nl + " {6}" + nl + " " + nl + " " + nl + ""; private static String GESCHAEFTS_BEREICH_ATTRIBUTE = " " + nl + " {0}" + nl + " " + nl; private static String WBPK_ATTRIBUTE = " " + nl + " " + nl + " " + nl + " {0}" + nl + " {1}" + nl + " " + nl + " " + nl + " " + nl; /** * Constructor for AuthenticationBlockAssertionBuilder. */ public AuthenticationBlockAssertionBuilder() { super(); } /** * Builds the authentication block <saml:Assertion> * * @param issuer authentication block issuer; "GivenName FamilyName" * @param issueInstant current timestamp * @param authURL URL of MOA-ID authentication component * @param target "Geschäftsbereich"; maybe null if the application * is a business application * @param identityLinkValue the content of the <pr:Value> * child element of the <pr:Identification> * element derived from the Identitylink; this is the * value of the wbPK; * maybe null if the application is a public service * @param identiyLinkType the content of the <pr:Type> * child element of the <pr:Identification> * element derived from the Identitylink; this includes the * URN prefix and the identification number of the business * application used as input for wbPK computation; * maybe null if the application is a public service * @param oaURL public URL of online application requested * @return String representation of authentication block * <saml:Assertion> built */ public String buildAuthBlock(String issuer, String issueInstant, String authURL, String target, String identityLinkValue, String identityLinkType, String oaURL, String GebDat) { String gebeORwbpk = ""; String wbpkNSDeclaration = ""; if (target == null) { // OA is a business application gebeORwbpk = MessageFormat.format( WBPK_ATTRIBUTE, new Object[] { identityLinkValue, identityLinkType }); wbpkNSDeclaration = " xmlns:pr=\"" + PD_NS_URI + "\" xmlns:si=\"" + PD_NS_URI + "\""; } else { gebeORwbpk = MessageFormat.format( GESCHAEFTS_BEREICH_ATTRIBUTE, new Object[] { target }); } String assertion = MessageFormat.format( AUTH_BLOCK, new Object[] { wbpkNSDeclaration, issuer, issueInstant, authURL, gebeORwbpk, oaURL, GebDat}); return assertion; } }