Package org.xmlBlaster.util

Examples of org.xmlBlaster.util.FileLocator


         this.doConnect = this.global.get("doConnect", true, null, this.pluginInfo);
         this.doDisconnect = this.global.get("doDisconnect", true, null, this.pluginInfo);

         if (this.directoryName == null || this.directoryName.length() < 1) {
            // Use xmlBlaster search path (including CLASSPATH)
            FileLocator fileLocator = new FileLocator(this.global);
            this.scriptFileUrl = fileLocator.findFileInXmlBlasterSearchPath((String)null, this.scriptFileName);
         }
         else {
            // Use given path
            File f = new File(this.directoryName, this.scriptFileName);
            if (f.exists() && f.isFile() && f.canRead()) {
View Full Code Here


            // Can be changed by "keystore.type" in JAVA_HOME/lib/security/java.security, defaults to "jks"
            // "JKS" in caps works ok on java 1.4.x.. on java 1.5 you must use "jks" in lowercase
            String storeType = address.getEnv("keystore.type", java.security.KeyStore.getDefaultType()).getValue();

            // keyStore with my private key
               FileLocator locator = new FileLocator(glob);
               URL url = locator.findFileInXmlBlasterSearchPath((String)null, keyStore);
               if (url != null) {
                  InputStream in = url.openStream();
                  java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType); // since JDK 1.2
                  ks.load(in, keyStorePassword.toCharArray());
                  kmf = javax.net.ssl.KeyManagerFactory.getInstance(javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm());
                  kmf.init(ks, keyStorePassword.toCharArray());
                  if (firstKey) {
                     log.info("SSL client socket keyStore="+url.getFile().toString());
                     firstKey = false;
                  }
               }
               else {
                  log.warning("SSL client socket can't find keyStore=" + keyStore + " in xmlBlaster search pathes, see http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html#SSL");
               }
            }
            {  // trustStore with others public keys
               FileLocator locator = new FileLocator(glob);
               URL url = locator.findFileInXmlBlasterSearchPath((String)null, trustStore);
               if (url != null) {
                  InputStream in = url.openStream();
                  java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType);
                  ks.load(in, trustStorePassword.toCharArray());
                  tmf = javax.net.ssl.TrustManagerFactory.getInstance(javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm());
View Full Code Here

            // Can be changed by "keystore.type" in JAVA_HOME/lib/security/java.security, defaults to "jks"
            // "JKS" in caps works ok on java 1.4.x.. on java 1.5 you must use "jks" in lowercase
            String storeType = address.getEnv("keystore.type", java.security.KeyStore.getDefaultType()).getValue();

            // keyStore with my private key
               FileLocator locator = new FileLocator(glob);
               URL url = locator.findFileInXmlBlasterSearchPath((String)null, keyStore);
               if (url != null) {
                  InputStream in = url.openStream();
                  java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType); // since JDK 1.2
                  ks.load(in, keyStorePassword.toCharArray());
                  kmf = javax.net.ssl.KeyManagerFactory.getInstance(javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm());
                  kmf.init(ks, keyStorePassword.toCharArray());
                  if (firstKey) {
                     log.info("SSL client socket keyStore="+url.getFile().toString());
                     firstKey = false;
                  }
               }
               else {
                  log.warning("SSL client socket can't find keyStore=" + keyStore + " in xmlBlaster search pathes, see http://www.xmlblaster.org/xmlBlaster/doc/requirements/protocol.socket.html#SSL");
               }
            }
            {  // trustStore with others public keys
               FileLocator locator = new FileLocator(glob);
               URL url = locator.findFileInXmlBlasterSearchPath((String)null, trustStore);
               if (url != null) {
                  InputStream in = url.openStream();
                  java.security.KeyStore ks = java.security.KeyStore.getInstance(storeType);
                  ks.load(in, trustStorePassword.toCharArray());
                  tmf = javax.net.ssl.TrustManagerFactory.getInstance(javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm());
View Full Code Here

    * xmlBlaster search strategy specified in the engine.runlevel requirement.
    * @see <a href="http://www.xmlblaster.org/xmlBlaster/doc/requirements/engine.runlevel.html">engine.runlevel requirement</a>
    */
   public PluginHolder readConfigFile() throws XmlBlasterException {
      if (log.isLoggable(Level.FINER)) log.finer("readConfigFile");
      FileLocator fileLocator = new FileLocator(this.glob);
      URL url = fileLocator.findFileInXmlBlasterSearchPath("pluginsFile", "xmlBlasterPlugins.xml");

      // null pointer check here ....
      if (url == null) {
         throw new XmlBlasterException(this.glob, ErrorCode.RESOURCE_CONFIGURATION, ME + ".readConfigFile",
         "the file 'xmlBlasterPlugins.xml' has not been found in the search path nor in the property 'pluginsFile'");
View Full Code Here

   }

  
   public void testHttpAccess() throws XmlBlasterException {
      Global glob = Global.instance();
      FileLocator locator = new FileLocator(glob);
      URL url = locator.findFileInXmlBlasterSearchPath(null, "http://www.xmlblaster.org/empty.html");
      assertNotNull(url);
      String content = locator.read(url);
      assertTrue("Downloaded file is empty", content.length() > 5);
   }
View Full Code Here

   }

   public void testFileAccess() throws XmlBlasterException {
      FileLocator.writeFile("FileLocatorTest.dummy", "Hello");
      Global glob = Global.instance();
      FileLocator locator = new FileLocator(glob);
      URL url = locator.findFileInXmlBlasterSearchPath(null, "file:FileLocatorTest.dummy");
      assertNotNull(url);
      String content = locator.read(url);
      assertNotNull(content);
      assertEquals("file://FileLocatorTest.dummy", "Hello", content.trim());
      File f = new File("FileLocatorTest.dummy");
      f.delete();
   }
View Full Code Here

TOP

Related Classes of org.xmlBlaster.util.FileLocator

Copyright © 2018 www.massapicom. 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.