コード例 #1
0
 @Override
 @Transactional
 public List<Entitlement> getEntitlementsByRole(String role) {
   List<Entitlement> list =
       (List<Entitlement>) genericDAO.listByStringColumnSearch("Entitlement", "role", role);
   return list;
 }
コード例 #2
0
  @Override
  @Transactional
  public boolean isUserEntitled(String userEmail, String url, String httpMethod) {
    boolean userEntitledForURLAndMethod = false;
    APPUser user = userService.getUserByUserEmail(userEmail);
    List<Entitlement> entitlements = new ArrayList<Entitlement>();
    for (String role : user.getRoles()) {
      entitlements.addAll(getEntitlementsByRole(role));
    }

    for (Entitlement entitlement : entitlements) {

      List<URLPatternMethodAndEntitlement> urlEntitlements =
          (List<URLPatternMethodAndEntitlement>)
              genericDAO.listByStringColumnSearch(
                  "URLPatternMethodAndEntitlement", "entitlement", entitlement.getEntitlement());

      for (URLPatternMethodAndEntitlement urlEntitlement : urlEntitlements) {
        /*
         * DB retrieves for "\\" contain "\\\\"
         * e.g. \\w retrieved as \\\\w
         */
        String regularExpression = urlEntitlement.getUrlPattern().replace("\\\\", "\\");

        // Create a Pattern object
        Pattern pattern = Pattern.compile(regularExpression);

        // Now create matcher object.
        Matcher matcher = pattern.matcher(url);

        if (matcher.matches() && httpMethod.toUpperCase().equals(urlEntitlement.getMethod())) {
          userEntitledForURLAndMethod = true;
          return userEntitledForURLAndMethod;
        }
      }
    }

    return userEntitledForURLAndMethod;
  }
コード例 #3
0
 @Override
 @Transactional
 public Entitlement getEntitlementByPK(Object compositePK) {
   return (Entitlement)
       genericDAO.getByCompositePK("org.nikhil.webapp.nodeadmin.entity.Entitlement", compositePK);
 }
コード例 #4
0
 @Override
 @Transactional
 public List<Entitlement> listEntitlements() {
   return (List<Entitlement>) genericDAO.listObjects("Entitlement");
 }
コード例 #5
0
 @Override
 @Transactional
 public void updateEntitlement(Entitlement entitlement) {
   genericDAO.updateObject(entitlement);
 }
コード例 #6
0
 @Override
 @Transactional
 public void addEntitlement(Entitlement entitlement) {
   genericDAO.addObject(entitlement);
 }