@Test
 public void testInfoBySection() {
   Properties props = new Properties();
   props.put("foo", "bar");
   doReturn(Arrays.asList(new Object[] {props})).when(nativeConnection).closePipeline();
   super.testInfoBySection();
 }
 private void loadUser(DocearUser user) {
   String token = properties.getProperty(DOCEAR_CONNECTION_TOKEN_PROPERTY);
   if (token == null) {
     token =
         DocearController.getPropertiesController().getProperty(DOCEAR_CONNECTION_TOKEN_PROPERTY);
   }
   user.setAccessToken(token);
   String strRetrieval = properties.getProperty(DOCEAR_INFORMATION_RETRIEVAL);
   if (strRetrieval == null) {
     strRetrieval =
         DocearController.getPropertiesController().getProperty(DOCEAR_INFORMATION_RETRIEVAL);
   }
   if (strRetrieval != null) {
     int ir = Integer.parseInt(strRetrieval);
     user.setRecommendationsEnabled((DocearUser.RECOMMENDATIONS & ir) > 0);
     user.setCollaborationEnabled(((DocearUser.COLLABORATION & ir) > 0));
     user.setBackupEnabled(((DocearUser.BACKUP & ir) > 0));
     user.setSynchronizationEnabled(((DocearUser.SYNCHRONIZATION & ir) > 0));
   }
   if (DocearController.getPropertiesController().getProperty(DOCEAR_SAVE_BACKUP) != null) {
     user.setBackupEnabled(
         Boolean.parseBoolean(
             DocearController.getPropertiesController().getProperty(DOCEAR_SAVE_BACKUP)));
   }
   //		WorkspaceController.load();
 }
Exemplo n.º 3
1
  public static Color getTitleBarForeground(String theme) {
    if (!themeProperties.containsKey(theme)) {
      Properties pros = loadThemeProperties(theme);
      if (pros != null) {
        themeProperties.put(theme, pros);
      }
    }
    Properties pros = (Properties) themeProperties.get(theme);
    if (pros != null) {
      try {
        String value = pros.getProperty("TitlBar.Foreground");
        String[] rgbs = value.split(",");
        if (rgbs.length == 3) {
          int r = Integer.parseInt(rgbs[0]);
          int g = Integer.parseInt(rgbs[1]);
          int b = Integer.parseInt(rgbs[2]);
          return ColorCache.getInstance().getColor(r, g, b);
        }

      } catch (Exception e) {

      }
    }
    return ColorCache.getInstance().getBlack();
  }
 public Map<String, String> getRequiredFields() {
   HashMap<String, String> fields = new HashMap<String, String>();
   for (String key : _requiredFields.stringPropertyNames()) {
     fields.put(key, _requiredFields.getProperty(key));
   }
   return fields;
 }
Exemplo n.º 5
1
  private File() {
    Properties properties = System.getProperties();

    line = properties.getProperty("line.separator");
    encoding = properties.getProperty("file.encoding");
    separator = properties.getProperty("file.separator");
  }
Exemplo n.º 6
1
 public boolean hasGithubProperties() {
   return props.containsKey(GITHUB_USER) //
       && props.containsKey(GITHUB_PASSWORD) //
       && props.containsKey(GITHUB_OAUTH_TOKEN) //
       && props.containsKey(GITHUB_REPONAME) //
       && props.containsKey(GITHUB_REPOOWNER);
 }
