001/** 002 * 003 * Copyright 2014 the original author or authors 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smack.java7; 018 019import java.util.List; 020 021import org.jivesoftware.smack.SmackConfiguration; 022import org.jivesoftware.smack.initializer.SmackInitializer; 023import org.jivesoftware.smack.util.DNSUtil; 024import org.jivesoftware.smack.util.StringTransformer; 025import org.jivesoftware.smack.util.stringencoder.Base64; 026import org.jivesoftware.smack.util.stringencoder.Base64UrlSafeEncoder; 027import org.jivesoftware.smack.util.stringencoder.java7.Java7Base64Encoder; 028import org.jivesoftware.smack.util.stringencoder.java7.Java7Base64UrlSafeEncoder; 029 030public class Java7SmackInitializer implements SmackInitializer { 031 032 @Override 033 public List<Exception> initialize() { 034 SmackConfiguration.setDefaultHostnameVerifier(new Java7HostnameVerifier()); 035 Base64.setEncoder(Java7Base64Encoder.getInstance()); 036 Base64UrlSafeEncoder.setEncoder(Java7Base64UrlSafeEncoder.getInstance()); 037 DNSUtil.setIdnaTransformer(new StringTransformer() { 038 @Override 039 public String transform(String string) { 040 return java.net.IDN.toASCII(string); 041 } 042 }); 043 return null; 044 } 045 046}