Wordpress identity store (#67)
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* mxisd - Matrix Identity Server Daemon
|
||||
* Copyright (C) 2018 Kamax Sàrl
|
||||
*
|
||||
* https://www.kamax.io/
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.kamax.mxisd.config.wordpress;
|
||||
|
||||
import io.kamax.mxisd.exception.ConfigurationException;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties("wordpress")
|
||||
public class WordpressConfig {
|
||||
|
||||
public static class Credential {
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Rest {
|
||||
|
||||
private Credential credential = new Credential();
|
||||
private String base;
|
||||
|
||||
public String getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public void setBase(String base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public Credential getCredential() {
|
||||
return credential;
|
||||
}
|
||||
|
||||
public void setCredential(Credential credential) {
|
||||
this.credential = credential;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Query {
|
||||
|
||||
private Map<String, String> threepid;
|
||||
private Map<String, String> directory;
|
||||
|
||||
public Map<String, String> getThreepid() {
|
||||
return threepid;
|
||||
}
|
||||
|
||||
public void setThreepid(Map<String, String> threepid) {
|
||||
this.threepid = threepid;
|
||||
}
|
||||
|
||||
public Map<String, String> getDirectory() {
|
||||
return directory;
|
||||
}
|
||||
|
||||
public void setDirectory(Map<String, String> directory) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Sql {
|
||||
|
||||
private String type;
|
||||
private String connection;
|
||||
private Query query;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public void setConnection(String connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public Query getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(Query query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean enabled;
|
||||
private Rest rest = new Rest();
|
||||
private Sql sql = new Sql();
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public Rest getRest() {
|
||||
return rest;
|
||||
}
|
||||
|
||||
public void setRest(Rest rest) {
|
||||
this.rest = rest;
|
||||
}
|
||||
|
||||
public Sql getSql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
public void setSql(Sql sql) {
|
||||
this.sql = sql;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void build() {
|
||||
if (!isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getRest().getBase())) {
|
||||
throw new ConfigurationException("wordpress.rest.base");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user