Пример #1
0
  /**
   * @param contextSequence
   * @param contextItem
   * @param stringArg
   * @return
   * @throws XPathException
   */
  private Sequence evalGeneric(Sequence[] args, Sequence stringArg) throws XPathException {
    String string = stringArg.getStringValue();
    String pattern = translateRegexp(args[1].getStringValue());

    int flags = 0;
    if (args.length == 3) flags = parseFlags(args[2].getStringValue());

    return match(string, pattern, flags);
  }
Пример #2
0
 public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException {
   Sequence userSeq = getArgument(0).eval(contextSequence, contextItem);
   Sequence passwdSeq = getArgument(1).eval(contextSequence, contextItem);
   if (userSeq.isEmpty()) throw new XPathException(getASTNode(), "No user specified");
   String userName = userSeq.getStringValue();
   String passwd = passwdSeq.getStringValue();
   org.exist.security.SecurityManager security =
       context.getBroker().getBrokerPool().getSecurityManager();
   User user = security.getUser(userName);
   if (user == null) throw new XPathException(getASTNode(), "Authentication failed");
   if (user.validate(passwd)) {
     User oldUser = context.getBroker().getUser();
     try {
       context.getBroker().setUser(user);
       return getArgument(2).eval(contextSequence, contextItem);
     } finally {
       context.getBroker().setUser(oldUser);
     }
   } else throw new XPathException(getASTNode(), "Authentication failed");
 }