List of usage examples for org.apache.commons.codec.digest DigestUtils sha1Hex
public static String sha1Hex(String data)
From source file:org.incode.eurocommercial.ecpcrm.module.api.dom.authentication.AuthenticationDeviceRepository.java
@Programmatic private String generateSecret() { return DigestUtils.sha1Hex(new Random().nextInt() + ""); }
From source file:org.mangelp.fakeSmtpWeb.httpServer.mailBrowser.MailFile.java
/** * Parse the file on disk using a MimeMessageParser and set all the instance * properties we will be using.//from ww w.j a va 2s . c om * * @throws FileNotFoundException * @throws MessagingException * @throws ParseException * @throws IOException */ protected void parseEmail() throws FileNotFoundException, MessagingException, ParseException, IOException { InputStream inputStream = new BufferedInputStream(new FileInputStream(this.getFile())); try { final Session session = Session.getDefaultInstance(new Properties()); MimeMessage message = new MimeMessage(session, inputStream); MimeMessageParser mimeParser = new MimeMessageParser(message); mimeParser.parse(); this.setSubject(mimeParser.getSubject()); this.setFrom(mimeParser.getFrom()); this.setReplyTo(mimeParser.getReplyTo()); ArrayList<String> toList = new ArrayList<String>(); for (Address emailAddress : mimeParser.getTo()) { toList.add(emailAddress.toString()); } this.setTo(toList.toArray(this.getTo())); ArrayList<String> ccList = new ArrayList<String>(); for (Address emailAddress : mimeParser.getCc()) { ccList.add(emailAddress.toString()); } this.setCc(ccList.toArray(this.getCc())); ArrayList<String> bccList = new ArrayList<String>(); for (Address emailAddress : mimeParser.getBcc()) { bccList.add(emailAddress.toString()); } this.setBcc(bccList.toArray(this.getBcc())); if (mimeParser.hasAttachments()) { attachments = new ArrayList<MailAttachment>(mimeParser.getAttachmentList().size()); int index = 0; for (DataSource ds : mimeParser.getAttachmentList()) { attachments.add(new MailAttachment(++index, ds)); } } if (mimeParser.hasHtmlContent()) { this.setHtmlContent(mimeParser.getHtmlContent()); } if (mimeParser.hasPlainContent()) { this.setPlainContent(mimeParser.getPlainContent()); } } catch (Exception e) { throw new ParseException("Failed to parse file " + this.getFile().toString() + ": " + e.getMessage()); } this.setId(DigestUtils.sha1Hex(inputStream)); inputStream.close(); }
From source file:org.matonto.jaas.engines.RdfEngine.java
private Resource createUserIri(String username) { return factory.createIRI(userNamespace + DigestUtils.sha1Hex(username)); }
From source file:org.matonto.jaas.engines.RdfEngine.java
private Resource createGroupIri(String groupTitle) { return factory.createIRI(groupNamespace + DigestUtils.sha1Hex(groupTitle)); }
From source file:org.mconf.UrlFixer.java
/** * @param args/* www. jav a 2 s. c o m*/ * @throws IOException */ public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Server salt: "); String salt = in.readLine(); System.out.println("Paste BigBlueButton API calls to fix the checksum (CTRL+C or empty to quit)"); String s; while ((s = in.readLine()) != null && s.length() != 0) { try { String prefix = s.substring(0, s.indexOf("/api/") + 5); s = s.substring(prefix.length(), s.lastIndexOf("&checksum=")); String checksum = DigestUtils.sha1Hex(s.replaceFirst("[?]", "") + salt); s = prefix + s + "&checksum=" + checksum; System.out.println("=> " + s); } catch (Exception e) { e.printStackTrace(); } } }
From source file:org.mule.modules.wechat.WechatConnector.java
/** * Verify validity of the URL/* w w w .j ava 2 s. c om*/ * <br><a href="http://admin.wechat.com/wiki/index.php?title=Getting_Started#Step_2._Verify_validity_of_the_URL">http://admin.wechat.com/wiki/index.php?title=Getting_Started#Step_2._Verify_validity_of_the_URL</a> * * @param uri URI sent by WeChat Official Account Admin System * @return The developer's backend system should return the echostr parameter value indicating that the request has been successfully received * @throws Exception If anything fails */ @Processor public Object verifyUrl(@Default("#[message.inboundProperties.'http.request.uri']") String uri) throws Exception { String result = ""; MultiValueMap<String, String> parameters = UriComponentsBuilder.fromUri(new URI(uri)).build() .getQueryParams(); if (parameters.containsKey("timestamp") && parameters.containsKey("nonce") && parameters.containsKey("signature")) { String[] arr = { config.getToken(), parameters.get("timestamp").get(0), parameters.get("nonce").get(0) }; Arrays.sort(arr); String tmpStr = String.join("", arr); tmpStr = DigestUtils.sha1Hex(tmpStr); if (tmpStr.equals(parameters.get("signature").get(0))) { if (parameters.containsKey("echostr")) { result = parameters.get("echostr").get(0); } } } return result; }
From source file:org.openestate.is24.restapi.utils.ExportHandler.java
/** * Save a real estate to the Webservice. * * @param object//from w ww.j a v a 2 s .co m * real estate to save * * @param poolObjectId * real estate ID within export pool * * @return * ID of the processed real estate in the Webservice or null, if the object * was not updated * * @throws IOException * if the operation failed */ protected Long doUpdateObject(RealEstate object, String poolObjectId) throws IOException { final String externalObjectId = object.getExternalId(); final org.openestate.is24.restapi.xml.realestates.ObjectFactory realEstatesFactory = new org.openestate.is24.restapi.xml.realestates.ObjectFactory(); final org.openestate.is24.restapi.xml.attachmentsorder.ObjectFactory attachmentsorderFactory = new org.openestate.is24.restapi.xml.attachmentsorder.ObjectFactory(); object.setRealEstateState(RealEstateState.ACTIVE); // Ansprechpartner zuweisen, wenn nicht bereits explizit eine intene // Ansprechpartner-ID hinterlegt wurde Long is24ContactId = (object.getContact() != null) ? object.getContact().getId() : null; if (is24ContactId == null || is24ContactId < 1) { String externalContactId = (object.getContact() != null) ? StringUtils.trimToNull(object.getContact().getExternalId()) : null; // Duplikat des Ansprechpartners verwenden if (externalContactId != null && this.duplicatedContactIds.containsKey(externalContactId)) { is24ContactId = this.duplicatedContactIds.get(externalContactId); if (object.getContact() == null) object.setContact(realEstatesFactory.createRealEstateContact()); object.getContact().setId(is24ContactId); object.getContact().setExternalId(null); } // sicherstellen, dass der Ansprechpartner vorher erfolgreich whrend des Transports exportiert wurde else if (externalContactId != null && !this.savedContactIds.contains(externalContactId)) { this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_WITHOUT_CONTACT, "The contact '" + externalContactId + "' was not saved during the export process."); object.setContact(null); } } try { // prfen, ob eine Immobilie mit der externen ID bereits im Webservice existiert RealEstate oldIs24Object; try { oldIs24Object = ImportExport.RealEstateService.getByExternalId(this.client, externalObjectId); } catch (RequestFailedException ex) { LOGGER.error("Can't get property '" + externalObjectId + "' from the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_FOUND, ex); // Fortschritt protokollieren this.addProgress(this.pool.getObjectSize(poolObjectId, true)); return null; } //Messages responseMessages; final Long is24ObjectId; // Immobilie im Portal lschen, // wenn diese bereits im Portal existiert // und einer anderen Rubrik zugewiesen ist if (oldIs24Object != null && !oldIs24Object.getClass().getName().equals(object.getClass().getName())) { //LOGGER.debug( "RUBRIK GENDERT" ); //LOGGER.debug( "> fr Immobilie #" + oldIs24Object.getId() ); //LOGGER.debug( "> alte Rubrik " + oldIs24Object.getClass().getName() ); //LOGGER.debug( "> neue Rubrik " + object.getClass().getName() ); try { ImportExport.RealEstateService.deleteByIs24Id(this.client, oldIs24Object.getId()); oldIs24Object = null; } catch (RequestFailedException ex) { LOGGER.error("Can't delete property '" + externalObjectId + "' (" + oldIs24Object.getId() + ") at the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_SAVED, ex); // Fortschritt protokollieren this.addProgress(this.pool.getObjectSize(poolObjectId, true)); return null; } } // neue Immobilie erstellen if (oldIs24Object == null) { try { is24ObjectId = ImportExport.RealEstateService.post(this.client, object, this.isUseNewEnergySourceEnev2014Values()); //LOGGER.debug( "created object with IS24-ID #" + is24ObjectId ); } catch (RequestFailedException ex) { LOGGER.error("Can't add property '" + externalObjectId + "' to the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_SAVED, ex); // Fortschritt protokollieren this.addProgress(this.pool.getObjectSize(poolObjectId, true)); return null; } } // bestehende Immobilie aktualisieren else { is24ObjectId = oldIs24Object.getId(); object.setId(is24ObjectId); try { ImportExport.RealEstateService.putByIs24Id(this.client, object, is24ObjectId, this.isUseNewEnergySourceEnev2014Values()); //LOGGER.debug( "updated object with IS24-ID #" + is24ObjectId ); } catch (RequestFailedException ex) { LOGGER.error("Can't update property '" + externalObjectId + "' (" + is24ObjectId + ") at the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_NOT_SAVED, ex); // Fortschritt protokollieren this.addProgress(this.pool.getObjectSize(poolObjectId, true)); return null; } } // Fortschritt protokollieren this.addProgress(this.pool.getObjectSize(poolObjectId, false)); // bestehende Anhnge / Web-Links ermitteln final Map<String, Attachment> oldIs24Attachments = new HashMap<String, Attachment>(); boolean ignoreAttachments = false; try { Attachments attachments = ImportExport.AttachmentService.getAll(this.client, externalObjectId); if (attachments != null && !attachments.getAttachment().isEmpty()) { for (Attachment attachment : attachments.getAttachment()) { Long is24AttachmentId = attachment.getId(); String externalAttachmentId = StringUtils.trimToNull(attachment.getExternalId()); // Anhang bernehmen, wenn ein Hashwert hinterlegt ist // und dieser noch nicht bernommen wurde if (externalAttachmentId != null && !oldIs24Attachments.containsKey(externalAttachmentId)) { //LOGGER.debug( "> found old attachment #" + is24AttachmentId + " / " + externalAttachmentId + " / " + externalAttachmentId.length() ); oldIs24Attachments.put(externalAttachmentId, attachment); continue; } // alten Anhang entfernen try { //LOGGER.debug( "> removing old attachment #" + is24AttachmentId + " without external id" ); ImportExport.AttachmentService.deleteById(this.client, externalObjectId, is24AttachmentId); } catch (RequestFailedException ex) { LOGGER.error("Can't remove old attachment (" + is24AttachmentId + ") " + "of property '" + externalObjectId + "' (" + is24ObjectId + ") from the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_OLD_ATTACHMENT_NOT_REMOVED, ex); } } } } catch (RequestFailedException ex) { LOGGER.error("Can't get attachments of property '" + externalObjectId + "' (" + is24ObjectId + ") from the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_WITHOUT_ATTACHMENTS, ex); ignoreAttachments = true; } if (ignoreAttachments) { // Fortschritt protokollieren long totalAttachmentSize = this.pool.getObjectSize(poolObjectId, true) - this.pool.getObjectSize(poolObjectId, false); this.addProgress(totalAttachmentSize); } else { // Anhnge zur bertragung ermitteln und zugehrige Hash-Werte berechnen List<String> attachmentHashes = new ArrayList<String>(); Map<String, Attachment> attachments = new TreeMap<String, Attachment>(new AlphanumComparator()); Map<String, File> attachmentFiles = new HashMap<String, File>(); for (String attachmentKey : this.pool.getObjectAttachmentIds(poolObjectId)) { Attachment is24Attachment = this.pool.getObjectAttachment(poolObjectId, attachmentKey); if (is24Attachment == null) { LOGGER.error("Can't read the XML file for attachment!"); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_ATTACHMENT_NOT_SAVED, "Can't read the XML file for attachment!"); // Fortschritt protokollieren this.addProgress(this.pool.getObjectAttachmentSize(poolObjectId, attachmentKey)); continue; } // Anhang als Web-Link verarbeiten if (is24Attachment instanceof Link) { Link link = (Link) is24Attachment; // Hashwert zur Identifizierung des Anhangs errechnen URL url = link.getUrl(); String externalAttachmentId = (url != null) ? DigestUtils.sha1Hex(is24ObjectId + "-" + url.toString()) : DigestUtils.sha1Hex(is24ObjectId + "-" + attachmentKey); // Sicherstellen, dass der gleiche Anhang nicht mehrfach hochgeladen wird if (attachmentHashes.contains(externalAttachmentId)) continue; attachmentHashes.add(externalAttachmentId); link.setExternalId(externalAttachmentId); } // Anhang als Datei verarbeiten else { // Datei ermitteln File attachFile = this.pool.getObjectAttachmentFile(poolObjectId, is24Attachment); // ggf. Datei herunterladen, wenn noch nicht im Pool hinterlegt if (attachFile == null) { URL attachUrl = this.pool.getObjectAttachmentURL(poolObjectId, attachmentKey); if (attachUrl != null) { try { attachFile = doDownloadFile(attachUrl); } catch (Exception ex) { LOGGER.warn("Can't download file from URL: " + attachUrl); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); } } } if (attachFile == null || !attachFile.isFile()) { LOGGER.error("Can't find file for attachment!"); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_ATTACHMENT_NOT_SAVED, "Can't find file for attachment!"); // Fortschritt protokollieren this.addProgress(this.pool.getObjectAttachmentSize(poolObjectId, attachmentKey)); continue; } // Datei des Anhangs vormerken attachmentFiles.put(attachmentKey, attachFile.getAbsoluteFile()); // Hashwert zur Identifizierung des Anhangs errechnen final String externalAttachmentId; InputStream input = null; try { input = new FileInputStream(attachFile); String attachFileHash = DigestUtils.sha1Hex(input); externalAttachmentId = DigestUtils.sha1Hex(is24ObjectId + "-" + attachFileHash); // Sicherstellen, dass der gleiche Anhang nicht mehrfach hochgeladen wird if (attachmentHashes.contains(externalAttachmentId)) continue; attachmentHashes.add(externalAttachmentId); is24Attachment.setExternalId(externalAttachmentId); } finally { IOUtils.closeQuietly(input); } } attachments.put(attachmentKey, is24Attachment); } // alte Anhnge entfernen String[] oldIs24AttachmentIds = oldIs24Attachments.keySet() .toArray(new String[oldIs24Attachments.size()]); for (String oldIs24AttachmentId : oldIs24AttachmentIds) { if (attachmentHashes.contains(oldIs24AttachmentId)) continue; Attachment is24Attachment = oldIs24Attachments.remove(oldIs24AttachmentId); Long is24AttachmentId = is24Attachment.getId(); try { //LOGGER.debug( "> removing old attachment #" + is24AttachmentId ); ImportExport.AttachmentService.deleteById(this.client, externalObjectId, is24AttachmentId); } catch (RequestFailedException ex) { LOGGER.error("Can't remove old attachment (" + is24AttachmentId + ") " + "of property '" + externalObjectId + "' (" + is24ObjectId + ") from the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_OLD_ATTACHMENT_NOT_REMOVED, ex); } } // Anhnge aus dem Exportverzeichnis der Immobilie ermitteln Map<Integer, Long> attachmentsOrder = new TreeMap<Integer, Long>(); for (Map.Entry<String, Attachment> entry : attachments.entrySet()) { final String attachmentKey = entry.getKey(); final Attachment is24Attachment = entry.getValue(); final String externalAttachmentId = is24Attachment.getExternalId(); int pos; try { pos = Math.abs(Integer.parseInt(attachmentKey)); } catch (NumberFormatException ex) { LOGGER.warn("Can't read attachment position!"); LOGGER.warn("> " + ex.getLocalizedMessage(), ex); pos = 999; } // Anhang als Web-Link verarbeiten if (is24Attachment instanceof Link) { Link link = (Link) is24Attachment; try { // zuvor gespeicherten Web-Link mit gleichem Hashwert aktualisieren if (oldIs24Attachments.containsKey(externalAttachmentId)) { Attachment oldAttachment = oldIs24Attachments.get(externalAttachmentId); long is24AttachmentId = oldAttachment.getId(); //LOGGER.debug( "> updating attached link #" + is24AttachmentId ); //LOGGER.debug( ">> " + externalAttachmentId + " / " + externalAttachmentId.length() ); ImportExport.AttachmentService.putById(client, is24ObjectId, is24AttachmentId, link); oldIs24Attachments.remove(externalAttachmentId); } // neuen Web-Link erzeugen else { //LOGGER.debug( "> adding attached link" ); //LOGGER.debug( ">> " + externalAttachmentId + " / " + externalAttachmentId.length() ); ImportExport.AttachmentService.post(this.client, externalObjectId, is24Attachment, null, null, null); } } catch (RequestFailedException ex) { LOGGER.error("Can't save attachment of property '" + externalObjectId + "' (" + is24ObjectId + ") to the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_ATTACHMENT_NOT_SAVED, ex); } // Fortschritt protokollieren this.addProgress(this.pool.getObjectAttachmentSize(poolObjectId, attachmentKey)); continue; } // Datei ermitteln File attachFile = attachmentFiles.get(attachmentKey); if (attachFile == null || !attachFile.isFile()) { LOGGER.error("Can't find file for attachment!"); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_ATTACHMENT_NOT_SAVED, "Can't find file for attachment!"); // Fortschritt protokollieren this.addProgress(this.pool.getObjectAttachmentSize(poolObjectId, attachmentKey)); continue; } // Name und Gre des Dateianhangs ermitteln final String attachFileName = attachFile.getName(); final long attachFileSize = attachFile.length(); InputStream attachFileInput = null; try { // zuvor gespeicherten Anhang mit gleichem Hashwert aktualisieren if (oldIs24Attachments.containsKey(externalAttachmentId)) { Attachment oldAttachment = oldIs24Attachments.get(externalAttachmentId); long is24AttachmentId = oldAttachment.getId(); //LOGGER.debug( "> updating attached file #" + is24AttachmentId ); //LOGGER.debug( ">> " + externalAttachmentId + " / " + externalAttachmentId.length() ); ImportExport.AttachmentService.putById(client, is24ObjectId, is24AttachmentId, is24Attachment); oldIs24Attachments.remove(externalAttachmentId); // Sortierung des Anhangs vormerken if (!StreamingVideo.class.isInstance(is24Attachment)) { while (attachmentsOrder.containsKey(pos)) { pos++; } attachmentsOrder.put(pos, is24AttachmentId); //LOGGER.debug( "untouched attachment #" + is24AttachmentId + " (" + StringUtils.trimToEmpty( is24Attachment.getTitle() ) + ") at " + pos ); } } // neuen Anhang erzeugen else { //LOGGER.debug( "> adding attached file" ); //LOGGER.debug( ">> " + externalAttachmentId + " / " + externalAttachmentId.length() ); // MIME-Type des Dateianhangs ermitteln final String attachFileMimeType; if (is24Attachment instanceof PDFDocument) { attachFileMimeType = "application/pdf"; } else if (is24Attachment instanceof Picture) { if (attachFileName.toLowerCase().endsWith(".png")) attachFileMimeType = "image/png"; else if (attachFileName.toLowerCase().endsWith(".gif")) attachFileMimeType = "image/gif"; else attachFileMimeType = "image/jpeg"; } //else if (is24Attachment instanceof VideoFile) //{ // mimeType = "application/octet-stream"; //} else { //mimeType = "application/octet-stream"; attachFileMimeType = null; } attachFileInput = new FileInputStream(attachFile); // Video auf separaten Webservice bertragen if (is24Attachment instanceof StreamingVideo) { // Videodatei via UploadService bertragen //LOGGER.debug( "UPLOAD STREAMING VIDEO '" + attachFileName + "'" ); String videoId = ImportExport.VideoUploadService.doVideoUpload(this.client, attachFileInput, attachFileName, attachFileSize); // Anhang mit ID des bertragenen Videos zum Webservice senden //LOGGER.debug( "POST STREAMING VIDEO WITH ID '" + videoId + "'" ); StreamingVideo streamingVideo = (StreamingVideo) is24Attachment; streamingVideo.setVideoId(videoId); ImportExport.AttachmentService.post(this.client, externalObjectId, streamingVideo, null, null, null); } // Anhang direkt bertragen else { long is24AttachmentId = ImportExport.AttachmentService.post(this.client, externalObjectId, is24Attachment, attachFileInput, attachFileName, attachFileMimeType); // Sortierung des Anhangs vormerken while (attachmentsOrder.containsKey(pos)) { pos++; } attachmentsOrder.put(pos, is24AttachmentId); //LOGGER.debug( "new attachment #" + is24AttachmentId + " (" + StringUtils.trimToEmpty( is24Attachment.getTitle() ) + ") at " + pos ); } } } catch (RequestFailedException ex) { LOGGER.error("Can't save attachment of property '" + externalObjectId + "' (" + is24ObjectId + ") to the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_ATTACHMENT_NOT_SAVED, ex); } finally { IOUtils.closeQuietly(attachFileInput); // Fortschritt protokollieren this.addProgress( this.pool.getObjectAttachmentSize(poolObjectId, attachmentKey) + attachFileSize); } } // nicht aktualisierte Anhnge entfernen for (Attachment is24Attachment : oldIs24Attachments.values()) { Long is24AttachmentId = is24Attachment.getId(); try { //LOGGER.debug( "> removing untouched attachment #" + is24AttachmentId ); ImportExport.AttachmentService.deleteById(this.client, externalObjectId, is24AttachmentId); } catch (RequestFailedException ex) { LOGGER.error( "Can't remove untouched attachment (" + is24AttachmentId + ") " + "of property '" + externalObjectId + "' (" + is24ObjectId + ") from the Webservice!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_OLD_ATTACHMENT_NOT_REMOVED, ex); } } // Reihenfolge der Bild-Anhnge setzen if (!attachmentsOrder.isEmpty()) { //LOGGER.debug( "update attachment order for property '" + externalObjectId + "' (" + is24ObjectId + ")" ); //LOGGER.debug( "> " + StringUtils.join( attachmentsOrder.values(), ", " ) ); org.openestate.is24.restapi.xml.attachmentsorder.List list = attachmentsorderFactory .createList(); for (Long is24AttachmentId : attachmentsOrder.values()) { list.getAttachmentId().add(is24AttachmentId); } try { ImportExport.AttachmentsOrderService.put(this.client, externalObjectId, list); } catch (RequestFailedException ex) { LOGGER.error("Can't order attachments of property '" + externalObjectId + "' (" + is24ObjectId + ")!"); if (ex.requestRefNumber != null) LOGGER.error("> referring request: " + ex.requestRefNumber); logMessagesAsError(ex.responseMessages); LOGGER.error("> " + ex.getLocalizedMessage(), ex); this.putObjectMessage(externalObjectId, ExportMessage.Code.OBJECT_UNORDERED_ATTACHMENTS, ex); } } } return is24ObjectId; } catch (JAXBException ex) { //LOGGER.error( "Can't read / write XML while communicating with the Webservice!" ); //LOGGER.error( "> " + ex.getLocalizedMessage(), ex ); throw new IOExceptionWithCause("Can't read / write XML while communicating with the Webservice!", ex); } catch (OAuthException ex) { //LOGGER.error( "Can't authorize at the Webservice!" ); //LOGGER.error( "> " + ex.getLocalizedMessage(), ex ); throw new IOExceptionWithCause("Authorization failed!", ex); } catch (IOException ex) { //LOGGER.error( "Can't communicate with the Webservice!" ); //LOGGER.error( "> " + ex.getLocalizedMessage(), ex ); throw new IOExceptionWithCause("Communication failed!", ex); } }
From source file:org.opensaml.storage.ReplayCache.java
/** * Returns true iff the check value is not found in the cache, and stores it. * /* w ww . j a v a2 s .co m*/ * @param context a context label to subdivide the cache * @param s value to check * @param expires time (in milliseconds since beginning of epoch) for disposal of value from cache * * @return true iff the check value is not found in the cache */ public synchronized boolean check(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String s, final long expires) { String key; StorageCapabilities caps = storage.getCapabilities(); if (context.length() > caps.getContextSize()) { log.error("context {} too long for StorageService (limit {})", context, caps.getContextSize()); return false; } else if (s.length() > caps.getKeySize()) { key = DigestUtils.sha1Hex(s); } else { key = s; } try { StorageRecord entry = storage.read(context, key); if (entry == null) { log.debug("Value '{}' was not a replay, adding to cache with expiration time {}", s, expires); storage.create(context, key, "x", expires); return true; } else { log.debug("Replay of value '{}' detected in cache, expires at {}", s, entry.getExpiration()); return false; } } catch (IOException e) { log.error("Exception reading/writing to storage service, returning {}", e, strict ? "failure" : "success"); return !strict; } }
From source file:org.rdcit.ocSync.controller.UserCredentials.java
public UserCredentials(String userName, String password) { this.userName = userName; this.password = DigestUtils.sha1Hex(password); this.verifiy = false; }
From source file:org.sakaiproject.archive.impl.SiteZipper.java
/** * Zip a site archive. It is stored back in the zip directory * @param siteId site that has already been archived * @param m_storagePath path to where the archives are * @return//from w w w . j a v a2 s . c o m * @throws IOException */ public boolean zipArchive(String siteId, String m_storagePath) throws IOException { //get path to archive dir for this site //suffix of -archive is hardcoded as per archive service String archivePath = m_storagePath + siteId + "-archive"; //setup timestamp SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); String timestamp = dateFormat.format(Calendar.getInstance().getTime()); //create path to compressed archive String compressedArchivePath = m_storagePath + siteId + "-" + timestamp + ".zip"; File zipFile = new File(compressedArchivePath); if (!zipFile.exists()) { log.info("Creating zip file: " + compressedArchivePath); zipFile.createNewFile(); } FileOutputStream fOut = null; FileInputStream zip = null; BufferedOutputStream bOut = null; ZipArchiveOutputStream zOut = null; try { fOut = new FileOutputStream(zipFile); bOut = new BufferedOutputStream(fOut); zOut = new ZipArchiveOutputStream(bOut); addFileToZip(zOut, archivePath, ""); //add the directory which will then add all files recursively //create a sha1 hash of the zip String hashPath = m_storagePath + siteId + "-" + timestamp + ".sha1"; log.info("Creating hash: " + hashPath); zip = new FileInputStream(compressedArchivePath); String hash = DigestUtils.sha1Hex(zip); FileUtils.writeStringToFile(new File(hashPath), hash); } finally { zOut.finish(); zOut.close(); bOut.close(); fOut.close(); zip.close(); } return true; }