Java Code Examples for org.apache.commons.lang3.ArrayUtils#toString()

The following examples show how to use org.apache.commons.lang3.ArrayUtils#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrustServiceStatusListSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static boolean isValid(String xml) {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes("UTF-8"), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      }

      X509Certificate cert = signatureResult.getSigningCert();
      if (cert.getExtendedKeyUsage().contains("0.4.0.2231.3.0")) {
         LOG.debug("ExtendedKeyUsage correct. OID 0.4.0.2231.3.0 found.");
         dumpTsloStore();
         return match(baseOnCert(cert)) || match(basedOnPublicKey(cert));
      }
   } catch (Exception var4) {
      LOG.error("Unable to verify signature Reason:" + var4.getMessage(), var4);
   }

   return false;
}
 
Example 2
Source File: TrustServiceStatusListSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static boolean isValid(String xml) {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes("UTF-8"), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      }

      X509Certificate cert = signatureResult.getSigningCert();
      if (cert.getExtendedKeyUsage().contains("0.4.0.2231.3.0")) {
         LOG.debug("ExtendedKeyUsage correct. OID 0.4.0.2231.3.0 found.");
         dumpTsloStore();
         return match(baseOnCert(cert)) || match(basedOnPublicKey(cert));
      }
   } catch (Exception var4) {
      LOG.error("Unable to verify signature Reason:" + var4.getMessage(), var4);
   }

   return false;
}
 
Example 3
Source File: TrustServiceStatusListSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
public static boolean isValid(String xml) {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes("UTF-8"), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      }

      X509Certificate cert = signatureResult.getSigningCert();
      if (cert.getExtendedKeyUsage().contains("0.4.0.2231.3.0")) {
         LOG.debug("ExtendedKeyUsage correct. OID 0.4.0.2231.3.0 found.");
         dumpTsloStore();
         return match(baseOnCert(cert)) || match(basedOnPublicKey(cert));
      }
   } catch (Exception var4) {
      LOG.error("Unable to verify signature Reason:" + var4.getMessage(), var4);
   }

   return false;
}
 
Example 4
Source File: LangTest.java    From java-study with Apache License 2.0 5 votes vote down vote up
public static void test() {
	// 1 合并两个数组: org.apache.commons.lang. ArrayUtils
	String[] s1 = new String[] { "1", "2", "3" };
	String[] s2 = new String[] { "a", "b", "c" };
	String[] s = (String[]) ArrayUtils.addAll(s1, s2);
	for (int i = 0; i < s.length; i++) {
		System.out.println(s[i]);
	}
	String str = ArrayUtils.toString(s);
	str = str.substring(1, str.length() - 1);
	System.out.println(str + ">>" + str.length());

	System.out.println("测试截取:" + StringUtils.substringAfter("SELECT * FROM PERSON ", "FROM"));
	// 3 判断该字符串是不是为数字(0~9)组成,如果是,返回true 但该方法不识别有小数点和 请注意。
	System.out.println("数字判断:" + StringUtils.isNumeric("454534"));
	System.out.println("取得类名:" + ClassUtils.getShortClassName(LangTest.class));
	System.out.println("获取包名:" + ClassUtils.getPackageName(LangTest.class));

	System.out.println("是否是数字:" + NumberUtils.isCreatable("123"));
	System.out.println("随机数字和字母:" + RandomStringUtils.randomAlphanumeric(5));
	System.out.println("<>进行转义" + StringEscapeUtils.escapeHtml("<html>"));

	System.out.println("是否是null字符 :" + StringUtils.isBlank(null));
	System.out.println("是否是空字符 :" + StringUtils.isBlank(""));
	System.out.println("是否是空格字符 :" + StringUtils.isBlank("   "));
	System.out.println("分割数组:" + StringUtils.join(s1, ","));
	System.out.println("添加某个字符,使其长度等于所设置的:" + StringUtils.rightPad("abc", 6, 'T'));
	System.out.println("首字母大写:" + StringUtils.capitalize("abc"));
	System.out.println("去掉空格:" + StringUtils.deleteWhitespace("   ab  c  "));
	System.out.println("是否包含该字符:" + StringUtils.contains("abc", "ba"));
	System.out.println("表示左边的字符:" + StringUtils.left("abc", 2));
}
 
