private static BundleFile getBundlFile(Class<?> clazz) throws BundleException { URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation(); File jarOrDirectory = new File(objUrl.getPath()); if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) { throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUrl, clazz.getName()), BundleException.READ_ERROR); } try { return jarOrDirectory.isDirectory() ? new DirBundleFile(jarOrDirectory, false) : new ZipBundleFile(jarOrDirectory, null, null, null); } catch (IOException e) { throw new BundleException(String.format("Cannot access bundle at '%s'.", jarOrDirectory), BundleException.READ_ERROR, e); } }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public BundleFile createBundleFile(File content, Generation generation, boolean isDirectory, boolean isBase) { BundleFile result; try { if (isDirectory) { boolean strictPath = Boolean.parseBoolean(equinoxContainer.getConfiguration().getConfiguration(EquinoxConfiguration.PROPERTY_STRICT_BUNDLE_ENTRY_PATH, Boolean.FALSE.toString())); result = new DirBundleFile(content, strictPath); } else { result = new ZipBundleFile(content, generation, mruList, getConfiguration().getDebug()); } } catch (IOException e) { throw new RuntimeException("Could not create bundle file.", e); //$NON-NLS-1$ } return wrapBundleFile(result, generation, isBase); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // Make sure we have a ZipFile first, this will throw an IOException if not valid. // Use SecureAction because it gives better errors about the path on exceptions ZipFile temp = secureAction.getZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (SignatureException e) { throw new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (CertificateException e) { throw new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchAlgorithmException e) { throw new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // Make sure we have a ZipFile first, this will throw an IOException if not valid. // Use SecureAction because it gives better errors about the path on exceptions ZipFile temp = secureAction.getZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (SignatureException e) { throw new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (CertificateException e) { throw new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchAlgorithmException e) { throw new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content), e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // make sure we have a ZipFile first, this will throw an IOException if not valid ZipFile temp = new ZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (SignatureException e) { throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (CertificateException e) { throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchAlgorithmException e) { throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // make sure we have a ZipFile first, this will throw an IOException if not valid ZipFile temp = new ZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (SignatureException e) { throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (CertificateException e) { throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchAlgorithmException e) { throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // Make sure we have a ZipFile first, this will throw an IOException if not valid. // Use SecureAction because it gives better errors about the path on exceptions ZipFile temp = secureAction.getZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (SignatureException e) { throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (CertificateException e) { throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchAlgorithmException e) { throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }
public SignedContent getSignedContent(File content) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { if (content == null) throw new IllegalArgumentException("null content"); //$NON-NLS-1$ BundleFile contentBundleFile; if (content.isDirectory()) { contentBundleFile = new DirBundleFile(content, false); } else { // Make sure we have a ZipFile first, this will throw an IOException if not valid. // Use SecureAction because it gives better errors about the path on exceptions ZipFile temp = secureAction.getZipFile(content); temp.close(); contentBundleFile = new ZipBundleFile(content, null, null, container.getConfiguration().getDebug()); } SignedBundleFile result = new SignedBundleFile(contentBundleFile, null, VERIFY_ALL, this); try { result.initializeSignedContent(); } catch (InvalidKeyException e) { throw (InvalidKeyException) new InvalidKeyException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (SignatureException e) { throw (SignatureException) new SignatureException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (CertificateException e) { throw (CertificateException) new CertificateException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchAlgorithmException e) { throw (NoSuchAlgorithmException) new NoSuchAlgorithmException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } catch (NoSuchProviderException e) { throw (NoSuchProviderException) new NoSuchProviderException(NLS.bind(SignedContentMessages.Factory_SignedContent_Error, content)).initCause(e); } return new SignedContentFile(result.getSignedContent()); }