Skip to content

Instantly share code, notes, and snippets.

@techforum-repo
Created November 17, 2020 23:38
Show Gist options
  • Save techforum-repo/f6d9f73fc7cc7b50260716cadaf5f563 to your computer and use it in GitHub Desktop.
Save techforum-repo/f6d9f73fc7cc7b50260716cadaf5f563 to your computer and use it in GitHub Desktop.
package com.example;
import java.io.ObjectInputFilter;
import java.io.ObjectInputFilter.FilterInfo;
public class CustomMethodFilter {
static ObjectInputFilter.Status classFilter(FilterInfo info) {
Class<?> serialClass = info.serialClass();
if (serialClass != null) {
return !(serialClass.getName().equals("com.example.Employee")) //serialClass.getPackageName().equals("com.example")
? ObjectInputFilter.Status.ALLOWED
: ObjectInputFilter.Status.REJECTED;
}
return ObjectInputFilter.Status.UNDECIDED;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment