import java.net.URLConnection;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.Base64;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.util.typedef.internal.U;
-import static org.apache.ignite.internal.util.GridUnsafe.encodeBase64;
-
/**
*
*/
md.update(s.getBytes());
- String hash = encodeBase64(md.digest());
+ String hash = Base64.getEncoder().encodeToString(md.digest());
return ts + ":" + hash;
}
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
+import java.util.Base64;
import java.util.Collection;
import java.util.Collections;
import java.util.StringTokenizer;
import org.apache.ignite.lang.IgniteBiTuple;
import org.jetbrains.annotations.Nullable;
-import static org.apache.ignite.internal.util.GridUnsafe.encodeBase64;
-
/**
* Abstract protocol adapter.
*/
md.update(s.getBytes(UTF_8));
- String compHash = encodeBase64(md.digest());
+ String compHash = Base64.getEncoder().encodeToString(md.digest());
return hash.equalsIgnoreCase(compHash);
}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.util;
-
-/**
- * BASE64 encoder interface.
- *
- * @deprecated Temporary interface. Use {@code java.util.Base64} directly instead.
- */
-@Deprecated
-public interface Base64Encoder {
- /**
- * Encodes given byte array.
- *
- * @return Encoded string.
- */
- public String encode(byte[] msg);
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.util;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Implementation of {@link Base64Encoder} interface for Java 8 and later.
- *
- * @deprecated Use {@code java.util.Base64} directly instead.
- */
-@Deprecated
-public class Base64EncoderImpl implements Base64Encoder {
- /** {@inheritDoc} */
- @Override public String encode(byte[] msg) {
- try {
- Object encoder = Class.forName("java.util.Base64").getDeclaredMethod("getEncoder").invoke(null);
-
- Class<?> encCls = Class.forName("java.util.Base64$Encoder");
-
- Method encMtd = encCls.getDeclaredMethod("encodeToString", byte[].class);
-
- return (String)encMtd.invoke(encoder, (Object)msg);
- }
- catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
- throw new RuntimeException("Failed to encode Base64 message", e);
- }
- }
-}
? new ReflectiveDirectBufferCleaner()
: new UnsafeDirectBufferCleaner();
- /** */
- private static final Base64Encoder BASE64_ENC =
- majorJavaVersion(jdkVersion()) < 8
- ? new LegacyBase64Encoder()
- : new Base64EncoderImpl();
-
/** JavaNioAccess object. */
private static final Object JAVA_NIO_ACCESS_OBJ = javaNioAccessObject();
UNSAFE.putByte(addr, (byte)(val));
}
}
-
- /**
- * Encodes bytes into Base64 string.
- *
- * @param msg Message to encode.
- * @return Encoded message.
- */
- public static String encodeBase64(byte[] msg) {
- return BASE64_ENC.encode(msg);
- }
-}
\ No newline at end of file
+}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.util;
-
-import java.lang.reflect.Method;
-
-/**
- * Implementation of {@link Base64Encoder} interface for Java 7 and earlier.
- *
- * @deprecated Use {@code jaba.util.Base64} instead.
- */
-@Deprecated
-public class LegacyBase64Encoder implements Base64Encoder {
- /** {@inheritDoc} */
- @Override public String encode(byte[] msg) {
- try {
- Class<?> encoderCls = Class.forName("sun.misc.BASE64Encoder");
-
- Method mtd = encoderCls.getMethod("encode", byte[].class);
-
- return (String)mtd.invoke(encoderCls.newInstance(), (Object)msg);
- }
- catch (ReflectiveOperationException e) {
- throw new RuntimeException("Failed to encode message to BASE64", e);
- }
- }
-}