List of usage examples for org.apache.commons.lang StringUtils trimToEmpty
public static String trimToEmpty(String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null
.
From source file:mp.platform.cyclone.webservices.utils.server.PaymentHelper.java
/** * Transform a payment parameters into a DoExternalPaymentDTO *///from ww w . ja v a 2s . c o m public DoExternalPaymentDTO toExternalPaymentDTO(final AbstractPaymentParameters params, final AccountOwner from, final AccountOwner to) { if (params == null) { return null; } final DoExternalPaymentDTO dto = new DoExternalPaymentDTO(); dto.setAmount(params.getAmount()); dto.setCurrency(currencyHelper.resolve(params.getCurrency())); dto.setDescription(params.getDescription()); dto.setFrom(from == null ? resolveFromMember(params) : from); dto.setTo(to == null ? resolveToMember(params) : to); // Do not accept empty trace numbers. if (params.getTraceNumber() != null && params.getTraceNumber().trim().equals("")) { throw new ValidationException(); } dto.setTraceNumber(params.getTraceNumber()); dto.setClientId(WebServiceContext.getClient().getId()); // Handle specific types if (params instanceof RequestPaymentParameters) { // When requesting a payment, the payment itself will be from the destination channel final RequestPaymentParameters request = (RequestPaymentParameters) params; final String destinationChannel = request.getDestinationChannel(); dto.setChannel(destinationChannel); if (destinationChannel == null) { dto.setChannel(channelHelper.restricted()); } } else if (params instanceof PaymentParameters) { final PaymentParameters payment = (PaymentParameters) params; dto.setChannel(channelHelper.restricted()); // Only positive id for transfer types if (payment.getTransferTypeId() != null && payment.getTransferTypeId() <= 0L) { throw new ValidationException(); } // It also includes the transfer type TransferType transferType = fetchService .fetch(CoercionHelper.coerce(TransferType.class, payment.getTransferTypeId())); if (transferType == null) { // Try to find a default transfer type final Collection<TransferType> possibleTypes = listPossibleTypes(dto); if (possibleTypes.isEmpty()) { throw new UnexpectedEntityException(); } transferType = possibleTypes.iterator().next(); } dto.setTransferType(transferType); // Get the custom fields by internal name final Map<String, PaymentCustomField> customFields = new HashMap<String, PaymentCustomField>(); for (final PaymentCustomField customField : customFieldService.listPaymentFields(transferType)) { customFields.put(customField.getInternalName(), customField); } // Build a custom field values collection final Collection<PaymentCustomFieldValue> customValues = new ArrayList<PaymentCustomFieldValue>(); final List<FieldValueVO> fieldValues = payment.getCustomValues(); if (fieldValues != null) { for (final FieldValueVO fieldValue : fieldValues) { final String internalName = fieldValue == null ? null : StringUtils.trimToEmpty(fieldValue.getField()); if (internalName == null) { continue; } final PaymentCustomField customField = customFields.get(internalName); if (customField == null) { throw new IllegalArgumentException("Invalid custom field passed: " + internalName); } final PaymentCustomFieldValue value = new PaymentCustomFieldValue(); value.setField(customField); value.setValue(fieldValue.getValue()); customValues.add(value); } } dto.setCustomValues(customValues); // Set the default description as the transfer type description if (StringUtils.isEmpty(payment.getDescription())) { dto.setDescription(transferType.getDescription()); } } // Set the context, according to the current owners if (dto.getFrom().equals(dto.getTo())) { dto.setContext(TransactionContext.SELF_PAYMENT); } else { dto.setContext(TransactionContext.AUTOMATIC); } return dto; }
From source file:com.prowidesoftware.swift.model.field.Field70E.java
/** * Get the Narrative as a concatenation of component2 to component11. * @return the Narrative from components *//*from w w w. j a va 2 s .c o m*/ public String getNarrative() { StringBuilder result = new StringBuilder(); for (int i = 2; i < 12; i++) { if (StringUtils.isNotBlank(getComponent(i))) { if (result.length() > 0) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent(i))); } } return result.toString(); }
From source file:com.hangum.tadpole.login.core.dialog.LoginDialog.java
@Override protected void okPressed() { String strEmail = StringUtils.trimToEmpty(textEMail.getText()); String strPass = StringUtils.trimToEmpty(textPasswd.getText()); if (!validation(strEmail, strPass)) return;//ww w. j a v a 2s. com try { UserDAO userDao = TadpoleSystem_UserQuery.login(strEmail, strPass); // firsttime email confirm if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getIs_email_certification())) { InputDialog inputDialog = new InputDialog(getShell(), LoginDialogMessages.get().LoginDialog_10, String.format(LoginDialogMessages.get().LoginDialog_17, strEmail), "", null); //$NON-NLS-3$ //$NON-NLS-1$ if (inputDialog.open() == Window.OK) { if (!userDao.getEmail_key().equals(inputDialog.getValue())) { throw new Exception(LoginDialogMessages.get().LoginDialog_19); } else { TadpoleSystem_UserQuery.updateEmailConfirm(strEmail); } } else { throw new Exception(LoginDialogMessages.get().LoginDialog_20); } } if (PublicTadpoleDefine.YES_NO.NO.name().equals(userDao.getApproval_yn())) { MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, LoginDialogMessages.get().LoginDialog_27); return; } // login // Check the allow ip String strAllowIP = userDao.getAllow_ip(); String ip_servletRequest = RequestInfoUtils.getRequestIP(); boolean isAllow = IPUtil.ifFilterString(strAllowIP, ip_servletRequest); if (logger.isDebugEnabled()) logger.debug(LoginDialogMessages.get().LoginDialog_21 + userDao.getEmail() + LoginDialogMessages.get().LoginDialog_22 + strAllowIP + LoginDialogMessages.get().LoginDialog_23 + RequestInfoUtils.getRequestIP()); if (!isAllow) { logger.error(LoginDialogMessages.get().LoginDialog_21 + userDao.getEmail() + LoginDialogMessages.get().LoginDialog_22 + strAllowIP + LoginDialogMessages.get().LoginDialog_26 + RequestInfoUtils.getRequestIP()); MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, LoginDialogMessages.get().LoginDialog_28); return; } if (PublicTadpoleDefine.YES_NO.YES.name().equals(userDao.getUse_otp())) { GoogleOTPLoginDialog otpDialog = new GoogleOTPLoginDialog(getShell()); otpDialog.open(); if (!GoogleAuthManager.getInstance().isValidate(userDao.getOtp_secret(), otpDialog.getIntOTPCode())) { throw new Exception(LoginDialogMessages.get().LoginDialog_2); } } // ? . registLoginID(); // SessionManager.addSession(userDao, SessionManager.LOGIN_IP_TYPE.SERVLET_REQUEST.name(), ip_servletRequest); // session preLogin(); // save login_history TadpoleSystem_UserQuery.saveLoginHistory(userDao.getSeq()); } catch (TadpoleAuthorityException e) { logger.error( String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage()); textPasswd.setText(""); textPasswd.setFocus(); return; } catch (TadpoleRuntimeException e) { logger.error( String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage())); //$NON-NLS-1$ MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage()); textPasswd.setFocus(); return; } catch (Exception e) { logger.error(String.format("Login exception. request email is %s, reason %s", strEmail, e.getMessage()), //$NON-NLS-1$ e); MessageDialog.openWarning(getParentShell(), CommonMessages.get().Warning, e.getMessage()); textPasswd.setFocus(); return; } super.okPressed(); }
From source file:com.hangum.tadpole.rdb.core.dialog.dbconnect.MongoDBLoginComposite.java
public boolean isValidate() { if (!message(comboGroup, "Group")) //$NON-NLS-1$ return false; if (!message(textHost, "Host")) //$NON-NLS-1$ return false; if (!message(textPort, "Port")) //$NON-NLS-1$ return false; if (!message(textDatabase, "Database")) //$NON-NLS-1$ return false; if (!message(textDisplayName, "Display Name")) //$NON-NLS-1$ return false; String host = StringUtils.trimToEmpty(textHost.getText()); String port = StringUtils.trimToEmpty(textPort.getText()); // replica set String strReplcaSet = textReplicaSet.getText(); String[] urls = StringUtils.split(strReplcaSet, ","); //$NON-NLS-1$ for (String ipPort : urls) { String[] strIpPort = StringUtils.split(ipPort, ":"); //$NON-NLS-1$ try {/* www . j ava2 s. c om*/ if (!isPing(strIpPort[0], strIpPort[1])) { MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.MongoDBLoginComposite_2 + strIpPort[0] + ":" + strIpPort[1]); //$NON-NLS-2$ return false; } } catch (NumberFormatException nfe) { MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4); return false; } catch (ArrayIndexOutOfBoundsException aobe) { MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MongoDBLoginComposite_4); return false; } } try { if (!isPing(host, port)) { MessageDialog.openError(null, Messages.DBLoginDialog_14, Messages.MySQLLoginComposite_8); return false; } } catch (NumberFormatException nfe) { MessageDialog.openError(null, Messages.MySQLLoginComposite_3, Messages.MySQLLoginComposite_4); return false; } return true; }
From source file:com.hangum.tadpole.rdb.core.actions.object.rdb.object.ObjectDropAction.java
@Override public void run(IStructuredSelection selection, UserDBDAO userDB, OBJECT_TYPE actionType) { try {//from w ww. ja va 2s. co m if (!GrantCheckerUtils.ifExecuteQuery(userDB)) return; } catch (Exception e) { MessageDialog.openError(getWindow().getShell(), Messages.get().Error, e.getMessage()); return; } if (actionType == PublicTadpoleDefine.OBJECT_TYPE.TABLES) { TableDAO dao = (TableDAO) selection.getFirstElement(); if (userDB.getDBDefine() != DBDefine.MONGODB_DEFAULT) { if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_3)) { for (Object selObjec : selection.toList()) { TableDAO selTableDao = (TableDAO) selObjec; String strSQL = "drop table " + SQLUtil.getTableName(userDB, selTableDao);// dao.getSysName(); //$NON-NLS-1$ try { if (DBDefine.TAJO_DEFAULT == userDB.getDBDefine()) { new TajoConnectionManager().executeUpdate(userDB, strSQL); } else { executeSQL(userDB, strSQL); } } catch (Exception e) { logger.error("drop table", e); exeMessage(Messages.get().ObjectDeleteAction_0, e); } } refreshTable(); } } else if (userDB.getDBDefine() == DBDefine.MONGODB_DEFAULT) { if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_3)) { try { MongoDBQuery.dropCollection(userDB, dao.getName()); refreshTable(); } catch (Exception e) { logger.error("Collection Delete", e); //$NON-NLS-1$ exeMessage("Collection", e); //$NON-NLS-1$ } } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.VIEWS) { TableDAO viewDao = (TableDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_9)) { try { executeSQL(userDB, "drop view " + viewDao.getSysName()); //$NON-NLS-1$ refreshView(); } catch (Exception e) { logger.error("drop view", e); exeMessage(Messages.get().ObjectDeleteAction_1, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.SYNONYM) { OracleSynonymDAO dao = (OracleSynonymDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_synonym)) { try { executeSQL(userDB, "drop synonym " + dao.getTable_owner() + "." + dao.getSynonym_name()); //$NON-NLS-1$ //$NON-NLS-2$ refreshSynonym(); } catch (Exception e) { logger.error("drop synoym", e); exeMessage(Messages.get().ObjectDeleteAction_1, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.INDEXES) { if (selection.getFirstElement() instanceof InformationSchemaDAO) { InformationSchemaDAO indexDAO = (InformationSchemaDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_16)) { try { if (userDB.getDBDefine() != DBDefine.POSTGRE_DEFAULT || userDB.getDBDefine() == DBDefine.ALTIBASE_DEFAULT) { executeSQL(userDB, "drop index " + indexDAO.getINDEX_NAME() + " on " + indexDAO.getTABLE_NAME()); //$NON-NLS-1$ //$NON-NLS-2$ } else { executeSQL(userDB, "drop index " + indexDAO.getINDEX_NAME() + ";"); //$NON-NLS-1$ //$NON-NLS-2$ } refreshIndexes(); } catch (Exception e) { logger.error("Delete index", e); exeMessage(Messages.get().ObjectDeleteAction_4, e); } } } else { MongoDBIndexDAO indexDAO = (MongoDBIndexDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_16)) { //$NON-NLS-1$ //$NON-NLS-2$ try { MongoDBQuery.dropIndex(userDB, indexDAO.getNs(), indexDAO.getName()); refreshIndexes(); } catch (Exception e) { logger.error("Collection Delete", e); //$NON-NLS-1$ exeMessage("Collection", e); //$NON-NLS-1$ } } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.CONSTRAINTS) { TableConstraintsDAO constraintDAO = (TableConstraintsDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, "Do you want to drop Constraints?")) { try { if (userDB.getDBDefine() != DBDefine.POSTGRE_DEFAULT || userDB.getDBDefine() == DBDefine.ALTIBASE_DEFAULT) { executeSQL(userDB, "drop constraints " + constraintDAO.getCONSTRAINT_NAME() + " on " //$NON-NLS-1$//$NON-NLS-2$ + constraintDAO.getTABLE_NAME()); } else { executeSQL(userDB, "drop constraints " + constraintDAO.getCONSTRAINT_NAME() + ";"); //$NON-NLS-1$ //$NON-NLS-2$ } this.refreshConstraints(); } catch (Exception e) { logger.error("Delete constraints", e); exeMessage("CONSTRAINTS", e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.PROCEDURES) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_24)) { try { if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { StringBuffer sbQuery = new StringBuffer("drop function " + procedureDAO.getName() + "("); ProcedureExecuterManager pm = new ProcedureExecuterManager(userDB, procedureDAO); pm.isExecuted(procedureDAO, userDB); List<InOutParameterDAO> inList = pm.getExecuter().getInParameters(); InOutParameterDAO inOutParameterDAO = inList.get(0); String[] inParams = StringUtils.split(inOutParameterDAO.getRdbType(), ","); for (int i = 0; i < inParams.length; i++) { String name = StringUtils.trimToEmpty(inParams[i]); if (i == (inParams.length - 1)) sbQuery.append(String.format("%s", name)); else sbQuery.append(String.format("%s, ", name)); } sbQuery.append(")"); if (logger.isDebugEnabled()) logger.debug("=[PROCEDURES]===> " + sbQuery); executeSQL(userDB, sbQuery.toString()); //$NON-NLS-1$ } else { executeSQL(userDB, "drop procedure " + procedureDAO.getName()); //$NON-NLS-1$ } refreshProcedure(); } catch (Exception e) { logger.error("drop procedure", e); exeMessage(Messages.get().ObjectDeleteAction_10, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.PACKAGES) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDropAction_1)) { try { try { executeSQL(userDB, "drop package body " + procedureDAO.getName()); //$NON-NLS-1$ } catch (Exception e) { // package body ? ? ?. } executeSQL(userDB, "drop package " + procedureDAO.getName()); //$NON-NLS-1$ refreshPackage(); } catch (Exception e) { logger.error("drop package", e); exeMessage(Messages.get().ObjectDeleteAction_10, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.FUNCTIONS) { ProcedureFunctionDAO functionDAO = (ProcedureFunctionDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_30)) { try { if (userDB.getDBDefine() == DBDefine.ALTIBASE_DEFAULT) { executeSQL(userDB, "drop function " + functionDAO.getDefiner() + "." + functionDAO.getName()); } else if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { StringBuffer sbQuery = new StringBuffer("drop function " + functionDAO.getName() + "("); ProcedureExecuterManager pm = new ProcedureExecuterManager(userDB, functionDAO); pm.isExecuted(functionDAO, userDB); List<InOutParameterDAO> inList = pm.getExecuter().getInParameters(); InOutParameterDAO inOutParameterDAO = inList.get(0); String[] inParams = StringUtils.split(inOutParameterDAO.getRdbType(), ","); for (int i = 0; i < inParams.length; i++) { String name = StringUtils.trimToEmpty(inParams[i]); if (i == (inParams.length - 1)) sbQuery.append(String.format("%s", name)); else sbQuery.append(String.format("%s, ", name)); } sbQuery.append(")"); if (logger.isDebugEnabled()) logger.debug("=[FUNCTIONS]===> " + sbQuery); executeSQL(userDB, sbQuery.toString()); //$NON-NLS-1$ } else { executeSQL(userDB, "drop function " + functionDAO.getName()); //$NON-NLS-1$ } refreshFunction(); } catch (Exception e) { logger.error("drop function", e); exeMessage(Messages.get().ObjectDeleteAction_17, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.TRIGGERS) { TriggerDAO triggerDAO = (TriggerDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_36)) { try { if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { executeSQL(userDB, "drop trigger " + triggerDAO.getTrigger() + " on " + triggerDAO.getTable_name()); //$NON-NLS-1$ } else { executeSQL(userDB, "drop trigger " + triggerDAO.getTrigger()); //$NON-NLS-1$ } refreshTrigger(); } catch (Exception e) { logger.error("drop trigger", e); exeMessage(Messages.get().ObjectDeleteAction_18, e); } } } else if (actionType == PublicTadpoleDefine.OBJECT_TYPE.JAVASCRIPT) { MongoDBServerSideJavaScriptDAO jsDAO = (MongoDBServerSideJavaScriptDAO) selection.getFirstElement(); if (MessageDialog.openConfirm(getWindow().getShell(), Messages.get().Confirm, Messages.get().ObjectDeleteAction_42)) { try { MongoDBQuery.deleteJavaScirpt(userDB, jsDAO.getName()); refreshJS(); } catch (Exception e) { logger.error("MongoDB ServerSide JavaScript delelte", e); //$NON-NLS-1$ exeMessage("JavaScript", e); //$NON-NLS-1$ } } } }
From source file:net.sf.yal10n.svn.SVNUtil.java
/** * Utility method to combine a prefix and url to get the complete repository URL. * Duplicated slashed will be removed./*from w w w . j a v a2s.c o m*/ * @param repoPrefix the prefix * @param repoUrl the url * @return the complete repo url */ public static String toCompleteUrl(String repoPrefix, String repoUrl) { String prefix = StringUtils.trimToEmpty(repoPrefix); String suffix = StringUtils.trimToEmpty(repoUrl); if (!prefix.isEmpty() && !prefix.endsWith("/")) { prefix = prefix + "/"; } if (suffix.startsWith("/")) { suffix = suffix.substring(1); } if (suffix.endsWith("/")) { suffix = suffix.substring(0, suffix.lastIndexOf("/")); } return prefix + suffix; }
From source file:module.signature.util.XAdESValidator.java
/** * @author joantune// ww w . j a va 2 s .com * * Makes sure that the document which was signed is equal to the one * that was sent. It also checks to see if the signers are the * correct persons or not NOTE: It does note validate the validity * of the signature itself, only that what was sent was the same * that was receveived. * * To validate, see: * * @see XAdESValidator#validateXMLSignature(byte[]) * @param receivedContent * the received signature * @param originalContent * the byte array of what was sent to the signer * @param usersPermitted * Users that are permitted to be on the signature * @param usersExcluded * Users which must not be on the list of signers, or null/empty * list if none is excluded * @param allUsersPermittedShouldBeThere * if true, all of the users of <i>usersPermitted</i> must be on * the list of signers * @throws SignatureDataException * if any error has been observed, thus the validation fails */ public static void validateSentAndReceivedContent(String receivedContent, byte[] originalContent, Set<User> usersPermitted, Set<User> usersExcluded, boolean allUsersPermittedShouldBeThere) throws SignatureDataException { //let's validate the content. That is, what we received against what we sent and make sure it hasn't changed if (schemaXSD == null) { loadXAdESSchemas(); } //we know that we are receiving a XaDES-T signature boolean validSignature = false; try { //let's extract the signatureContent and compare it against what we sent //let's decode and interpret the XML file //making the objects to interpret the XML document DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder parser = dbf.newDocumentBuilder(); ErrorHandler eh = new ErrorHandler() { @Override public void warning(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void error(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } @Override public void fatalError(SAXParseException exception) throws SAXException { throw new UnsupportedOperationException("Not supported yet.", exception); } }; //let's decode the document byte[] signatureDecoded = Base64.decode(receivedContent); ByteArrayInputStream bais = new ByteArrayInputStream(signatureDecoded); // let's parse the document parser.setErrorHandler(eh); Document document = parser.parse(bais); NodeList fileContentNodeList = document.getElementsByTagName("FileContent"); //Even if we have more than one signature, we should only have one file content!! if not, let's throw an exception here if (fileContentNodeList.getLength() > 1) { throw new SignatureDataException("too.many.file.content.nodes.malformed.signature.document", true, null); } if (fileContentNodeList.getLength() < 1) { throw new SignatureDataException("no.file.content.nodes.in.received.signature", true, null); } Node fileContentNode = fileContentNodeList.item(0).getFirstChild(); //now finally, we can compare the content of this node with the one that we generated //debug lines: byte[] receivedDecodedByteContent = Base64.decode(fileContentNode.getNodeValue()); //ok, so let's parse this again to strings and then we can better compare them and maybe know exactly why they are different String originalEncodedContent = Base64.encodeBytes(originalContent); String originalDecodedContent = new String(Base64.decode(originalEncodedContent), Charset.forName("UTF-8")); String receivedDecodedContent = new String(receivedDecodedByteContent, Charset.forName("UTF-8")); //now let's //make sure the signature is from the right person //TODO uncomment the following line: // validateSigner(document, usersPermitted, usersExcluded, allUsersPermittedShouldBeThere); if (!StringUtils.equals(StringUtils.trimToEmpty(originalDecodedContent), StringUtils.trimToEmpty(receivedDecodedContent))) { // } throw new SignatureDataException("signature.content.sent.and.received.are.different"); } else { validSignature = true; } //TODO FENIX-196 assert if one should be notified of these errors } catch (IOException e1) { // e1.printStackTrace(); throw new SignatureDataException("error.decoding.base64.sig", e1); } catch (SAXException e) { // e.printStackTrace(); throw new SignatureDataException("error.parsing.received.signature.file", e); } catch (ParserConfigurationException e) { // e.printStackTrace(); throw new SignatureDataException("error.parsing.received.signature.file.parser.configuration", e); } if (!validSignature) { throw new SignatureDataException("invalid.signature.content"); } }
From source file:de.xirp.plugin.PluginManager.java
/** * Removes all white spaces from the given string which might have * been read from the XML file./*from w w w. j a va2 s .co m*/ * * @param mainClass * the string to remove the white spaces from * @return the string without white spaces */ public static String strip(String mainClass) { return StringUtils.trimToEmpty(mainClass); }
From source file:com.prowidesoftware.swift.model.field.Field95V.java
/** * Get the Name And Address as a concatenation of component2 to component11. * @return the Name And Address from components *//*from w ww . ja v a 2 s .c o m*/ public String getNameAndAddress() { StringBuilder result = new StringBuilder(); for (int i = 2; i < 12; i++) { if (StringUtils.isNotBlank(getComponent(i))) { if (result.length() > 0) { result.append(com.prowidesoftware.swift.io.writer.FINWriterVisitor.SWIFT_EOL); } result.append(StringUtils.trimToEmpty(getComponent(i))); } } return result.toString(); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopSuggestionField.java
protected void handleSearchInput() { JTextField searchEditor = getComboBoxEditorField(); String currentSearchString = StringUtils.trimToEmpty(searchEditor.getText()); if (!Objects.equals(currentSearchString, lastSearchString)) { lastSearchString = currentSearchString; if (searchExecutor != null) { if (asyncSearchWorker != null) { log.debug("Cancel previous search"); asyncSearchWorker.cancel(true); }/*from w w w . ja v a 2 s . co m*/ if (currentSearchString.length() >= minSearchStringLength) { Map<String, Object> params = null; if (searchExecutor instanceof ParametrizedSearchExecutor) { //noinspection unchecked params = ((ParametrizedSearchExecutor) searchExecutor).getParams(); } asyncSearchWorker = createSearchWorker(currentSearchString, params); asyncSearchWorker.execute(); } } } }