Exemplo n.º 7
0
  /**
   * Called by the VelocityServlet init(). We want to set a set of properties so that templates will
   * be found in the webapp root. This makes this easier to work with as an example, so a new user
   * doesn't have to worry about config issues when first figuring things out
   */
  protected Properties loadConfiguration(ServletConfig config)
      throws IOException, FileNotFoundException {
    Properties p = new Properties();

    /*
     *  first, we set the template path for the
     *  FileResourceLoader to the root of the
     *  webapp.  This probably won't work under
     *  in a WAR under WebLogic, but should
     *  under tomcat :)
     */

    String path = config.getServletContext().getRealPath("/");

    if (path == null) {
      System.out.println(
          " SampleServlet.loadConfiguration() : unable to "
              + "get the current webapp root.  Using '/'. Please fix.");

      path = "/";
    }

    p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);

    /** and the same for the log file */
    p.setProperty("runtime.log", path + "velocity.log");

    return p;
  }
  /**
   * Find valid library AndroidManifest files referenced from an already loaded AndroidManifest's
   * "project.properties" file.
   *
   * @param androidManifest
   */
  private static List<FsFile> findLibraries(AndroidManifest androidManifest) {
    List<FsFile> libraryBaseDirs = new ArrayList<>();

    if (androidManifest.getResDirectory() != null) {
      FsFile baseDir = androidManifest.getResDirectory().getParent();
      final Properties properties = getProperties(baseDir.join("project.properties"));
      Properties overrideProperties = getProperties(baseDir.join("test-project.properties"));
      properties.putAll(overrideProperties);

      int libRef = 1;
      String lib;
      while ((lib = properties.getProperty("android.library.reference." + libRef)) != null) {
        FsFile libraryBaseDir = baseDir.join(lib);
        if (libraryBaseDir.isDirectory()) {
          // Ignore directories without any files
          FsFile[] libraryBaseDirFiles = libraryBaseDir.listFiles();
          if (libraryBaseDirFiles != null && libraryBaseDirFiles.length > 0) {
            libraryBaseDirs.add(libraryBaseDir);
          }
        }

        libRef++;
      }
    }
    return libraryBaseDirs;
  }
  public String badSource(HttpServletRequest request, HttpServletResponse response)
      throws Throwable {
    String data;

    if (CWE601_Open_Redirect__Servlet_PropertiesFile_22a.badPublicStatic) {
      data = ""; /* Initialize data */
      /* retrieve the property */
      {
        Properties properties = new Properties();
        FileInputStream streamFileInput = null;
        try {
          streamFileInput = new FileInputStream("../common/config.properties");
          properties.load(streamFileInput);
          /* POTENTIAL FLAW: Read data from a .properties file */
          data = properties.getProperty("data");
        } catch (IOException exceptIO) {
          IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
        } finally {
          /* Close stream reading object */
          try {
            if (streamFileInput != null) {
              streamFileInput.close();
            }
          } catch (IOException exceptIO) {
            IO.logger.log(Level.WARNING, "Error closing FileInputStream", exceptIO);
          }
        }
      }
    } else {
      /* INCIDENTAL: CWE 561 Dead Code, the code below will never run
       * but ensure data is inititialized before the Sink to avoid compiler errors */
      data = null;
    }
    return data;
  }
Exemplo n.º 10
0
  public void init() throws DBException {
    Properties props = getProperties();
    int port;

    // retrieve port
    String portString = props.getProperty("port");
    if (portString != null) {
      port = Integer.parseInt(portString);
    } else {
      port = 3000;
    }

    // retrieve host
    String host = props.getProperty("host");
    if (host == null) {
      host = "localhost";
    }

    // retrieve namespace
    String ns = props.getProperty("ns");
    if (ns != null) {
      NAMESPACE = ns;
    }

    // retrieve set
    String st = props.getProperty("set");
    if (st != null) {
      SET = st;
    }
    try {
      as = new com.aerospike.client.AerospikeClient(host, port);
    } catch (AerospikeException e) {
      throw new DBException(String.format("Failed to add %s:%d to cluster.", host, port));
    }
  }
Exemplo n.º 11
0
  private static void join() {
    System.out.println("Joining server group...");
    Properties newRMIconfig = localServer.getRmiSettings();
    findActive();
    if (remoteServer != null) {
      try {
        String tempselfName = remoteServer.serverJoin(newRMIconfig.getProperty("publicIP"));
        if (tempselfName != null) {
          selfName = tempselfName;
          newRMIconfig.setProperty("name", selfName);

          try {
            PropertyHandler.save(RMI_CONFIG_FILE, newRMIconfig);
            init();
          } catch (Exception ex) {
            System.out.println("save rmiserver config failed");
          }
          System.out.println("You have joined the server group of " + remoteServer.getServerName());
        } else {
          System.out.println("you are already in the group of " + remoteServer.getServerName());
        }
      } catch (RemoteException ex) {
        System.out.println("no active server");
        System.exit(1);
      }

      startClientMode();
    } else {
      System.out.println("no active server");
      System.exit(1);
    }
  }
