Finish implementation of protected routes but passwords must still be encrypted
This commit is contained in:
@@ -5,28 +5,20 @@ import com.sun.net.httpserver.HttpExchange;
|
||||
import httpsServer.httpServer.src.annotations.AllowedVerb;
|
||||
import httpsServer.httpServer.src.annotations.OnlyAuthorizedClients;
|
||||
import httpsServer.httpServer.src.authorization.AuthorizedClients;
|
||||
import httpsServer.httpServer.src.authorization.Client;
|
||||
import httpsServer.httpServer.src.exceptions.NoSuchVerbException;
|
||||
import httpsServer.httpServer.src.exceptions.ClientAuthorisationException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.Buffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class RequestInterceptor implements InvocationHandler {
|
||||
|
||||
private final AuthorizedClients authorizedClients;
|
||||
private final ObjectMapper mapper;
|
||||
private final Object target;
|
||||
|
||||
public RequestInterceptor(Object target) {
|
||||
authorizedClients = new AuthorizedClients();
|
||||
mapper = new ObjectMapper();
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@@ -71,9 +63,8 @@ public class RequestInterceptor implements InvocationHandler {
|
||||
throw new ClientAuthorisationException("Unable to read body");
|
||||
}
|
||||
|
||||
String base64Credentials = authHeader.substring("Basic ".length());
|
||||
String credentials = new String(Base64.getDecoder().decode(base64Credentials));
|
||||
String[] values = credentials.split(":", 1);
|
||||
String credentials = authHeader.substring("Basic ".length());
|
||||
String[] values = credentials.split(":", 2);
|
||||
String username = values[0];
|
||||
String password = values[1];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user