Complete the documentation and polish the code
This commit is contained in:
@@ -81,7 +81,7 @@ public class ExecAuthStore extends ExecStore implements AuthenticatorProvider {
|
||||
json.setPassword(tokens.getPassword());
|
||||
return json;
|
||||
});
|
||||
p.addInputTemplate(MultilinesType, tokens -> tokens.getLocalpart() + System.lineSeparator() +
|
||||
p.addInputTemplate(PlainType, tokens -> tokens.getLocalpart() + System.lineSeparator() +
|
||||
tokens.getDomain() + System.lineSeparator() +
|
||||
tokens.getMxid() + System.lineSeparator() +
|
||||
tokens.getPassword() + System.lineSeparator()
|
||||
@@ -102,7 +102,7 @@ public class ExecAuthStore extends ExecStore implements AuthenticatorProvider {
|
||||
|
||||
return result;
|
||||
});
|
||||
p.addSuccessMapper(MultilinesType, output -> {
|
||||
p.addSuccessMapper(PlainType, output -> {
|
||||
String[] lines = output.split("\\R");
|
||||
if (lines.length > 2) {
|
||||
throw new InternalServerError("Exec auth command returned more than 2 lines (" + lines.length + ")");
|
||||
|
@@ -60,7 +60,7 @@ public class ExecDirectoryStore extends ExecStore implements IDirectoryProvider
|
||||
Processor<UserDirectorySearchResult> p = new Processor<>(cfg);
|
||||
|
||||
p.addJsonInputTemplate(tokens -> new UserDirectorySearchRequest(tokens.getType(), tokens.getQuery()));
|
||||
p.addInputTemplate(MultilinesType, tokens -> tokens.getType() + System.lineSeparator() + tokens.getQuery());
|
||||
p.addInputTemplate(PlainType, tokens -> tokens.getType() + System.lineSeparator() + tokens.getQuery());
|
||||
|
||||
p.addTokenMapper(cfg.getToken().getType(), request::getBy);
|
||||
p.addTokenMapper(cfg.getToken().getQuery(), request::getSearchTerm);
|
||||
|
@@ -111,7 +111,7 @@ public class ExecIdentityStore extends ExecStore implements IThreePidProvider {
|
||||
p.addTokenMapper(getSingleCfg().getToken().getAddress(), request::getThreePid);
|
||||
|
||||
p.addJsonInputTemplate(tokens -> new ThreePid(tokens.getMedium(), tokens.getAddress()));
|
||||
p.addInputTemplate(MultilinesType, tokens -> tokens.getMedium()
|
||||
p.addInputTemplate(PlainType, tokens -> tokens.getMedium()
|
||||
+ System.lineSeparator()
|
||||
+ tokens.getAddress()
|
||||
);
|
||||
@@ -128,7 +128,7 @@ public class ExecIdentityStore extends ExecStore implements IThreePidProvider {
|
||||
.map(mxId -> new SingleLookupReply(request, mxId));
|
||||
});
|
||||
|
||||
p.addSuccessMapper(MultilinesType, output -> {
|
||||
p.addSuccessMapper(PlainType, output -> {
|
||||
String[] lines = output.split("\\R");
|
||||
if (lines.length > 2) {
|
||||
throw new InternalServerError("Exec auth command returned more than 2 lines (" + lines.length + ")");
|
||||
@@ -138,7 +138,7 @@ public class ExecIdentityStore extends ExecStore implements IThreePidProvider {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
String type = StringUtils.trimToEmpty(lines.length == 1 ? "uid" : lines[0]);
|
||||
String type = StringUtils.trimToEmpty(lines.length == 1 ? UserIdType.Localpart.getId() : lines[0]);
|
||||
String value = StringUtils.trimToEmpty(lines.length == 2 ? lines[1] : lines[0]);
|
||||
|
||||
if (UserIdType.Localpart.is(type)) {
|
||||
@@ -168,7 +168,7 @@ public class ExecIdentityStore extends ExecStore implements IThreePidProvider {
|
||||
.collect(Collectors.toList()));
|
||||
return GsonUtil.get().toJson(GsonUtil.makeObj("lookup", tpids));
|
||||
});
|
||||
p.addInput(MultilinesType, () -> {
|
||||
p.addInput(PlainType, () -> {
|
||||
StringBuilder input = new StringBuilder();
|
||||
for (ThreePidMapping mapping : mappings) {
|
||||
input.append(mapping.getMedium()).append("\t").append(mapping.getValue()).append(System.lineSeparator());
|
||||
|
@@ -58,7 +58,7 @@ public class ExecProfileStore extends ExecStore implements ProfileProvider {
|
||||
Processor<Optional<JsonProfileResult>> p = new Processor<>(cfg);
|
||||
|
||||
p.addJsonInputTemplate(tokens -> new JsonProfileRequest(tokens.getLocalpart(), tokens.getDomain(), tokens.getMxid()));
|
||||
p.addInputTemplate(MultilinesType, tokens -> tokens.getLocalpart() + System.lineSeparator()
|
||||
p.addInputTemplate(PlainType, tokens -> tokens.getLocalpart() + System.lineSeparator()
|
||||
+ tokens.getDomain() + System.lineSeparator()
|
||||
+ tokens.getMxid() + System.lineSeparator()
|
||||
);
|
||||
|
@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
||||
public class ExecStore {
|
||||
|
||||
public static final String JsonType = "json";
|
||||
public static final String MultilinesType = "multilines";
|
||||
public static final String PlainType = "plain";
|
||||
|
||||
protected static String toJson(Object o) {
|
||||
return GsonUtil.get().toJson(o);
|
||||
|
Reference in New Issue
Block a user