refactor: 优化代码.

移除未使用 import, 移除废弃的注释代码.
This commit is contained in:
LamGC 2021-08-15 13:30:41 +08:00
parent 4b03b7cc1e
commit e8cc82e321
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
5 changed files with 2 additions and 29 deletions

View File

@ -13,7 +13,6 @@ import com.oracle.bmc.identity.requests.GetUserRequest;
import com.oracle.bmc.identity.responses.GetUserResponse; import com.oracle.bmc.identity.responses.GetUserResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;

View File

@ -1,7 +1,6 @@
package net.lamgc.oracle.sentry.common; package net.lamgc.oracle.sentry.common;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
public class OutputStreamWrapper extends OutputStream { public class OutputStreamWrapper extends OutputStream {

View File

@ -4,10 +4,8 @@ import com.google.common.base.Strings;
import com.google.gson.*; import com.google.gson.*;
import org.apache.sshd.common.config.keys.KeyUtils; import org.apache.sshd.common.config.keys.KeyUtils;
import org.apache.sshd.common.config.keys.PublicKeyEntry; import org.apache.sshd.common.config.keys.PublicKeyEntry;
import org.apache.sshd.common.config.keys.PublicKeyEntryDataResolver;
import org.apache.sshd.common.config.keys.PublicKeyEntryDecoder; import org.apache.sshd.common.config.keys.PublicKeyEntryDecoder;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
@ -23,6 +21,8 @@ public final class SshAuthInfoSerializer implements JsonSerializer<SshAuthInfo>,
public final static SshAuthInfoSerializer INSTANCE = new SshAuthInfoSerializer(); public final static SshAuthInfoSerializer INSTANCE = new SshAuthInfoSerializer();
private SshAuthInfoSerializer() {}
@Override @Override
public SshAuthInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public SshAuthInfo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (!json.isJsonObject()) { if (!json.isJsonObject()) {
@ -109,22 +109,6 @@ public final class SshAuthInfoSerializer implements JsonSerializer<SshAuthInfo>,
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
PublicKeyEntry.appendPublicKeyEntry(builder, key); PublicKeyEntry.appendPublicKeyEntry(builder, key);
return builder.toString(); return builder.toString();
/*
// 以下代码改写自 KnownHosts 的那个认证器, 说实话翻一下官方代码还可以找到不错的东西.
@SuppressWarnings("unchecked") PublicKeyEntryDecoder<PublicKey, ?> decoder
= (PublicKeyEntryDecoder<PublicKey, ?>) KeyUtils.getPublicKeyEntryDecoder(key);
if (decoder == null) {
throw new JsonParseException("Cannot retrieve decoder for key=" + key.getAlgorithm());
}
try (ByteArrayOutputStream s = new ByteArrayOutputStream(Byte.MAX_VALUE)) {
String keyType = decoder.encodePublicKey(s, key);
byte[] bytes = s.toByteArray();
PublicKeyEntryDataResolver encoder = PublicKeyEntry.resolveKeyDataEntryResolver(keyType);
return encoder.encodeEntryKeyData(bytes);
} catch (IOException e) {
throw new RuntimeException(e);
}*/
} }
} }

View File

@ -1,8 +1,5 @@
package net.lamgc.oracle.sentry.script; package net.lamgc.oracle.sentry.script;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
/** /**
* @author LamGC * @author LamGC
*/ */

View File

@ -1,17 +1,11 @@
package net.lamgc.oracle.sentry.script.groovy; package net.lamgc.oracle.sentry.script.groovy;
import net.lamgc.oracle.sentry.ComputeInstanceManager;
import net.lamgc.oracle.sentry.script.*;
import groovy.lang.Closure; import groovy.lang.Closure;
import groovy.lang.DelegatesTo; import groovy.lang.DelegatesTo;
import net.lamgc.oracle.sentry.script.groovy.trigger.*; import net.lamgc.oracle.sentry.script.groovy.trigger.*;
import net.lamgc.oracle.sentry.script.tools.http.ScriptHttpClient; import net.lamgc.oracle.sentry.script.tools.http.ScriptHttpClient;
import org.codehaus.groovy.runtime.DefaultGroovyMethods; import org.codehaus.groovy.runtime.DefaultGroovyMethods;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
/** /**
* Groovy DSL 脚本的父类. * Groovy DSL 脚本的父类.
* @author LamGC * @author LamGC