Refactor backend packages
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.auth.provider
|
package io.kamax.mxisd.backend.firebase
|
||||||
|
|
||||||
import com.google.firebase.FirebaseApp
|
import com.google.firebase.FirebaseApp
|
||||||
import com.google.firebase.FirebaseOptions
|
import com.google.firebase.FirebaseOptions
|
||||||
@@ -28,6 +28,7 @@ import com.google.firebase.tasks.OnFailureListener
|
|||||||
import com.google.firebase.tasks.OnSuccessListener
|
import com.google.firebase.tasks.OnSuccessListener
|
||||||
import io.kamax.matrix.ThreePidMedium
|
import io.kamax.matrix.ThreePidMedium
|
||||||
import io.kamax.mxisd.auth.UserAuthResult
|
import io.kamax.mxisd.auth.UserAuthResult
|
||||||
|
import io.kamax.mxisd.auth.provider.AuthenticatorProvider
|
||||||
import org.apache.commons.lang.StringUtils
|
import org.apache.commons.lang.StringUtils
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
@@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.lookup.provider
|
package io.kamax.mxisd.backend.firebase
|
||||||
|
|
||||||
import com.google.firebase.FirebaseApp
|
import com.google.firebase.FirebaseApp
|
||||||
import com.google.firebase.FirebaseOptions
|
import com.google.firebase.FirebaseOptions
|
||||||
@@ -33,6 +33,7 @@ import io.kamax.matrix.ThreePidMedium
|
|||||||
import io.kamax.mxisd.lookup.SingleLookupReply
|
import io.kamax.mxisd.lookup.SingleLookupReply
|
||||||
import io.kamax.mxisd.lookup.SingleLookupRequest
|
import io.kamax.mxisd.lookup.SingleLookupRequest
|
||||||
import io.kamax.mxisd.lookup.ThreePidMapping
|
import io.kamax.mxisd.lookup.ThreePidMapping
|
||||||
|
import io.kamax.mxisd.lookup.provider.IThreePidProvider
|
||||||
import org.apache.commons.lang.StringUtils
|
import org.apache.commons.lang.StringUtils
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
@@ -18,12 +18,11 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.auth.provider;
|
package io.kamax.mxisd.backend.ldap;
|
||||||
|
|
||||||
import io.kamax.matrix.MatrixID;
|
import io.kamax.matrix.MatrixID;
|
||||||
import io.kamax.mxisd.auth.UserAuthResult;
|
import io.kamax.mxisd.auth.UserAuthResult;
|
||||||
import io.kamax.mxisd.backend.LdapBackend;
|
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
|
||||||
import io.kamax.mxisd.lookup.provider.LdapProvider;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.directory.api.ldap.model.cursor.CursorException;
|
import org.apache.directory.api.ldap.model.cursor.CursorException;
|
||||||
import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
|
import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException;
|
||||||
@@ -40,7 +39,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LdapAuthProvider extends LdapBackend implements AuthenticatorProvider {
|
public class LdapAuthProvider extends LdapGenericBackend implements AuthenticatorProvider {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(LdapAuthProvider.class);
|
private Logger log = LoggerFactory.getLogger(LdapAuthProvider.class);
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ public class LdapAuthProvider extends LdapBackend implements AuthenticatorProvid
|
|||||||
|
|
||||||
String uidType = getCfg().getAttribute().getUid().getType();
|
String uidType = getCfg().getAttribute().getUid().getType();
|
||||||
MatrixID mxIdExt = new MatrixID(id);
|
MatrixID mxIdExt = new MatrixID(id);
|
||||||
String userFilterValue = StringUtils.equals(LdapProvider.UID, uidType) ? mxIdExt.getLocalPart() : mxIdExt.getId();
|
String userFilterValue = StringUtils.equals(LdapThreePidProvider.UID, uidType) ? mxIdExt.getLocalPart() : mxIdExt.getId();
|
||||||
String userFilter = "(" + getCfg().getAttribute().getUid().getValue() + "=" + userFilterValue + ")";
|
String userFilter = "(" + getCfg().getAttribute().getUid().getValue() + "=" + userFilterValue + ")";
|
||||||
EntryCursor cursor = conn.search(getCfg().getConn().getBaseDn(), userFilter, SearchScope.SUBTREE, getUidAttribute(), getCfg().getAttribute().getName());
|
EntryCursor cursor = conn.search(getCfg().getConn().getBaseDn(), userFilter, SearchScope.SUBTREE, getUidAttribute(), getCfg().getAttribute().getName());
|
||||||
try {
|
try {
|
@@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.backend;
|
package io.kamax.mxisd.backend.ldap;
|
||||||
|
|
||||||
import io.kamax.mxisd.config.ldap.LdapConfig;
|
import io.kamax.mxisd.config.ldap.LdapConfig;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -31,9 +31,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class LdapBackend {
|
public class LdapGenericBackend {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(LdapBackend.class);
|
private Logger log = LoggerFactory.getLogger(LdapGenericBackend.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LdapConfig ldapCfg;
|
private LdapConfig ldapCfg;
|
@@ -18,13 +18,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.lookup.provider
|
package io.kamax.mxisd.backend.ldap
|
||||||
|
|
||||||
import io.kamax.mxisd.backend.LdapBackend
|
|
||||||
import io.kamax.mxisd.config.MatrixConfig
|
import io.kamax.mxisd.config.MatrixConfig
|
||||||
import io.kamax.mxisd.lookup.SingleLookupReply
|
import io.kamax.mxisd.lookup.SingleLookupReply
|
||||||
import io.kamax.mxisd.lookup.SingleLookupRequest
|
import io.kamax.mxisd.lookup.SingleLookupRequest
|
||||||
import io.kamax.mxisd.lookup.ThreePidMapping
|
import io.kamax.mxisd.lookup.ThreePidMapping
|
||||||
|
import io.kamax.mxisd.lookup.provider.IThreePidProvider
|
||||||
import org.apache.commons.lang.StringUtils
|
import org.apache.commons.lang.StringUtils
|
||||||
import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException
|
import org.apache.directory.api.ldap.model.cursor.CursorLdapReferralException
|
||||||
import org.apache.directory.api.ldap.model.cursor.EntryCursor
|
import org.apache.directory.api.ldap.model.cursor.EntryCursor
|
||||||
@@ -38,12 +38,12 @@ import org.springframework.beans.factory.annotation.Autowired
|
|||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class LdapProvider extends LdapBackend implements IThreePidProvider {
|
class LdapThreePidProvider extends LdapGenericBackend implements IThreePidProvider {
|
||||||
|
|
||||||
public static final String UID = "uid"
|
public static final String UID = "uid"
|
||||||
public static final String MATRIX_ID = "mxid"
|
public static final String MATRIX_ID = "mxid"
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(LdapProvider.class)
|
private Logger log = LoggerFactory.getLogger(LdapThreePidProvider.class)
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MatrixConfig mxCfg
|
private MatrixConfig mxCfg
|
@@ -18,9 +18,10 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.auth.provider;
|
package io.kamax.mxisd.backend.sql;
|
||||||
|
|
||||||
import io.kamax.mxisd.auth.UserAuthResult;
|
import io.kamax.mxisd.auth.UserAuthResult;
|
||||||
|
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
|
||||||
import io.kamax.mxisd.config.ServerConfig;
|
import io.kamax.mxisd.config.ServerConfig;
|
||||||
import io.kamax.mxisd.config.sql.SqlProviderConfig;
|
import io.kamax.mxisd.config.sql.SqlProviderConfig;
|
||||||
import io.kamax.mxisd.invitation.InvitationManager;
|
import io.kamax.mxisd.invitation.InvitationManager;
|
@@ -18,7 +18,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.kamax.mxisd.lookup.provider;
|
package io.kamax.mxisd.backend.sql;
|
||||||
|
|
||||||
import io.kamax.matrix.MatrixID;
|
import io.kamax.matrix.MatrixID;
|
||||||
import io.kamax.mxisd.config.MatrixConfig;
|
import io.kamax.mxisd.config.MatrixConfig;
|
||||||
@@ -26,6 +26,7 @@ import io.kamax.mxisd.config.sql.SqlProviderConfig;
|
|||||||
import io.kamax.mxisd.lookup.SingleLookupReply;
|
import io.kamax.mxisd.lookup.SingleLookupReply;
|
||||||
import io.kamax.mxisd.lookup.SingleLookupRequest;
|
import io.kamax.mxisd.lookup.SingleLookupRequest;
|
||||||
import io.kamax.mxisd.lookup.ThreePidMapping;
|
import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||||
|
import io.kamax.mxisd.lookup.provider.IThreePidProvider;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -38,9 +39,9 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class SqlProvider implements IThreePidProvider {
|
public class SqlThreePidProvider implements IThreePidProvider {
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger(SqlProvider.class);
|
private Logger log = LoggerFactory.getLogger(SqlThreePidProvider.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MatrixConfig mxCfg;
|
private MatrixConfig mxCfg;
|
@@ -21,8 +21,8 @@
|
|||||||
package io.kamax.mxisd.config;
|
package io.kamax.mxisd.config;
|
||||||
|
|
||||||
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
|
import io.kamax.mxisd.auth.provider.AuthenticatorProvider;
|
||||||
import io.kamax.mxisd.auth.provider.GoogleFirebaseAuthenticator;
|
import io.kamax.mxisd.backend.firebase.GoogleFirebaseAuthenticator;
|
||||||
import io.kamax.mxisd.lookup.provider.GoogleFirebaseProvider;
|
import io.kamax.mxisd.backend.firebase.GoogleFirebaseProvider;
|
||||||
import io.kamax.mxisd.lookup.provider.IThreePidProvider;
|
import io.kamax.mxisd.lookup.provider.IThreePidProvider;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
package io.kamax.mxisd.config.ldap
|
package io.kamax.mxisd.config.ldap
|
||||||
|
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
import io.kamax.mxisd.lookup.provider.LdapProvider
|
import io.kamax.mxisd.backend.ldap.LdapThreePidProvider
|
||||||
import org.apache.commons.lang.StringUtils
|
import org.apache.commons.lang.StringUtils
|
||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
@@ -112,7 +112,7 @@ class LdapConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String uidType = attribute.getUid().getType();
|
String uidType = attribute.getUid().getType();
|
||||||
if (!StringUtils.equals(LdapProvider.UID, uidType) && !StringUtils.equals(LdapProvider.MATRIX_ID, uidType)) {
|
if (!StringUtils.equals(LdapThreePidProvider.UID, uidType) && !StringUtils.equals(LdapThreePidProvider.MATRIX_ID, uidType)) {
|
||||||
throw new IllegalArgumentException("Unsupported LDAP UID type: " + uidType)
|
throw new IllegalArgumentException("Unsupported LDAP UID type: " + uidType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user