@Override public List<Exception> initialize() { if (SystemUtil.onAndroid()) { // @formatter:off throw new RuntimeException( "You need to remove the smack-java7 dependency/jar from your build, " + "as it does not run on Android. " + "Use smack-android instead."); // @formatter:on } SmackConfiguration.setDefaultHostnameVerifier(new Java7HostnameVerifier()); Base64.setEncoder(Java7Base64Encoder.getInstance()); Base64UrlSafeEncoder.setEncoder(Java7Base64UrlSafeEncoder.getInstance()); DNSUtil.setIdnaTransformer(new StringTransformer() { @Override public String transform(String string) { return java.net.IDN.toASCII(string); } }); return null; }
/** * SASLprep the given String. * * @param string the String to sasl prep. * @return the given String SASL preped * @see <a href="http://tools.ietf.org/html/rfc4013">RFC 4013 - SASLprep: Stringprep Profile for User Names and Passwords</a> */ protected static String saslPrep(String string) { StringTransformer stringTransformer = saslPrepTransformer; if (stringTransformer != null) { return stringTransformer.transform(string); } return string; }
/** * Set the SASLPrep StringTransformer. * <p> * A simple SASLPrep StringTransformer would be for example: <code>java.text.Normalizer.normalize(string, Form.NFKC);</code> * </p> * * @param stringTransformer set StringTransformer to use for SASLPrep. * @see <a href="http://tools.ietf.org/html/rfc4013">RFC 4013 - SASLprep: Stringprep Profile for User Names and Passwords</a> */ public static void setSaslPrepTransformer(StringTransformer stringTransformer) { saslPrepTransformer = stringTransformer; }