Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
smthing committed Sep 5, 2024
1 parent a2fd1c4 commit 5f40810
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.NetworkInterface;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -123,6 +121,7 @@ private void loadLicense() {
licenseTO = loadLicense(entity);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(":: Licensed to " + ConsoleColors.BOLD + ConsoleColors.ANSI_UNDERLINE_ON + ConsoleColors.BLUE + licenseTO.getApplicant() + ConsoleColors.ANSI_RESET + " until " + ConsoleColors.BOLD + ConsoleColors.ANSI_UNDERLINE_ON + ConsoleColors.BLUE + sdf.format(new Date(licenseTO.getExpireTime())) + ConsoleColors.ANSI_RESET);
System.out.println(":: SN: " + ConsoleColors.BOLD + ConsoleColors.ANSI_UNDERLINE_ON + licenseTO.getSn() + ConsoleColors.RESET);
System.out.println(":: Copyright© " + licenseTO.getVendor() + " ,E-mail: " + licenseTO.getContact());
if (licenseTO.getTrialDuration() > 0) {
System.out.println(ConsoleColors.RED + ":: Trial: " + licenseTO.getTrialDuration() + " minutes" + ConsoleColors.RESET);
Expand Down Expand Up @@ -151,28 +150,25 @@ private LicenseTO loadLicense(LicenseEntity entity) throws IOException {

private List<String> getMacAddresses() {
List<String> macs = new ArrayList<>();
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
byte[] mac = networkInterface.getHardwareAddress();
if (mac != null) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < mac.length; i++) {
sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
}
macs.add(sb.toString());
}
}
} catch (Exception e) {
e.printStackTrace();
}
// try {
// Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
// while (networkInterfaces.hasMoreElements()) {
// NetworkInterface networkInterface = networkInterfaces.nextElement();
// byte[] mac = networkInterface.getHardwareAddress();
// if (mac != null) {
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < mac.length; i++) {
// sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));
// }
// macs.add(sb.toString());
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
return macs;
}

public LicenseTO getLicenseTO() {
return licenseTO;
}

static class ConsoleColors {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public HttpSessionImpl getSession(HttpServletRequestImpl request, HttpServletRes
if (response.isCommitted()) {
throw new IllegalStateException("response has already committed!");
}
//该sessionId生成策略缺乏安全性,后续重新设计
httpSession = new HttpSessionImpl(this, createSessionId(), request.getServletContext()) {
@Override
public void invalid() {
Expand Down

0 comments on commit 5f40810

Please sign in to comment.