Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ login.institution.support.afterLink=for assistance.
login.builtin.credential.usernameOrEmail=Username/Email
login.builtin.credential.password=Password
login.builtin.invalidUsernameEmailOrPassword=The username, email address, or password you entered is invalid. Need assistance accessing your account?
login.echo.credential.name=Name
login.echo.credential.email=Email
login.echo.credential.affiliation=Affiliation
# how do we exercise login.error? Via a password upgrade failure? See https://github.com/IQSS/dataverse/pull/2922
login.error=Error validating the username, email address, or password. Please try again. If the problem persists, contact an administrator.
user.error.cannotChangePassword=Sorry, your password cannot be changed. Please contact your system administrator.
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/Bundle_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ login.institution.support.afterLink=pour obtenir de l'aide.
login.builtin.credential.usernameOrEmail=Nom d'utilisateur/courriel
login.builtin.credential.password=Mot de passe
login.builtin.invalidUsernameEmailOrPassword=Le nom d'utilisateur, le courriel ou le mot de passe indiqu� n'est pas valide. Avez-vous besoin d'aide pour acc�der � votre compte?
login.echo.credential.name=Nom
login.echo.credential.email=Email
login.echo.credential.affiliation=Affiliation
# how do we exercise login.error? Via a password upgrade failure? See https://github.com/IQSS/dataverse/pull/2922
login.error=Une erreur s'est produite au moment de la validation du nom d'utilisateur ou du mot de passe. Veuillez essayer � nouveau. Si le probl�me persiste, communiquez avec un administrateur.
user.error.cannotChangePassword=D�sol�, votre mot de passe ne peut pas �tre modifi�. Veuillez contacter votre administrateur syst�me.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/LoginPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public String login() {
}
for ( FilledCredential fc : filledCredentialsList ) {
if(fc.getValue()==null || fc.getValue().isEmpty()){
JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("login."+fc.getCredential().getTitle()));
JH.addMessage(FacesMessage.SEVERITY_ERROR, BundleUtil.getStringFromBundle("login."+fc.getCredential().getKey()));
}
authReq.putCredential(fc.getCredential().getTitle(), fc.getValue());
authReq.putCredential(fc.getCredential().getKey(), fc.getValue());
}
authReq.setIpAddress( dvRequestService.getDataverseRequest().getSourceAddress() );
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
public interface CredentialsAuthenticationProvider extends AuthenticationProvider {

static class Credential {
private final String title;
private final String key;

/**
* When {@code true}, the login form will use the secret/password widget rather than the regular text field.
*/
private final boolean secret;

public Credential(String title, boolean secret) {
this.title = title;
public Credential(String key, boolean secret) {
this.key = key;
this.secret = secret;
}
public Credential(String title) {
this( title, false);
public Credential(String key) {
this( key, false);
}

public String getTitle() {
return title;
public String getKey() {
return key;
}

public boolean isSecret() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
public class BuiltinAuthenticationProvider implements CredentialsAuthenticationProvider {

public static final String PROVIDER_ID = "builtin";
private static String KEY_USERNAME_OR_EMAIL;
private static String KEY_PASSWORD;
private static final String KEY_USERNAME_OR_EMAIL = "login.builtin.credential.usernameOrEmail";
private static final String KEY_PASSWORD = "login.builtin.credential.password";
private static List<Credential> CREDENTIALS_LIST;

final BuiltinUserServiceBean bean;
Expand All @@ -35,8 +35,6 @@ public BuiltinAuthenticationProvider( BuiltinUserServiceBean aBean, PasswordVali
this.bean = aBean;
this.authBean = auBean;
this.passwordValidatorService = passwordValidatorService;
KEY_USERNAME_OR_EMAIL = BundleUtil.getStringFromBundle("login.builtin.credential.usernameOrEmail");
KEY_PASSWORD = BundleUtil.getStringFromBundle("login.builtin.credential.password");
CREDENTIALS_LIST = Arrays.asList(new Credential(KEY_USERNAME_OR_EMAIL), new Credential(KEY_PASSWORD, true));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class EchoAuthenticationProvider implements CredentialsAuthenticationProv
private final String prefix;
private final String postfix;
private final AuthenticationProviderDisplayInfo info;
private final String KEY_NAME = "login.echo.credential.name";
private final String KEY_EMAIL = "login.echo.credential.email";
private final String KEY_AFFILIATION = "login.echo.credential.affiliation";


public EchoAuthenticationProvider(String id, String prefix, String postfix, AuthenticationProviderDisplayInfo someInfo) {
Expand All @@ -42,9 +45,9 @@ public EchoAuthenticationProvider(String id) {

@Override
public List<Credential> getRequiredCredentials() {
return Arrays.asList( new Credential("Name"),
new Credential("Email"),
new Credential("Affiliation") );
return Arrays.asList( new Credential(KEY_NAME),
new Credential(KEY_EMAIL),
new Credential(KEY_AFFILIATION) );
}

@Override
Expand All @@ -60,10 +63,10 @@ public AuthenticationProviderDisplayInfo getInfo() {
@Override
public AuthenticationResponse authenticate(AuthenticationRequest request) {
AuthenticatedUserDisplayInfo disinf = new AuthenticatedUserDisplayInfo(
prefix + " " + request.getCredential("Name") + " " + postfix,
prefix + " " + request.getCredential("Name") + " " + postfix,
request.getCredential("Email"),
request.getCredential("Affiliation"),
prefix + " " + request.getCredential(KEY_NAME) + " " + postfix,
prefix + " " + request.getCredential(KEY_NAME) + " " + postfix,
request.getCredential(KEY_EMAIL),
request.getCredential(KEY_AFFILIATION),
null);
return AuthenticationResponse.makeSuccess(disinf.getEmailAddress(), disinf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ public String convertExistingAccount() {
BuiltinAuthenticationProvider biap = new BuiltinAuthenticationProvider(builtinUserSvc, passwordValidatorService, authenticationSvc);
AuthenticationRequest auReq = new AuthenticationRequest();
final List<CredentialsAuthenticationProvider.Credential> creds = biap.getRequiredCredentials();
auReq.putCredential(creds.get(0).getTitle(), getUsername());
auReq.putCredential(creds.get(1).getTitle(), getPassword());
auReq.putCredential(creds.get(0).getKey(), getUsername());
auReq.putCredential(creds.get(1).getKey(), getPassword());
try {
AuthenticatedUser existingUser = authenticationSvc.getUpdateAuthenticatedUser(BuiltinAuthenticationProvider.PROVIDER_ID, auReq);
authenticationSvc.updateProvider(existingUser, newUser.getServiceId(), newUser.getIdInService());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static String getStringFromBundle(String key, List<String> arguments) {

public static String getStringFromBundle(String key, List<String> arguments, ResourceBundle bundle) {
try {
return getStringFromBundleNoMissingCheck(key, arguments, bundle);
return getStringFromBundleNoMissingCheck(key, arguments, bundle);
} catch (MissingResourceException ex) {
logger.warning("Could not find key \"" + key + "\" in bundle file: ");
logger.log(Level.CONFIG, ex.getMessage(), ex);
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/loginpage.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ui:repeat id="credentialsContainer" value="#{LoginPage.filledCredentials}" var="fc">
<div class="form-group text-left">
<label class="col-sm-4 control-label" for="credValue">
#{fc.credential.title}
#{bundle[fc.credential.key]}
</label>
<div class="col-sm-8">
<h:inputText rendered="#{not fc.credential.secret}" value="#{fc.value}" id="credValue" styleClass="form-control"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public void testVerifyPassword() {
@Test
public void testAuthenticate() {
bean.save(makeBuiltInUser());
String crdUsername = sut.getRequiredCredentials().get(0).getTitle();
String crdPassword = sut.getRequiredCredentials().get(1).getTitle();
String crdUsername = sut.getRequiredCredentials().get(0).getKey();
String crdPassword = sut.getRequiredCredentials().get(1).getKey();
AuthenticationRequest req = new AuthenticationRequest();
req.putCredential(crdUsername, "username");
req.putCredential(crdPassword, "password");
Expand Down