feat: support hessian packer (#36)

This commit is contained in:
ReaJason
2025-02-20 22:28:34 +08:00
parent 4a7301c7f0
commit f3ced55d8a
22 changed files with 349 additions and 49 deletions
+8 -7
View File
@@ -28,6 +28,7 @@ dependencies {
cb170 'commons-beanutils:commons-beanutils:1.7.0'
cb161 'commons-beanutils:commons-beanutils:1.6.1'
implementation 'com.caucho:hessian:4.0.66'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
@@ -35,18 +36,18 @@ war {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
doFirst {
delete "${webAppDir}/WEB-INF/dep"
delete "src/main/webapp/WEB-INF/dep"
copy { from configurations.cb110 into "${webAppDir}/WEB-INF/dep" }
copy { from configurations.cb194 into "${webAppDir}/WEB-INF/dep" }
copy { from configurations.cb183 into "${webAppDir}/WEB-INF/dep" }
copy { from configurations.cb170 into "${webAppDir}/WEB-INF/dep" }
copy { from configurations.cb161 into "${webAppDir}/WEB-INF/dep" }
copy { from configurations.cb110 into "src/main/webapp/WEB-INF/dep" }
copy { from configurations.cb194 into "src/main/webapp/WEB-INF/dep" }
copy { from configurations.cb183 into "src/main/webapp/WEB-INF/dep" }
copy { from configurations.cb170 into "src/main/webapp/WEB-INF/dep" }
copy { from configurations.cb161 into "src/main/webapp/WEB-INF/dep" }
}
}
clean {
delete "${webAppDir}/WEB-INF/dep"
delete "src/main/webapp/WEB-INF/dep"
}
test {
@@ -0,0 +1,28 @@
import com.caucho.hessian.io.AbstractHessianInput;
import com.caucho.hessian.io.Hessian2Input;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Base64;
/**
* @author ReaJason
* @since 2025/2/20
*/
@WebServlet("/hessian2")
public class Hessian2ReadObjServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String data = req.getParameter("data");
byte[] base64 = Base64.getDecoder().decode(data);
ByteArrayInputStream bis = new ByteArrayInputStream(base64);
AbstractHessianInput in = new Hessian2Input(bis);
in.readObject();
}
}
@@ -0,0 +1,28 @@
import com.caucho.hessian.io.AbstractHessianInput;
import com.caucho.hessian.io.HessianInput;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Base64;
/**
* @author ReaJason
* @since 2025/2/20
*/
@WebServlet("/hessian")
public class HessianReadObjServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String data = req.getParameter("data");
byte[] base64 = Base64.getDecoder().decode(data);
ByteArrayInputStream bis = new ByteArrayInputStream(base64);
AbstractHessianInput in = new HessianInput(bis);
in.readObject();
}
}