Example 5
Source File: UnderSamplingByMaskingMultiDataSetPreProcessor.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * Will change the default minority label from "1" to "0" and correspondingly the majority class from "0" to "1"
 * for the label at the index specified
 */
public void overrideMinorityDefault(int index) {
    if (targetMinorityDistMap.containsKey(index)) {
        minorityLabelMap.put(index, 0);
    } else {
        throw new IllegalArgumentException(
                        "Index specified is not contained in the target minority distribution map specified with the preprocessor. Map contains "
                                        + ArrayUtils.toString(targetMinorityDistMap.keySet().toArray()));
    }
}
 
Example 6
Source File: AbstractSpringConfigurablePlugin.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void beforeRun(Outline outline, Options options) throws Exception {
	super.beforeRun(outline, options);
	final String[] configLocations = getConfigLocations();
	if (!ArrayUtils.isEmpty(configLocations)) {
		final String configLocationsString = ArrayUtils
				.toString(configLocations);
		logger.debug("Loading application context from ["
				+ configLocationsString + "].");
		try {
			applicationContext = new FileSystemXmlApplicationContext(
					configLocations, false);
			applicationContext.setClassLoader(Thread.currentThread()
					.getContextClassLoader());
			applicationContext.refresh();
			if (getAutowireMode() != AutowireCapableBeanFactory.AUTOWIRE_NO) {
				applicationContext.getBeanFactory().autowireBeanProperties(
						this, getAutowireMode(), isDependencyCheck());
			}
		} catch (Exception ex) {
			ex.printStackTrace();
			ex.getCause().printStackTrace();
			logger.error("Error loading applicaion context from ["
					+ configLocationsString + "].", ex);
			throw new BadCommandLineException(
					"Error loading  applicaion context from ["
							+ configLocationsString + "].", ex);
		}
	}
}
 
Example 7
Source File: MqttUnsubscribePayload.java    From mithqtt with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this)
            + '['
            + "topics=" + ArrayUtils.toString(topics)
            + ']';
}
 
Example 8
Source File: MqttSubscribePayload.java    From mithqtt with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this)
            + '['
            + "subscriptions=" + ArrayUtils.toString(subscriptions)
            + ']';
}
 
Example 9
Source File: MqttSubAckPayload.java    From mithqtt with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this)
            + '['
            + "grantedQoSLevels=" + ArrayUtils.toString(grantedQoSLevels)
            + ']';
}
 
Example 10
Source File: EntityFacade.java    From cukes with Apache License 2.0 5 votes vote down vote up
private String toString(Object value) throws NamingException {
    try {
        if (value instanceof byte[]) {
            return new String((byte[]) value, "UTF-8");
        } else if (value instanceof char[]) {
            return new String((char[]) value);
        } else if (value.getClass().isArray()) {
            return ArrayUtils.toString(value);
        }
        return value.toString();
    } catch (UnsupportedEncodingException e) {
        throw new CucumberException("Failed to convert value to string", e);
    }
}
 
Example 11
Source File: UnderSamplingByMaskingMultiDataSetPreProcessor.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * Will change the default minority label from "1" to "0" and correspondingly the majority class from "0" to "1"
 * for the label at the index specified
 */
public void overrideMinorityDefault(int index) {
    if (targetMinorityDistMap.containsKey(index)) {
        minorityLabelMap.put(index, 0);
    } else {
        throw new IllegalArgumentException(
                        "Index specified is not contained in the target minority distribution map specified with the preprocessor. Map contains "
                                        + ArrayUtils.toString(targetMinorityDistMap.keySet().toArray()));
    }
}
 
