-
Notifications
You must be signed in to change notification settings - Fork 4
Add the ability to sign statements #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
688d5c8
refactor client
Selindek f9d4523
fcs
Selindek 047d6de
fixup
Selindek aab9d97
SOME PROGRESS
Selindek 17bccb8
working version
Selindek 948ce2e
fixup merge
Selindek c1adaae
simplify MultipartHelper
Selindek cee5aaf
fixup
Selindek 48dd75a
sss
Selindek e44e10a
fcs, tests, fixup
Selindek e691e5c
fcs
Selindek 7721b42
add signature handling
Selindek f6bec60
fsi
Selindek ccf2f46
add support for attachments
Selindek 4f9143b
Merge branch 'get_attachments' of
Selindek fad29eb
fixup
Selindek 5a24762
fsi
Selindek 7fc3a9d
fix merge issues
Selindek 22a4f50
fix more merge issues
Selindek af124b8
Merge branch 'main' into signature
knoake c11c30f
Merge branch 'main' into signature
Selindek 65b68b1
rename sign to signAndBuild
Selindek a85af5b
add post signed statement sample
Selindek 27ae2d9
fcs
Selindek c23494e
fcs
Selindek 0550cfc
add paragraph to README.md
Selindek 6905db2
add test
Selindek abf8d31
fsi
Selindek c5eb2bf
Merge remote-tracking branch 'origin/main' into signature
Selindek d026938
Merge branch 'main' into signature
Selindek 2ce5aeb
Apply suggestions from code review
thomasturrell a814a37
Merge branch 'main' into signature
thomasturrell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>dev.learning.xapi.samples</groupId> | ||
| <artifactId>xapi-samples-build</artifactId> | ||
| <version>1.1.4-SNAPSHOT</version> | ||
| </parent> | ||
| <artifactId>post-signed-statement</artifactId> | ||
| <name>Post xAPI Signed Statement Sample</name> | ||
| <description>Post xAPI Signed Statement</description> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>dev.learning.xapi</groupId> | ||
| <artifactId>xapi-client</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>dev.learning.xapi.samples</groupId> | ||
| <artifactId>core</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.jsonwebtoken</groupId> | ||
| <artifactId>jjwt-impl</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>io.jsonwebtoken</groupId> | ||
| <artifactId>jjwt-jackson</artifactId> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> |
66 changes: 66 additions & 0 deletions
66
...src/main/java/dev/learning/xapi/samples/poststatement/PostSignedStatementApplication.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| /* | ||
| * Copyright 2016-2023 Berry Cloud Ltd. All rights reserved. | ||
| */ | ||
|
|
||
| package dev.learning.xapi.samples.poststatement; | ||
|
|
||
| import dev.learning.xapi.client.XapiClient; | ||
| import dev.learning.xapi.model.Verb; | ||
| import java.security.KeyPairGenerator; | ||
| import java.util.Locale; | ||
| import java.util.UUID; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.CommandLineRunner; | ||
| import org.springframework.boot.SpringApplication; | ||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| import org.springframework.http.ResponseEntity; | ||
|
|
||
| /** | ||
| * Sample using xAPI client to post a statement. | ||
| * <p> | ||
| * See <code>pom.xml</code> for extra dependencies. | ||
| * </p> | ||
| * | ||
| * @author Thomas Turrell-Croft | ||
| * @author István Rátkai (Selindek) | ||
| */ | ||
| @SpringBootApplication | ||
| public class PostSignedStatementApplication implements CommandLineRunner { | ||
|
|
||
| /** | ||
| * Default xAPI client. Properties are picked automatically from application.properties. | ||
| */ | ||
| @Autowired | ||
| private XapiClient client; | ||
|
|
||
| public static void main(String[] args) { | ||
| SpringApplication.run(PostSignedStatementApplication.class, args).close(); | ||
| } | ||
|
|
||
| @Override | ||
| public void run(String... args) throws Exception { | ||
|
|
||
| final var keyPairGenerator = KeyPairGenerator.getInstance("RSA"); | ||
| keyPairGenerator.initialize(2048); | ||
| final var keyPair = keyPairGenerator.generateKeyPair(); | ||
|
|
||
| // Post a statement | ||
| ResponseEntity< | ||
| UUID> response = | ||
| client | ||
| .postStatement(r -> r.signedStatement( | ||
| s -> s.actor(a -> a.name("A N Other").mbox("mailto:another@example.com")) | ||
|
|
||
| .verb(Verb.ATTEMPTED) | ||
|
|
||
| .activityObject(o -> o.id("https://example.com/activity/simplestatement") | ||
| .definition(d -> d.addName(Locale.ENGLISH, "Simple Statement"))), | ||
|
|
||
| keyPair.getPrivate())) | ||
| .block(); | ||
|
|
||
| // Print the statementId of the newly created statement to the console | ||
| System.out.println("StatementId " + response.getBody()); | ||
| } | ||
|
|
||
| } |
3 changes: 3 additions & 0 deletions
3
samples/post-signed-statement/src/main/resources/application.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| xapi.client.username = admin | ||
| xapi.client.password = password | ||
| xapi.client.baseUrl = https://example.com/xapi/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.