Exemplo n.º 12
0
  public void execute(
      PluginNode pNode, DMConnection pCon, IDfPersistentObject[] pTargets, ALogger pLogger)
      throws Exception {

    for (int t = 0; t < pTargets.length; t++) {

      IDfSysObject obj = (IDfSysObject) pTargets[t];
      String id = obj.getObjectId().toString();
      String dql =
          "select f.dos_extension,f.name "
              + "FROM dm_sysobject (ALL) s, dmr_content r, dm_store t, dm_format f "
              + "WHERE r_object_id = ID('"
              + id
              + "') "
              + "AND ANY (parent_id=ID('"
              + id
              + "') AND page = 0) "
              + "AND r.storage_id=t.r_object_id "
              + "AND f.r_object_id=r.format";

      IDfQuery query = pCon.createQuery(dql);
      IDfCollection res = query.execute(pCon.getSession(), IDfQuery.READ_QUERY);

      while (res.next()) {

        try {
          String name = res.getString("name");
          pLogger.out.println(">>> " + name + "@" + ObjectTool.getName(obj));
          String ext = res.getString("dos_extension");
          ByteArrayInputStream stream = obj.getContentEx2(name, 0, null);
          String content = AFile.readFile(stream);
          stream.close();

          for (Enumeration i = properties.keys(); i.hasMoreElements(); ) {
            String key = (String) i.nextElement();
            content = content.replaceAll(key, properties.getProperty(key));
          }

          content = AFile.readFile(fileHeader) + content + AFile.readFile(fileFooter);

          File f =
              new File(
                  tmpDir,
                  obj.getObjectName()
                      + "_"
                      + obj.getString("language_code")
                      + "_"
                      + name
                      + "."
                      + ext);
          pLogger.out.println("--- WRITE: " + f.getAbsolutePath());
          AFile.writeFile(f, content);

        } catch (Exception e) {
          pLogger.out.println(e.toString());
        }
      }
      res.close();
    }
  }
