Skip to content

1.7.4 #77

Merged
merged 2 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion core/src/main/java/ru/tinkoff/acquiring/sdk/AcquiringSdk.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@

package ru.tinkoff.acquiring.sdk;

import java.math.BigInteger;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import ru.tinkoff.acquiring.sdk.requests.AddCardRequest;
Expand Down Expand Up @@ -415,7 +419,11 @@ private String getIpAddress() {
for (Enumeration<InetAddress> enumIpAddr = networkInterface.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress();
if (inetAddress instanceof Inet6Address) {
return formatIpv6Address(inetAddress);
} else {
return inetAddress.getHostAddress();
}
}
}
}
Expand All @@ -424,4 +432,24 @@ private String getIpAddress() {
}
return "";
}

private String formatIpv6Address(InetAddress address) {
String strAddress = new BigInteger(1, address.getAddress()).toString(16);
List<String> strings = new ArrayList<>();

int i = 0;
while (i < strAddress.length()) {
strings.add(strAddress.substring(i, Math.min(i + 4, strAddress.length())));
i += 4;
}

StringBuilder stringBuilder = new StringBuilder();
for (int j = 0; j < strings.size(); j++) {
stringBuilder.append(strings.get(j));
if (j != strings.size() - 1) {
stringBuilder.append(":");
}
}
return stringBuilder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SessionParams {
private static final String SDK_TERMINAL_ID = "TestSDK";
private static final String NON_3DS_TERMINAL_ID = "sdkNon3DS";

private static final String PASSWORD = "5l9v23g7hlhqchyb";
private static final String PASSWORD = "12345678";
private static final String PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5Yg3RyEkszggDVMDHCAG\n" +
"zJm0mYpYT53BpasrsKdby8iaWJVACj8ueR0Wj3Tu2BY64HdIoZFvG0v7UqSFztE/\n" +
"zUvnznbXVYguaUcnRdwao9gLUQO2I/097SHF9r++BYI0t6EtbbcWbfi755A1EWfu\n" +
Expand Down