Пример #1
0
 /** Any imcp rules created without ports should have the values updated to -1 (any) */
 private void setPortsForIcmpRules() {
   try (final TransactionResource tx = Entities.distinctTransactionFor(NetworkRule.class)) {
     for (final NetworkRule rule :
         Entities.criteriaQuery(
                 Entities.restriction(NetworkRule.class)
                     .any(
                         Entities.restriction(NetworkRule.class)
                             .isNull(NetworkRule_.lowPort)
                             .build(),
                         Entities.restriction(NetworkRule.class)
                             .isNull(NetworkRule_.highPort)
                             .build())
                     .equal(NetworkRule_.protocol, Protocol.icmp))
             .list()) {
       logger.info(
           "Updating ports for icmp rule in group "
               + rule.getGroup().getGroupId()
               + "/"
               + rule.getGroup().getDisplayName());
       if (rule.getLowPort() == null) {
         rule.setLowPort(-1);
       }
       if (rule.getHighPort() == null) {
         rule.setHighPort(-1);
       }
     }
     tx.commit();
   } catch (Exception ex) {
     logger.error("Error updating ports for icmp rules", ex);
   }
 }
Пример #2
0
 public Integer extractHighPort(NetworkRule rule) {
   return rule.getHighPort();
 }
Пример #3
0
 @Override
 public Integer extractIcmpCode(final NetworkRule rule) {
   return rule.getHighPort();
 }