コード例 #1
0
 protected boolean setSigner(final String clazzFile) {
   NotesContext ctx = NotesContext.getCurrent();
   NSFComponentModule module = ctx.getRunningModule();
   RuntimeFileSystem fs = module.getRuntimeFileSystem();
   NSFResource res = fs.getResource(clazzFile);
   if ((res != null) && ((res instanceof RuntimeFileSystem.NSFFile))) {
     ctx.setSignerSessionRights(clazzFile);
     return true;
   }
   return false;
 }
コード例 #2
0
  /**
   * @param req
   * @param res
   * @throws ServletException
   * @throws JobExecutionException
   */
  protected void invoke(final ServletRequest req, final ServletResponse res) {

    String clazzName = req.getParameter(NSFJobGroup.class.getName());

    NotesContext ctx = NotesContext.getCurrent();
    NSFComponentModule moduleCurrent = ctx.getModule();

    WorkerJob wj = WorkerJob.getInstance();
    try {

      String clazzFile = "WEB-INF/classes/" + clazzName.replace('.', '/') + ".class";
      // ctx.setSignerSessionRights(clazzFile);

      Class<?> clazz = moduleCurrent.getModuleClassLoader().loadClass(clazzName);

      if (NSFJobGroup.class.isAssignableFrom(clazz)) {
        execScheduleDefinition((NSFJobGroup) clazz.newInstance(), wj);
      } else {
        throw new ClassCastException(
            "Class '" + clazzName + "' is not a instance of '" + NSFJobGroup.class.getName() + "'");
      }
    } catch (Exception e) {
      e.printStackTrace();
      log_.log(Level.SEVERE, "Error while executing jobGroup: " + clazzName, e);
    }

    // } catch (JobExecutionException jex) {
    // HttpRequestJob outerJob = HttpRequestJob.getInstance();
    // if (outerJob != null) {
    // outerJob.setJobExecutionException(jex);
    // }
    // throw new ServletException("Error while executing class: " + clazzName, jex);
    // } catch (Exception iex) {
    // throw new ServletException("Could not instantiate class: " + clazzName, iex);
    //

  }
コード例 #3
0
  /**
   * Registers the definitions at the XPage Scheduler.
   *
   * @param req
   * @param res
   * @throws SchedulerException
   */
  private void registerTransponder(final ServletRequest req, final ServletResponse res) {

    // the root of the definition is the META-INF/services file which MUST have a valid signature

    String clazzFile = "META-INF/services/" + TransponderData.class.getName();
    if (!setSigner(clazzFile)) return;

    NotesContext ctx = NotesContext.getCurrent();
    NSFComponentModule module = ctx.getRunningModule();

    String signer = null;
    try {
      Session signerSession = ctx.getSessionAsSigner();
      signer = signerSession.getEffectiveUserName();
    } catch (NotesException e) {
    }
    // here wo do some security checks (I like signers!)
    if (signer == null) {
      log_.severe("!!! The file " + module.getDatabasePath() + "/" + clazzFile + " is not signed!");
      TransponderRegistry.unRegister(module.getDatabasePath());

    } else {
      List<TransponderData> defs = ServiceLocator.findServices(TransponderData.class, Scope.NONE);
      // everything must be signed by the SAME user!!! - check it after loading all services
      if (ctx.getSessionAsSigner() == null) {
        log_.severe(
            "!!! One or more classes listed in "
                + module.getDatabasePath()
                + "/"
                + clazzFile
                + " are not properly signed!");
        TransponderRegistry.unRegister(module.getDatabasePath());
      } else {
        TransponderRegistry.register(module.getDatabasePath(), defs);
      }
    }
  }