Examples of XStreamPersister


Examples of org.geoserver.config.util.XStreamPersister

        Catalog catalog = geoserver.getCatalog();
        if ( catalog instanceof Wrapper ) {
            catalog = ((Wrapper)geoserver.getCatalog()).unwrap(Catalog.class);
        }
       
        XStreamPersister xp = xpf.createXMLPersister();
        xp.setCatalog( catalog );
       
        loadCatalog( catalog, xp );
        loadGeoServer( geoserver, xp);
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

    @Override
    protected ReflectiveXMLFormat createXMLFormat(Request request,Response response) {
        return new ReflectiveXMLFormat() {
            @Override
            protected void write(Object data, OutputStream output) throws IOException  {
                XStreamPersister p = xpf.createXMLPersister();
                p.setCatalog( catalog );
                p.setReferenceByName(true);
                p.setExcludeIds();
               
                configurePersister(p,this);
                p.save( data, output );
            }
           
            @Override
            protected Object read(InputStream in)
                    throws IOException {
                XStreamPersister p = xpf.createXMLPersister();
                p.setCatalog( catalog );
               
                configurePersister(p,this);
                return p.load( in, clazz );
            }
        };
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

    protected ReflectiveJSONFormat createJSONFormat(Request request,Response response) {
        return new ReflectiveJSONFormat() {
            @Override
            protected void write(Object data, OutputStream output)
                    throws IOException {
                XStreamPersister p = xpf.createJSONPersister();
                p.setCatalog(catalog);
                p.setReferenceByName(true);
                p.setExcludeIds();
               
                configurePersister(p,this);
                p.save( data, output );
            }
           
            @Override
            protected Object read(InputStream input)
                    throws IOException {
                XStreamPersister p = xpf.createJSONPersister();
                p.setCatalog(catalog);
               
                configurePersister(p,this);
                return p.load( input, clazz );
            }
        };
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

    private synchronized void loadConfig() throws IOException {
        File configFile = findConfigFile();
        checkNotNull(configFile, "gwc config file does not exist: ", GWC_CONFIG_FILE);

        XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister();
        configureXstream(xmlPersister.getXStream());
        try {
            InputStream in = new FileInputStream(configFile);
            try {
                this.config = xmlPersister.load(in, GWCConfig.class);
            } finally {
                in.close();
            }
            LOGGER.fine("GWC GeoServer specific configuration loaded from " + GWC_CONFIG_FILE);
        } catch (Exception e) {
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

     * @throws IOException
     */
    public void save(final GWCConfig config) throws IOException {
        LOGGER.finer("Saving integrated GWC configuration");
        File tmp = new File(getConfigRoot(), GWC_CONFIG_FILE + ".tmp");
        XStreamPersister xmlPersister = this.persisterFactory.createXMLPersister();
        configureXstream(xmlPersister.getXStream());
        OutputStream out = new FileOutputStream(tmp);
        try {
            xmlPersister.save(config, out);
        } finally {
            out.close();
        }
        File configFile = new File(getConfigRoot(), GWC_CONFIG_FILE);
        IOUtils.rename(tmp, configFile);
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

        LoggingInfo logging = geoServer.getFactory().createLogging();
        geoServer.setLogging(logging);
    }

    XStreamPersister createXStreamPersister() {
        XStreamPersister xp = new XStreamPersisterFactory().createXMLPersister();
        xp.setEncryptPasswordFields(false);
        return xp;
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

        File store = new File(getDataDirectory().root(),"workspaces/password/password/datastore.xml");
        Document dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(store);
        XPath xpath = XPathFactory.newInstance().newXPath();
        String encrypted = xpath.evaluate("//entry[@key='passwd']", dom.getDocumentElement());
        assertTrue((prefix+"secret").equals(encrypted));
        XStreamPersister xs = new XStreamPersisterFactory().createXMLPersister();

        FileInputStream fin = new FileInputStream(store);
        DataStoreInfo load = xs.load(fin, DataStoreInfo.class);
        fin.close();

        assertEquals("secret",load.getConnectionParameters().get("passwd"));
       
        // now encrypt
        config.setConfigPasswordEncrypterName(getPBEPasswordEncoder().getName());
        getSecurityManager().saveSecurityConfig(config);
        getSecurityManager().updateConfigurationFilesWithEncryptedFields();
       
//        FileInputStream fi = new FileInputStream(store);
//        BufferedReader r = new BufferedReader(new InputStreamReader(fi));
//        String line;
//        while ((line= r.readLine())!=null)
//            System.out.println(line);
//        fi.close();
       
        dom = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(store);
        xpath = XPathFactory.newInstance().newXPath();
        encrypted = xpath.evaluate("//entry[@key='passwd']", dom.getDocumentElement());
       
        // TODO, assertion does not pass with mvn clean install
        // but it passes with  mvn test -Dtest=org.geoserver.security.impl.MemoryUserDetailsServiceTest
        // ???????
       
        // assertFalse("secret".equals(encrypted));
       
        xs = new XStreamPersisterFactory().createXMLPersister();

        fin = new FileInputStream(store);

        load = xs.load(fin, DataStoreInfo.class);
        assertEquals("secret",load.getConnectionParameters().get("passwd"));
        fin.close();
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

    }
   
    @Test
    public void testGeneratedStyles() throws Exception {
        XStreamPersisterFactory xpf = new XStreamPersisterFactory();
        XStreamPersister xp = xpf.createXMLPersister();
        xp.setCatalog( catalog );
        loader.initializeStyles(catalog, xp);
       
        StyleInfo polygon = catalog.getStyleByName( StyleInfo.DEFAULT_POLYGON );
        assertEquals( "default_polygon.sld", polygon.getFilename() );
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

       

        if(source instanceof Serializable) {
            return (T) cloneSerializable((Serializable)source);
        } else {
            XStreamPersister persister = XSTREAM_PERSISTER_FACTORY.createXMLPersister();
            XStream xs = persister.getXStream();
            String xml = xs.toXML(source);
            T copy = (T) xs.fromXML(xml);
            return copy;
        }
    }
View Full Code Here

Examples of org.geoserver.config.util.XStreamPersister

        }
        return result;
    }

    <T> T fromJSON(JSONObject json, Class<T> clazz) throws IOException {
        XStreamPersister xp = importer.createXStreamPersisterJSON();
        return (T) xp.load(new ByteArrayInputStream(json.toString().getBytes()), clazz);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.