use of com.djrapitops.plan.delivery.web.resolver.request.URIPath in project Plan by plan-player-analytics.
the class RequestHandler method buildRequest.
private Request buildRequest(HttpExchange exchange) {
String requestMethod = exchange.getRequestMethod();
URIPath path = new URIPath(exchange.getRequestURI().getPath());
URIQuery query = new URIQuery(exchange.getRequestURI().getRawQuery());
byte[] requestBody = readRequestBody(exchange);
WebUser user = getWebUser(exchange);
Map<String, String> headers = getRequestHeaders(exchange);
return new Request(requestMethod, path, query, user, headers, requestBody);
}
use of com.djrapitops.plan.delivery.web.resolver.request.URIPath in project Plan by plan-player-analytics.
the class PlayerPageResolver method canAccess.
@Override
public boolean canAccess(Request request) {
URIPath path = request.getPath();
WebUser user = request.getUser().orElse(new WebUser(""));
boolean isOwnPage = path.getPart(1).map(nameOrUUID -> {
// name matches user
if (user.getName().equalsIgnoreCase(nameOrUUID))
return true;
return // uuid matches user
uuidUtility.getNameOf(nameOrUUID).map(user.getName()::equalsIgnoreCase).orElse(// uuid or name don't match
false);
}).orElse(// No name or UUID given
true);
return user.hasPermission("page.player.other") || user.hasPermission("page.player.self") && isOwnPage;
}
Aggregations