use of fi.otavanopisto.pyramus.dao.DAOFactory in project pyramus by otavanopisto.
the class ClientApplicationAuthorizationCodeAPI method create.
public Long create(String authorizationCode, String redirectUrl, Long userId, Long clientApplicationId) throws InvalidScriptException {
DAOFactory daoFactory = DAOFactory.getInstance();
User user = daoFactory.getStaffMemberDAO().findById(userId);
if (user == null) {
user = daoFactory.getStudentDAO().findById(userId);
}
if (user == null) {
throw new InvalidScriptException("User not found");
}
ClientApplication clientApplication = daoFactory.getClientApplicationDAO().findById(clientApplicationId);
if (clientApplication == null) {
throw new InvalidScriptException("Client application not found");
}
ClientApplicationAuthorizationCode code = DAOFactory.getInstance().getClientApplicationAuthorizationCodeDAO().create(user, clientApplication, authorizationCode, redirectUrl);
return code.getId();
}
use of fi.otavanopisto.pyramus.dao.DAOFactory in project pyramus by otavanopisto.
the class UserIdentificationAPI method create.
public Long create(Long personId, String authSource, String externalId) throws InvalidScriptException {
DAOFactory daoFactory = DAOFactory.getInstance();
Person person = daoFactory.getPersonDAO().findById(personId);
if (person == null) {
throw new InvalidScriptException("Person not found");
}
UserIdentification userIdentification = daoFactory.getUserIdentificationDAO().create(person, authSource, externalId);
if (userIdentification == null) {
return null;
} else {
return userIdentification.getId();
}
}
Aggregations