use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.ISResponseData in project perun by CESNET.
the class MuPasswordManagerModuleTest method changePassword.
@Test
public void changePassword() throws Exception {
ISResponseData okResponseData = new ISResponseData();
okResponseData.setStatus(IS_OK_STATUS);
when(isServiceCallerMock.call(anyString(), anyInt())).thenReturn(okResponseData);
module.checkPasswordStrength(sess, null, "randomPassword2.");
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.ISResponseData in project perun by CESNET.
the class MuPasswordManagerModuleTest method generatedPasswordContainsOnlyAllowedChars.
@Test
public void generatedPasswordContainsOnlyAllowedChars() throws Exception {
ISResponseData okResponseData = new ISResponseData();
okResponseData.setStatus(IS_OK_STATUS);
when(isServiceCallerMock.call(anyString(), anyInt())).thenReturn(okResponseData);
// test that password does not contain any invalid character
Assert.assertFalse(MUPasswordContainsNotAllowedChars.matcher(module.generateRandomPassword(sess, null)).matches());
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.ISResponseData in project perun by CESNET.
the class MuPasswordManagerModuleTest method generatedPasswordHasValidLength.
@Test
public void generatedPasswordHasValidLength() throws Exception {
ISResponseData okResponseData = new ISResponseData();
okResponseData.setStatus(IS_OK_STATUS);
when(isServiceCallerMock.call(anyString(), anyInt())).thenReturn(okResponseData);
Assert.assertEquals(module.generateRandomPassword(sess, null).length(), randomPasswordLength);
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.ISResponseData in project perun by CESNET.
the class MuPasswordManagerModule method changePasswordWithoutCheck.
private void changePasswordWithoutCheck(PerunSession sess, String login, String password) throws PasswordStrengthException {
try {
int requestID = (new Random()).nextInt(1000000) + 1;
String requestBody = getPwdChangeRequest(sess, login, password, requestID);
// if error, throws exception, otherwise it's ok
ISResponseData responseData = isServiceCaller.call(requestBody, requestID);
if (IS_ERROR_STATUS.equals(responseData.getStatus())) {
throw new PasswordStrengthException(responseData.getError());
}
} catch (IOException e) {
throw new InternalErrorException(e);
}
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.ISResponseData in project perun by CESNET.
the class MuPasswordManagerModule method generateAccount.
@Override
public Map<String, String> generateAccount(PerunSession session, Map<String, String> parameters) throws PasswordStrengthException {
if (parameters.get(PASSWORD_KEY) != null && !parameters.get(PASSWORD_KEY).isEmpty()) {
checkPasswordStrength(session, "--not yet known--", parameters.get(PASSWORD_KEY));
} else {
parameters.put(PASSWORD_KEY, generateRandomPassword(session, "--not yet known--"));
}
try {
int requestID = (new Random()).nextInt(1000000) + 1;
String requestBody = getGenerateAccountRequest(session, parameters, requestID);
ISResponseData responseData = isServiceCaller.call(requestBody, requestID);
if (!IS_OK_STATUS.equals(responseData.getStatus())) {
throw new InternalErrorException("IS MU (password manager backend) responded with error to a Request ID: " + requestID + " Error: " + responseData.getError());
}
return parseUCO(responseData.getResponse(), requestID);
} catch (IOException e) {
throw new InternalErrorException(e);
}
}
Aggregations