Skip to content

Commit

Permalink
Refactor osf unconfirmed account exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cslzchen committed Jan 31, 2020
1 parent c14dc5f commit 5c2b1e7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import io.cos.cas.adaptors.postgres.models.OpenScienceFrameworkGuid;
import io.cos.cas.adaptors.postgres.models.OpenScienceFrameworkTimeBasedOneTimePassword;
import io.cos.cas.adaptors.postgres.models.OpenScienceFrameworkUser;
import io.cos.cas.authentication.exceptions.AccountNotConfirmedIdPLoginException;
import io.cos.cas.authentication.exceptions.AccountNotConfirmedOsfLoginException;
import io.cos.cas.authentication.InvalidVerificationKeyException;
import io.cos.cas.authentication.LoginNotAllowedException;
import io.cos.cas.authentication.OneTimePasswordFailedLoginException;
import io.cos.cas.authentication.OneTimePasswordRequiredException;
import io.cos.cas.authentication.OpenScienceFrameworkCredential;
import io.cos.cas.authentication.ShouldNotHappenException;
import io.cos.cas.authentication.exceptions.AccountNotConfirmedIdPLoginException;
import io.cos.cas.authentication.oath.TotpUtils;

import org.jasig.cas.authentication.AccountDisabledException;
Expand Down Expand Up @@ -189,7 +189,7 @@ protected final HandlerResult authenticateInternal(final OpenScienceFrameworkCre

// Check user's status, and only ACTIVE user can sign in
if (USER_NOT_CONFIRMED_OSF.equals(userStatus)) {
throw new LoginNotAllowedException(username + " is registered but not confirmed");
throw new AccountNotConfirmedOsfLoginException(username + " is registered but not confirmed");
} else if (USER_NOT_CONFIRMED_IDP.equals(userStatus)) {
throw new AccountNotConfirmedIdPLoginException(username + " is registered via external IdP but not confirmed ");
} else if (USER_DISABLED.equals(userStatus)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015. Center for Open Science
* Copyright (c) 2020. Center for Open Science
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,23 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cos.cas.authentication;
package io.cos.cas.authentication.exceptions;

import javax.security.auth.login.AccountException;

/**
* Describes an error condition where authentication occurs from an registered but not confirmed account.
* Describes an error condition where authentication occurs from a registered (via OSF email-password sign-up) but
* not confirmed account.
*
* @author Michael Haselton
* @author Longze Chen
* @since 4.1.5
* @since 20.0.0
*/
public class LoginNotAllowedException extends AccountException {
public class AccountNotConfirmedOsfLoginException extends AccountException {

private static final long serialVersionUID = 3376259469680697722L;

/** Instantiates a new exception (default). */
public LoginNotAllowedException() {
public AccountNotConfirmedOsfLoginException() {
super();
}

Expand All @@ -38,7 +38,7 @@ public LoginNotAllowedException() {
*
* @param message the message
*/
public LoginNotAllowedException(final String message) {
public AccountNotConfirmedOsfLoginException(final String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import java.util.Set;

import io.cos.cas.authentication.exceptions.AccountNotConfirmedIdPLoginException;
import io.cos.cas.authentication.exceptions.AccountNotConfirmedOsfLoginException;
import io.cos.cas.authentication.exceptions.CasClientLoginException;
import io.cos.cas.authentication.exceptions.DelegatedLoginException;
import io.cos.cas.authentication.exceptions.OrcidClientLoginException;
import io.cos.cas.authentication.InvalidVerificationKeyException;
import io.cos.cas.authentication.LoginNotAllowedException;
import io.cos.cas.authentication.OneTimePasswordFailedLoginException;
import io.cos.cas.authentication.OneTimePasswordRequiredException;
import io.cos.cas.authentication.RemoteUserFailedLoginException;
Expand All @@ -52,7 +52,7 @@
*
* @author Michael Haselton
* @author Longze Chen
* @since 4.1.5
* @since 19.0.0
*/
public class OpenScienceFrameworkAuthenticationExceptionHandler extends AuthenticationExceptionHandler {

Expand Down Expand Up @@ -81,7 +81,7 @@ public class OpenScienceFrameworkAuthenticationExceptionHandler extends Authenti
// Customized exceptions for OSF
static {
DEFAULT_ERROR_LIST.add(InvalidVerificationKeyException.class);
DEFAULT_ERROR_LIST.add(LoginNotAllowedException.class);
DEFAULT_ERROR_LIST.add(AccountNotConfirmedOsfLoginException.class);
DEFAULT_ERROR_LIST.add(AccountNotConfirmedIdPLoginException.class);
DEFAULT_ERROR_LIST.add(ShouldNotHappenException.class);
DEFAULT_ERROR_LIST.add(RemoteUserFailedLoginException.class);
Expand Down
6 changes: 3 additions & 3 deletions cas-server-webapp/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ screen.badworkstation.heading=You cannot login from this workstation.
screen.badworkstation.message=Please contact <a style="white-space: nowrap" href="mailto:[email protected]">[email protected]</a> to regain access.

# OSF Login Failure Pages
screen.loginnotallowed.heading=Account not confirmed
screen.loginnotallowed.message=The OSF account associated with the email has been registered but not confirmed. Please check your email (and spam folder) or click the button below to resend your confirmation email.
screen.accountnotconfirmed.osflogin.heading=Account not confirmed
screen.accountnotconfirmed.osflogin.message=The OSF account associated with the email has been registered but not confirmed. Please check your email (and spam folder) or click the button below to resend your confirmation email.
screen.accountnotconfirmed.osflogin.button.resendConfirmation=Resend confirmation email
screen.accountnotconfirmed.idplogin.heading=Account not confirmed
screen.accountnotconfirmed.idplogin.message=The OSF account associated with the email has been registered but not confirmed. Our records show that this account was created via ORCiD login. Please check your email (and spam folder) for the confirmation link. If you believe this should not happen, please contact <a style="white-space: nowrap" href="mailto:[email protected]">OSF Support</a>.
screen.loginnotallowed.button.resendConfirmation=Resend confirmation email
screen.accountdisabled.heading=Account disabled
screen.accountdisabled.message=The OSF account associated with the email has been disabled. Please contact <a style="white-space: nowrap" href="mailto:[email protected]">OSF Support</a> to regain access.
screen.shouldnothappen.heading=Account not active
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%--
Copyright (c) 2015. Center for Open Science
Copyright (c) 2020. Center for Open Science
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -16,19 +16,19 @@
--%>

<%-- Login exception page: account not confirmed --%>
<%-- Login exception page: account created via OSF email-password sign-up but not confirmed --%>

<jsp:directive.include file="includes/top.jsp"/>

<div id="msg" class="errors">
<h2><spring:message code="screen.loginnotallowed.heading"/></h2>
<p><spring:message code="screen.loginnotallowed.message"/></p>
<h2><spring:message code="screen.accountnotconfirmed.osflogin.heading"/></h2>
<p><spring:message code="screen.accountnotconfirmed.osflogin.message"/></p>
<hr/><br/>
<section class="row">
<spring:eval var="osfResendConfirmationUrl" expression="@casProperties.getProperty('osf.resendConfirmation.url')"/>
<a id="alt-login-inst" class="btn-alt-login" href="${osfResendConfirmationUrl}">
<img class="osf-alt-logo" src="../images/osf-logo.png">
<span class="label-login"><spring:message code="screen.loginnotallowed.button.resendConfirmation"/></span>
<span class="label-login"><spring:message code="screen.accountnotconfirmed.osflogin.button.resendConfirmation"/></span>
</a>
</section>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<transition on="AccountDisabledException" to="casAccountDisabledView"/>
<!-- Customized exceptions for OSF -->
<transition on="InvalidVerificationKeyException" to="casInvalidVerificationKeyView" />
<transition on="LoginNotAllowedException" to="casLoginNotAllowedView" />
<transition on="AccountNotConfirmedOsfLoginException" to="casAccountNotConfirmedOsfLoginView" />
<transition on="AccountNotConfirmedIdPLoginException" to="casAccountNotConfirmedIdPLoginView" />
<transition on="ShouldNotHappenException" to="casShouldNotHappenView" />
<transition on="RemoteUserFailedLoginException" to="casRemoteUserFailedLoginView" />
Expand Down Expand Up @@ -283,7 +283,7 @@
<end-state id="casAccountLockedView" view="casAccountLockedView"/>
<end-state id="casBadHoursView" view="casBadHoursView"/>
<end-state id="casBadWorkstationView" view="casBadWorkstationView"/>
<end-state id="casLoginNotAllowedView" view="casLoginNotAllowedView" />
<end-state id="casAccountNotConfirmedOsfLoginView" view="casAccountNotConfirmedOsfLoginView" />
<end-state id="casAccountNotConfirmedIdPLoginView" view="casAccountNotConfirmedIdPLoginView" />
<end-state id="casShouldNotHappenView" view="casShouldNotHappenView" />
<end-state id="casRemoteUserFailedLoginView" view="casRemoteUserFailedLoginView" />
Expand Down

0 comments on commit 5c2b1e7

Please sign in to comment.