/** * Copyright (c) 2006 by Know-Center, Graz, Austria * * This software is the confidential and proprietary information of Know-Center, * Graz, Austria. You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with Know-Center. * * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. * * $Id: PdfASID.java,v 1.1 2006/08/25 17:04:16 wprinz Exp $ */ package at.knowcenter.wag.egov.egiz; import java.io.Serializable; import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException; /** * This class encapsulates the Pdf-AS ID ("Kennzeichnung") urn. * * @author wprinz */ public class PdfASID implements Serializable { /** * SVUID. */ private static final long serialVersionUID = 4776635173830445739L; /** * The urn word that leads in the identifier. */ protected static final String URN = "urn"; /** * The namespace of the urn. */ protected static final String NAMESPACE = "pdfsigfilter"; /** * The separator between urn blocks. */ protected static final String SPLIT_STRING = ":"; /** * The vendor. */ protected String vendor = null; /** * The algorithm type. */ protected String type = null; /** * The version of the algorithm. */ protected String version = null; /** * Constructor that fills in the parameters directly. * * @param vendor * @param type * @param version */ public PdfASID(String vendor, String type, String version) { set(vendor, type, version); } /** * Parses the given id String and throws an Exception if it is not valid. * * @param id * The id String to be parsed. */ public PdfASID(String id) throws InvalidIDException { String[] tokens = id.split(SPLIT_STRING); if (tokens.length != 5) { throw new InvalidIDException(800, "The doesn't have enough tokens (" + id + ")"); } if (!tokens[0].equals(URN)) { throw new InvalidIDException(800, "The id must start with " + URN + " (" + id + ")"); } if (!tokens[1].equals(NAMESPACE)) { throw new InvalidIDException(800, "The namespace of the id must be " + NAMESPACE + " (" + id + ")"); } set(tokens[2], tokens[3], tokens[4]); } /** * Copy Constructor. * * @param other * The other PdfASID to copy the data from. */ public PdfASID(final PdfASID other) { set(other.vendor, other.type, other.version); } /** * Auxiliary constructor. * * @param vendor * The vendor. * @param type * The type. * @param version * The version. */ private void set(String vendor, String type, String version) { this.vendor = vendor; this.type = type; this.version = version; } /** * Returns the type. * * @return Returns the type. */ public String getType() { return this.type; } /** * Returns the vendor. * * @return Returns the vendor. */ public String getVendor() { return this.vendor; } /** * Returns the version. * * @return Returns the version. */ public String getVersion() { return this.version; } /** * @see java.lang.Object#toString() */ public String toString() { return URN + SPLIT_STRING + NAMESPACE + SPLIT_STRING + this.vendor + SPLIT_STRING + this.type + SPLIT_STRING + this.version; } }