Search in sources :

Example 1 with UserCredentials

use of fi.otavanopisto.pyramus.rest.model.UserCredentials in project muikku by otavanopisto.

the class PyramusUserSchoolDataBridge method updateUserCredentials.

@Override
public void updateUserCredentials(String userIdentifier, String oldPassword, String newUsername, String newPassword) {
    Long personId = getPersonId(userIdentifier);
    if (personId == null) {
        logger.warning(String.format("PyramusUserSchoolDataBridge.updateUserCredentials malformed user identifier %s", userIdentifier));
        throw new SchoolDataBridgeInternalException(String.format("Malformed user identifier %s\n%s", userIdentifier, ExceptionUtils.getStackTrace(new Throwable())));
    }
    try {
        UserCredentials change = new UserCredentials(oldPassword, newUsername, newPassword);
        pyramusClient.put("/persons/persons/" + personId + "/credentials", change);
    } catch (PyramusRestClientUnauthorizedException purr) {
        throw new SchoolDataBridgeUnauthorizedException(purr.getMessage());
    }
}
Also used : SchoolDataBridgeInternalException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException) SchoolDataBridgeUnauthorizedException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeUnauthorizedException) UserCredentials(fi.otavanopisto.pyramus.rest.model.UserCredentials) PyramusRestClientUnauthorizedException(fi.otavanopisto.muikku.plugins.schooldatapyramus.rest.PyramusRestClientUnauthorizedException)

Aggregations

PyramusRestClientUnauthorizedException (fi.otavanopisto.muikku.plugins.schooldatapyramus.rest.PyramusRestClientUnauthorizedException)1 SchoolDataBridgeInternalException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeInternalException)1 SchoolDataBridgeUnauthorizedException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeUnauthorizedException)1 UserCredentials (fi.otavanopisto.pyramus.rest.model.UserCredentials)1