use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule in project perun by CESNET.
the class UsersManagerBlImpl method deletePassword.
@Override
public void deletePassword(PerunSession sess, String userLogin, String loginNamespace) throws LoginNotExistsException, PasswordDeletionFailedException, PasswordOperationTimeoutException, InvalidLoginException {
log.info("Deleting password for {} in login-namespace {}.", userLogin, loginNamespace);
// Delete the password
PasswordManagerModule module = getPasswordManagerModule(sess, loginNamespace);
try {
module.deletePassword(sess, userLogin);
} catch (PasswordDeletionFailedRuntimeException e) {
throw new PasswordDeletionFailedException(e);
} catch (LoginNotExistsRuntimeException e) {
throw new LoginNotExistsException(e);
} catch (PasswordOperationTimeoutRuntimeException e) {
throw new PasswordOperationTimeoutException(e);
} catch (InvalidLoginException e) {
throw e;
} catch (Exception ex) {
// fallback for exception compatibility
throw new PasswordDeletionFailedException("Password deletion failed for " + loginNamespace + ":" + userLogin + ".", ex);
}
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule in project perun by CESNET.
the class UsersManagerBlImpl method deletePassword.
@Override
public void deletePassword(PerunSession sess, User user, String loginNamespace) throws LoginNotExistsException, PasswordDeletionFailedException, PasswordOperationTimeoutException, InvalidLoginException {
log.info("Deleting password for {} in login-namespace {}.", user, loginNamespace);
// Delete the password
PasswordManagerModule module = getPasswordManagerModule(sess, loginNamespace);
try {
Attribute attr = getPerunBl().getAttributesManagerBl().getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":" + AttributesManager.LOGIN_NAMESPACE + ":" + loginNamespace);
if (attr.getValue() == null) {
throw new LoginNotExistsException("Attribute containing login has empty value. Namespace: " + loginNamespace);
}
module.deletePassword(sess, attr.valueAsString());
} catch (PasswordDeletionFailedRuntimeException e) {
throw new PasswordDeletionFailedException(e);
} catch (LoginNotExistsRuntimeException e) {
throw new LoginNotExistsException(e);
} catch (PasswordOperationTimeoutRuntimeException e) {
throw new PasswordOperationTimeoutException(e);
} catch (Exception ex) {
// fallback for exception compatibility
throw new PasswordDeletionFailedException("Password deletion failed for " + loginNamespace + ": " + user + ".", ex);
}
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule in project perun by CESNET.
the class UsersManagerBlImpl method validatePassword.
@Override
public void validatePassword(PerunSession sess, User user, String loginNamespace) throws PasswordCreationFailedException, LoginNotExistsException, InvalidLoginException {
log.info("Validating password for {} in login-namespace {}.", user, loginNamespace);
// Get login.
try {
Attribute attr = getPerunBl().getAttributesManagerBl().getAttribute(sess, user, AttributesManager.NS_USER_ATTR_DEF + ":" + AttributesManager.LOGIN_NAMESPACE + ":" + loginNamespace);
if (attr.getValue() == null) {
throw new LoginNotExistsException("Attribute containing login has empty value. Namespace: " + loginNamespace);
}
// Validate the password
PasswordManagerModule module = getPasswordManagerModule(sess, loginNamespace);
try {
module.validatePassword(sess, attr.valueAsString(), user);
} catch (PasswordCreationFailedRuntimeException e) {
throw new PasswordCreationFailedException(e);
}
} catch (AttributeNotExistsException e) {
throw new LoginNotExistsException(e);
} catch (WrongAttributeAssignmentException e) {
throw new InternalErrorException(e);
}
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule in project perun by CESNET.
the class UsersManagerBlImpl method validatePassword.
@Override
public void validatePassword(PerunSession sess, String userLogin, String loginNamespace) throws PasswordCreationFailedException, InvalidLoginException {
log.info("Validating password for {} in login-namespace {}.", userLogin, loginNamespace);
// Validate the password
PasswordManagerModule module = getPasswordManagerModule(sess, loginNamespace);
try {
module.validatePassword(sess, userLogin, null);
} catch (PasswordCreationFailedRuntimeException e) {
throw new PasswordCreationFailedException(e);
}
}
use of cz.metacentrum.perun.core.implApi.modules.pwdmgr.PasswordManagerModule in project perun by CESNET.
the class urn_perun_user_attribute_def_def_login_namespace_eduteams_acc_nicknameTest method setUp.
@Before
public void setUp() throws Exception {
classInstance = new urn_perun_user_attribute_def_def_login_namespace_eduteams_acc_nickname();
session = mock(PerunSessionImpl.class);
user = new User();
attributeToCheck = new Attribute();
attributeToCheck.setNamespace(AttributesManager.NS_USER_ATTR_DEF);
attributeToCheck.setFriendlyName("login-namespace:eduteams-acc-nickname");
PerunBl perunBl = mock(PerunBl.class);
when(session.getPerunBl()).thenReturn(perunBl);
ModulesUtilsBl modulesUtilsBl = mock(ModulesUtilsBl.class);
when(perunBl.getModulesUtilsBl()).thenReturn(modulesUtilsBl);
UsersManagerBl usersManagerBl = mock(UsersManagerBl.class);
when(perunBl.getUsersManagerBl()).thenReturn(usersManagerBl);
PasswordManagerModule module = mock(GenericPasswordManagerModule.class);
when(session.getPerunBl().getUsersManagerBl().getPasswordManagerModule(session, "eduteams-acc-nickname")).thenReturn(module);
}
Aggregations