Example 12
Source File: NumpyArray.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
private void setND4JArray() {

        long size = 1;
        for (long d : shape) {
            size *= d;
        }

        String cacheKey = address + "_" + size + "_" + dtype + "_" + ArrayUtils.toString(strides);
        nd4jArray = arrayCache.get(cacheKey);
        if (nd4jArray == null) {
            Pointer ptr = nativeOps.pointerForAddress(address);
            ptr = ptr.limit(size);
            ptr = ptr.capacity(size);
            DataBuffer buff = Nd4j.createBuffer(ptr, size, dtype);

            int elemSize = buff.getElementSize();
            long[] nd4jStrides = new long[strides.length];
            for (int i = 0; i < strides.length; i++) {
                nd4jStrides[i] = strides[i] / elemSize;
            }

            nd4jArray = Nd4j.create(buff, shape, nd4jStrides, 0, Shape.getOrder(shape, nd4jStrides, 1), dtype);
            arrayCache.put(cacheKey, nd4jArray);
        }
        else{
            if (!Arrays.equals(nd4jArray.shape(), shape)){
                nd4jArray = nd4jArray.reshape(shape);
            }
        }
        Nd4j.getAffinityManager().ensureLocation(nd4jArray, AffinityManager.Location.HOST);
    }
 
Example 13
Source File: StatusPageSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static boolean isValid(String xml) throws TechnicalConnectorException {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes(), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      } else {
         return true;
      }
   } catch (Exception var3) {
      LOG.error("Unable to verify signature Reason:" + var3.getMessage(), var3);
      return false;
   }
}
 
Example 14
Source File: StatusPageSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static boolean isValid(String xml) throws TechnicalConnectorException {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes(), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      } else {
         return true;
      }
   } catch (Exception var3) {
      LOG.error("Unable to verify signature Reason:" + var3.getMessage(), var3);
      return false;
   }
}
 
Example 15
Source File: StatusPageSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static boolean isValid(String xml) throws TechnicalConnectorException {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes(), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      } else {
         return true;
      }
   } catch (Exception var3) {
      LOG.error("Unable to verify signature Reason:" + var3.getMessage(), var3);
      return false;
   }
}
 
Example 16
Source File: TensorTest.java    From pacaya with Apache License 2.0 5 votes vote down vote up
private void auxTestMatlabIndex(int configIx, int[] dims, int... expected) {
    ArrayUtils.toString(expected);
    int[] observed = Tensor.unravelIndexMatlab(configIx, dims);
    System.out.println(String.format("expected: %s\nobserved: %s", ArrayUtils.toString(expected), ArrayUtils.toString(observed)));
    org.junit.Assert.assertArrayEquals(expected, observed);
    org.junit.Assert.assertEquals(configIx, Tensor.ravelIndexMatlab(expected, dims));
}
 
Example 17
Source File: StatusPageSignatureVerifier.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public static boolean isValid(String xml) throws TechnicalConnectorException {
   try {
      Map<String, Object> options = new HashMap();
      SignatureVerificationResult signatureResult = SignatureBuilderFactory.getSignatureBuilder(AdvancedElectronicSignatureEnumeration.XAdES).verify(xml.getBytes(), options);
      if (!signatureResult.isValid()) {
         throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_SIGNATURE_VALIDATION, new Object[]{ArrayUtils.toString(signatureResult.getErrors().toArray())});
      } else {
         return true;
      }
   } catch (Exception var3) {
      LOG.error("Unable to verify signature Reason:" + var3.getMessage(), var3);
      return false;
   }
}
 
Example 18
Source File: Server.java    From riiablo with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  return ArrayUtils.toString(clients);
}
 
Example 19
Source File: ArrayOperations.java    From tutorials with MIT License 4 votes vote down vote up
public static String printObjectArray(Integer[] array) {
    return ArrayUtils.toString(array);
}
 
Example 20
Source File: ArrayOperations.java    From tutorials with MIT License 4 votes vote down vote up
public static String printIntArray(int[][] array) {
    return ArrayUtils.toString(array);
}