Example usage for org.apache.commons.lang3 SerializationUtils deserialize

List of usage examples for org.apache.commons.lang3 SerializationUtils deserialize

Introduction

In this page you can find the example usage for org.apache.commons.lang3 SerializationUtils deserialize.

Prototype

public static <T> T deserialize(final byte[] objectData) 

Source Link

Document

Deserializes a single Object from an array of bytes.

Usage

From source file:net.spfbl.data.Provider.java

public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/provider.set");
    if (file.exists()) {
        try {//  www  . j  a  v  a 2 s  .  c  o m
            TreeSet<String> set;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                set = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String token : set) {
                try {
                    addExact(token);
                } catch (ProcessException ex) {
                    Server.logDebug("PROVIDER CIDR " + token + " " + ex.getErrorMessage());
                }
            }
            CHANGED = false;
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.data.Trap.java

public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/trap.map");
    if (file.exists()) {
        try {//ww w.j av a 2 s .com
            Map<String, Long> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String token : map.keySet()) {
                Long time2 = map.get(token);
                putExact(token, time2);
            }
            CHANGED = false;
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.data.White.java

public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/white.set");
    if (file.exists()) {
        try {//from   w ww .j  a  v a2s .  com
            Set<String> set;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                set = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            // Processo temporrio de transio.
            for (String token : set) {
                String client;
                String identifier;
                if (token.contains(":")) {
                    int index = token.indexOf(':');
                    client = token.substring(0, index);
                    identifier = token.substring(index + 1);
                } else {
                    client = null;
                    identifier = token;
                }
                if (client != null && client.startsWith("WHOIS/")) {
                    // Correo temporria do defeito no registro WHOIS.
                    while (client.startsWith("WHOIS/")) {
                        client = client.substring(6);
                    }
                    token = client + ':' + identifier;
                }
                if (identifier.startsWith("WHOIS/WHOIS/")) {
                    // Correo temporria do defeito no registro WHOIS.
                    token = null;
                } else if (identifier.startsWith("WHOIS/") && !identifier.contains("=")
                        && !identifier.contains("<") && !identifier.contains(">")) {
                    // Correo temporria do defeito no registro WHOIS.
                    identifier = null;
                } else if (Subnet.isValidCIDR(identifier)) {
                    identifier = "CIDR=" + Subnet.normalizeCIDR(identifier);
                } else if (Owner.isOwnerID(identifier)) {
                    identifier = "WHOIS/ownerid=" + identifier;
                } else {
                    identifier = normalizeTokenWhite(identifier);
                }
                if (identifier != null) {
                    try {
                        if (client == null) {
                            addExact(identifier);
                        } else if (Domain.isEmail(client)) {
                            addExact(client + ':' + identifier);
                        }
                    } catch (ProcessException ex) {
                        Server.logDebug("WHITE CIDR " + identifier + " " + ex.getErrorMessage());
                    }
                }
            }
            CHANGED = false;
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.dns.QueryDNS.java

public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/zone.map");
    if (file.exists()) {
        try {//from  w  ww  . j a v  a2 s .c o  m
            Map<String, Zone> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                Zone value = map.get(key);
                putExact(key, value);
            }
            CHANGED = false;
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    } else {
        file = new File("./data/dnsbl.map");
        if (file.exists()) {
            try {
                Map<String, ServerDNSBL> map;
                FileInputStream fileInputStream = new FileInputStream(file);
                try {
                    map = SerializationUtils.deserialize(fileInputStream);
                } finally {
                    fileInputStream.close();
                }
                for (String key : map.keySet()) {
                    ServerDNSBL value = map.get(key);
                    putExact(key, value);
                }
                CHANGED = false;
                Server.logLoad(time, file);
            } catch (Exception ex) {
                Server.logError(ex);
            }
        }
    }
}

From source file:net.spfbl.dnsbl.QueryDNSBL.java

public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/dnsbl.map");
    if (file.exists()) {
        try {//  ww  w  .  jav a 2  s .  c  o m
            Map<String, ServerDNSBL> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                ServerDNSBL value = map.get(key);
                putExact(key, value);
            }
            CHANGED = false;
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    } else if ((file = new File("./data/dns.map")).exists()) {
        try {
            HashMap<String, InetAddress> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                String message = "<IP> is listed in this server.";
                ServerDNSBL server = new ServerDNSBL(key, message);
                putExact(key, server);
                CHANGED = true;
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.http.ServerHTTP.java

public synchronized void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/url.map");
    if (file.exists()) {
        try {/*from  w  ww . j  ava2 s .c o m*/
            HashMap<String, String> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            MAP.putAll(map);
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.whois.AutonomousSystem.java

/**
 * Carregamento de cache do disco.// www.  ja  v  a  2  s.c o  m
 */
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/as.map");
    if (file.exists()) {
        try {
            HashMap<String, Object> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                Object value = map.get(key);
                if (value instanceof AutonomousSystem) {
                    AutonomousSystem as = (AutonomousSystem) value;
                    put(key, as);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.whois.Domain.java

/**
 * Carregamento de cache do disco.// w w w.  j av a  2s.  c o  m
 */
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/domain.map");
    if (file.exists()) {
        try {
            HashMap<String, Object> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                Object value = map.get(key);
                if (value instanceof Domain) {
                    Domain domain = (Domain) value;
                    put(key, domain);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
    time = System.currentTimeMillis();
    file = new File("./data/tld.set");
    if (file.exists()) {
        try {
            Collection<String> set;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                set = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            addAll(set);
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.whois.Handle.java

/**
 * Carregamento de cache do disco.//from  w w w .  j a va 2s.c o  m
 */
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/handle.map");
    if (file.exists()) {
        try {
            HashMap<String, Object> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                Object value = map.get(key);
                if (value instanceof Handle) {
                    Handle handle = (Handle) value;
                    put(key, handle);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}

From source file:net.spfbl.whois.NameServer.java

/**
* Carregamento de cache do disco./*w  w  w . j  a  v  a 2  s  .c o m*/
*/
public static void load() {
    long time = System.currentTimeMillis();
    File file = new File("./data/ns.map");
    if (file.exists()) {
        try {
            HashMap<String, NameServer> map;
            FileInputStream fileInputStream = new FileInputStream(file);
            try {
                map = SerializationUtils.deserialize(fileInputStream);
            } finally {
                fileInputStream.close();
            }
            for (String key : map.keySet()) {
                Object value = map.get(key);
                if (value instanceof NameServer) {
                    NameServer ns = (NameServer) value;
                    putMap(key, ns);
                }
            }
            Server.logLoad(time, file);
        } catch (Exception ex) {
            Server.logError(ex);
        }
    }
}