Exemplo n.º 13
0
  // Only for test
  private int getVideoDimens() {

    File file = new File("sdcard/nim.properties");

    if (file.exists()) {
      InputStream is = null;

      try {
        is = new BufferedInputStream(new FileInputStream(file));
        Properties properties = new Properties();
        properties.load(is);
        int dimens = Integer.parseInt(properties.getProperty("avchat.video.dimens", "0"));
        LogUtil.i(TAG, "dimes:" + dimens);
        return dimens;
      } catch (IOException e) {
        e.printStackTrace();
      } finally {
        if (is != null) {
          try {
            is.close();
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
    }

    return 0;
  }
Exemplo n.º 14
0
  @Bean
  public JavaMailSenderImpl javaMailSender(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring mail server");
    String host = jHipsterProperties.getMail().getHost();
    int port = jHipsterProperties.getMail().getPort();
    String user = jHipsterProperties.getMail().getUsername();
    String password = jHipsterProperties.getMail().getPassword();
    String protocol = jHipsterProperties.getMail().getProtocol();
    Boolean tls = jHipsterProperties.getMail().isTls();
    Boolean auth = jHipsterProperties.getMail().isAuth();

    JavaMailSenderImpl sender = new JavaMailSenderImpl();
    if (host != null && !host.isEmpty()) {
      sender.setHost(host);
    } else {
      log.warn("Warning! Your SMTP server is not configured. We will try to use one on localhost.");
      log.debug("Did you configure your SMTP settings in your application.yml?");
      sender.setHost(DEFAULT_HOST);
    }
    sender.setPort(port);
    sender.setUsername(user);
    sender.setPassword(password);

    Properties sendProperties = new Properties();
    sendProperties.setProperty(PROP_SMTP_AUTH, auth.toString());
    sendProperties.setProperty(PROP_STARTTLS, tls.toString());
    sendProperties.setProperty(PROP_TRANSPORT_PROTO, protocol);
    sender.setJavaMailProperties(sendProperties);
    return sender;
  }
  @Test
  public void testBuildWithServiceOverride() {
    StandardServiceRegistryImpl serviceRegistry =
        (StandardServiceRegistryImpl)
            new StandardServiceRegistryBuilder()
                .applySettings(ConnectionProviderBuilder.getConnectionProviderProperties())
                .buildServiceRegistry();
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);

    assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
    assertTrue(
        jdbcServices
            .getConnectionProvider()
            .isUnwrappableAs(DriverManagerConnectionProviderImpl.class));

    Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
    props.setProperty(Environment.DIALECT, H2Dialect.class.getName());

    serviceRegistry =
        (StandardServiceRegistryImpl)
            new StandardServiceRegistryBuilder()
                .applySettings(props)
                .addService(ConnectionProvider.class, new UserSuppliedConnectionProviderImpl())
                .buildServiceRegistry();
    jdbcServices = serviceRegistry.getService(JdbcServices.class);

    assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
    assertTrue(
        jdbcServices
            .getConnectionProvider()
            .isUnwrappableAs(UserSuppliedConnectionProviderImpl.class));

    serviceRegistry.destroy();
  }
Exemplo n.º 16
0
 @Before
 public void setUp() throws Exception {
   File f = new File(new File(System.getProperty("user.home")), ".jenkins-ci.org");
   if (!f.exists()) {
     LOGGER.warning(f + " doesn't exist. Skipping JDK installation tests");
   } else {
     Properties prop = new Properties();
     FileInputStream in = new FileInputStream(f);
     try {
       prop.load(in);
       String u = prop.getProperty("oracle.userName");
       String p = prop.getProperty("oracle.password");
       if (u == null || p == null) {
         LOGGER.warning(
             f
                 + " doesn't contain oracle.userName and oracle.password. Skipping JDK installation tests.");
       } else {
         DescriptorImpl d = j.jenkins.getDescriptorByType(DescriptorImpl.class);
         d.doPostCredential(u, p);
       }
     } finally {
       in.close();
     }
   }
 }
Exemplo n.º 17
0
 /**
  * Get specified unit test property.
  *
  * @param key Name of property
  * @return Property value
  */
 public static String getUnitTestProperty(final String key) {
   Properties props = SystemUtils.loadProperties(UNIT_TEST_PROPS_FILE);
   if (props == null) {
     throw new WebGenomeSystemException("Cannot find 'unit_test.properties' file");
   }
   return props.getProperty(key);
 }
Exemplo n.º 18
0
  private void loadDecoratorMappers(NodeList nodes) {
    clearDecoratorMappers();
    Properties emptyProps = new Properties();

    pushDecoratorMapper("com.opensymphony.module.sitemesh.mapper.NullDecoratorMapper", emptyProps);

    // note, this works from the bottom node up.
    for (int i = nodes.getLength() - 1; i > 0; i--) {
      if (nodes.item(i) instanceof Element) {
        Element curr = (Element) nodes.item(i);
        if ("mapper".equalsIgnoreCase(curr.getTagName())) {
          String className = curr.getAttribute("class");
          Properties props = new Properties();
          // build properties from <param> tags.
          NodeList children = curr.getChildNodes();
          for (int j = 0; j < children.getLength(); j++) {
            if (children.item(j) instanceof Element) {
              Element currC = (Element) children.item(j);
              if ("param".equalsIgnoreCase(currC.getTagName())) {
                String value = currC.getAttribute("value");
                props.put(currC.getAttribute("name"), replaceProperties(value));
              }
            }
          }
          // add mapper
          pushDecoratorMapper(className, props);
        }
      }
    }

    pushDecoratorMapper(
        "com.opensymphony.module.sitemesh.mapper.InlineDecoratorMapper", emptyProps);
  }
Exemplo n.º 19
0
 public boolean hasJiraProperties() {
   return props.containsKey(JIRA_USER) //
       && props.containsKey(JIRA_PASSWORD) //
       && props.containsKey(JIRA_URL) //
       && props.containsKey(JIRA_PROJECTKEY)
       && props.containsKey(JIRA_FORCE_UPDATE);
 }
Exemplo n.º 20
0
  /**
   * Locates the executable for the jarsigner tool.
   *
   * @Copy&paste from org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo
   * @return The executable of the jarsigner tool, never <code>null<code>.
   */
  private String getExecutable() {
    String command = "jarsigner" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : "");

    String executable =
        findExecutable(
            command, System.getProperty("java.home"), new String[] {"../bin", "bin", "../sh"});

    if (executable == null) {
      try {
        Properties env = CommandLineUtils.getSystemEnvVars();

        String[] variables = {"JDK_HOME", "JAVA_HOME"};

        for (int i = 0; i < variables.length && executable == null; i++) {
          executable =
              findExecutable(command, env.getProperty(variables[i]), new String[] {"bin", "sh"});
        }
      } catch (IOException e) {
        if (getLog().isDebugEnabled()) {
          getLog()
              .warn("Failed to retrieve environment variables, cannot search for " + command, e);
        } else {
          getLog().warn("Failed to retrieve environment variables, cannot search for " + command);
        }
      }
    }

    if (executable == null) {
      executable = command;
    }

    return executable;
  }
Exemplo n.º 21
0
 /**
  * Adds the specified user name and password to the specified collection as Jdbc driver
  * properties. Creates a new collection if none is specified.
  */
 static Properties addUserAuthenticationProperties(
     Properties connProps, String user, String password) {
   if (connProps == null) connProps = new Properties();
   if (user != null) connProps.setProperty(JDBC_USER_PROP_NAME, user);
   if (password != null) connProps.setProperty(JDBC_PASSWORD_PROP_NAME, password);
   return connProps;
 }
Exemplo n.º 22
0
  private void setJasperResourceNames(ToolBoxDTO toolBoxDTO, String barDir)
      throws BAMToolboxDeploymentException {
    String jasperDirectory =
        barDir
            + File.separator
            + BAMToolBoxDeployerConstants.DASHBOARD_DIR
            + File.separator
            + BAMToolBoxDeployerConstants.JASPER_DIR;
    if (new File(jasperDirectory).exists()) {
      toolBoxDTO.setJasperParentDirectory(
          barDir
              + File.separator
              + BAMToolBoxDeployerConstants.DASHBOARD_DIR
              + File.separator
              + BAMToolBoxDeployerConstants.JASPER_DIR);
      Properties properties = new Properties();
      try {
        properties.load(
            new FileInputStream(
                barDir
                    + File.separator
                    + BAMToolBoxDeployerConstants.DASHBOARD_DIR
                    + File.separator
                    + BAMToolBoxDeployerConstants.JASPER_META_FILE));

        setJasperTabAndJrxmlNames(toolBoxDTO, properties);

        toolBoxDTO.setDataSource(properties.getProperty(BAMToolBoxDeployerConstants.DATASOURCE));
        toolBoxDTO.setDataSourceConfiguration(
            barDir
                + File.separator
                + BAMToolBoxDeployerConstants.DASHBOARD_DIR
                + File.separator
                + properties.getProperty(BAMToolBoxDeployerConstants.DATASOURCE_CONFIGURATION));
      } catch (FileNotFoundException e) {
        log.error(
            "No "
                + BAMToolBoxDeployerConstants.JASPER_META_FILE
                + " found in dir:"
                + barDir
                + File.separator
                + BAMToolBoxDeployerConstants.DASHBOARD_DIR,
            e);
        throw new BAMToolboxDeploymentException(
            "No "
                + BAMToolBoxDeployerConstants.JASPER_META_FILE
                + " found in dir:"
                + barDir
                + File.separator
                + BAMToolBoxDeployerConstants.DASHBOARD_DIR,
            e);
      } catch (IOException e) {
        log.error(e.getMessage(), e);
        throw new BAMToolboxDeploymentException(e.getMessage(), e);
      }
    } else {
      toolBoxDTO.setJasperParentDirectory(null);
      toolBoxDTO.setJasperTabs(new ArrayList<JasperTabDTO>());
    }
  }
Exemplo n.º 23
0
  /**
   * Does the configuration setup and schema parsing and setup.
   *
   * @param table_schema String
   * @param columnsToRead String
   */
  private void setup(String table_schema) {

    if (table_schema == null)
      throw new RuntimeException(
          "The table schema must be defined as colname type, colname type.  All types are hive types");

    // create basic configuration for hdfs and hive
    conf = new Configuration();
    hiveConf = new HiveConf(conf, SessionState.class);

    // parse the table_schema string
    List<String> types = HiveRCSchemaUtil.parseSchemaTypes(table_schema);
    List<String> cols = HiveRCSchemaUtil.parseSchema(pcols, table_schema);

    List<FieldSchema> fieldSchemaList = new ArrayList<FieldSchema>(cols.size());

    for (int i = 0; i < cols.size(); i++) {
      fieldSchemaList.add(
          new FieldSchema(cols.get(i), HiveRCSchemaUtil.findPigDataType(types.get(i))));
    }

    pigSchema = new ResourceSchema(new Schema(fieldSchemaList));

    props = new Properties();

    // setting table schema properties for ColumnarSerDe
    // these properties are never changed by the columns to read filter,
    // because the columnar serde needs to now the
    // complete format of each record.
    props.setProperty(Constants.LIST_COLUMNS, HiveRCSchemaUtil.listToString(cols));
    props.setProperty(Constants.LIST_COLUMN_TYPES, HiveRCSchemaUtil.listToString(types));
  }
Exemplo n.º 24
0
  public String getDeviceName(Context context) {
    String manufacturer = Build.MANUFACTURER;
    String undecodedModel = Build.MODEL;
    String model = null;

    try {
      Properties prop = new Properties();
      InputStream fileStream;
      // Read the device name from a precomplied list:
      // see http://making.meetup.com/post/29648976176/human-readble-android-device-names
      fileStream = context.getAssets().open("android_models.properties");
      prop.load(fileStream);
      fileStream.close();
      String decodedModel = prop.getProperty(undecodedModel.replaceAll(" ", "_"));
      if (decodedModel != null && !decodedModel.trim().equals("")) {
        model = decodedModel;
      }
    } catch (IOException e) {
      AppLog.e(T.UTILS, e.getMessage());
    }

    if (model == null) { // Device model not found in the list
      if (undecodedModel.startsWith(manufacturer)) {
        model = capitalize(undecodedModel);
      } else {
        model = capitalize(manufacturer) + " " + undecodedModel;
      }
    }
    return model;
  }
  /** Load config. */
  private void loadConfig() {
    try {

      if (properties.isEmpty()) {
        URL url = new URL(this.getCodeBase(), Constants.FTP_CONFIG_FILE_NAME);
        URLConnection uc = url.openConnection();
        properties.load(uc.getInputStream());
      }

      List<FtpConfig> ftpConfigs =
          JSON.parseObject(
              properties.getProperty(Constants.FTP_CONFIGS),
              new TypeReference<List<FtpConfig>>() {});
      int cfgIndex = (int) (Math.random() * (ftpConfigs.size() - 1));
      this.ftpConfig = ftpConfigs.get(cfgIndex);
      this.separator = ftpConfig.getOs() == OS.WINDOWS ? "\\" : "/";

      if (messageSource.isEmpty()) {
        URL murl = new URL(this.getCodeBase(), Constants.MESSAGE_SOURCE_NAME);
        URLConnection muc = murl.openConnection();
        messageSource.load(muc.getInputStream());
      }
    } catch (IOException e) {
      JOptionPane.showMessageDialog(this, getMessage(MessageCode.FTP_CONFIG_ERROR));
    }
  }
Exemplo n.º 26
0
  public void initEJB() {
    try {
      InputStream inputStream =
          this.getClass()
              .getClassLoader()
              .getResourceAsStream("hu/neuron/java/sales/services/Settings.properties");

      Properties properties = new Properties();

      try {
        properties.load(inputStream);
      } catch (IOException e) {
        e.printStackTrace();
      }

      Hashtable<String, String> env = new Hashtable<String, String>();
      env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, properties.getProperty("SECURITY_PRINCIPAL"));
      env.put(Context.SECURITY_CREDENTIALS, properties.getProperty("SECURITY_CREDENTIALS"));
      env.put(Context.PROVIDER_URL, properties.getProperty("PROVIDER_URL"));
      Context ctx;

      ctx = new InitialContext(env);
      System.out.println("ctx  = " + ctx);
      offerService =
          (OfferServiceRemote)
              ctx.lookup("OfferService#hu.neuron.java.sales.service.OfferServiceRemote");
    } catch (NamingException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 27
0
  /** @param args */
  public static void main(String[] args) {
    Properties props = new Properties(System.getProperties());
    props.setProperty("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
    props.setProperty("java.naming.security.authentication", "simple");
    //		props.setProperty( "java.naming.provider.url", "ldap://bowmore.dev.ksi.co.jp:50389/" );
    //		props.setProperty( "java.naming.security.principal", "cn=Directory Manager" );
    //		props.setProperty( "java.naming.security.credentials", "amAdmin25" );
    props.setProperty("java.naming.provider.url", "ldap://fscs1.ap.ksi.co.jp/");
    //		props.setProperty( "java.naming.security.principal", "cn=Directory Manager" );
    //		props.setProperty( "java.naming.security.credentials", "amAdmin25" );
    String base = "OU=User,OU=Account,DC=oa,DC=ksi,DC=co,DC=jp";

    String searchText = "(objectClass=*)";
    int scope = LdapManager.ONELEVEL_SCOPE;
    LdapManager ldap = new LdapManager();
    try {
      ldap = new LdapManager(props);
      System.out.println("baseDN=" + ldap.getBaseDN());
      ldap.searchEntry(base, searchText, scope);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      ldap.close();
    }
  }
  @BeforeComponent
  public void registerConfiguration() throws Exception {
    Properties properties = new Properties();
    properties.setProperty("mail.smtp.starttls.enable", "true");

    // Required by GreenMail. When using XWiki with Gmail for example this is not required.
    properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

    this.configuration =
        new TestMailSenderConfiguration(
            this.mail.getSmtps().getPort(), "peter", "password", properties);
    this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);

    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));

    Provider<XWikiContext> xwikiContextProvider =
        this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(Mockito.mock(XWikiContext.class));

    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(Execution.class);

    EnvironmentConfiguration environmentConfiguration =
        this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath())
        .thenReturn(System.getProperty("java.io.tmpdir"));
  }
