Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
chore: introduce HessianSerializerFactoryWithBlackList
Browse files Browse the repository at this point in the history
  • Loading branch information
linux-china committed Mar 17, 2024
1 parent 04ca8d6 commit 181821d
Showing 1 changed file with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import com.alibaba.rsocket.encoding.ObjectEncodingHandler;
import com.alibaba.rsocket.metadata.RSocketMimeType;
import com.alibaba.rsocket.observability.RsocketErrorCode;
import com.caucho.hessian.io.*;
import com.caucho.hessian.io.HessianSerializerInput;
import com.caucho.hessian.io.HessianSerializerOutput;
import com.caucho.hessian.io.SerializerFactory;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
Expand All @@ -15,22 +17,14 @@

import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
* object encoding handler hessian implementation
*
* @author leijuan
*/
public class ObjectEncodingHandlerHessianImpl implements ObjectEncodingHandler {
public static final Set<String> BLACK_CLASSES = new HashSet<>();
public static final SerializerFactory serializerFactory = new SerializerFactoryWithBlackList();

static {
BLACK_CLASSES.add("org.springframework.context.support.ClassPathXmlApplicationContext");
BLACK_CLASSES.add("javax.swing.UIDefaults$ProxyLazyValue");
}
public static final SerializerFactory serializerFactory = new HessianSerializerFactoryWithBlackList();

@NotNull
@Override
Expand Down Expand Up @@ -103,13 +97,4 @@ public static Object decode(@Nullable ByteBuf byteBuf) throws IOException {

}

public static class SerializerFactoryWithBlackList extends SerializerFactory {
@Override
public Deserializer getObjectDeserializer(String type, Class cl) throws HessianProtocolException {
if (BLACK_CLASSES.contains(type)) {
throw new HessianProtocolException(RsocketErrorCode.message("RST-700401", type));
}
return super.getObjectDeserializer(type, cl);
}
}
}

0 comments on commit 181821d

Please sign in to comment.