From 0224ef49788ec7132a6a8b4db0098c111ad5b4bf Mon Sep 17 00:00:00 2001 From: Andrea Ceccanti Date: Wed, 10 Feb 2016 17:52:36 +0100 Subject: [PATCH] Add ability to disable member expiration warnings Issue: https://issues.infn.it/jira/browse/VOMS-706 --- .../scripts/configure/voms_configure.py | 2 + .../resources/templates/service.properties | 6 ++ .../VOMSConfigurationConstants.java | 1 + .../impl/DefaultMembershipCheckBehaviour.java | 61 +++++++++++-------- .../NoOpHandleExpiringMembersStrategy.java | 39 ++++++++++++ 5 files changed, 82 insertions(+), 27 deletions(-) create mode 100644 voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/NoOpHandleExpiringMembersStrategy.java diff --git a/voms-admin-server/resources/scripts/configure/voms_configure.py b/voms-admin-server/resources/scripts/configure/voms_configure.py index b326fbd6..420229e6 100644 --- a/voms-admin-server/resources/scripts/configure/voms_configure.py +++ b/voms-admin-server/resources/scripts/configure/voms_configure.py @@ -272,6 +272,8 @@ def setup_cl_options(): membership_opt_group.add_option("--preserve-expired-members", action="store_true", dest="preserve_expired_members", help="Do not suspend users whose membership has expired.", default=False) membership_opt_group.add_option("--preserve-aup-failing-members", action="store_true", dest="preserve_aup_failing_members", help="Do not suspend users that fail to sign the AUP in time.", default=False) membership_opt_group.add_option("--disable-membership-end-time", action="store_true", dest="disable_membership_end_time", help="Disable membership end time checks completely.", default=False) + + membership_opt_group.add_option("--disable-membership-expiration-warnings", action="store_true", dest="disable_membership_expiration_warning", help="Disable membership expiration warnings.", default=False) membership_opt_group.add_option("--membership-default-lifetime", type="int", dest="membership_default_lifetime", help="Default VO membership lifetime duration (in months).", metavar="MONTHS", default=12) diff --git a/voms-admin-server/resources/templates/service.properties b/voms-admin-server/resources/templates/service.properties index 9fa06831..2f78c134 100644 --- a/voms-admin-server/resources/templates/service.properties +++ b/voms-admin-server/resources/templates/service.properties @@ -56,6 +56,12 @@ voms.membership.default_lifetime = $membership_default_lifetime ## this configuration option. voms.membership.expiration_warning_period = $membership_expiration_warning_period +## Disable membership expiration warning notifications. +## When this flag is set to true, VOMS admin does not send notifications +## to VO Admins about users about to expired in the time period defined by the +## voms.membership.expiration_warning_period configuration property. +voms.membership.disable_expiration_warning = $disable_membership_expiration_warning + ## Membership expiration grace period (in days). In the grace period ## the user will be maintained active even if its membership has expired. ## Note that this option has no effect if the voms.preserve_expired_members diff --git a/voms-admin-server/src/main/java/org/glite/security/voms/admin/configuration/VOMSConfigurationConstants.java b/voms-admin-server/src/main/java/org/glite/security/voms/admin/configuration/VOMSConfigurationConstants.java index aa01ccf2..def32f61 100644 --- a/voms-admin-server/src/main/java/org/glite/security/voms/admin/configuration/VOMSConfigurationConstants.java +++ b/voms-admin-server/src/main/java/org/glite/security/voms/admin/configuration/VOMSConfigurationConstants.java @@ -95,6 +95,7 @@ public interface VOMSConfigurationConstants { */ public static final String DEFAULT_MEMBERSHIP_LIFETIME = "voms.membership.default_lifetime"; public static final String MEMBERSHIP_CHECK_PERIOD = "voms.task.membership_check.period"; + public static final String DISABLE_MEMBERSHIP_EXPIRATION_WARNING="voms.membership.disable_expiration_warning"; public static final String MEMBERSHIP_EXPIRATION_WARNING_PERIOD = "voms.membership.expiration_warning_period"; public static final String MEMBERSHIP_EXPIRATION_WARNING_PERIOD_DEFAULT_VALUE = "15"; public static final String MEMBERSHIP_EXPIRATION_GRACE_PERIOD = "voms.membership.expiration_grace_period"; diff --git a/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/DefaultMembershipCheckBehaviour.java b/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/DefaultMembershipCheckBehaviour.java index ff253f18..4ec0fceb 100644 --- a/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/DefaultMembershipCheckBehaviour.java +++ b/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/DefaultMembershipCheckBehaviour.java @@ -30,8 +30,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class DefaultMembershipCheckBehaviour extends - AbstractMembershipCheckBehaviour { +public class DefaultMembershipCheckBehaviour + extends AbstractMembershipCheckBehaviour { public static final Logger log = LoggerFactory .getLogger(DefaultMembershipCheckBehaviour.class); @@ -50,17 +50,14 @@ protected void validateMembershipCheckConfiguration() { boolean disableMembershipEndTime = conf.getBoolean( VOMSConfigurationConstants.DISABLE_MEMBERSHIP_END_TIME, false); - boolean preserveExpiredMembers = conf.getBoolean( - VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS, false); - - + boolean preserveExpiredMembers = conf + .getBoolean(VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS, false); + if (disableMembershipEndTime && preserveExpiredMembers) { - log - .error( - "The {} and {} configuration properties cannot be true at the same time", - new String[] { - VOMSConfigurationConstants.DISABLE_MEMBERSHIP_END_TIME, - VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS }); + log.error( + "The {} and {} configuration properties cannot be true at the same time", + new String[] { VOMSConfigurationConstants.DISABLE_MEMBERSHIP_END_TIME, + VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS }); log.warn("Setting {} to false", VOMSConfigurationConstants.DISABLE_MEMBERSHIP_END_TIME); @@ -80,31 +77,41 @@ public DefaultMembershipCheckBehaviour() { VOMSConfigurationConstants.PRESERVE_AUP_FAILING_MEMBERS, false); aupFMLookupStrategy = new DefaultAUPFailingMembersLookupStrategy(); - - if (preserveAUPFailingMembers){ + + if (preserveAUPFailingMembers) { log.warn("Members that fail to sign the VO AUP in time will NOT be " + "automatically suspended, as requested by the configuration."); - + aupFailingMembersStrategy = new NoOpAUPFailingMembersStrategy(); - }else { + } else { aupFailingMembersStrategy = new SuspendAUPFailingMembersStrategy(); } - boolean disableMembershipEndTime = conf.getBoolean( VOMSConfigurationConstants.DISABLE_MEMBERSHIP_END_TIME, false); - boolean preserveExpiredMembers = conf.getBoolean( - VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS, false); + boolean preserveExpiredMembers = conf + .getBoolean(VOMSConfigurationConstants.PRESERVE_EXPIRED_MEMBERS, false); - int notificationInterval = VOMSConfiguration.instance().getInt( - VOMSConfigurationConstants.NOTIFICATION_WARNING_RESEND_PERIOD, 1); + int notificationInterval = VOMSConfiguration.instance() + .getInt(VOMSConfigurationConstants.NOTIFICATION_WARNING_RESEND_PERIOD, 1); + + final boolean disableExpiringMembersNotification = conf.getBoolean( + VOMSConfigurationConstants.DISABLE_MEMBERSHIP_EXPIRATION_WARNING, false); + + HandleExpiringMembersStrategy ems = new SendWarningAboutExpiringMembersStrategy(); + + if (disableExpiringMembersNotification) { + ems = new NoOpHandleExpiringMembersStrategy(); + log.warn( + "Disabling expiring members warnings as requested by configuration."); + } if (disableMembershipEndTime) { IgnoreMembershipEndTimeStrategy s = new IgnoreMembershipEndTimeStrategy(); - log - .warn("The membership end time will be IGNORED by the VOMS membership check behaviour as requested by configuration."); + log.warn( + "The membership end time will be IGNORED by the VOMS membership check behaviour as requested by configuration."); expiredMembersLookupStrategy = s; expiredMembersStrategy = s; @@ -113,15 +120,15 @@ public DefaultMembershipCheckBehaviour() { } else if (preserveExpiredMembers) { - log - .warn("Expired members will NOT be suspended as requested. Administrators will be notified of expired members via email."); + log.warn( + "Expired members will NOT be suspended as requested. Administrators will be notified of expired members via email."); expiredMembersStrategy = new PreserveExpiredMembersStrategy( notificationInterval); expiredMembersLookupStrategy = new DefaultExpiredMembersLookupStrategy(); expiringMembersLookupStrategy = new DefaultExpiringMembersLookupStrategy(); - expiringMembersStrategy = new SendWarningAboutExpiringMembersStrategy(); + expiringMembersStrategy = ems; } else { @@ -140,7 +147,7 @@ public DefaultMembershipCheckBehaviour() { expiredMembersStrategy = new GracePeriodExpiredMembersStrategy( gracePeriodInDays, notificationInterval); - expiringMembersStrategy = new SendWarningAboutExpiringMembersStrategy(); + expiringMembersStrategy = ems; } } diff --git a/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/NoOpHandleExpiringMembersStrategy.java b/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/NoOpHandleExpiringMembersStrategy.java new file mode 100644 index 00000000..ef18cf86 --- /dev/null +++ b/voms-admin-server/src/main/java/org/glite/security/voms/admin/core/validation/strategies/impl/NoOpHandleExpiringMembersStrategy.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) Istituto Nazionale di Fisica Nucleare (INFN). 2006-2015 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.glite.security.voms.admin.core.validation.strategies.impl; + +import java.util.List; + +import org.glite.security.voms.admin.core.validation.strategies.HandleExpiringMembersStrategy; +import org.glite.security.voms.admin.persistence.model.VOMSUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NoOpHandleExpiringMembersStrategy + implements HandleExpiringMembersStrategy { + + public static final Logger LOG = LoggerFactory + .getLogger(NoOpHandleExpiringMembersStrategy.class); + + @Override + public void handleMembersAboutToExpire(List expiringMembers) { + + LOG.debug("Doing nothing about members about to expire, as requested"); + + + } + +}