Exemplo n.º 29
0
 /**
  * Tests that an exception is thrown when the {@link Constants#USER_FILE_BUFFER_BYTES} overflows.
  */
 @Test
 public void variableUserFileBufferBytesOverFlowCheckTest() {
   Properties mProperties = new Properties();
   mProperties.put(Constants.USER_FILE_BUFFER_BYTES, String.valueOf(Integer.MAX_VALUE + 1) + "B");
   mThrown.expect(IllegalArgumentException.class);
   new Configuration(mProperties);
 }
Exemplo n.º 30
0
  public static void sendSmtpMessage(Session session, Message message, Address[] recipients)
      throws MessagingException {

    // message = cloneMimeMessage(message);
    message.setSentDate(new Date());
    setHeaderFieldValue(message, HEADER_X_MAILER, X_MAILER);
    message.saveChanges();

    LOG.info(
        "Sending message '"
            + message.getSubject()
            + "' from '"
            + Str.format(message.getFrom())
            + "' to '"
            + Str.format(recipients)
            + "'.");

    Transport trans = session.getTransport("smtp");
    Properties properties = session.getProperties();
    trans.connect(
        properties.getProperty("mail.smtp.host"),
        properties.getProperty("mail.smtp.auth.user"),
        properties.getProperty("mail.smtp.auth.password"));
    trans.sendMessage(message, recipients);
    trans.close();
  }