Skip to content

Commit 85f7df2

Browse files
Add docs
Thanks, Claude!
1 parent 3e95b26 commit 85f7df2

11 files changed

Lines changed: 67 additions & 1 deletion

src/main/java/com/scalepoint/oauth_token_client/CertificateWithPrivateKey.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ public CertificateWithPrivateKey(PrivateKey privateKey, X509Certificate certific
2828
}
2929

3030
/**
31+
* Gets the X.509 certificate.
32+
*
3133
* @return Certificate
3234
*/
3335
public X509Certificate getCertificate() {
3436
return certificate;
3537
}
3638

3739
/**
40+
* Gets the private key associated with the certificate.
41+
*
3842
* @return Private key
3943
*/
4044
public PrivateKey getPrivateKey() {

src/main/java/com/scalepoint/oauth_token_client/ClientCredentialsGrantTokenClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public ClientCredentialsGrantTokenClient(String tokenEndpointUri, ClientCredenti
3838
* @param scopes OAuth2 scopes to request
3939
* @return Access token
4040
* @throws IOException Exception during token endpoint communication
41+
* @throws InterruptedException if the thread is interrupted during token retrieval
4142
*/
4243
@SuppressWarnings("UnusedReturnValue")
4344
public String getToken(final String... scopes) throws IOException, InterruptedException {

src/main/java/com/scalepoint/oauth_token_client/CustomGrantTokenClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@
44
import java.util.ArrayList;
55
import java.util.List;
66

7+
/**
8+
* Abstract base class for OAuth2 custom grant token clients.
9+
* Provides common functionality for obtaining access tokens using custom grant types.
10+
*/
711
public abstract class CustomGrantTokenClient {
812
private final ClientCredentials clientCredentials;
913
private final TokenEndpointHttpClient tokenEndpointHttpClient;
1014
private final String partialCacheKey;
1115
private final TokenCache cache;
1216

17+
/**
18+
* Constructs a custom grant token client.
19+
*
20+
* @param tokenEndpointUri URI of the OAuth2 token endpoint
21+
* @param clientCredentials client credentials for authentication
22+
* @param cache token cache for storing and retrieving tokens
23+
*/
1324
public CustomGrantTokenClient(String tokenEndpointUri, ClientCredentials clientCredentials, TokenCache cache) {
1425
this.tokenEndpointHttpClient = new TokenEndpointHttpClient(tokenEndpointUri);
1526
this.clientCredentials = clientCredentials;
@@ -24,6 +35,7 @@ public CustomGrantTokenClient(String tokenEndpointUri, ClientCredentials clientC
2435
* @param scopes OAuth2 scopes to request
2536
* @return Access token
2637
* @throws IOException Exception during token endpoint communication
38+
* @throws InterruptedException if the thread is interrupted during token retrieval
2739
*/
2840
protected String getTokenInternal(final List<NameValuePair> parameters, final String... scopes) throws IOException, InterruptedException {
2941

@@ -55,6 +67,8 @@ public ExpiringToken get() throws IOException, InterruptedException {
5567
}
5668

5769
/**
70+
* Gets the OAuth2 grant type for this client.
71+
*
5872
* @return Grant type (i.e. "client_credentials")
5973
*/
6074
protected abstract String getGrantType();

src/main/java/com/scalepoint/oauth_token_client/ExpiringToken.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ public class ExpiringToken {
1919
}
2020

2121
/**
22+
* Gets the access token string.
23+
*
2224
* @return Token
2325
*/
2426
public String getToken() {
2527
return token;
2628
}
2729

2830
/**
31+
* Gets the token expiration time in seconds.
32+
*
2933
* @return Expiration in seconds
3034
*/
3135
public int getExpiresInSeconds() {

src/main/java/com/scalepoint/oauth_token_client/InMemoryTokenCache.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
public class InMemoryTokenCache implements TokenCache {
1212
private final ConcurrentMap<String, CachedToken> cache = new ConcurrentHashMap<>();
1313

14+
/**
15+
* Constructs a new in-memory token cache.
16+
*/
17+
public InMemoryTokenCache() {
18+
// Default constructor
19+
}
20+
1421
/**
1522
* Wrapper class to store token with its expiration time
1623
*/

src/main/java/com/scalepoint/oauth_token_client/NameValuePair.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ public class NameValuePair {
99
final String value;
1010

1111
/**
12+
* Constructs a name-value pair.
13+
*
1214
* @param name Name
1315
* @param value Value
1416
*/

src/main/java/com/scalepoint/oauth_token_client/NoCache.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
*/
88
@SuppressWarnings("unused")
99
public class NoCache implements TokenCache {
10+
11+
/**
12+
* Constructs a new no-cache implementation.
13+
*/
14+
public NoCache() {
15+
// Default constructor
16+
}
17+
1018
/**
1119
* @param cacheKey Cache key
1220
* @param underlyingSource Underlying token source to invoke

src/main/java/com/scalepoint/oauth_token_client/ResourceScopedAccessGrantParameters.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,34 +35,47 @@ public ResourceScopedAccessGrantParameters(String scope, String resource, String
3535
}
3636

3737
/**
38+
* Gets the OAuth2 scope for the access request.
39+
*
3840
* @return OAuth2 scope
3941
*/
4042
public String getScope() {
4143
return scope;
4244
}
4345

4446
/**
47+
* Gets the specific resource identifier for the access request.
48+
*
4549
* @return Specific resource identifier
4650
*/
4751
public String getResource() {
4852
return resource;
4953
}
5054

5155
/**
56+
* Gets the resource tenant identifier.
57+
*
5258
* @return Resource tenant identifier
5359
*/
5460
public String getTenantId() {
5561
return tenantId;
5662
}
5763

5864
/**
65+
* Gets the original authentication method references.
66+
*
5967
* @return Original authentication method references
6068
*/
6169
@SuppressWarnings("unused")
6270
public String[] getAmr() {
6371
return amr;
6472
}
6573

74+
/**
75+
* Gets the authentication method references as a space-separated string.
76+
*
77+
* @return AMR values as a space-separated string, or null if no AMR values are set
78+
*/
6679
protected String getAmrString() {
6780
return (amr == null || amr.length < 1)
6881
? null

src/main/java/com/scalepoint/oauth_token_client/ResourceScopedAccessGrantTokenClient.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
@SuppressWarnings("WeakerAccess")
1111
public class ResourceScopedAccessGrantTokenClient extends CustomGrantTokenClient {
1212

13+
/**
14+
* Constructs a resource-scoped access grant token client.
15+
*
16+
* @param tokenEndpointUri URI of the OAuth2 token endpoint
17+
* @param clientCredentials client credentials for authentication
18+
*/
1319
@SuppressWarnings("SameParameterValue")
1420
public ResourceScopedAccessGrantTokenClient(String tokenEndpointUri, ClientCredentials clientCredentials) {
1521
super(tokenEndpointUri, clientCredentials, new NoCache());
@@ -21,6 +27,7 @@ public ResourceScopedAccessGrantTokenClient(String tokenEndpointUri, ClientCrede
2127
* @param parameters Custom grant parameters
2228
* @return Access token
2329
* @throws IOException Exception during token endpoint communication
30+
* @throws InterruptedException if the thread is interrupted during token retrieval
2431
*/
2532
@SuppressWarnings("UnusedReturnValue")
2633
public String getToken(ResourceScopedAccessGrantParameters parameters) throws IOException, InterruptedException {

src/main/java/com/scalepoint/oauth_token_client/TokenCache.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
*/
88
public interface TokenCache {
99
/**
10+
* Gets a token from the cache or retrieves it from the underlying source if not cached.
11+
*
1012
* @param cacheKey Cache key
1113
* @param underlyingSource Underlying token source to invoke on cache miss
1214
* @return Token from either cache or underlying source
1315
* @throws IOException Exception from underlying cache
16+
* @throws InterruptedException if the thread is interrupted during token retrieval
1417
*/
1518
String get(String cacheKey, TokenSource underlyingSource) throws IOException, InterruptedException;
1619
}

0 commit comments

Comments
 (0)