use of org.eclipse.scout.rt.shared.services.common.file.RemoteFile in project scout.rt by eclipse.
the class FileSystemBookmarkStorageService method readBookmarkFolder.
/**
* Reads a bookmark folder.
*
* @since 3.8.2
*/
private BookmarkFolder readBookmarkFolder(String filename) {
RemoteFile spec = new RemoteFile("bookmarks", filename, 0);
RemoteFile f = BEANS.get(IRemoteFileService.class).getRemoteFile(spec);
if (f.exists()) {
try {
byte[] bytes = f.extractData();
return SerializationUtility.createObjectSerializer().deserialize(bytes, BookmarkFolder.class);
} catch (Exception t) {
LOG.error("Could not deserialize bookmark folder", t);
}
}
return null;
}
use of org.eclipse.scout.rt.shared.services.common.file.RemoteFile in project scout.rt by eclipse.
the class HolidayCalendarService method getItems.
@Override
public Set<? extends ICalendarItem> getItems(RemoteFile spec, Date minDate, Date maxDate) {
// load new items
HolidayCalendarItemParser p = null;
String key = spec.getPath();
synchronized (m_holidayXmlCache) {
p = m_holidayXmlCache.get(key);
if (p == null) {
try {
RemoteFile f = BEANS.get(IRemoteFileService.class).getRemoteFile(spec);
if (f != null) {
p = new HolidayCalendarItemParser(f.getDecompressedInputStream(), spec.getPath());
m_holidayXmlCache.put(key, p);
}
} catch (Exception e) {
LOG.warn("parsing remote file: {}", spec, e);
}
}
}
final Set<? extends ICalendarItem> result;
if (p != null) {
result = p.getItems(NlsLocale.get(), minDate, maxDate);
} else {
result = CollectionUtility.hashSet();
}
return result;
}
use of org.eclipse.scout.rt.shared.services.common.file.RemoteFile in project scout.rt by eclipse.
the class GlobalTrustManager method getTrustedCertificates.
protected X509Certificate[] getTrustedCertificates() throws IOException, CertificateException {
FilenameFilter certFilter = new FilenameFilter() {
@Override
public boolean accept(File file, String name) {
return (name.toLowerCase().endsWith(".der"));
}
};
List<X509Certificate> trustedCerts = null;
try {
RemoteFile[] certRemoteFiles = BEANS.get(IRemoteFileService.class).getRemoteFiles(PATH_CERTS, certFilter, null);
if (certRemoteFiles.length == 0) {
LOG.warn("No certificates to trust in folder '{}' could be found.", PATH_CERTS);
}
trustedCerts = installTrustedCertificates(certRemoteFiles);
} catch (RuntimeException e) {
LOG.error("Could not access folder '{}' to import trusted certificates.", PATH_CERTS, e);
}
return trustedCerts == null ? new X509Certificate[] {} : trustedCerts.toArray(new X509Certificate[trustedCerts.size()]);
}
use of org.eclipse.scout.rt.shared.services.common.file.RemoteFile in project scout.rt by eclipse.
the class GlobalTrustManager method installTrustedCertificates.
protected List<X509Certificate> installTrustedCertificates(RemoteFile[] certRemoteFiles) {
List<X509Certificate> trustedCerts = new LinkedList<X509Certificate>();
for (RemoteFile certRemoteFile : certRemoteFiles) {
try {
LOG.info("Trusted certificate '{}' found.", certRemoteFile.getName());
ByteArrayOutputStream os = new ByteArrayOutputStream();
certRemoteFile.writeData(os);
X509Certificate cert = readX509Cert(new ByteArrayInputStream(os.toByteArray()));
trustedCerts.add(cert);
LOG.info("Trusted certificate '{}' successfully installed.", certRemoteFile.getName());
} catch (Exception e) {
LOG.info("Failed to install trusted certificate '{}'.", certRemoteFile.getName(), e);
}
}
return trustedCerts;
}
Aggregations