コード例 #1
0
 /**
  * Whether or not the effective user of the Session has access to read logs
  *
  * @param session Session (remember you can use sessionAsSigner / sessionAsSignerWithFullAccess)
  * @return boolean whether user has access
  * @since org.openntf.domino.xsp 2.5.0
  */
 private boolean canReadLogs(final lotus.domino.Session session) {
   boolean result = false;
   try {
     String username = session.getEffectiveUserName();
     DominoServer server = new DominoServer();
     result = server.checkServerAccess(username, ServerAccess.PROG_UNRESTRICTED);
     result = result || server.checkServerAccess(username, ServerAccess.VIEW_ONLY_ADMIN);
   } catch (NotesException ne) {
     ne.printStackTrace();
   }
   return result;
 }
コード例 #2
0
 @Override
 public int executeCode(Session arg0, Database arg1) {
   try {
     setCurrentTaskStatus("Task started");
     setTaskCompletion(0);
     System.out.println(arg0.getCommonUserName());
     System.out.println(arg0.getEffectiveUserName());
     System.out.println(arg1.getFilePath());
     setCurrentTaskStatus("Task finished");
     setTaskCompletion(100);
   } catch (Exception e) {
     e.printStackTrace();
   }
   return 0;
 }
コード例 #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);
      }
    }
  }