protected static String stripCommas(String string) { if (Utility.stringIsNullOrEmpty(string)) { return string; } return string.replace(',', ' ').trim(); }
@Override public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError, ServicePolicy policy) { if (outError == null) { outError = new AtomicReference<String>(); } if (!(policy instanceof TransactionalWebServicePolicy)) { outError.set("This rule only applies to Transactional Service Policies. " + outError.get()); } if (Utility.stringIsNullOrEmpty(outError.get())) { return true; } else { return false; } }
@Override public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError,ServicePolicy policy) { if (outError == null) { outError = new AtomicReference<String>(); } if (!(policy instanceof TransactionalWebServicePolicy)) { outError.set("This rule only applies to Transactional Service Policies. " + outError.get()); } if (Utility.stringIsNullOrEmpty(outError.get())) { return true; } else { return false; } }
/** * removes the trailing comma * * @param msg * @return */ private static String trimFaultMsg(String msg) { if (Utility.stringIsNullOrEmpty(msg)) { return ""; } String s = msg.trim(); if (s.endsWith(",")) { s = s.substring(0, s.length() - 1); } return s; }
HashMap getWSAgentIgnoreList() { HashMap IgnoreList = new HashMap(); String t = prop.getProperty("message.processor.ignoreList"); if (!Utility.stringIsNullOrEmpty(t)) { if (t.contains("|")) { String[] ts = t.split("\\|"); for (int i = 0; i < ts.length; i++) { IgnoreList.put(ts[i].toLowerCase(), false); } } else { IgnoreList.put(t.toLowerCase(), false); } } return IgnoreList; } private void EnsureFolderExists(String folder) throws ConfigurationException {
public long getDeadMessageQueueDuration() { String s = prop.getProperty("message.processor.dead.message.queue.duration"); long ret = 10000; if (!Utility.stringIsNullOrEmpty(s)) { try { ret = Long.parseLong(s); } catch (Exception ex) { log.warn("error parsing message.processor.dead.message.queue.duration"); } } if (ret < 10000) { ret = 10000; } return ret; }
/** * converts a list of string to a single string whitespace, null and empty * strings are ignored */ public static String listStringtoString(List<String> data) { if (data == null || data.isEmpty()) { return ""; } StringBuilder sb = new StringBuilder(); // String s = ""; for (int i = 0; i < data.size(); i++) { if (!stringIsNullOrEmpty(data.get(i))) { String t = data.get(i); t = t.trim(); if (!stringIsNullOrEmpty(t)) { sb = sb.append(t).append(" "); //s += t + " "; } } } return sb.toString().trim(); }
/** * used from tree view of home page, returns all nodes that have a * null or empty parent object * * @param completelist * @return */ public static List<ServiceType> GetParentNodes(List<ServiceType> completelist) { List<ServiceType> ret = new ArrayList<ServiceType>(); if (completelist == null || completelist.isEmpty()) { return ret; } for (int i = 0; i < completelist.size(); i++) { if (Utility.stringIsNullOrEmpty(completelist.get(i).getParentobject())) { ret.add(completelist.get(i)); } } return ret; }
/** * used on the index.jsp page of fgsms, finds a particular record * returned from fgsms.StatusService and returns the specific record. * */ public static GetStatusResponseMsg Findrecord(String url, List<GetStatusResponseMsg> list) { if (Utility.stringIsNullOrEmpty(url)) { return null; } if (list == null || list.isEmpty()) { return null; } for (int i = 0; i < list.size(); i++) { if (list.get(i).getURI().equalsIgnoreCase(url)) { GetStatusResponseMsg t = list.get(i); list.remove(i); return t; } } return null; }
/** * used from tree view of home page, returns all child nodes from * a given parent * * @param uri * @param completelist * @return */ public static List<ServiceType> GetChildNodes(String uri, List<ServiceType> completelist) { List<ServiceType> ret = new ArrayList<ServiceType>(); if (completelist == null || completelist.isEmpty()) { return ret; } for (int i = 0; i < completelist.size(); i++) { if (!Utility.stringIsNullOrEmpty(completelist.get(i).getParentobject())) { if (completelist.get(i).getParentobject().equalsIgnoreCase(uri)) { ret.add(completelist.get(i)); } } } return ret; }
@Override public boolean ValidateConfiguration(List<NameValuePair> params, AtomicReference<String> outError) { if (outError == null) { outError = new AtomicReference<String>(); } if (params == null || params.isEmpty()) { outError.set("The parameter 'Logger' is required for action " + this.GetDisplayName() +". " + outError.get()); } boolean foundLogger=false; for (int i = 0; i < params.size(); i++) { if (params.get(i).getName().equals("Logger")) { foundLogger=true; if (Utility.stringIsNullOrEmpty(params.get(i).getValue())) { outError.set("A value must be specified for the parameter 'Logger'. " + outError.get()); } } } if (!foundLogger) outError.set("The parameter 'Logger' is required. " + outError.get()); if (Utility.stringIsNullOrEmpty(outError.get())) { return true; } else { return false; } }
@Override public boolean ValidateConfiguration(FederationPolicy fp, AtomicReference<String> outMessage) { boolean ok = true; if (outMessage == null) { outMessage = new AtomicReference<String>(""); } FederationPolicyExt e = new FederationPolicyExt(fp); if (e.getPublishTimeRange().isEmpty()) { ok = false; outMessage.set("Time Range is required to have at least one value."); } if (Utility.stringIsNullOrEmpty(e.getBindingKey())) { ok = false; outMessage.set("A binding key is required for publication."); } return ok; }
/** * encrypts a password AES 256 bit Requires the Unlimited Strength Crypto * Extensions * * @param clear * @return */ public static String EN(String clear) { if (stringIsNullOrEmpty(clear)) { return ""; } try { return AES.EN(clear); } catch (Exception ex) { log.log(Level.FATAL, "############################################# fgsms cannot encrypt! Check to make sure the unlimited strength JCE is installed: " + ex.getMessage()); } return ""; }
/** * Decrypts a password or other sensitive data. If the parameter is null or * empty, an empty string is returned. If the parameter is not encrypted or * was encrypted using a different key or it fails to decrypt, the original * text is returned. * * @param cipher * @return */ public static String DE(String cipher) { if (stringIsNullOrEmpty(cipher)) { return ""; } try { return AES.DE(cipher); } catch (Exception ex) { log.log(Level.FATAL, "############################################# fgsms cannot decrypt! Check to make sure the unlimited strength JCE is installed: " + ex.getMessage()); } return cipher; }
@Override public ArrayList<String> getUsersfromXpath(ArrayOfXPathExpressionType xpaths, String message) { ArrayList<String> userlist = new ArrayList<String>(); if (xpaths == null || xpaths.getXPathExpressionType() == null || xpaths.getXPathExpressionType().isEmpty()) { return new ArrayList<String>(); } try { InputStream is = new ByteArrayInputStream(message.getBytes(Constants.CHARSET)); Document xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is); for (int i = 0; i < xpaths.getXPathExpressionType().size(); i++) { XPath xpath = XPathFactory.newInstance().newXPath(); javax.xml.xpath.XPathExpression xp = xpath.compile(xpaths.getXPathExpressionType().get(i).getXPath()); String t2 = (String) xp.evaluate(xmlDocument, XPathConstants.STRING); if (!Utility.stringIsNullOrEmpty(t2)) { userlist.add(t2); } } } catch (Exception ex) { log.log(Level.WARN, "Error evaluating xpath expression for consumer identification", ex); } return userlist; }
@Override public void processMessageOutput(String HashCode, String responseXML, int responseSize, boolean isFault, Long dod, HashMap headers, String relatedTransaction) { long now = System.currentTimeMillis(); log.log(Level.TRACE, "MessageProcessor.ProcessMessageOutput0 timer: " + (System.currentTimeMillis() - now) + " thread:" + Thread.currentThread().getId()); MessageCorrelator mc = (MessageCorrelator) messageMap.get(HashCode); if (mc == null) { log.log(Level.DEBUG, "fgsms ProcessOutboundMessage, MsgMap:" + messageMap.size() + " Outbound Queue:" + outboundQueue.size()); log.log(Level.WARN, "fgsms on processMessageOutput, a corresponding request could not be paired to the " + "response with id " + HashCode + ". It's possible that property message.processor.dead.message.queue.duration is set too low in the" + " fgsms-agent.properties file. This shouldn't happen often, if it does, please contact the fgsms developers at https://github.com/mil-oss/fgsms"); removeDeadMessage(); run(); return; } if (!Utility.stringIsNullOrEmpty(relatedTransaction)) { mc.RelatedMsgId = relatedTransaction; } processMessageOutput(HashCode, responseXML, responseSize, isFault, dod, headers); }
private String Login(String username, String password) { if (Utility.stringIsNullOrEmpty(username) || Utility.stringIsNullOrEmpty(password)) { return ""; } if (uddiauth != AuthMode.Uddi) { return ""; } //return "";/* GetAuthToken request = new GetAuthToken(); request.setUserID(username); request.setCred(Utility.DE(password)); try { AuthToken response = security.getAuthToken(request); return response.getAuthInfo(); } catch (Exception ex) { log.log(Level.ERROR, "Error authenticating to the UDDI server: ", ex); throw new IllegalArgumentException("can't authenticate to UDDI with the provided credentials"); //return ""; } }
private String login(String username, String password) { if (Utility.stringIsNullOrEmpty(username) || Utility.stringIsNullOrEmpty(password)) { return ""; } if (uddiauth != AuthMode.Uddi) { return ""; } //return "";/* GetAuthToken request = new GetAuthToken(); request.setUserID(username); request.setCred(Utility.DE(password)); try { AuthToken response = security.getAuthToken(request); return response.getAuthInfo(); } catch (Exception ex) { log.log(Level.ERROR, "Error authenticating to the UDDI server: ", ex); throw new IllegalArgumentException("can't authenticate to UDDI with the provided credentials"); //return ""; } } ///
private String Login(String username, String encryptedpassword) { if (Utility.stringIsNullOrEmpty(username) || Utility.stringIsNullOrEmpty(encryptedpassword)) { return ""; } //return "";/* GetAuthToken request = new GetAuthToken(); request.setUserID(username); request.setCred(Utility.DE(encryptedpassword)); try { AuthToken response = security.getAuthToken(request); return response.getAuthInfo(); } catch (Exception ex) { log.log(Level.ERROR, "Error authenticating to the UDDI server: ", ex); good = false; return ""; } }
/** * creates a new send an email sla action * * @param from * @param subject * @param body * @return */ public static SLAAction newEmailAction(String from, String subject, String body) { SLAAction r = new SLAAction(); r.setImplementingClassName("org.miloss.fgsms.sla.actions.EmailAlerter"); if (!stringIsNullOrEmpty(from)) { r.getParameterNameValue().add(newNameValuePair("From", from, false, false)); } r.getParameterNameValue().add(newNameValuePair("Body", body, false, false)); r.getParameterNameValue().add(newNameValuePair("Subject", subject, false, false)); return r; }