question: private void sign ( final byte [ ] contentBytes , final ByteArrayOutputStream mimeContent ) throws Exception { String algId = conf . getSignatureAlgorithmId ( ) ; String keyId = conf . getActiveSigningKey ( ) ; log . debug ( "Signing directory with signing key '{}' " + "and signing algorithm '{}'" , keyId , algId ) ; String signature = signHelper ( keyId , algId , contentBytes ) ; mimeContent . write ( envelopeHeader . getBytes ( ) ) ; try ( MultipartEncoder encoder = new MultipartEncoder ( mimeContent , envelopeBoundary ) ) { encoder . startPart ( mpMixedContentType ( dataBoundary ) ) ; encoder . write ( contentBytes ) ; String algURI = CryptoUtils . getSignatureAlgorithmURI ( algId ) ; String hashURI = hashCalculator . getAlgoURI ( ) ; Path verificatioCertPath = conf . getCertPath ( keyId ) ; encoder . startPart ( MimeTypes . BINARY , new String [ ] { HEADER_CONTENT_TRANSFER_ENCODING + ": base64" , HEADER_SIG_ALGO_ID + ": " + algURI , HEADER_VERIFICATION_CERT_HASH + ": " + getVerificationCertHash ( verificatioCertPath ) + "; " + HEADER_HASH_ALGORITHM_ID + "=" + hashURI } ) ; encoder . write ( signature . getBytes ( ) ) ; } log . debug ( "Generated signed directory:\n{}\n" , mimeContent . toString ( ) ) ; Files . write ( tempConfPath , mimeContent . toByteArray ( ) ) ; log . debug ( "Written signed directory to '{}'" , tempConfPath ) ; }
target:  Signs the global configuration directory content.