Skip to content

Commit

Permalink
add http setup, non-functional
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlxs committed Oct 17, 2024
1 parent e80ac50 commit 9e26017
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public Grading getGradingForAssignmentForStudent(@Argument final UUID assessment
public List<ExternalAssignment> getExternalAssignments(@Argument final UUID courseId, @ContextValue final LoggedInUser currentUser) {
return gradingService.getExternalAssignments(courseId, currentUser);
}

/* Mutation Mappings */

@MutationMapping(name = "_internal_noauth_createAssignment")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import static de.unistuttgart.iste.meitrex.common.user_handling.UserCourseAccessValidator.validateUserHasAccessToCourse;

Expand Down Expand Up @@ -49,7 +56,28 @@ public List<ExternalAssignment> getExternalAssignments(final UUID courseId, fina
} catch (final NoAccessToCourseException ex) {
return null;
}

// get stuff from TMS here

CompletableFuture<String> response;
try (HttpClient client = HttpClient.newBuilder().authenticator(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
"username",
"password".toCharArray());
}
}).build()) {
HttpRequest request = HttpRequest.newBuilder().uri(URI.create("")).build();
response = client.sendAsync(request, HttpResponse.BodyHandlers.ofString()).thenApply(HttpResponse::body);
}
String body = response.join();
List<ExternalAssignment> externalAssignments = this.parseStringIntoList(body);

return externalAssignments;
}

private List<ExternalAssignment> parseStringIntoList(final String string) {
return null;
}

Expand Down

0 comments on commit 9e26017

Please sign in to comment.