Skip to content

Commit 215d59f

Browse files
authored
Added support for connectionKeys Endpoint (#721)
1 parent 0be0144 commit 215d59f

File tree

9 files changed

+508
-29
lines changed

9 files changed

+508
-29
lines changed

src/main/java/com/auth0/client/mgmt/ConnectionsEntity.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.auth0.client.mgmt.filter.EnabledClientsFilter;
55
import com.auth0.json.mgmt.connections.*;
66
import com.auth0.net.BaseRequest;
7+
import com.auth0.net.EmptyBodyRequest;
78
import com.auth0.net.Request;
89
import com.auth0.net.VoidRequest;
910
import com.auth0.net.client.Auth0HttpClient;
@@ -424,4 +425,42 @@ public Request<Void> updateEnabledClients(String connectionId, List<EnabledClien
424425
return request;
425426
}
426427

428+
/**
429+
* Get the Connection Keys.
430+
* A token with scope read:connections_keys is needed.
431+
* @param connectionId the connection id.
432+
* @return a Request to execute.
433+
*/
434+
public Request<List<ConnectionKeys>> getKeys(String connectionId) {
435+
Asserts.assertNotNull(connectionId, "connection id");
436+
437+
String url = baseUrl
438+
.newBuilder()
439+
.addPathSegments("api/v2/connections")
440+
.addPathSegment(connectionId)
441+
.addPathSegment("keys")
442+
.build()
443+
.toString();
444+
return new BaseRequest<>(client, tokenProvider, url, HttpMethod.GET, new TypeReference<List<ConnectionKeys>>() {
445+
});
446+
}
447+
448+
/** * Rotate the Connection Keys.
449+
* A token with scope create:connections_keys and update:connections_keys is needed.
450+
* @param connectionId the connection id.
451+
* @return a Request to execute.
452+
*/
453+
public Request<RotateKey> rotateKey(String connectionId) {
454+
Asserts.assertNotNull(connectionId, "connection id");
455+
456+
String url = baseUrl
457+
.newBuilder()
458+
.addPathSegments("api/v2/connections")
459+
.addPathSegment(connectionId)
460+
.addPathSegments("keys/rotate")
461+
.build()
462+
.toString();
463+
464+
return new EmptyBodyRequest<>(client, tokenProvider, url, HttpMethod.POST, new TypeReference<RotateKey>() {});
465+
}
427466
}
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
package com.auth0.json.mgmt.connections;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
public class ConnectionKeys {
10+
@JsonProperty("kid")
11+
private String kid;
12+
13+
@JsonProperty("algorithm")
14+
private String algorithm;
15+
16+
@JsonProperty("key_use")
17+
private String keyUse;
18+
19+
@JsonProperty("subject_dn")
20+
private String subjectDn;
21+
22+
@JsonProperty("cert")
23+
private String cert;
24+
25+
@JsonProperty("fingerprint")
26+
private String fingerprint;
27+
28+
@JsonProperty("thumbprint")
29+
private String thumbprint;
30+
31+
@JsonProperty("pkcs")
32+
private String pkcs;
33+
34+
@JsonProperty("current")
35+
private Boolean current;
36+
37+
@JsonProperty("current_since")
38+
private String currentSince;
39+
40+
@JsonProperty("next")
41+
private Boolean next;
42+
43+
/**
44+
* Getter for the Key ID (kid).
45+
* @return the Key ID (kid).
46+
*/
47+
public String getKid() {
48+
return kid;
49+
}
50+
51+
/**
52+
* Setter for the Key ID (kid).
53+
* @param kid the Key ID (kid).
54+
*/
55+
public void setKid(String kid) {
56+
this.kid = kid;
57+
}
58+
59+
/**
60+
* Getter for the algorithm used by the key.
61+
* @return the algorithm used by the key.
62+
*/
63+
public String getAlgorithm() {
64+
return algorithm;
65+
}
66+
67+
/**
68+
* Setter for the algorithm used by the key.
69+
* @param algorithm the algorithm used by the key.
70+
*/
71+
public void setAlgorithm(String algorithm) {
72+
this.algorithm = algorithm;
73+
}
74+
75+
/**
76+
* Getter for the key use (e.g., "sig" for signature).
77+
* @return the key use.
78+
*/
79+
public String getKeyUse() {
80+
return keyUse;
81+
}
82+
83+
/**
84+
* Setter for the key use.
85+
* @param keyUse the key use (e.g., "sig" for signature).
86+
*/
87+
public void setKeyUse(String keyUse) {
88+
this.keyUse = keyUse;
89+
}
90+
91+
/**
92+
* Getter for the subject distinguished name (DN).
93+
* @return the subject DN.
94+
*/
95+
public String getSubjectDn() {
96+
return subjectDn;
97+
}
98+
99+
/**
100+
* Setter for the subject distinguished name (DN).
101+
* @param subjectDn the subject DN.
102+
*/
103+
public void setSubjectDn(String subjectDn) {
104+
this.subjectDn = subjectDn;
105+
}
106+
107+
/**
108+
* Getter for the certificate associated with the key.
109+
* @return the certificate.
110+
*/
111+
public String getCert() {
112+
return cert;
113+
}
114+
115+
/**
116+
* Setter for the certificate associated with the key.
117+
* @param cert the certificate.
118+
*/
119+
public void setCert(String cert) {
120+
this.cert = cert;
121+
}
122+
123+
/**
124+
* Getter for the fingerprint of the key.
125+
* @return the fingerprint.
126+
*/
127+
public String getFingerprint() {
128+
return fingerprint;
129+
}
130+
131+
/**
132+
* Setter for the fingerprint of the key.
133+
* @param fingerprint the fingerprint.
134+
*/
135+
public void setFingerprint(String fingerprint) {
136+
this.fingerprint = fingerprint;
137+
}
138+
139+
/**
140+
* Getter for the thumbprint of the key.
141+
* @return the thumbprint.
142+
*/
143+
public String getThumbprint() {
144+
return thumbprint;
145+
}
146+
147+
/**
148+
* Setter for the thumbprint of the key.
149+
* @param thumbprint the thumbprint.
150+
*/
151+
public void setThumbprint(String thumbprint) {
152+
this.thumbprint = thumbprint;
153+
}
154+
155+
/**
156+
* Getter for the PKCS#8 representation of the key.
157+
* @return the PKCS#8 representation.
158+
*/
159+
public String getPkcs() {
160+
return pkcs;
161+
}
162+
163+
/**
164+
* Setter for the PKCS#8 representation of the key.
165+
* @param pkcs the PKCS#8 representation.
166+
*/
167+
public void setPkcs(String pkcs) {
168+
this.pkcs = pkcs;
169+
}
170+
171+
/**
172+
* Getter for whether the key is currently active.
173+
* @return true if the key is current, false otherwise.
174+
*/
175+
public Boolean getCurrent() {
176+
return current;
177+
}
178+
179+
/**
180+
* Setter for whether the key is currently active.
181+
* @param current true if the key is current, false otherwise.
182+
*/
183+
public void setCurrent(Boolean current) {
184+
this.current = current;
185+
}
186+
187+
/**
188+
* Getter for the timestamp when the key became current.
189+
* @return the timestamp in ISO 8601 format.
190+
*/
191+
public String getCurrentSince() {
192+
return currentSince;
193+
}
194+
195+
/**
196+
* Setter for the timestamp when the key became current.
197+
* @param currentSince the timestamp in ISO 8601 format.
198+
*/
199+
public void setCurrentSince(String currentSince) {
200+
this.currentSince = currentSince;
201+
}
202+
203+
/**
204+
* Getter for whether there is a next key available.
205+
* @return true if there is a next key, false otherwise.
206+
*/
207+
public Boolean getNext() {
208+
return next;
209+
}
210+
211+
/**
212+
* Setter for whether there is a next key available.
213+
* @param next true if there is a next key, false otherwise.
214+
*/
215+
public void setNext(Boolean next) {
216+
this.next = next;
217+
}
218+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.auth0.json.mgmt.connections;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
public class RotateKey {
10+
@JsonProperty("cert")
11+
private String cert;
12+
@JsonProperty("kid")
13+
private String kid;
14+
15+
/**
16+
* Returns the certificate used for the key rotation.
17+
* @return the certificate as a String.
18+
*/
19+
public String getCert() {
20+
return cert;
21+
}
22+
23+
/**
24+
* Sets the certificate used for the key rotation.
25+
* @param cert the certificate as a String.
26+
*/
27+
public void setCert(String cert) {
28+
this.cert = cert;
29+
}
30+
31+
/**
32+
* Returns the Key ID (kid) of the key being rotated.
33+
* @return the Key ID as a String.
34+
*/
35+
public String getKid() {
36+
return kid;
37+
}
38+
39+
/**
40+
* Sets the Key ID (kid) of the key being rotated.
41+
* @param kid the Key ID as a String.
42+
*/
43+
public void setKid(String kid) {
44+
this.kid = kid;
45+
}
46+
}

src/test/java/com/auth0/client/MockServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class MockServer {
5050
public static final String MGMT_CONNECTION_SCIM_TOKENS = "src/test/resources/mgmt/connection_scim_tokens.json";
5151
public static final String MGMT_CONNECTION_SCIM_TOKEN = "src/test/resources/mgmt/connection_scim_token.json";
5252
public static final String MGMT_ENABLED_CLIENTS_FOR_CONNECTION = "src/test/resources/mgmt/enabled_clients_for_connection.json";
53+
public static final String MGMT_CONNECTION_KEY = "src/test/resources/mgmt/connection_key.json";
54+
public static final String MGMT_ROTATE_KEY = "src/test/resources/mgmt/rotate_key.json";
5355
public static final String MGMT_DEVICE_CREDENTIALS_LIST = "src/test/resources/mgmt/device_credentials_list.json";
5456
public static final String MGMT_DEVICE_CREDENTIALS = "src/test/resources/mgmt/device_credentials.json";
5557
public static final String MGMT_GRANTS_LIST = "src/test/resources/mgmt/grants_list.json";

0 commit comments

Comments
 (0)