diff options
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java | 479 |
1 files changed, 242 insertions, 237 deletions
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java index 32eab9e..c097b0c 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java @@ -21,18 +21,8 @@ * that you distribute must include a readable copy of the "NOTICE" text file. */ - package at.gv.egovernment.moa.spss.server.invoke; -import iaik.server.modules.algorithms.HashAlgorithms; -import iaik.server.modules.keys.KeyEntryID; -import iaik.server.modules.keys.KeyModule; -import iaik.server.modules.keys.KeyModuleFactory; -import iaik.server.modules.xml.Canonicalization; -import iaik.server.modules.xmlsign.SignatureStructureTypes; -import iaik.server.modules.xmlsign.XMLSignatureCreationProfile; -import iaik.server.modules.xmlsign.XMLSignatureInsertionLocation; - import java.math.BigInteger; import java.security.Principal; import java.security.cert.X509Certificate; @@ -70,12 +60,20 @@ import at.gv.egovernment.moa.spss.util.MessageProvider; import at.gv.egovernment.moaspss.logging.LogMsg; import at.gv.egovernment.moaspss.logging.Logger; import at.gv.egovernment.moaspss.util.Constants; +import iaik.server.modules.algorithms.HashAlgorithms; +import iaik.server.modules.keys.KeyEntryID; +import iaik.server.modules.keys.KeyModule; +import iaik.server.modules.keys.KeyModuleFactory; +import iaik.server.modules.xml.Canonicalization; +import iaik.server.modules.xmlsign.SignatureStructureTypes; +import iaik.server.modules.xmlsign.XMLSignatureCreationProfile; +import iaik.server.modules.xmlsign.XMLSignatureInsertionLocation; /** * A factory to create <code>XMLSignatureCreationProfile</code>s from a * <code>CreateXMLSignatureRequest</code>, based on the current MOA * configuration. - * + * * @author Patrick Peck * @version $Id$ */ @@ -91,24 +89,25 @@ public class XMLSignatureCreationProfileFactory { HASH_ALGORITHM_MAPPING.put(Constants.SHA512_URI, HashAlgorithms.SHA512); } - /** The <code>CreateXMLSignatureRequest</code> for which to create the - * profile.*/ - private CreateXMLSignatureRequest request; + /** + * The <code>CreateXMLSignatureRequest</code> for which to create the profile. + */ + private final CreateXMLSignatureRequest request; /** How many profiles have been created based on the same request. */ private int createProfileCount; - /** The <code>Set</code> of reserved object IDs.*/ - private Set reserved; + /** The <code>Set</code> of reserved object IDs. */ + private final Set reserved; /** * Create a new <code>XMLSignatureCreationProfileFactory</code>. - * - * @param request The request for which to create profiles. - * @param reserved The <code>Set</code> of reserved object IDs. IDs will - * be added during signature creation. + * + * @param request The request for which to create profiles. + * @param reserved The <code>Set</code> of reserved object IDs. IDs will be + * added during signature creation. */ public XMLSignatureCreationProfileFactory( - CreateXMLSignatureRequest request, - Set reserved) { + CreateXMLSignatureRequest request, + Set reserved) { this.request = request; this.reserved = reserved; createProfileCount = 1; @@ -117,98 +116,98 @@ public class XMLSignatureCreationProfileFactory { /** * Create a <code>XMLSignatureCreationProfile</code> for the given * <code>SingleSignatureInfo</code> object.. - * + * * @param singleSignatureInfo The <code>SingleSignatureInfo</code> object - * containing information about the creation of a signature. - * @param sigInfoReservedIDs The <code>Set</code> of reserved ID attribue values - * for the particular <code>singleSignatureInfo</code>. + * containing information about the creation of a + * signature. + * @param sigInfoReservedIDs The <code>Set</code> of reserved ID attribue + * values for the particular + * <code>singleSignatureInfo</code>. * @return The <code>XMLSignatureCreationProfile</code> containing additional - * information for creating an XML signature. - * @throws MOASystemException A system error occurred during creation of the - * profile. See message for details - * @throws MOAApplicationException An application error occurred during - * creation of the profile. See message for details. + * information for creating an XML signature. + * @throws MOASystemException A system error occurred during creation of + * the profile. See message for details + * @throws MOAApplicationException An application error occurred during creation + * of the profile. See message for details. */ public XMLSignatureCreationProfile createProfile(SingleSignatureInfo singleSignatureInfo, - Set sigInfoReservedIDs) throws MOASystemException, MOAApplicationException { + Set sigInfoReservedIDs) throws MOASystemException, MOAApplicationException { - HashSet allReservedIDs = new HashSet(reserved); + final HashSet allReservedIDs = new HashSet(reserved); allReservedIDs.addAll(sigInfoReservedIDs); - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ConfigurationProvider config = context.getConfiguration(); + final TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + final ConfigurationProvider config = context.getConfiguration(); List dataObjectTreatmentList; Set keySet; List transformationSupplements; List createTransformsProfiles; // get the key group id - String keyGroupID = request.getKeyIdentifier(); + final String keyGroupID = request.getKeyIdentifier(); // get digest method on key group level (if configured) - KeyGroup keygroup = config.getKeyGroup(keyGroupID); - if(null == keygroup) { - Logger.error("Could not find key group '" + keyGroupID + "'"); - throw new MOAApplicationException("2231", null); + final KeyGroup keygroup = config.getKeyGroup(keyGroupID); + if (null == keygroup) { + Logger.error("Could not find key group '" + keyGroupID + "'"); + throw new MOAApplicationException("2231", null); } - String configDigestMethodKG = keygroup.getDigestMethodAlgorithm(); + final String configDigestMethodKG = keygroup.getDigestMethodAlgorithm(); // get default digest method (if configured) - String configDigestMethod = config.getDigestMethodAlgorithmName(); - - String xadesVersion = config.getXAdESVersion(); - + final String configDigestMethod = config.getDigestMethodAlgorithmName(); + + final String xadesVersion = config.getXAdESVersion(); + String digestMethodXAdES142 = null; boolean isXAdES142 = false; // if XAdES Version 1.4.2 is configured if (xadesVersion != null && xadesVersion.compareTo("1.4.2") == 0) { - isXAdES142 = true; - Logger.debug("XAdES version '" + xadesVersion + "' used"); + isXAdES142 = true; + Logger.debug("XAdES version '" + xadesVersion + "' used"); } - + if (isXAdES142) { - if (configDigestMethodKG != null) { - // if KG specific digest method is configured - digestMethodXAdES142 = (String) HASH_ALGORITHM_MAPPING.get(configDigestMethodKG); - if (digestMethodXAdES142 == null) { - error( - "config.17", - new Object[] { configDigestMethodKG}); - throw new MOASystemException("2900", null); - } - Logger.debug("Digest algorithm: " + digestMethodXAdES142 + "(configured in KeyGroup)"); - } - else { - // else get default configured digest method - digestMethodXAdES142 = (String) HASH_ALGORITHM_MAPPING.get(configDigestMethod); - if (digestMethodXAdES142 == null) { - error( - "config.17", - new Object[] { configDigestMethod}); - throw new MOASystemException("2900", null); - } - Logger.debug("Digest algorithm: " + digestMethodXAdES142 + "(default)"); - - } + if (configDigestMethodKG != null) { + // if KG specific digest method is configured + digestMethodXAdES142 = (String) HASH_ALGORITHM_MAPPING.get(configDigestMethodKG); + if (digestMethodXAdES142 == null) { + error( + "config.17", + new Object[] { configDigestMethodKG }); + throw new MOASystemException("2900", null); + } + Logger.debug("Digest algorithm: " + digestMethodXAdES142 + "(configured in KeyGroup)"); + } else { + // else get default configured digest method + digestMethodXAdES142 = (String) HASH_ALGORITHM_MAPPING.get(configDigestMethod); + if (digestMethodXAdES142 == null) { + error( + "config.17", + new Object[] { configDigestMethod }); + throw new MOASystemException("2900", null); + } + Logger.debug("Digest algorithm: " + digestMethodXAdES142 + "(default)"); + + } } - - XMLSignatureCreationProfileImpl profile = - new XMLSignatureCreationProfileImpl(createProfileCount, allReservedIDs, digestMethodXAdES142); - + final XMLSignatureCreationProfileImpl profile = + new XMLSignatureCreationProfileImpl(createProfileCount, allReservedIDs, digestMethodXAdES142); + // build the transformation supplements createTransformsProfiles = - getCreateTransformsInfoProfiles(singleSignatureInfo); + getCreateTransformsInfoProfiles(singleSignatureInfo); transformationSupplements = - buildTransformationSupplements(createTransformsProfiles); + buildTransformationSupplements(createTransformsProfiles); // build and set the data object treatment list dataObjectTreatmentList = - buildDataObjectTreatmentList( - singleSignatureInfo, - createTransformsProfiles, - transformationSupplements, - allReservedIDs, - digestMethodXAdES142); + buildDataObjectTreatmentList( + singleSignatureInfo, + createTransformsProfiles, + transformationSupplements, + allReservedIDs, + digestMethodXAdES142); profile.setDataObjectTreatmentList(dataObjectTreatmentList); // set the key set @@ -232,27 +231,28 @@ public class XMLSignatureCreationProfileFactory { // set insertion location profile.setSignatureInsertionLocation( - getSignatureInsertionLocationIndex(singleSignatureInfo)); + getSignatureInsertionLocationIndex(singleSignatureInfo)); // set the canonicalization algorithm - String canonicalizationURI = config.getCanonicalizationAlgorithmName(); + final String canonicalizationURI = config.getCanonicalizationAlgorithmName(); if (Canonicalization.ALL_EXCLUSIVE.contains(canonicalizationURI)) { - ExclusiveCanonicalizationImpl canonicalization = new ExclusiveCanonicalizationImpl(config.getCanonicalizationAlgorithmName(), null); - profile.setSignedInfoCanonicalization(canonicalization); - + final ExclusiveCanonicalizationImpl canonicalization = new ExclusiveCanonicalizationImpl(config + .getCanonicalizationAlgorithmName(), null); + profile.setSignedInfoCanonicalization(canonicalization); + } else { - CanonicalizationImpl canonicalization = - new CanonicalizationImpl(config.getCanonicalizationAlgorithmName()); - profile.setSignedInfoCanonicalization(canonicalization); - + final CanonicalizationImpl canonicalization = + new CanonicalizationImpl(config.getCanonicalizationAlgorithmName()); + profile.setSignedInfoCanonicalization(canonicalization); + } - + // set the signed properties profile.setSignedProperties(Collections.EMPTY_LIST); // set security layer conformity profile.setSecurityLayerConform( - singleSignatureInfo.isSecurityLayerConform()); + singleSignatureInfo.isSecurityLayerConform()); // update the createProfileCount createProfileCount++; @@ -262,31 +262,32 @@ public class XMLSignatureCreationProfileFactory { /** * Get the <code>List</code> of all <code>CreateTransformsInfoProfile</code>s - * contained in all the <code>DataObjectInfo</code>s of the given + * contained in all the <code>DataObjectInfo</code>s of the given * <code>SingleSignatureInfo</code>. - * + * * @param singleSignatureInfo The <code>SingleSignatureInfo</code> object from - * which to extract the <code>CreateTransformsInfoProfile</code>s. - * @return All <code>CreateTransformsInfoProfile</code>s of all - * <code>DataObjectInfo</code>s of <code>singleSignatureInfo</code>. + * which to extract the + * <code>CreateTransformsInfoProfile</code>s. + * @return All <code>CreateTransformsInfoProfile</code>s of all + * <code>DataObjectInfo</code>s of <code>singleSignatureInfo</code>. * @throws MOAApplicationException An error occurred creating one of the - * profiles. + * profiles. */ List getCreateTransformsInfoProfiles(SingleSignatureInfo singleSignatureInfo) - throws MOAApplicationException { - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ConfigurationProvider config = context.getConfiguration(); - List dataObjInfos = singleSignatureInfo.getDataObjectInfos(); - List profiles = new ArrayList(); + throws MOAApplicationException { + final TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + final ConfigurationProvider config = context.getConfiguration(); + final List dataObjInfos = singleSignatureInfo.getDataObjectInfos(); + final List profiles = new ArrayList(); Iterator dtIter; for (dtIter = dataObjInfos.iterator(); dtIter.hasNext();) { - DataObjectInfo dataObjInfo = (DataObjectInfo) dtIter.next(); - CreateTransformsInfoProfileExplicit profile = - ProfileMapper.mapCreateTransformsInfoProfile( - dataObjInfo.getCreateTransformsInfoProfile(), - config); + final DataObjectInfo dataObjInfo = (DataObjectInfo) dtIter.next(); + final CreateTransformsInfoProfileExplicit profile = + ProfileMapper.mapCreateTransformsInfoProfile( + dataObjInfo.getCreateTransformsInfoProfile(), + config); profiles.add(profile); } @@ -296,41 +297,42 @@ public class XMLSignatureCreationProfileFactory { /** * Build the <code>List</code> of transformation supplements contained in a * <code>SingleSignatureInfo</code> object. - * - * @param createTransformsInfoProfiles The - * <code>CreateTransformsInfoProfile</code> object from which to extract the - * transformation supplements. + * + * @param createTransformsInfoProfiles The + * <code>CreateTransformsInfoProfile</code> + * object from which to extract the + * transformation supplements. * @return A <code>List</code> of <code>DataObject</code>s containing the - * transformation supplements. - * @throws MOASystemException A system error occurred creating one of the - * transformation supplements. + * transformation supplements. + * @throws MOASystemException A system error occurred creating one of the + * transformation supplements. * @throws MOAApplicationException An error occurred creating one of the - * transformation supplements. + * transformation supplements. */ private List buildTransformationSupplements(List createTransformsInfoProfiles) - throws MOASystemException, MOAApplicationException { + throws MOASystemException, MOAApplicationException { - List transformationSupplements = new ArrayList(); - DataObjectFactory factory = DataObjectFactory.getInstance(); + final List transformationSupplements = new ArrayList(); + final DataObjectFactory factory = DataObjectFactory.getInstance(); Iterator iter; for (iter = createTransformsInfoProfiles.iterator(); iter.hasNext();) { - CreateTransformsInfoProfileExplicit profile = - (CreateTransformsInfoProfileExplicit) iter.next(); - List supplements = profile.getSupplements(); + final CreateTransformsInfoProfileExplicit profile = + (CreateTransformsInfoProfileExplicit) iter.next(); + final List supplements = profile.getSupplements(); if (supplements != null) { Iterator supplIter; for (supplIter = supplements.iterator(); supplIter.hasNext();) { - XMLDataObjectAssociation supplement = - (XMLDataObjectAssociation) supplIter.next(); + final XMLDataObjectAssociation supplement = + (XMLDataObjectAssociation) supplIter.next(); transformationSupplements.add( - factory.createFromXmlDataObjectAssociation( - supplement, - false, - true)); + factory.createFromXmlDataObjectAssociation( + supplement, + false, + true)); } } } @@ -341,35 +343,40 @@ public class XMLSignatureCreationProfileFactory { /** * Build the <code>List</code> of <code>DataObjectTreatment</code>s for the * given <code>SingleSignatureInfo</code> object.. - * - * @param singleSignatureInfo The <code>SingleSignatureInfo</code> object - * from which to exctract the <code>CreateTransformsInfoProfile</code>s - * containing the data for the <code>DataObjectTreatment</code>s. - * @param createTransformsInfoProfiles The - * <code>CreateTransformsInfoProfile</code>s contained in the - * <code>singleSignatureInfo</code>. - * @param transformationSupplements Additional parameters for - * transformations contained in <code>DataObjectTreatment</code>s. - * @param reservedIDs The <code>Set</code> of reserved object IDs. + * + * @param singleSignatureInfo The <code>SingleSignatureInfo</code> + * object from which to exctract the + * <code>CreateTransformsInfoProfile</code>s + * containing the data for the + * <code>DataObjectTreatment</code>s. + * @param createTransformsInfoProfiles The + * <code>CreateTransformsInfoProfile</code>s + * contained in the + * <code>singleSignatureInfo</code>. + * @param transformationSupplements Additional parameters for transformations + * contained in + * <code>DataObjectTreatment</code>s. + * @param reservedIDs The <code>Set</code> of reserved object + * IDs. * @return A <code>List</code> of <code>DataObjectTreatment</code> objects. * @throws MOAApplicationException An error occurred building one of the - * <code>DataObjectTreatment</code>s. - * @throws MOASystemException A system error occurred building one of the - * <code>DataObjectTreatment</code>s. + * <code>DataObjectTreatment</code>s. + * @throws MOASystemException A system error occurred building one of the + * <code>DataObjectTreatment</code>s. */ private List buildDataObjectTreatmentList( - SingleSignatureInfo singleSignatureInfo, - List createTransformsInfoProfiles, - List transformationSupplements, - Set reservedIDs, - String digestMethodXAdES142) - throws MOASystemException, MOAApplicationException { - - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ConfigurationProvider config = context.getConfiguration(); - List treatments = new ArrayList(); - List dataObjInfos = singleSignatureInfo.getDataObjectInfos(); + SingleSignatureInfo singleSignatureInfo, + List createTransformsInfoProfiles, + List transformationSupplements, + Set reservedIDs, + String digestMethodXAdES142) + throws MOASystemException, MOAApplicationException { + + final TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + final ConfigurationProvider config = context.getConfiguration(); + final List treatments = new ArrayList(); + final List dataObjInfos = singleSignatureInfo.getDataObjectInfos(); int dataObjectTreatmentCount = 1; String hashAlgorithmName; Iterator dtIter; @@ -377,44 +384,40 @@ public class XMLSignatureCreationProfileFactory { prIter = createTransformsInfoProfiles.iterator(); for (dtIter = dataObjInfos.iterator(); dtIter.hasNext();) { - CreateTransformsInfoProfileExplicit profile = - (CreateTransformsInfoProfileExplicit) prIter.next(); - DataObjectInfo dataObjInfo = (DataObjectInfo) dtIter.next(); - IdGenerator objIdGen = - new IdGenerator( - ("signed-data-" + createProfileCount) - + ("-" + dataObjectTreatmentCount++), - reservedIDs); - DataObjectTreatmentImpl treatment = new DataObjectTreatmentImpl(objIdGen); + final CreateTransformsInfoProfileExplicit profile = + (CreateTransformsInfoProfileExplicit) prIter.next(); + final DataObjectInfo dataObjInfo = (DataObjectInfo) dtIter.next(); + final IdGenerator objIdGen = + new IdGenerator( + "signed-data-" + createProfileCount + + "-" + dataObjectTreatmentCount++, + reservedIDs); + final DataObjectTreatmentImpl treatment = new DataObjectTreatmentImpl(objIdGen); treatment.setFinalContentType( - profile.getCreateTransformsInfo().getFinalDataMetaInfo().getMimeType()); + profile.getCreateTransformsInfo().getFinalDataMetaInfo().getMimeType()); treatment.setTransformationList(buildTransformationList(profile)); treatment.setReferenceInManifest(dataObjInfo.isChildOfManifest()); // if XAdES version is 1.4.2 if (digestMethodXAdES142 != null) { - // use configured digest algorithm - hashAlgorithmName = digestMethodXAdES142; - } - else { - // stay as it is - hashAlgorithmName = (String) HASH_ALGORITHM_MAPPING.get( - config.getDigestMethodAlgorithmName()); - if (hashAlgorithmName == null) { - error( - "config.17", - new Object[] { config.getDigestMethodAlgorithmName()}); - throw new MOASystemException("2900", null); - } + // use configured digest algorithm + hashAlgorithmName = digestMethodXAdES142; + } else { + // stay as it is + hashAlgorithmName = (String) HASH_ALGORITHM_MAPPING.get( + config.getDigestMethodAlgorithmName()); + if (hashAlgorithmName == null) { + error( + "config.17", + new Object[] { config.getDigestMethodAlgorithmName() }); + throw new MOASystemException("2900", null); + } } - - - treatment.setHashAlgorithmName(hashAlgorithmName); treatment.setIncludedInSignature( - DataObjectInfo.STRUCTURE_ENVELOPING.equals(dataObjInfo.getStructure())); + DataObjectInfo.STRUCTURE_ENVELOPING.equals(dataObjInfo.getStructure())); treatment.setTransformationSupplements(transformationSupplements); treatments.add(treatment); @@ -427,48 +430,48 @@ public class XMLSignatureCreationProfileFactory { /** * Build the <code>List</code> of transformations contained in a * <code>CreateTransformsInfoProfile</code> object. - * - * @param profile The <code>CreateTransformsInfoProfile</code> object - * from which to extract the <code>Transform</code>s. - * @return A <code>List</code> of <code>Transformation</code>s contained in - * the given <code>CreateTransformsInfoProfile</code>. + * + * @param profile The <code>CreateTransformsInfoProfile</code> object from which + * to extract the <code>Transform</code>s. + * @return A <code>List</code> of <code>Transformation</code>s contained in the + * given <code>CreateTransformsInfoProfile</code>. * @throws MOAApplicationException An error occurred building one of the - * <code>Transformation</code>s. + * <code>Transformation</code>s. */ private List buildTransformationList(CreateTransformsInfoProfileExplicit profile) - throws MOAApplicationException { + throws MOAApplicationException { - TransformationFactory factory = TransformationFactory.getInstance(); - List transforms = profile.getCreateTransformsInfo().getTransforms(); + final TransformationFactory factory = TransformationFactory.getInstance(); + final List transforms = profile.getCreateTransformsInfo().getTransforms(); return transforms != null - ? factory.createTransformationList(transforms) - : Collections.EMPTY_LIST; + ? factory.createTransformationList(transforms) + : Collections.EMPTY_LIST; } /** * Build the set of <code>KeyEntryID</code>s available to the given * <code>keyGroupID</code>. - * + * * @param keyGroupID The keygroup ID for which the available keys should be - * returned. - * @return The <code>Set</code> of <code>KeyEntryID</code>s - * identifying the available keys. + * returned. + * @return The <code>Set</code> of <code>KeyEntryID</code>s identifying the + * available keys. */ private Set buildKeySet(String keyGroupID) { - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ConfigurationProvider config = context.getConfiguration(); + final TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + final ConfigurationProvider config = context.getConfiguration(); Set keyGroupEntries; // get the KeyGroup entries from the configuration if (context.getClientCertificate() != null) { - X509Certificate cert = context.getClientCertificate()[0]; - Principal issuer = cert.getIssuerDN(); - BigInteger serialNumber = cert.getSerialNumber(); + final X509Certificate cert = context.getClientCertificate()[0]; + final Principal issuer = cert.getIssuerDN(); + final BigInteger serialNumber = cert.getSerialNumber(); keyGroupEntries = - config.getKeyGroupEntries(issuer, serialNumber, keyGroupID); + config.getKeyGroupEntries(issuer, serialNumber, keyGroupID); } else { keyGroupEntries = config.getKeyGroupEntries(null, null, keyGroupID); } @@ -479,23 +482,23 @@ public class XMLSignatureCreationProfileFactory { } else if (keyGroupEntries.size() == 0) { return Collections.EMPTY_SET; } else { - KeyModule module = - KeyModuleFactory.getInstance( - new TransactionId(context.getTransactionID())); - Set keyEntryIDs = module.getPrivateKeyEntryIDs(); - Set keySet = new HashSet(); + final KeyModule module = + KeyModuleFactory.getInstance( + new TransactionId(context.getTransactionID())); + final Set keyEntryIDs = module.getPrivateKeyEntryIDs(); + final Set keySet = new HashSet(); Iterator iter; // filter out the keys that do not exist in the IAIK configuration // by walking through the key entries and checking if the exist in the // keyGroupEntries for (iter = keyEntryIDs.iterator(); iter.hasNext();) { - KeyEntryID entryID = (KeyEntryID) iter.next(); - KeyGroupEntry entry = - new KeyGroupEntry( - entryID.getModuleID(), - entryID.getCertificateIssuer(), - entryID.getCertificateSerialNumber()); + final KeyEntryID entryID = (KeyEntryID) iter.next(); + final KeyGroupEntry entry = + new KeyGroupEntry( + entryID.getModuleID(), + entryID.getCertificateIssuer(), + entryID.getCertificateSerialNumber()); if (keyGroupEntries.contains(entry)) { keySet.add(entryID); } @@ -507,29 +510,31 @@ public class XMLSignatureCreationProfileFactory { /** * Get the signature location index where the signature will be inserted into * the signature parent element. - * + * * @param singleSignatureInfo The <code>SingleSignatureInfo</code> object - * containing the <code>CreateSignatureLocation</code>. + * containing the + * <code>CreateSignatureLocation</code>. * @return The index at which to insert the signature into the signature - * environment. - * @throws MOAApplicationException An error occurred parsing the - * <code>CreateSignatureEnvironmentProfile</code>. + * environment. + * @throws MOAApplicationException An error occurred parsing the + * <code>CreateSignatureEnvironmentProfile</code>. */ - private XMLSignatureInsertionLocation getSignatureInsertionLocationIndex(SingleSignatureInfo singleSignatureInfo) - throws MOAApplicationException { + private XMLSignatureInsertionLocation getSignatureInsertionLocationIndex( + SingleSignatureInfo singleSignatureInfo) + throws MOAApplicationException { - CreateSignatureInfo createInfo = - singleSignatureInfo.getCreateSignatureInfo(); + final CreateSignatureInfo createInfo = + singleSignatureInfo.getCreateSignatureInfo(); if (createInfo != null) { - TransactionContext context = - TransactionContextManager.getInstance().getTransactionContext(); - ConfigurationProvider config = context.getConfiguration(); - CreateSignatureEnvironmentProfileExplicit profile = - ProfileMapper.mapCreateSignatureEnvironmentProfile( - createInfo.getCreateSignatureEnvironmentProfile(), - config); - int index = profile.getCreateSignatureLocation().getIndex(); + final TransactionContext context = + TransactionContextManager.getInstance().getTransactionContext(); + final ConfigurationProvider config = context.getConfiguration(); + final CreateSignatureEnvironmentProfileExplicit profile = + ProfileMapper.mapCreateSignatureEnvironmentProfile( + createInfo.getCreateSignatureEnvironmentProfile(), + config); + final int index = profile.getCreateSignatureLocation().getIndex(); return new XMLSignatureInsertionLocationImpl(index); } else { @@ -539,12 +544,12 @@ public class XMLSignatureCreationProfileFactory { /** * Utility function to issue an error message to the log. - * - * @param messageId The ID of the message to log. + * + * @param messageId The ID of the message to log. * @param parameters Additional message parameters. */ private static void error(String messageId, Object[] parameters) { - MessageProvider msg = MessageProvider.getInstance(); + final MessageProvider msg = MessageProvider.getInstance(); Logger.error(new LogMsg(msg.getMessage(messageId, parameters))); } |