X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FFcpInterface.java;h=e190aef74e6999da7d1f48d0ea7eb9e48d6eb6bf;hp=c6957f4a29ee51a393c816ff1ed2c131bc584967;hb=2bacfa78f3191fd9847574a6c8b218a4882844a4;hpb=914d5522692e7714ba5bdefb002fedc8e293f5fc
diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java
index c6957f4..e190aef 100644
--- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java
+++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java
@@ -54,16 +54,12 @@ import com.google.inject.Inject;
/**
* Implementation of an FCP interface for other clients or plugins to
* communicate with Sone.
- *
- * @author David âBombeâ Roden
*/
@Singleton
public class FcpInterface {
/**
* The action level that full access for the FCP connection is required.
- *
- * @author David âBombeâ Roden
*/
public enum FullAccessRequired {
@@ -85,7 +81,7 @@ public class FcpInterface {
private final AtomicBoolean active = new AtomicBoolean();
/** What function full access is required for. */
- private final AtomicReference fullAccessRequired = new AtomicReference(FullAccessRequired.ALWAYS);
+ private final AtomicReference fullAccessRequired = new AtomicReference<>(FullAccessRequired.ALWAYS);
/** All available FCP commands. */
private final Map commands;
@@ -144,22 +140,22 @@ public class FcpInterface {
* {@link FredPluginFCP#ACCESS_FCP_RESTRICTED}
*/
public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
+ String identifier = parameters.get("Identifier");
+ if ((identifier == null) || (identifier.length() == 0)) {
+ sendErrorReply(pluginReplySender, null, 400, "Missing Identifier.");
+ return;
+ }
if (!active.get()) {
- sendErrorReply(pluginReplySender, null, 503, "FCP Interface deactivated");
+ sendErrorReply(pluginReplySender, identifier, 503, "FCP Interface deactivated");
return;
}
AbstractSoneCommand command = commands.get(parameters.get("Message"));
if (command == null) {
- sendErrorReply(pluginReplySender, null, 404, "Unrecognized Message: " + parameters.get("Message"));
+ sendErrorReply(pluginReplySender, identifier, 404, "Unrecognized Message: " + parameters.get("Message"));
return;
}
if (!accessAuthorizer.authorized(AccessType.values()[accessType], fullAccessRequired.get(), command.requiresWriteAccess())) {
- sendErrorReply(pluginReplySender, null, 401, "Not authorized");
- return;
- }
- String identifier = parameters.get("Identifier");
- if ((identifier == null) || (identifier.length() == 0)) {
- sendErrorReply(pluginReplySender, null, 400, "Missing Identifier.");
+ sendErrorReply(pluginReplySender, identifier, 401, "Not authorized");
return;
}
try {