Removed old database configurations (closes #612)
Change-Id: I63766bf887a38aa53d86ec79f1cc51c570f21cf4
diff --git a/full/Changes b/full/Changes
index 2135576..7648ee3 100644
--- a/full/Changes
+++ b/full/Changes
@@ -1,7 +1,7 @@
# version 0.71
-- Removed auditing (closes #611)
-
+- Removed auditing (#611)
+- Removed old database configurations (#612)
# version 0.70.1
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
index 2fcc4e9..5b4f9c8 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/AuthenticationManager.java
@@ -12,7 +12,6 @@
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.security.context.TokenContext;
import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.Userdata;
/**
* @author hanl
@@ -61,8 +60,6 @@
public abstract User getUser (String username) throws KustvaktException;
- public abstract boolean isRegistered (String id);
-
public abstract User authenticate (AuthenticationMethod method,
String username, String password, Map<String, Object> attributes)
throws KustvaktException;
@@ -72,20 +69,6 @@
public abstract void setAccessAndLocation (User user, HttpHeaders headers);
- public abstract void logout (TokenContext context) throws KustvaktException;
-
- public abstract void lockAccount (User user) throws KustvaktException;
-
- public abstract boolean deleteAccount (User user) throws KustvaktException;
-
- @Deprecated
- public abstract <T extends Userdata> T getUserData (User user,
- Class<T> clazz) throws KustvaktException;
-
- @Deprecated
- public abstract void updateUserData (Userdata data)
- throws KustvaktException;
-
public String providerList () {
return "provider list: " + this.providers.toString();
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
index cd8f02c..306bf95 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/DummyAuthenticationManager.java
@@ -13,7 +13,6 @@
import de.ids_mannheim.korap.security.context.TokenContext;
import de.ids_mannheim.korap.user.KorAPUser;
import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.Userdata;
import de.ids_mannheim.korap.utils.TimeUtils;
public class DummyAuthenticationManager extends AuthenticationManager {
@@ -45,12 +44,6 @@
}
@Override
- public boolean isRegistered (String id) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
public User authenticate (AuthenticationMethod method, String username,
String password, Map<String, Object> attributes)
throws KustvaktException {
@@ -72,37 +65,6 @@
}
@Override
- public void logout (TokenContext context) throws KustvaktException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void lockAccount (User user) throws KustvaktException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public boolean deleteAccount (User user) throws KustvaktException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public <T extends Userdata> T getUserData (User user, Class<T> clazz)
- throws KustvaktException {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void updateUserData (Userdata data) throws KustvaktException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public User getUser (String username, String method)
throws KustvaktException {
// TODO Auto-generated method stub
diff --git a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
index af55b3e..1a55905 100644
--- a/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
+++ b/full/src/main/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManager.java
@@ -3,7 +3,6 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Map;
import javax.ws.rs.core.HttpHeaders;
@@ -14,25 +13,21 @@
import org.eclipse.jetty.http.HttpHeader;
import org.springframework.beans.factory.annotation.Autowired;
-import com.mchange.rmi.NotAuthorizedException;
// import com.novell.ldap.*; search() funktioniert nicht korrekt, ausgewechselt gegen unboundID's Bibliothek 20.04.17/FB
//Using JAR from unboundID:
import com.unboundid.ldap.sdk.LDAPException;
import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeansFactory;
import de.ids_mannheim.korap.config.FullConfiguration;
import de.ids_mannheim.korap.config.URIParam;
import de.ids_mannheim.korap.constant.AuthenticationMethod;
import de.ids_mannheim.korap.constant.TokenType;
-import de.ids_mannheim.korap.dao.AdminDao;
import de.ids_mannheim.korap.exceptions.EmptyResultException;
import de.ids_mannheim.korap.exceptions.KustvaktException;
import de.ids_mannheim.korap.exceptions.StatusCodes;
import de.ids_mannheim.korap.exceptions.WrappedException;
import de.ids_mannheim.korap.interfaces.EncryptionIface;
import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.security.context.TokenContext;
import de.ids_mannheim.korap.user.DemoUser;
import de.ids_mannheim.korap.user.KorAPUser;
@@ -40,9 +35,6 @@
import de.ids_mannheim.korap.user.User;
import de.ids_mannheim.korap.user.User.CorpusAccess;
import de.ids_mannheim.korap.user.User.Location;
-import de.ids_mannheim.korap.user.UserDetails;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-import de.ids_mannheim.korap.user.Userdata;
import de.ids_mannheim.korap.utils.TimeUtils;
import de.ids_mannheim.korap.validator.Validator;
@@ -61,22 +53,15 @@
private EncryptionIface crypto;
private EntityHandlerIface entHandler;
@Autowired
- private AdminDao adminDao;
private FullConfiguration config;
- @Deprecated
- private Collection userdatadaos;
- private LoginCounter counter;
@Autowired
private Validator validator;
- public KustvaktAuthenticationManager(EntityHandlerIface userdb, EncryptionIface crypto,
- FullConfiguration config, Collection<UserDataDbIface> userdatadaos) {
+ public KustvaktAuthenticationManager(EncryptionIface crypto,
+ FullConfiguration config) {
super("id_tokens");
- this.entHandler = userdb;
this.config = config;
this.crypto = crypto;
- this.counter = new LoginCounter(config);
- this.userdatadaos = userdatadaos;
// todo: load via beancontext
// try {
// this.validator = new ApacheValidator();
@@ -300,16 +285,6 @@
return context;
}
- // todo: test
- @Deprecated
- private boolean matchStatus(String host, String useragent, TokenContext context) {
- if (host.equals(context.getHostAddress())) {
- if (useragent.equals(context.getUserAgent()))
- return true;
- }
- return false;
- }
-
@Deprecated
private User authenticateShib(Map<String, Object> attributes) throws KustvaktException {
// todo use persistent id, since eppn is not unique
@@ -322,8 +297,6 @@
attributes.put(Attributes.EMAIL, eppn);
User user = null;
- if (isRegistered(eppn))
- user = createShibbUserAccount(attributes);
return user;
}
@@ -357,7 +330,6 @@
}
}
- boolean isAdmin = adminDao.isAdmin(unknown.getUsername());
if (DEBUG) {
jlog.debug(
"Authentication: found username " + unknown.getUsername());
@@ -373,7 +345,6 @@
if (!check) {
// the fail counter only applies for wrong password
jlog.warn("Wrong Password!");
- processLoginFail(unknown);
throw new WrappedException(new KustvaktException(user.getId(), StatusCodes.BAD_CREDENTIALS),
StatusCodes.LOGIN_FAILED, username);
}
@@ -391,7 +362,6 @@
}
if (TimeUtils.getNow().isAfter(param.getUriExpiration())) {
jlog.error("URI token is expired. Deleting account for user "+ user.getUsername());
- deleteAccount(user);
throw new WrappedException(
new KustvaktException(unknown.getId(), StatusCodes.EXPIRED,
"account confirmation uri has expired!", param.getUriFragment()),
@@ -429,7 +399,6 @@
private User authenticateIdM(String username, String password, Map<String, Object> attr) throws KustvaktException {
- Map<String, Object> attributes = validator.validateMap(attr);
User unknown = null;
// just to make sure that the plain password does not appear anywhere in
// the logs!
@@ -543,9 +512,10 @@
* username); }
*/
- } else if (unknown instanceof ShibbolethUser) {
- // todo
- }
+ }
+// else if (unknown instanceof ShibbolethUser) {
+// // todo
+// }
if (DEBUG) {
jlog.debug("Authentication done: " + username);
@@ -554,224 +524,4 @@
} // authenticateIdM
- @Deprecated
- public boolean isRegistered(String username) {
- User user;
- if (username == null || username.isEmpty())
- return false;
- // throw new KustvaktException(username, StatusCodes.ILLEGAL_ARGUMENT,
- // "username must be set", username);
-
- try {
- user = entHandler.getAccount(username);
- } catch (EmptyResultException e) {
- jlog.debug("user does not exist: "+ username);
- return false;
-
- } catch (KustvaktException e) {
- jlog.error("KorAPException "+ e.string());
- return false;
- // throw new KustvaktException(username,
- // StatusCodes.ILLEGAL_ARGUMENT,
- // "username invalid", username);
- }
- return user != null;
- }
-
- @Deprecated
- public void logout(TokenContext context) throws KustvaktException {
- try {
- AuthenticationIface provider = getProvider(context.getTokenType(), null);
-
- if (provider == null) {
- throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT, "Authentication "
- + "provider not supported!", context.getTokenType().displayName());
- }
- provider.removeUserSession(context.getToken());
- } catch (KustvaktException e) {
- throw new WrappedException(e, StatusCodes.LOGOUT_FAILED, context.toString());
- }
- this.removeCacheEntry(context.getToken());
- }
-
- @Deprecated
- private void processLoginFail(User user) throws KustvaktException {
- counter.registerFail(user.getUsername());
- if (!counter.validate(user.getUsername())) {
- try {
- this.lockAccount(user);
- } catch (KustvaktException e) {
- jlog.error("user account could not be locked", e);
- throw new WrappedException(e, StatusCodes.UPDATE_ACCOUNT_FAILED);
- }
- throw new WrappedException(new KustvaktException(user.getId(), StatusCodes.ACCOUNT_DEACTIVATED),
- StatusCodes.LOGIN_FAILED);
- }
- }
-
- @Deprecated
- public void lockAccount(User user) throws KustvaktException {
- if (!(user instanceof KorAPUser))
- throw new KustvaktException(StatusCodes.REQUEST_INVALID);
-
- KorAPUser u = (KorAPUser) user;
- u.setAccountLocked(true);
- jlog.info("locking account for user: "+ user.getUsername());
- entHandler.updateAccount(u);
- }
-
- @Deprecated // todo:
- private ShibbolethUser createShibbUserAccount(Map<String, Object> attributes) throws KustvaktException {
- if (DEBUG) {
- jlog.debug("creating shibboleth user account for user attr: "
- + attributes);
- }
- Map<String, Object> safeMap = validator.validateMap(attributes);
-
- // todo eppn non-unique.join with idp or use persistent_id as username
- // identifier
- // EM: disabled
-// ShibbolethUser user = User.UserFactory.getShibInstance((String) safeMap.get(Attributes.EPPN),
-// (String) safeMap.get(Attributes.MAIL), (String) safeMap.get(Attributes.CN));
-// user.setAffiliation((String) safeMap.get(Attributes.EDU_AFFIL));
-// user.setAccountCreation(TimeUtils.getNow().getMillis());
-
- ShibbolethUser user = null;
-
- UserDetails d = new UserDetails();
- d.read(attributes, true);
-
- UserSettingProcessor s = new UserSettingProcessor();
- s.read(attributes, true);
-
- entHandler.createAccount(user);
-
-// s.setUserId(user.getId());
-// d.setUserId(user.getId());
-
- UserDataDbIface dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(userdatadaos, UserDetails.class);
- assert dao != null;
- dao.store(d);
-
- dao = BeansFactory.getTypeFactory().getTypeInterfaceBean(userdatadaos, UserSettingProcessor.class);
- assert dao != null;
- dao.store(d);
-
- return user;
- }
-
- /**
- * link shibboleth and korap user account to one another.
- *
- * @param current
- * currently logged in user
- * @param for_name
- * foreign user name the current account should be linked to
- * @param transstrat
- * transfer status of user data (details, settings, user queries)
- * 0 = the currently logged in data should be kept 1 = the
- * foreign account data should be kept
- * @throws NotAuthorizedException
- * @throws KustvaktException
- */
- // todo:
- @Deprecated
- public void accountLink(User current, String for_name, int transstrat) throws KustvaktException {
- // User foreign = entHandler.getAccount(for_name);
-
- // if (current.getAccountLink() == null && current.getAccountLink()
- // .isEmpty()) {
- // if (current instanceof KorAPUser && foreign instanceof ShibUser) {
- // if (transstrat == 1)
- // current.transfer(foreign);
- //// foreign.setAccountLink(current.getUsername());
- //// current.setAccountLink(foreign.getUsername());
- // // entHandler.purgeDetails(foreign);
- // // entHandler.purgeSettings(foreign);
- // }else if (foreign instanceof KorAPUser
- // && current instanceof ShibUser) {
- // if (transstrat == 0)
- // foreign.transfer(current);
- //// current.setAccountLink(foreign.getUsername());
- // // entHandler.purgeDetails(current);
- // // entHandler.purgeSettings(current);
- // // entHandler.purgeSettings(current);
- // }
- // entHandler.updateAccount(current);
- // entHandler.updateAccount(foreign);
- // }
- }
-
- @Deprecated
- // todo: test and rest usage?!
- public boolean updateAccount(User user) throws KustvaktException {
- boolean result;
- if (user instanceof DemoUser)
- throw new KustvaktException(user.getId(), StatusCodes.REQUEST_INVALID,
- "account not updateable for demo user", user.getUsername());
- else {
- // crypto.validate(user);
- try {
- result = entHandler.updateAccount(user) > 0;
- } catch (KustvaktException e) {
- jlog.error("Error: "+ e.string());
- throw new WrappedException(e, StatusCodes.UPDATE_ACCOUNT_FAILED);
- }
- }
- return result;
- }
-
- @Deprecated
- public boolean deleteAccount(User user) throws KustvaktException {
- boolean result;
- if (user instanceof DemoUser)
- return true;
- else {
- try {
- result = entHandler.deleteAccount(user.getId()) > 0;
- } catch (KustvaktException e) {
- jlog.error("Error: "+ e.string());
- throw new WrappedException(e, StatusCodes.DELETE_ACCOUNT_FAILED);
- }
- }
- return result;
- }
-
- // EM: not in the new DB
- @Deprecated
- @Override
- public <T extends Userdata> T getUserData(User user, Class<T> clazz) throws WrappedException {
- try {
- UserDataDbIface<T> dao = BeansFactory.getTypeFactory()
- .getTypeInterfaceBean(BeansFactory.getKustvaktContext().getUserDataProviders(), clazz);
- T data = null;
- if (dao != null)
- data = dao.get(user);
-
- if (data == null)
- throw new KustvaktException(user.getId(), StatusCodes.NO_RESULT_FOUND, "No data found!",
- clazz.getSimpleName());
- return data;
- } catch (KustvaktException e) {
- jlog.error("Error during user data retrieval: "+ e.getEntity());
- throw new WrappedException(e, StatusCodes.GET_ACCOUNT_FAILED);
- }
- }
-
- @Deprecated
- // todo: cache userdata outside of the user object!
- @Override
- public void updateUserData(Userdata data) throws WrappedException {
- try {
- data.validate(this.validator);
- UserDataDbIface dao = BeansFactory.getTypeFactory()
- .getTypeInterfaceBean(BeansFactory.getKustvaktContext().getUserDataProviders(), data.getClass());
- if (dao != null)
- dao.update(data);
- } catch (KustvaktException e) {
- jlog.error("Error during update of user data! "+ e.getEntity());
- throw new WrappedException(e, StatusCodes.UPDATE_ACCOUNT_FAILED);
- }
- }
-
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java b/full/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
index f2e22ab..7626ec1 100644
--- a/full/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
+++ b/full/src/main/java/de/ids_mannheim/korap/config/ContextHolder.java
@@ -1,12 +1,8 @@
package de.ids_mannheim.korap.config;
-import java.util.Collection;
-
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
import de.ids_mannheim.korap.web.CoreResponseHandler;
/**
@@ -74,17 +70,6 @@
return (T) getBean(KUSTVAKT_CONFIG);
}
-
- @Deprecated
- public PersistenceClient getPersistenceClient () {
- return getBean(KUSTVAKT_DB);
- }
-
- @Deprecated
- public Collection<UserDataDbIface> getUserDataProviders () {
- return getBean(KUSTVAKT_USERDATA);
- }
-
private void close () {
this.context = null;
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
deleted file mode 100644
index ffc35e5..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import java.sql.Date;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.DuplicateKeyException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.jdbc.support.GeneratedKeyHolder;
-import org.springframework.jdbc.support.KeyHolder;
-
-import de.ids_mannheim.korap.config.ParamFields;
-import de.ids_mannheim.korap.config.URIParam;
-import de.ids_mannheim.korap.exceptions.DatabaseException;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
-import de.ids_mannheim.korap.interfaces.KustvaktBaseDaoInterface;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.user.KorAPUser;
-import de.ids_mannheim.korap.user.ShibbolethUser;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.BooleanUtils;
-import de.ids_mannheim.korap.utils.TimeUtils;
-
-/* WKP: In computer software, a data access object (DAO) is an object that provides an abstract interface to some type
- * of database or other persistence mechanism. By mapping application calls to the persistence layer, the DAO provides
- * some specific data operations without exposing details of the database.
- */
-@Deprecated
-/**
- * @author hanl
- * @date 13/01/2014
- */
-public class EntityDao implements EntityHandlerIface, KustvaktBaseDaoInterface {
-
- private static Logger jlog = LogManager.getLogger(EntityDao.class);
- private NamedParameterJdbcTemplate jdbcTemplate;
-
-
- public EntityDao (PersistenceClient client) {
- this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
- }
-
- // usersettings are fetched plus basic account info, no details, since i rarely use them anyway! (by Hanl)
- /* Version mit LDAP Authentication - 09.05.17/FB
- * getAccount(): KorAPUser: Account muss vorhanden sein.
- * DemoUser, DefaultUser: Account nicht vorhanden.
- */
- @Override
- public User getAccount (String username) throws KustvaktException {
-
- Map<String, String> namedParameters = Collections.singletonMap("username", username);
- final String sql = "select a.* from korap_users as a where a.username=:username;";
- User user = null;
-
- try {
- user = this.jdbcTemplate.queryForObject(sql, namedParameters,
- new RowMapperFactory.UserMapper());
- return user;
- }
- catch (EmptyResultDataAccessException ae) {
- jlog.warn("No user found for name "+ username);
- }
- catch (DataAccessException e) {
- jlog.warn("Could not retrieve user for name: " + username, e);
-
- /* DemoUser and DefaultUser have no account,
- * so it's ok they are not found.
- throw new DatabaseException(username, "korap_users",
- StatusCodes.DB_GET_FAILED,
- "Could not retrieve the user with username: " + username,
- username);
- */
- }
-
- // DemoUser or DefaultUser?
-
- { // User cannot be found in SQL DB since LDAP Authentication,
- // so create a User Object here.
- // TODO: what more data should be stored into it?
- // 28.04.17/FB
- user = new KorAPUser(); // oder eigentlich new DemoUser oder new DefaultUser.
- user.setUsername(username);
- return user;
- }
-
-
- } // getAccount()
-
- // usersettings are fetched plus basic account info, no details, since i rarely use them anyway! (by Hanl)
- /* Version before LDAP Authentication - 09.05.17/FB
- @Deprecated
- @Override
- public User getAccount (String username) throws KustvaktException {
-
- Boolean bDEBUG = true;
- Map<String, String> namedParameters = Collections
- .singletonMap("username", username);
- final String sql = "select a.* from korap_users as a where a.username=:username;";
- User user;
-
- try {
- user = this.jdbcTemplate.queryForObject(sql, namedParameters,
- new RowMapperFactory.UserMapper());
- }
- catch (EmptyResultDataAccessException ae) {
- jlog.warn("No user found for name '{}'", username);
- throw new EmptyResultException(username);
- }
- catch (DataAccessException e) {
- jlog.error("Could not retrieve user for name: " + username, e);
- throw new DatabaseException(username, "korap_users",
- StatusCodes.DB_GET_FAILED,
- "Could not retrieve the user with username: " + username,
- username);
- }
- return user;
- }
- */
-
- @Override
- public int updateAccount (User user) throws KustvaktException {
- MapSqlParameterSource np = new MapSqlParameterSource();
- final String query;
- if (user instanceof KorAPUser) {
- KorAPUser k = (KorAPUser) user;
- np.addValue("ali", k.getAccountLink());
- np.addValue("alo", k.isAccountLocked());
- if (k.getPassword() != null)
- np.addValue("ps", k.getPassword());
- // URIParam param = k.getField(URIParam.class);
- // if (param != null) {
- // np.addValue("frag", param.getUriFragment());
- // np.addValue("exp", new Date(param.getUriExpiration()));
- // }else {
- // np.addValue("frag", null);
- // np.addValue("exp", null);
- // }
- np.addValue("id", k.getId());
-
- query = "UPDATE korap_users SET account_lock=:alo,"
- + "account_link=:ali, password=:ps "
- // "uri_fragment=:frag," +
- // "uri_expiration=:exp "
- + "WHERE id=:id";
- }
- else if (user instanceof ShibbolethUser) {
- ShibbolethUser s = (ShibbolethUser) user;
- //todo:
- // np.addValue("ali", s.getAccountLink());
- np.addValue("ali", null);
- np.addValue("edu", s.getAffiliation());
- np.addValue("id", s.getId());
- np.addValue("cn", s.getCommonName());
- np.addValue("mail", s.getMail());
-
- query = "UPDATE shibusers SET account_link=:ali"
- + " eduPersonScopedAffiliation=:edu"
- + "mail=:mail, cn=:cn WHERE id=:id";
- }
- else
- return -1;
- try {
- return this.jdbcTemplate.update(query, np);
- }
- catch (DataAccessException e) {
- jlog.error(
- "Could not update user account for user: " + user.getId(),
- e);
- throw new DatabaseException(user.getId(), "korap_users",
- StatusCodes.DB_UPDATE_FAILED,
- "Could not update user account for user: " + user.getId(),
- user.toString());
- }
- }
-
-
- @Override
- public int createAccount (User user) throws KustvaktException {
- final String query;
- MapSqlParameterSource np = new MapSqlParameterSource();
-
- if (user instanceof KorAPUser) {
- final KorAPUser k = (KorAPUser) user;
-
- URIParam param = k.getField(URIParam.class);
- np.addValue("us", k.getUsername());
- np.addValue("alo", k.isAccountLocked());
- np.addValue("ali", k.getAccountLink());
- np.addValue("ps", k.getPassword());
- if (param != null) {
- np.addValue("uri", param.getUriFragment());
- np.addValue("urie", param.getUriExpiration());
- }
- else {
- np.addValue("uri", null);
- np.addValue("urie", null);
- }
-
- np.addValue("acr", System.currentTimeMillis());
- np.addValue("id", k.getId());
-
- if (user.getId() != -1)
- query = "INSERT INTO korap_users (id, username, account_lock, "
- + "account_link, password, uri_fragment, "
- + "account_creation, "
- + "uri_expiration) VALUES (:id, :us, :alo, :ali, "
- + ":ps, :uri, :acr, :urie);";
- else
- query = "INSERT INTO korap_users (username, account_lock, "
- + "account_link, password, uri_fragment, "
- + "account_creation, "
- + "uri_expiration) VALUES (:us, :alo, :ali, "
- + ":ps, :uri, :acr, :urie);";
-
- //fixme: still applicable?
- }
- else if (user instanceof ShibbolethUser) {
- ShibbolethUser s = (ShibbolethUser) user;
-
- query = "INSERT INTO shibusers (username, type, account_link, account_creation "
- + "eduPersonScopedAffiliation, cn, mail) "
- + "VALUES (:us, :type, :ali, "
- + ":edu, :cn, :mail, :logs, :logft);";
- np.addValue("us", s.getUsername());
- np.addValue("ali", null);
- np.addValue("edu", s.getAffiliation());
- np.addValue("mail", s.getMail());
- np.addValue("type", user.getType());
- np.addValue("cn", s.getCommonName());
- np.addValue("acr", System.currentTimeMillis());
-
- //todo: deprecate
- // }else if (user instanceof DemoUser) {
- // query = "INSERT INTO korap_users (id, username, type, account_lock, account_creation) VALUES "
- // + "(:id, :us, :type, :alo);";
- //
- // np.addValue("id", user.getId());
- // np.addValue("us", user.getUsername());
- // np.addValue("type", user.getType());
- // np.addValue("alo", user.isAccountLocked());
- // np.addValue("acr", System.currentTimeMillis());
- }
- else
- return -1;
-
- KeyHolder holder = new GeneratedKeyHolder();
-
- int r;
- try {
- r = this.jdbcTemplate.update(query, np, holder,
- new String[] { "id" });
- user.setId(holder.getKey().intValue());
- }
- catch (DuplicateKeyException e) {
- jlog.error("Could not create user account with username: "+
- user.getUsername());
- throw new DatabaseException(e, user.getUsername(), "korap_users",
- StatusCodes.DB_ENTRY_EXISTS, "Username exists.",
- user.getUsername());
- }
- catch (DataAccessException e) {
- throw new DatabaseException(e, user.getUsername(), "korap_users",
- StatusCodes.DB_ENTRY_EXISTS, "Username exists.",
- user.getUsername());
- }
-
- return r;
- }
-
-
- @Override
- public int deleteAccount (final Integer userid) throws KustvaktException {
- MapSqlParameterSource s = new MapSqlParameterSource();
- s.addValue("user", userid);
-
- try {
- int r;
- r = this.jdbcTemplate
- .update("DELETE FROM korap_users WHERE id=:user", s);
- // if (user instanceof KorAPUser)
- // r = this.jdbcTemplate
- // .update("DELETE FROM korap_users WHERE username=:user",
- // s);
- // else if (user instanceof ShibUser)
- // r = this.jdbcTemplate
- // .update("DELETE FROM shibusers WHERE username=:user",
- // s);
- // else
- // r = -1;
- return r;
- }
- catch (DataAccessException e) {
- jlog.error("Could not delete account for user: " + userid, e);
- // throw new KorAPException(e, StatusCodes.CONNECTION_ERROR);
- throw new DatabaseException(userid, "korap_users",
- StatusCodes.DB_DELETE_FAILED,
- "Could not delete account for user: " + userid,
- userid.toString());
- }
-
- }
-
-
- @Override
- public int truncate () {
- String sql = "DELETE FROM korap_users;";
- try {
- return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public int resetPassphrase (String username, String uriToken,
- String passphrase) throws KustvaktException {
- MapSqlParameterSource np = new MapSqlParameterSource();
- final String query = "UPDATE korap_users SET "
- + "uri_expiration=0, password=:pass WHERE uri_fragment=:uri AND uri_expiration > :now "
- + "AND username=:us AND uri_expiration > :now;";
- np.addValue("uri", uriToken);
- np.addValue("now", new Date(TimeUtils.getNow().getMillis()));
- np.addValue("pass", passphrase);
- np.addValue("us", username);
- try {
- return this.jdbcTemplate.update(query, np);
- }
- catch (DataAccessException e) {
- jlog.error("Could not reset password for name: " + username, e);
- throw new DatabaseException(username, "korap_users",
- StatusCodes.DB_UPDATE_FAILED,
- "Could not reset password for username: " + username,
- username, uriToken, passphrase);
- }
- }
-
-
- @Override
- public int activateAccount (String username, String uriToken)
- throws KustvaktException {
- MapSqlParameterSource np = new MapSqlParameterSource();
- final String query = "UPDATE korap_users SET uri_fragment='', "
- + "uri_expiration=0, account_lock=:lock WHERE uri_fragment=:uri AND username=:us AND "
- + "uri_expiration > :now;";
- np.addValue("uri", uriToken);
- np.addValue("now", TimeUtils.getNow().getMillis());
- np.addValue("us", username);
- np.addValue("lock", BooleanUtils.getBoolean(false));
- try {
- return this.jdbcTemplate.update(query, np);
- }
- catch (DataAccessException e) {
- jlog.error("Could not confirm registration for name " + username,
- e);
- throw new DatabaseException(username, "korap_users",
- StatusCodes.DB_UPDATE_FAILED,
- "Could not confirm registration for username " + username,
- username, uriToken);
- }
- }
-
-
- @Override
- public int size () {
- final String query = "SELECT COUNT(*) FROM korap_users;";
- return this.jdbcTemplate.queryForObject(query,
- new HashMap<String, Object>(), Integer.class);
- }
-
-
- //todo:
- public List getAccountLinks (User user) {
-
- return Collections.emptyList();
- }
-
-
- //todo:
- public void setAccountParameters (User user) {
- ParamFields fields = user.getFields();
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java b/full/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java
deleted file mode 100644
index e1c9acd..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLException;
-import java.util.HashMap;
-
-import javax.sql.DataSource;
-
-import org.springframework.core.io.InputStreamResource;
-import org.springframework.core.io.Resource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
-
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.utils.BooleanUtils;
-import lombok.AccessLevel;
-import lombok.Data;
-import lombok.Setter;
-
-/**
- * @author hanl
- * @date 13/01/2014
- */
-@Deprecated
-@Data
-public class JDBCClient extends PersistenceClient<NamedParameterJdbcTemplate> {
-
- @Setter(AccessLevel.NONE)
- private DataSource dataSource;
-
- public JDBCClient (DataSource datasource) {
- NamedParameterJdbcTemplate template = new NamedParameterJdbcTemplate(
- datasource);
- template.setCacheLimit(500);
- super.setSource(template);
- this.dataSource = datasource;
- }
-
-
- public JDBCClient (DataSource dataSource, Resource resource)
- throws IOException {
- this(dataSource);
- this.setSchema(resource.getInputStream());
- }
-
-
- @Override
- public void setSchema (InputStream stream) throws IOException {
- super.setSchema(stream);
- }
-
-
- @Override
- public boolean checkDatabase () {
- int size;
- NamedParameterJdbcTemplate tmp = this.getSource();
- try {
- // uses flyway schema table to determine of schema was applied succesfully
- size = tmp.queryForObject(
- "select count(*) from schema_version limit 5;",
- new HashMap<String, Object>(), Integer.class);
- }
- catch (Exception e) {
- System.out.println("No database schema found!");
- return false;
- }
- return size > 0;
- }
-
-
- @Override
- public void setDatabase (String name) {
- super.setDatabase(name);
- BooleanUtils.dbname = name;
- }
-
-
- // get schema file from configuration and create database
- @Override
- public void createDatabase () {
- if (!checkDatabase()) {
- final ResourceDatabasePopulator rdp = new ResourceDatabasePopulator();
- rdp.addScript(new InputStreamResource(this.getSchema()));
- rdp.setSeparator("$$");
- try {
- rdp.populate(this.dataSource.getConnection());
- }
- catch (SQLException e) {
- // do nothing
- e.printStackTrace();
- }
- }
- }
-
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
deleted file mode 100644
index b550dae..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/UserDetailsDao.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.DatabaseException;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserDetails;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.jdbc.support.GeneratedKeyHolder;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-
-/**
- * @author hanl
- * @date 27/01/2016
- */
-@Deprecated
-public class UserDetailsDao implements UserDataDbIface<UserDetails> {
-
- private NamedParameterJdbcTemplate jdbcTemplate;
-
-
- public UserDetailsDao (PersistenceClient client) {
- this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
- }
-
-
- @Override
- public int store (UserDetails data) throws KustvaktException {
- String sql = "INSERT INTO user_details (user_id, data) VALUES (:userid, :data);";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", data.getUserId());
- source.addValue("data", data.serialize());
-
- GeneratedKeyHolder gen = new GeneratedKeyHolder();
- try {
- this.jdbcTemplate.update(sql, source, gen);
- int id = gen.getKey().intValue();
- data.setId(id);
- return id;
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public int update (UserDetails data) throws KustvaktException {
- String sql = "UPDATE user_details SET data = :data WHERE user_id=:userid;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", data.getUserId());
- source.addValue("data", data.serialize());
-
- try {
- return this.jdbcTemplate.update(sql, source);
- }
- catch (DataAccessException e) {
- e.printStackTrace();
- return -1;
- }
- }
-
-
- @Override
- public UserDetails get (Integer id) throws DatabaseException {
- String sql = "SELECT * FROM user_details WHERE id=:id;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", id);
-
- try {
- return this.jdbcTemplate.queryForObject(sql, source,
- new RowMapper<UserDetails>() {
-
- @Override
- public UserDetails mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- UserDetails details = new UserDetails();
- details.setUserId(rs.getInt("user_id"));
- details.setId(rs.getInt("id"));
- details.setData(rs.getString("data"));
- return details;
- }
- });
-
- }
- catch (EmptyResultDataAccessException ex) {
- return null;
- }
- catch (DataAccessException e) {
- throw new DatabaseException(-1, "userDetails",
- StatusCodes.REQUEST_INVALID, "The request is invalid.",
- String.valueOf(id));
- }
- }
-
-
- @Override
- public UserDetails get (User user) throws DatabaseException {
- String sql = "SELECT * FROM user_details WHERE user_id=:userid;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", user.getId());
-
- try {
- return this.jdbcTemplate.queryForObject(sql, source,
- new RowMapper<UserDetails>() {
-
- @Override
- public UserDetails mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- UserDetails details = new UserDetails();
- details.setUserId(rs.getInt("user_id"));
- details.setId(rs.getInt("id"));
- details.setData(rs.getString("data"));
- return details;
- }
- });
- }
- catch (EmptyResultDataAccessException ex) {
- return null;
- }
- catch (DataAccessException e) {
- throw new DatabaseException(user.getId(), "userDetails",
- StatusCodes.REQUEST_INVALID, "The request is invalid.");
- }
- }
-
-
- @Override
- public int delete (UserDetails data) {
- String sql = "DELETE FROM user_details WHERE id=:id";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", data.getId());
- try {
- return this.jdbcTemplate.update(sql, source);
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public int deleteAll () {
- String sql = "DELETE FROM user_details;";
- try {
- return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
- }
- catch (DataAccessException e) {
- e.printStackTrace();
- return -1;
- }
- }
-
-
- @Override
- public Class<UserDetails> type () {
- return UserDetails.class;
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java b/full/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
deleted file mode 100644
index 326ddb3..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/handlers/UserSettingsDao.java
+++ /dev/null
@@ -1,176 +0,0 @@
-package de.ids_mannheim.korap.handlers;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.exceptions.DatabaseException;
-import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
-import de.ids_mannheim.korap.interfaces.db.UserDataDbIface;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
-import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
-import org.springframework.jdbc.support.GeneratedKeyHolder;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-
-/**
- * @author hanl
- * @date 28/01/2016
- */
-@Deprecated
-public class UserSettingsDao implements UserDataDbIface<UserSettingProcessor> {
-
- private static final Logger jlog = LogManager
- .getLogger(UserSettingsDao.class);
-
- private final NamedParameterJdbcTemplate jdbcTemplate;
-
-
- public UserSettingsDao (PersistenceClient client) {
- this.jdbcTemplate = (NamedParameterJdbcTemplate) client.getSource();
- }
-
-
- @Override
- public int store (UserSettingProcessor data) throws KustvaktException {
- String sql = "INSERT INTO user_settings (user_id, data) VALUES (:userid, :data);";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", data.getUserId());
- source.addValue("data", data.serialize());
-
- GeneratedKeyHolder gen = new GeneratedKeyHolder();
- try {
- this.jdbcTemplate.update(sql, source, gen);
- int id = gen.getKey().intValue();
- data.setId(id);
- return id;
- }
- catch (DataAccessException e) {
- jlog.error("couldn't store data in db for user with id "+
- data.getUserId());
- return -1;
- }
- }
-
-
- @Override
- public int update (UserSettingProcessor data) throws KustvaktException {
- String sql = "UPDATE user_settings SET data = :data WHERE user_id=:userid;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", data.getUserId());
- source.addValue("data", data.serialize());
-
- try {
- return this.jdbcTemplate.update(sql, source);
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public UserSettingProcessor get (Integer id) throws DatabaseException {
- String sql = "SELECT * FROM user_settings WHERE id=:id;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", id);
-
- try {
- return this.jdbcTemplate.queryForObject(sql, source,
- new RowMapper<UserSettingProcessor>() {
-
- @Override
- public UserSettingProcessor mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- UserSettingProcessor details = new UserSettingProcessor(
- rs.getInt("user_id"));
- details.setId(rs.getInt("id"));
- details.setData(rs.getString("data"));
- return details;
- }
- });
-
- }
- catch (EmptyResultDataAccessException ex) {
- return null;
- }
- catch (DataAccessException e) {
- throw new DatabaseException(-1, "userSettings",
- StatusCodes.REQUEST_INVALID, "The request is invalid.",
- String.valueOf(id));
- }
- }
-
-
- @Override
- public UserSettingProcessor get (User user) throws DatabaseException {
- String sql = "SELECT * FROM user_settings WHERE user_id=:userid;";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("userid", user.getId());
-
- try {
- return this.jdbcTemplate.queryForObject(sql, source,
- new RowMapper<UserSettingProcessor>() {
-
- @Override
- public UserSettingProcessor mapRow (ResultSet rs, int rowNum)
- throws SQLException {
- UserSettingProcessor details = new UserSettingProcessor(
- rs.getInt("user_id"));
- details.setId(rs.getInt("id"));
- details.setData(rs.getString("data"));
- return details;
- }
- });
-
- }
- catch (EmptyResultDataAccessException ex) {
- return null;
- }
- catch (DataAccessException e) {
- throw new DatabaseException(-1, "userSettings",
- StatusCodes.REQUEST_INVALID, "The request is invalid.");
- }
- }
-
-
- @Override
- public int delete (UserSettingProcessor data) {
- String sql = "DELETE FROM user_settings WHERE id=:id";
- MapSqlParameterSource source = new MapSqlParameterSource();
- source.addValue("id", data.getId());
- try {
- return this.jdbcTemplate.update(sql, source);
- }
- catch (DataAccessException e) {
- return -1;
- }
- }
-
-
- @Override
- public int deleteAll () {
- String sql = "DELETE FROM user_settings;";
- try {
- return this.jdbcTemplate.update(sql, new HashMap<String, Object>());
- }
- catch (DataAccessException e) {
- e.printStackTrace();
- return -1;
- }
- }
-
-
- @Override
- public Class<UserSettingProcessor> type () {
- return UserSettingProcessor.class;
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/interfaces/KustvaktBaseDaoInterface.java b/full/src/main/java/de/ids_mannheim/korap/interfaces/KustvaktBaseDaoInterface.java
deleted file mode 100644
index 42a2a74..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/interfaces/KustvaktBaseDaoInterface.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.ids_mannheim.korap.interfaces;
-
-/**
- * @author hanl
- * @date 11/02/2016
- */
-public interface KustvaktBaseDaoInterface {
-
- int size ();
-
-
- int truncate ();
-
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java b/full/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java
deleted file mode 100644
index 9fd0f79..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package de.ids_mannheim.korap.interfaces.db;
-
-import lombok.Getter;
-
-import java.io.*;
-
-@Getter
-public abstract class PersistenceClient<SOURCE> {
-
- private SOURCE source;
- private TYPE type;
-
- protected String database;
- private InputStream schema;
-
-
- public PersistenceClient (String database, TYPE type) {
- this.type = type;
- this.database = database;
- }
-
-
- public PersistenceClient (TYPE type) {
- this.type = type;
- }
-
-
- public PersistenceClient () {}
-
-
- protected void setSource (SOURCE conn) {
- this.source = conn;
- }
-
-
- public void setDatabase (String name) {
- this.database = name;
- }
-
-
- public void setSchema (String schema_path) throws FileNotFoundException {
- this.schema = new FileInputStream(new File(schema_path));
- }
-
-
- // for spring configuration
- @Deprecated
- public void setSchema (InputStream schema) throws IOException {
- this.schema = schema;
- }
-
-
- public abstract boolean checkDatabase ();
-
-
- public abstract void createDatabase () throws IOException;
-
- public enum TYPE {
- SQL, CASSANDRA
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java b/full/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
deleted file mode 100644
index 23dfbc4..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/interfaces/db/UserDataDbIface.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package de.ids_mannheim.korap.interfaces.db;
-
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.interfaces.KustvaktTypeInterface;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.Userdata;
-
-/**
- * @author hanl
- * @date 27/01/2016
- */
-public interface UserDataDbIface<T extends Userdata> extends
- KustvaktTypeInterface<T> {
-
- public int store (T data) throws KustvaktException;
-
-
- public int update (T data) throws KustvaktException;
-
-
- public T get (Integer id) throws KustvaktException;
-
-
- public T get (User user) throws KustvaktException;
-
-
- public int delete (T data) throws KustvaktException;
-
-
- public int deleteAll () throws KustvaktException;
-
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
index 597ae0e..9eac9d4 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/AuthenticationController.java
@@ -430,23 +430,4 @@
}
}
-
- //fixme: moved from userservice
- @GET
- @Path("logout")
- @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
- PiwikFilter.class })
- public Response logout (@Context SecurityContext ctx,
- @Context Locale locale) {
- TokenContext context = (TokenContext) ctx.getUserPrincipal();
- try {
- controller.logout(context);
- }
- catch (KustvaktException e) {
- jlog.error("Logout Exception:"+ e.string());
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
- }
-
}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/ShibbolethUserController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/ShibbolethUserController.java
deleted file mode 100644
index ce7ba2b..0000000
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/ShibbolethUserController.java
+++ /dev/null
@@ -1,340 +0,0 @@
-package de.ids_mannheim.korap.web.controller;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.SecurityContext;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import de.ids_mannheim.korap.web.utils.ResourceFilters;
-
-import de.ids_mannheim.korap.authentication.AuthenticationManager;
-import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.Scopes;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.security.context.TokenContext;
-import de.ids_mannheim.korap.user.KorAPUser;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserDetails;
-import de.ids_mannheim.korap.user.UserQuery;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-import de.ids_mannheim.korap.user.Userdata;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.utils.StringUtils;
-import de.ids_mannheim.korap.web.KustvaktResponseHandler;
-import de.ids_mannheim.korap.web.filter.APIVersionFilter;
-import de.ids_mannheim.korap.web.filter.AuthenticationFilter;
-import de.ids_mannheim.korap.web.filter.BlockingFilter;
-import de.ids_mannheim.korap.web.filter.DemoUserFilter;
-import de.ids_mannheim.korap.web.filter.PiwikFilter;
-
-/**
- *
- * @author hanl, margaretha
- */
-@Controller
-@Path("{version}/shibboleth/user")
-@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
-@ResourceFilters({APIVersionFilter.class, PiwikFilter.class })
-public class ShibbolethUserController {
-
- @Autowired
- private KustvaktResponseHandler kustvaktResponseHandler;
-
- private static Logger jlog = LogManager.getLogger(ShibbolethUserController.class);
- @Autowired
- private AuthenticationManager controller;
-
- private @Context UriInfo info;
-
- // EM: may be used for managing shib users
- //todo: password update in special function? --> password reset only!
- @POST
- @Path("update")
- @Consumes(MediaType.APPLICATION_JSON)
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response updateAccount (@Context SecurityContext ctx, String json) {
- TokenContext context = (TokenContext) ctx.getUserPrincipal();
- try {
- User user = controller.getUser(context.getUsername());
-
- JsonNode node = JsonUtils.readTree(json);
- KorAPUser ident = (KorAPUser) user;
- KorAPUser values = User.UserFactory.toUser(json);
- // user = controller
- // .checkPasswordAllowance(ident, values.getPassword(),
- // node.path("new_password").asText());
- // controller.updateAccount(user);
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
- }
-
- // todo: refactor and make something out of if --> needs to give some sort of feedback!
- @GET
- @Path("info")
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response getStatus (@Context SecurityContext context,
- @QueryParam("scopes") String scopes) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- Scopes m;
- try {
- User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, UserDetails.class);
-
- Set<String> base_scope = StringUtils.toSet(scopes, " ");
- if (scopes != null) base_scope.retainAll(StringUtils.toSet(scopes));
- scopes = StringUtils.toString(base_scope);
- m = Scopes.mapScopes(scopes, data);
- return Response.ok(m.toEntity()).build();
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- }
-
-
- @GET
- @Path("settings")
- @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
- PiwikFilter.class, BlockingFilter.class })
- public Response getUserSettings (@Context SecurityContext context,
- @Context Locale locale) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- String result;
- try {
- User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, UserSettingProcessor.class);
- data.setField(Attributes.USERNAME, ctx.getUsername());
- result = data.serialize();
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok(result).build();
- }
-
-
- @Deprecated
- @POST
- @Path("settings")
- @Consumes({ MediaType.APPLICATION_JSON })
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response updateSettings (@Context SecurityContext context,
- @Context Locale locale, Map settings) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
-
- if (settings == null) return Response.notModified().build();
-
- try {
- User user = controller.getUser(ctx.getUsername());
- if (User.UserFactory.isDemo(ctx.getUsername()))
- return Response.notModified().build();
-
- Userdata data = controller.getUserData(user, UserSettingProcessor.class);
- // todo: check setting only within the scope of user settings permissions; not foundry range. Latter is part of
- // frontend which only displays available foundries and
- // SecurityManager.findbyId(us.getDefaultConstfoundry(), user, Foundry.class);
- // SecurityManager.findbyId(us.getDefaultLemmafoundry(), user, Foundry.class);
- // SecurityManager.findbyId(us.getDefaultPOSfoundry(), user, Foundry.class);
- // SecurityManager.findbyId(us.getDefaultRelfoundry(), user, Foundry.class);
- Userdata new_data = new UserSettingProcessor(user.getId());
- new_data.readQuietly((Map<String, Object>) settings, false);
- data.update(new_data);
- controller.updateUserData(data);
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
-
- return Response.ok().build();
- }
-
- @GET
- @Path("details")
- @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
- PiwikFilter.class, BlockingFilter.class })
- public Response getDetails (@Context SecurityContext context,
- @Context Locale locale, @QueryParam("pointer") String pointer) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- String result;
- try {
- User user = controller.getUser(ctx.getUsername());
- Userdata data = controller.getUserData(user, UserDetails.class);
- data.setField(Attributes.USERNAME, ctx.getUsername());
- if (pointer != null)
- result = data.get(pointer).toString();
- else
- result = data.serialize();
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered: "+ e.string());
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok(result).build();
- }
-
-
- // EM: may be used for managing shib users
- @POST
- @Path("details")
- @Consumes({ MediaType.APPLICATION_JSON })
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response updateDetails (@Context SecurityContext context,
- @Context Locale locale, Map details) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
-
- if (details == null) return Response.notModified().build();
-
- try {
- User user = controller.getUser(ctx.getUsername());
- if (User.UserFactory.isDemo(ctx.getUsername()))
- return Response.notModified().build();
-
- UserDetails new_data = new UserDetails(user.getId());
- new_data.readQuietly((Map<String, Object>) details, false);
-
- UserDetails det = controller.getUserData(user, UserDetails.class);
- det.update(new_data);
- controller.updateUserData(det);
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
- }
-
-
- //fixme: if policy allows, foreign user might be allowed to change search!
- @POST
- @Path("queries")
- @Consumes(MediaType.APPLICATION_JSON)
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response updateQueries (@Context SecurityContext context,
- String json) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- Collection<UserQuery> add = new HashSet<>();
- try {
- User user = controller.getUser(ctx.getUsername());
- List<UserQuery> userQuieres = new ArrayList<>();
- JsonNode nodes = JsonUtils.readTree(json);
- Iterator<JsonNode> node = nodes.elements();
- while (node.hasNext()) {
- JsonNode cursor = node.next();
- UserQuery query =
- new UserQuery(cursor.path("id").asInt(), user.getId());
- query.setQueryLanguage(cursor.path("queryLanguage").asText());
- query.setQuery(cursor.path("query").asText());
- query.setDescription(cursor.path("description").asText());
- userQuieres.add(query);
- }
-
- //1: add all that are new, update all that are retained, delete the rest
- // Set<UserQuery> resources = ResourceFinder
- // .search(user, UserQuery.class);
- //
- // add.addAll(userQuieres);
- // add.removeAll(resources);
- // Collection<UserQuery> update = new HashSet<>(userQuieres);
- // update.retainAll(resources);
- // resources.removeAll(userQuieres);
- //
- // if (!update.isEmpty()) {
- // resourceHandler.updateResources(user,
- // update.toArray(new UserQuery[update.size()]));
- // }
- // if (!add.isEmpty()) {
- // resourceHandler.storeResources(user,
- // add.toArray(new UserQuery[add.size()]));
- // }
- // if (!resources.isEmpty()) {
- // resourceHandler.deleteResources(user,
- // resources.toArray(new UserQuery[resources.size()]));
- // }
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
- try {
- return Response.ok(JsonUtils.toJSON(add)).build();
- }
- catch (KustvaktException e) {
- throw kustvaktResponseHandler.throwit(e);
- }
- }
-
- // EM: may be used for managing shib users
- @DELETE
- @ResourceFilters({ AuthenticationFilter.class, PiwikFilter.class,
- BlockingFilter.class })
- public Response deleteUser (@Context SecurityContext context) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- try {
- User user = controller.getUser(ctx.getUsername());
- //todo: test that demo user cannot be deleted!
- controller.deleteAccount(user);
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok().build();
- }
-
-
- @GET
- @Path("queries")
- @ResourceFilters({ AuthenticationFilter.class, DemoUserFilter.class,
- PiwikFilter.class, BlockingFilter.class })
- public Response getQueries (@Context SecurityContext context,
- @Context Locale locale) {
- TokenContext ctx = (TokenContext) context.getUserPrincipal();
- String queryStr;
- try {
- User user = controller.getUser(ctx.getUsername());
- // Set<UserQuery> queries = ResourceFinder
- // .search(user, UserQuery.class);
- // queryStr = JsonUtils.toJSON(queries);
- //todo:
- queryStr = "";
- }
- catch (KustvaktException e) {
- jlog.error("Exception encountered!", e);
- throw kustvaktResponseHandler.throwit(e);
- }
- return Response.ok(queryStr).build();
- }
-}
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java b/full/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
index 5a9f19a..955e219 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/filter/PiwikFilter.java
@@ -8,41 +8,29 @@
import java.util.Map;
import java.util.Random;
-import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.container.ContainerRequestContext;
+import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.core.UriBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Priority;
-import javax.ws.rs.Priorities;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-
-import javax.ws.rs.client.Client;
-import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.WebTarget;
-
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.logging.LoggingFeature;
+import org.springframework.beans.factory.annotation.Autowired;
import de.ids_mannheim.korap.authentication.AuthenticationManager;
-import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.security.context.TokenContext;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-import de.ids_mannheim.korap.user.Userdata;
import net.minidev.json.JSONArray;
/**
* @author hanl
* @date 13/05/2014
*/
-@Component
-@Priority(Priorities.AUTHORIZATION)
+@Deprecated
+//@Component
+//@Priority(Priorities.AUTHORIZATION)
public class PiwikFilter implements ContainerRequestFilter {
private WebTarget service;
@@ -121,25 +109,25 @@
@Override
public void filter (ContainerRequestContext request) {
if (ENABLED) {
- try {
- TokenContext context;
- SecurityContext securityContext = request.getSecurityContext();
- if (securityContext != null) {
- context = (TokenContext) securityContext.getUserPrincipal();
-
- if (context.getUsername() != null){
- // since this is cached, not very expensive!
- User user = authenticationManager.getUser(context.getUsername());
- Userdata data = authenticationManager
- .getUserData(user, UserSettingProcessor.class);
- if ((Boolean) data.get(Attributes.COLLECT_AUDITING_DATA))
- customVars.put("username", context.getUsername());
- }
- }
- }
- catch (KustvaktException e) {
- //do nothing
- }
+// try {
+// TokenContext context;
+// SecurityContext securityContext = request.getSecurityContext();
+// if (securityContext != null) {
+// context = (TokenContext) securityContext.getUserPrincipal();
+//
+// if (context.getUsername() != null){
+// // since this is cached, not very expensive!
+// User user = authenticationManager.getUser(context.getUsername());
+// Userdata data = authenticationManager
+// .getUserData(user, UserSettingProcessor.class);
+// if ((Boolean) data.get(Attributes.COLLECT_AUDITING_DATA))
+// customVars.put("username", context.getUsername());
+// }
+// }
+// }
+// catch (KustvaktException e) {
+// //do nothing
+// }
send(request);
}
}
diff --git a/full/src/main/resources/default-config.xml b/full/src/main/resources/default-config.xml
index 491dcdb..7882650 100644
--- a/full/src/main/resources/default-config.xml
+++ b/full/src/main/resources/default-config.xml
@@ -122,12 +122,6 @@
<constructor-arg ref="flywayConfig"/>
</bean>
- <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
- <constructor-arg index="0" ref="dataSource" />
- <!-- deprecated property -->
- <property name="database" value="${jdbc.database}" />
- </bean>
-
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
depends-on="flyway">
@@ -254,10 +248,6 @@
<constructor-arg index="0" ref="mdGenerator" />
</bean>
- <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
<constructor-arg ref="kustvakt_config" />
</bean>
@@ -291,29 +281,12 @@
</util:list>
- <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <util:list id="kustvakt_userdata"
- value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
- <ref bean="userdata_details" />
- <ref bean="userdata_settings" />
- </util:list>
-
<!-- specify type for constructor argument -->
<bean id="authenticationManager"
class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
- <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
- ref="kustvakt_userdb" />
<constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
ref="kustvakt_encryption" />
<constructor-arg ref="kustvakt_config" />
- <constructor-arg ref="kustvakt_userdata" />
<!-- inject authentication providers to use -->
<property name="providers" ref="kustvakt_authproviders" />
</bean>
diff --git a/full/src/test/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManagerTest.java b/full/src/test/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManagerTest.java
deleted file mode 100644
index 6c2834b..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/authentication/KustvaktAuthenticationManagerTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package de.ids_mannheim.korap.authentication;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import de.ids_mannheim.korap.config.Attributes;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.config.KustvaktConfiguration;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.user.KorAPUser;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.user.UserDetails;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-import de.ids_mannheim.korap.user.Userdata;
-
-/**
- * EM: fix tests. new DB does not save users.
- * @author hanl
- * @date 04/02/2016
- */
-@Ignore
-public class KustvaktAuthenticationManagerTest extends BeanConfigTest {
-
- @Autowired
- private AuthenticationManager authenticationManager;
-
- @After
- public void after () {
- try {
- User user = authenticationManager
- .getUser(
- (String) KustvaktConfiguration.KUSTVAKT_USER
- .get(Attributes.USERNAME));
- authenticationManager
- .deleteAccount(user);
- }
- catch (KustvaktException e) {}
- }
-
- @Test
- public void testBatchStore () {
- int i = 6;
-
-// AuthenticationManagerIface manager = helper().getContext()
-// .getAuthenticationManager();
- for (int ix = 0; ix < i; ix++) {}
-
- }
-
-
- @Test
- @Ignore
- public void testUserdetailsGet () throws KustvaktException {
- User user = authenticationManager
- .getUser((String) KustvaktConfiguration.KUSTVAKT_USER
- .get(Attributes.USERNAME));
-
- Userdata data = authenticationManager.getUserData(user, UserDetails.class);
- assertNotNull(data);
- }
-
-
- @Test
- @Ignore
- public void testUsersettingsGet () throws KustvaktException {
- User user = authenticationManager
- .getUser((String) KustvaktConfiguration.KUSTVAKT_USER
- .get(Attributes.USERNAME));
-
- Userdata data = authenticationManager.getUserData(user, UserSettingProcessor.class);
- assertNotNull(data);
- }
-
-
- @Test(expected = KustvaktException.class)
- public void testUserDetailsGetNonExistent () throws KustvaktException {
- User user = new KorAPUser(10, "random");
- authenticationManager.getUserData(user, UserDetails.class);
- }
-
-
- @Test(expected = KustvaktException.class)
- public void testUserSettingsGetNonExistent () throws KustvaktException {
- User user = new KorAPUser(10, "random");
- authenticationManager.getUserData(user, UserSettingProcessor.class);
- }
-
-}
diff --git a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java b/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
index 0de7e58..3b308b0 100644
--- a/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/config/BeanConfigTest.java
@@ -13,7 +13,6 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
import net.jcip.annotations.NotThreadSafe;
/**
diff --git a/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java b/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java
deleted file mode 100644
index 4de83e0..0000000
--- a/full/src/test/java/de/ids_mannheim/korap/misc/BeanInjectTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package de.ids_mannheim.korap.misc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.util.Collection;
-
-import org.junit.Test;
-import org.springframework.aop.support.AopUtils;
-
-import de.ids_mannheim.korap.config.BeansFactory;
-import de.ids_mannheim.korap.handlers.UserDetailsDao;
-import de.ids_mannheim.korap.handlers.UserSettingsDao;
-import de.ids_mannheim.korap.user.UserDetails;
-import de.ids_mannheim.korap.user.UserSettingProcessor;
-
-/**
- * Created by hanl on 03.06.16.
- */
-public class BeanInjectTest {
-
- @Test
- public void testUserBeans () {
- BeansFactory.loadClasspathContext("test-config.xml");
- Collection coll = BeansFactory.getKustvaktContext()
- .getUserDataProviders();
- assertFalse(coll.isEmpty());
- Object o = BeansFactory.getTypeFactory().getTypeInterfaceBean(coll,
- UserSettingProcessor.class);
- assertEquals(UserSettingsDao.class, AopUtils.getTargetClass(o));
-
- o = BeansFactory.getTypeFactory().getTypeInterfaceBean(coll,
- UserDetails.class);
- assertEquals(UserDetailsDao.class, AopUtils.getTargetClass(o));
- BeansFactory.closeApplication();
- }
-
-}
diff --git a/full/src/test/resources/test-config-icc.xml b/full/src/test/resources/test-config-icc.xml
index 072f5ff..fed99a6 100644
--- a/full/src/test/resources/test-config-icc.xml
+++ b/full/src/test/resources/test-config-icc.xml
@@ -114,12 +114,6 @@
</bean>
- <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
- <!-- <constructor-arg index="0" ref="dataSource" /> -->
- <constructor-arg index="0" ref="sqliteDataSource" />
- <property name="database" value="${jdbc.database}" />
- </bean>
-
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- <property name="dataSource" ref="dataSource" /> -->
@@ -240,10 +234,6 @@
<constructor-arg index="0" ref="mdGenerator" />
</bean>
- <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
<constructor-arg ref="kustvakt_config" />
</bean>
@@ -263,29 +253,12 @@
</util:list>
- <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <util:list id="kustvakt_userdata"
- value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
- <ref bean="userdata_details" />
- <ref bean="userdata_settings" />
- </util:list>
-
<!-- specify type for constructor argument -->
<bean id="authenticationManager"
class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
- <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
- ref="kustvakt_userdb" />
<constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
ref="kustvakt_encryption" />
<constructor-arg ref="kustvakt_config" />
- <constructor-arg ref="kustvakt_userdata" />
<!-- inject authentication providers to use -->
<property name="providers" ref="kustvakt_authproviders" />
</bean>
diff --git a/full/src/test/resources/test-config.xml b/full/src/test/resources/test-config.xml
index d86cb8d..4ef13dc 100644
--- a/full/src/test/resources/test-config.xml
+++ b/full/src/test/resources/test-config.xml
@@ -114,12 +114,6 @@
</bean>
- <bean id="kustvakt_db" class="de.ids_mannheim.korap.handlers.JDBCClient">
- <!-- <constructor-arg index="0" ref="dataSource" /> -->
- <constructor-arg index="0" ref="sqliteDataSource" />
- <property name="database" value="${jdbc.database}" />
- </bean>
-
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- <property name="dataSource" ref="dataSource" /> -->
@@ -236,10 +230,6 @@
<constructor-arg index="0" ref="mdGenerator" />
</bean>
- <bean id="kustvakt_userdb" class="de.ids_mannheim.korap.handlers.EntityDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
<bean name="kustvakt_encryption" class="de.ids_mannheim.korap.encryption.KustvaktEncryption">
<constructor-arg ref="kustvakt_config" />
</bean>
@@ -277,30 +267,12 @@
<ref bean="oauth2_auth" />
</util:list>
-
- <bean id="userdata_details" class="de.ids_mannheim.korap.handlers.UserDetailsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <bean id="userdata_settings" class="de.ids_mannheim.korap.handlers.UserSettingsDao">
- <constructor-arg ref="kustvakt_db" />
- </bean>
-
- <util:list id="kustvakt_userdata"
- value-type="de.ids_mannheim.korap.interfaces.db.UserdataDbIface">
- <ref bean="userdata_details" />
- <ref bean="userdata_settings" />
- </util:list>
-
<!-- specify type for constructor argument -->
<bean id="authenticationManager"
class="de.ids_mannheim.korap.authentication.KustvaktAuthenticationManager">
- <constructor-arg type="de.ids_mannheim.korap.interfaces.EntityHandlerIface"
- ref="kustvakt_userdb" />
<constructor-arg type="de.ids_mannheim.korap.interfaces.EncryptionIface"
ref="kustvakt_encryption" />
<constructor-arg ref="kustvakt_config" />
- <constructor-arg ref="kustvakt_userdata" />
<!-- inject authentication providers to use -->
<property name="providers" ref="kustvakt_authproviders" />
</bean>