public void sign()

in jsign-core/src/main/java/net/jsign/SignerHelper.java [469:516]


    public void sign(File file) throws SignerException {
        if (file == null) {
            throw new SignerException("file must be set");
        }
        if (!file.exists()) {
            throw new SignerException("The file " + file + " couldn't be found");
        }
        
        Signable signable;
        try {
            signable = Signable.of(file, encoding);
        } catch (UnsupportedOperationException e) {
            throw new SignerException(e.getMessage());
        } catch (IOException e) {
            throw new SignerException("Couldn't open the file " + file, e);
        }

        if (detached && getDetachedSignature(file).exists()) {
            try {
                if (console != null) {
                    console.info("Attaching Authenticode signature to " + file);
                }
                attach(file);
                return;
            } catch (Exception e) {
                throw new SignerException("Couldn't attach the signature to " + file, e);
            }
        }

        try {
            if (signer == null) {
                signer = build();
            }
            
            if (console != null) {
                console.info("Adding Authenticode signature to " + file);
            }
            signer.sign(signable);

            if (detached) {
                detach(file);
            }
        } catch (SignerException e) {
            throw e;
        } catch (Exception e) {
            throw new SignerException("Couldn't sign " + file, e);
        }
    }