Exemplo n.º 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);
   }
 }
Exemplo n.º 2
0
 public Integer extractLowPort(NetworkRule rule) {
   return rule.getLowPort();
 }
Exemplo n.º 3
0
 @Override
 public Integer extractIcmpType(final NetworkRule rule) {
   return rule.getLowPort();
 }