DisableGoogleAuthenticatorCredentialClickListener.java

  1. /*
  2.  * Copyright 2010-2025 James Pether Sörling
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  *   http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  *
  16.  *  $Id$
  17.  *  $HeadURL$
  18. */
  19. package com.hack23.cia.web.impl.ui.application.views.pageclicklistener;

  20. import org.slf4j.Logger;
  21. import org.slf4j.LoggerFactory;

  22. import com.hack23.cia.service.api.action.common.ServiceResponse.ServiceResult;
  23. import com.hack23.cia.service.api.action.user.DisableGoogleAuthenticatorCredentialRequest;
  24. import com.hack23.cia.service.api.action.user.DisableGoogleAuthenticatorCredentialResponse;
  25. import com.vaadin.ui.Button.ClickEvent;
  26. import com.vaadin.ui.Button.ClickListener;
  27. import com.vaadin.ui.Notification;

  28. /**
  29.  * The Class DisableGoogleAuthenticatorCredentialClickListener.
  30.  *
  31.  * @see DisableGoogleAuthenticatorCredentialClickEvent
  32.  */
  33. public class DisableGoogleAuthenticatorCredentialClickListener extends AbstractClickListener implements ClickListener {

  34.     /** The Constant ERROR_MESSAGE. */
  35.     private static final String ERROR_MESSAGE = "Error message";

  36.     /** The Constant LOGGER. */
  37.     private static final Logger LOGGER = LoggerFactory
  38.             .getLogger(DisableGoogleAuthenticatorCredentialClickListener.class);

  39.     /** The Constant PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR. */
  40.     private static final String PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR = "Problem disable google authenticator";

  41.     /** The Constant PROBLEM_ENABLE_GOOGLE_AUTHENTICATOR_SESSIONID. */
  42.     private static final String PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR_SESSIONID = "Problem disable google authenticator, sessionid{}";

  43.     /** The Constant serialVersionUID. */
  44.     private static final long serialVersionUID = 1L;

  45.     /** The google auth request. */
  46.     private final DisableGoogleAuthenticatorCredentialRequest googleAuthRequest;

  47.     /**
  48.      * Instantiates a new disable google authenticator credential click listener.
  49.      *
  50.      * @param googleAuthRequest
  51.      *            the google auth request
  52.      */
  53.     public DisableGoogleAuthenticatorCredentialClickListener(
  54.             final DisableGoogleAuthenticatorCredentialRequest googleAuthRequest) {
  55.         this.googleAuthRequest = googleAuthRequest;
  56.     }

  57.     @Override
  58.     public final void buttonClick(final ClickEvent event) {
  59.         final DisableGoogleAuthenticatorCredentialResponse response = (DisableGoogleAuthenticatorCredentialResponse) getApplicationManager().service(googleAuthRequest);

  60.         if (ServiceResult.FAILURE == response.getResult()) {
  61.             showNotification(PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
  62.             LOGGER.info(PROBLEM_DISABLE_GOOGLE_AUTHENTICATOR_SESSIONID, googleAuthRequest.getSessionId());
  63.         }
  64.     }
  65. }