Package uk.gov.nationalarchives.droid.core.interfaces.signature

Examples of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo


     * @param parent the parent window
     */
    public void execute(Window parent) {
        File f = new File(fileName);
        try {
            SignatureFileInfo info = signatureManager.install(type, f, useAsDefault);
            String message = String.format("Signature file %s has been installed", info.getFile().getName());
            JOptionPane.showMessageDialog(parent, message, "Signature file installed", JOptionPane.INFORMATION_MESSAGE);
        } catch (SignatureFileException e) {
            JOptionPane.showMessageDialog(parent, e.getMessage(),
                    "Error installing signature file", JOptionPane.ERROR_MESSAGE);
        }           
View Full Code Here


        ProfileInstance profile = profileContextLocator.getProfileInstance(profileId);
       
        File profileHomeDir = new File(config.getProfilesDir(), profile.getUuid());
        profileHomeDir.mkdir();

        SignatureFileInfo binarySigFile = signatures.get(SignatureType.BINARY);
        if (binarySigFile != null) {
            profile.setSignatureFileVersion(binarySigFile.getVersion());
            profile.setSignatureFileName(binarySigFile.getFile().getName());
            copySignatureFile(binarySigFile.getFile(), profileHomeDir);
        }
       
        SignatureFileInfo containerSigFile = signatures.get(SignatureType.CONTAINER);
        if (containerSigFile != null) {
            profile.setContainerSignatureFileName(containerSigFile.getFile().getName());
            profile.setContainerSignatureFileVersion(containerSigFile.getVersion());
            copySignatureFile(containerSigFile.getFile(), profileHomeDir);
        }
       
        SignatureFileInfo textSigFile = signatures.get(SignatureType.TEXT);
        if (textSigFile != null) {
            profile.setTextSignatureFileName(textSigFile.getFile().getName());
            profile.setTextSignatureFileVersion(textSigFile.getVersion());
            copySignatureFile(textSigFile.getFile(), profileHomeDir);
        }

        profile.setUuid(profileId);
        profile.setProfileSpec(new ProfileSpec());
View Full Code Here

        proxySettings.setProxyHost(PROXY_HOST);
        proxySettings.setProxyPort(PROXY_PORT);
        proxySettings.setEnabled(true);
       
        importer.onProxyChange(proxySettings);
        SignatureFileInfo info = importer.getLatestVersion(1);
       
//        assertEquals(CURRENT_VER, info.getVersion());
        assertTrue(info.getVersion() > 0);
        assertEquals(false, info.isDeprecated());
        assertEquals(SignatureType.BINARY, info.getType());
    }
View Full Code Here

    public void testGetSigFileFromRemoteWebServiceSavesFileLocally() throws SignatureServiceException {
       
        File[] sigFiles = sigFileDir.listFiles();
        assertEquals(0, sigFiles.length);
       
        SignatureFileInfo info = importer.importSignatureFile(sigFileDir);
        sigFiles = sigFileDir.listFiles();
        assertEquals(1, sigFiles.length);
       
//        File file = new File("tmp_sig_files/DROID_SignatureFile_V" + CURRENT_VER + ".xml");
//        assertTrue(file.exists());
//        assertEquals(CURRENT_VER, info.getVersion());
       
        assertTrue(info.getVersion() > 0);
        assertEquals(false, info.isDeprecated());
        assertEquals(SignatureType.BINARY, info.getType());
    }
View Full Code Here

        return availableSigFiles;
    }
   
    private static SignatureFileInfo forBinarySigFile(File file, SignatureInfoParser parser)
        throws SignatureFileException {
        final SignatureFileInfo signatureFileInfo = parser.parse(file);
        signatureFileInfo.setFile(file);
        return signatureFileInfo;
    }
View Full Code Here

        throws SignatureFileException {
        // parse the version from the filename
        String filename = FilenameUtils.getBaseName(file.getName());
        try {
            int version = Integer.valueOf(StringUtils.substringAfterLast(filename, "-"));
            final SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, type);
            signatureFileInfo.setFile(file);
            return signatureFileInfo;
        } catch (NumberFormatException e) {
            String message = String.format("Invalid signature filename [%s]", file.getName());
            throw new SignatureFileException(message, e, ErrorCode.INVALID_SIGNATURE_FILE);
        }
View Full Code Here

            SignatureType type = entry.getKey();
            SignatureUpdateService updateService = entry.getValue();
            final Map<String, SignatureFileInfo> signaturesForType = availableSignatureFiles.get(type);
            try {
                int latestVersionForType = getLatestVersionForType(type, signaturesForType);
                SignatureFileInfo latestUpdate = updateService.getLatestVersion(latestVersionForType);
                if (latestUpdate != null
                    && latestUpdate.getVersion() > 0
                    && !signaturesForType.containsValue(latestUpdate)) {
                    latestSigFiles.put(type, latestUpdate);
                }
            } catch (SignatureServiceException e) {
                latestSigFiles.put(type, new SignatureFileInfo(e));
            }
        }
           
        return latestSigFiles;
    }
View Full Code Here

    }
   
    private int getLatestVersionForType(SignatureType type, Map<String, SignatureFileInfo> signatures) {
        int result = 0;
        for (String key : signatures.keySet()) {
            SignatureFileInfo info = signatures.get(key);
            if (info.getVersion() > result) {
                result = info.getVersion();
            }
        }
        return result;
    }
View Full Code Here

                throw new IllegalArgumentException("Invalid signature type : " + type);
        }
       
       
        try {
            SignatureFileInfo info = signatureUpdateServices.get(type).importSignatureFile(sigFileDir);
            final boolean autoSetDefaultSigFile = config.getBooleanProperty(DroidGlobalProperty.UPDATE_AUTOSET_DEFAULT);
            if (autoSetDefaultSigFile) {
                PropertiesConfiguration props = config.getProperties();
                props.setProperty(defaultVersionProperties.get(type).getName(),
                        FilenameUtils.getBaseName(info.getFile().getName()));
                try {
                    config.getProperties().save();
                } catch (ConfigurationException e) {
                    log.error(e);
                    throw new SignatureManagerException(e);
View Full Code Here

            Map<String, SignatureFileInfo> sigs = sigFileEntry.getValue();
            DroidGlobalProperty defaultSigFile = defaultVersionProperties.get(type);
           
            String defaultSigFileKey = config.getProperties().getString(defaultSigFile.getName());
            if (StringUtils.isNotBlank(defaultSigFileKey)) {
                SignatureFileInfo sigFileInfo = sigs.get(defaultSigFileKey);
                if (sigFileInfo == null) {
                    String errorMessage = String.format(errorMessagePattern, config.getProperties()
                            .getString(defaultVersionProperties.get(type).getName()));
                    throw new SignatureFileException(errorMessage, ErrorCode.FILE_NOT_FOUND);
                }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.