示例#1
0
    public static void ensureRightPrivilege() {
      IRight rightFact = AAAFactory.right();
      IPrivilege privFact = AAAFactory.privilege();
      for (Authority a : reg_.values()) {
        RequireRight rr = a.rr_;
        IRight r = a.r_;
        if (rr != null && r == null) {
          String s = rr.value();
          if (null == s) throw new NullPointerException("Null RequireRight found for " + a.key_);
          if (s.startsWith("aaa")) s = Play.configuration.getProperty(s);
          r = rightFact.getByName(s);
          if (null == r) {
            r = rightFact.create(s);
            r._save();
          }
          a.r_ = r;
        }

        RequirePrivilege rp = a.rp_;
        IPrivilege p = a.p_;
        if (rp != null && p == null) {
          String s = rp.value();
          if (null == s)
            throw new NullPointerException("Null RequirePrivilege found for " + a.key_);
          if (s.startsWith("aaa")) s = Play.configuration.getProperty(s);
          p = privFact.getByName(s);
          if (null == p) {
            p = privFact.create(s, 0);
            p._save();
          }
          a.p_ = p;
        }
      }
    }