Skip to content

Commit 55d7110

Browse files
committed
Add javadoc comments to some classes
1 parent d52cb40 commit 55d7110

8 files changed

Lines changed: 261 additions & 15 deletions

webauthn4j-core/src/main/java/com/webauthn4j/converter/AttestedCredentialDataConverter.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333
import java.nio.ByteBuffer;
3434
import java.util.Arrays;
3535

36+
/**
37+
* A converter class that handles conversion operations for WebAuthn Attested Credential Data.
38+
* This class provides functionality to convert between AttestedCredentialData objects and their byte array
39+
* representations, as well as extracting credential IDs from attested credential data.
40+
*
41+
* The class uses CBOR (Concise Binary Object Representation) for data serialization and
42+
* handles the WebAuthn attestation data format which includes AAGUID, credential ID,
43+
* and credential public key.
44+
*
45+
* @see AttestedCredentialData
46+
* @see COSEKey
47+
* @see CborConverter
48+
*/
3649
public class AttestedCredentialDataConverter {
3750

3851
private static final String ATTESTED_CREDENTIAL_DATA_MUST_NOT_BE_NULL = "attestedCredentialData must not be null";
@@ -46,6 +59,12 @@ public class AttestedCredentialDataConverter {
4659

4760
private final CborConverter cborConverter;
4861

62+
/**
63+
* Constructor for AttestedCredentialDataConverter
64+
*
65+
* @param objectConverter the object converter to use for CBOR serialization/deserialization
66+
* @throws IllegalArgumentException if objectConverter is null
67+
*/
4968
public AttestedCredentialDataConverter(@NotNull ObjectConverter objectConverter) {
5069
AssertUtil.notNull(objectConverter, "objectConverter must not be null");
5170
this.cborConverter = objectConverter.getCborConverter();
@@ -59,6 +78,12 @@ private static void assertCoseKey(@Nullable COSEKey coseKey) {
5978
AssertUtil.notNull(coseKey, "coseKey must not be null");
6079
}
6180

81+
/**
82+
* Converts an AttestedCredentialData object to its byte array representation.
83+
*
84+
* @param attestationData the AttestedCredentialData to convert
85+
* @return byte array representation of the attestation data
86+
*/
6287
public @NotNull byte[] convert(@NotNull AttestedCredentialData attestationData) {
6388
try {
6489
AssertUtil.notNull(attestationData, "attestationData must not be null");
@@ -79,6 +104,12 @@ private static void assertCoseKey(@Nullable COSEKey coseKey) {
79104
}
80105
}
81106

107+
/**
108+
* Converts a ByteBuffer containing attested credential data to an AttestedCredentialData object.
109+
*
110+
* @param attestedCredentialData ByteBuffer containing the credential data
111+
* @return converted AttestedCredentialData object
112+
*/
82113
public @NotNull AttestedCredentialData convert(@NotNull ByteBuffer attestedCredentialData) {
83114
try {
84115
AssertUtil.notNull(attestedCredentialData, ATTESTED_CREDENTIAL_DATA_MUST_NOT_BE_NULL);
@@ -105,6 +136,12 @@ private static void assertCoseKey(@Nullable COSEKey coseKey) {
105136
}
106137
}
107138

139+
/**
140+
* Converts a byte array containing attested credential data to an AttestedCredentialData object.
141+
*
142+
* @param attestedCredentialData byte array containing the credential data
143+
* @return converted AttestedCredentialData object
144+
*/
108145
public @NotNull AttestedCredentialData convert(@NotNull byte[] attestedCredentialData) {
109146
try {
110147
AssertUtil.notNull(attestedCredentialData, ATTESTED_CREDENTIAL_DATA_MUST_NOT_BE_NULL);

webauthn4j-core/src/main/java/com/webauthn4j/converter/AuthenticationExtensionsClientInputsConverter.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
/**
3030
* Converter for {@link AuthenticationExtensionsClientInputs}
31+
*
32+
* This class provides functionality to convert between AuthenticationExtensionsClientInputs objects and their JSON string
33+
* representation for WebAuthn extensions processing.
3134
*/
3235
public class AuthenticationExtensionsClientInputsConverter {
3336

@@ -38,6 +41,12 @@ public class AuthenticationExtensionsClientInputsConverter {
3841
// ~ Constructors
3942
// ================================================================================================
4043

44+
/**
45+
* Creates a new AuthenticationExtensionsClientInputsConverter instance.
46+
*
47+
* @param objectConverter converter for data serialization
48+
* @throws IllegalArgumentException if objectConverter is null
49+
*/
4150
public AuthenticationExtensionsClientInputsConverter(@NotNull ObjectConverter objectConverter) {
4251
AssertUtil.notNull(objectConverter, "objectConverter must not be null");
4352
this.jsonConverter = objectConverter.getJsonConverter();
@@ -46,6 +55,14 @@ public AuthenticationExtensionsClientInputsConverter(@NotNull ObjectConverter ob
4655
// ~ Methods
4756
// ================================================================================================
4857

58+
/**
59+
* Converts a JSON string to an AuthenticationExtensionsClientInputs object.
60+
*
61+
* @param value JSON string representation of authentication extensions client inputs
62+
* @param <T> the type of extension client input
63+
* @return the converted AuthenticationExtensionsClientInputs object
64+
* @throws DataConversionException if conversion fails
65+
*/
4966
public <T extends ExtensionClientInput> @Nullable AuthenticationExtensionsClientInputs<T> convert(@NotNull String value) {
5067
try {
5168
AssertUtil.notNull(value, "value must not be null");
@@ -57,6 +74,14 @@ public AuthenticationExtensionsClientInputsConverter(@NotNull ObjectConverter ob
5774
}
5875

5976

77+
/**
78+
* Converts an AuthenticationExtensionsClientInputs object to its JSON string representation.
79+
*
80+
* @param value the AuthenticationExtensionsClientInputs object to convert
81+
* @param <T> the type of extension client input
82+
* @return JSON string representation of the AuthenticationExtensionsClientInputs object
83+
* @throws DataConversionException if conversion fails
84+
*/
6085
public <T extends ExtensionClientInput> @NotNull String convertToString(@NotNull AuthenticationExtensionsClientInputs<T> value) {
6186
try {
6287
AssertUtil.notNull(value, "value must not be null");

webauthn4j-core/src/main/java/com/webauthn4j/converter/AuthenticationExtensionsClientOutputsConverter.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
/**
3030
* Converter for {@link AuthenticationExtensionsClientOutputs}
31+
*
32+
* This class provides functionality to convert between AuthenticationExtensionsClientOutputs objects and their JSON string
33+
* representation for WebAuthn extensions processing.
3134
*/
3235
public class AuthenticationExtensionsClientOutputsConverter {
3336

@@ -38,6 +41,12 @@ public class AuthenticationExtensionsClientOutputsConverter {
3841
// ~ Constructors
3942
// ================================================================================================
4043

44+
/**
45+
* Creates a new AuthenticationExtensionsClientOutputsConverter instance.
46+
*
47+
* @param objectConverter converter for data serialization
48+
* @throws IllegalArgumentException if objectConverter is null
49+
*/
4150
public AuthenticationExtensionsClientOutputsConverter(@NotNull ObjectConverter objectConverter) {
4251
AssertUtil.notNull(objectConverter, "objectConverter must not be null");
4352
this.jsonConverter = objectConverter.getJsonConverter();
@@ -46,6 +55,14 @@ public AuthenticationExtensionsClientOutputsConverter(@NotNull ObjectConverter o
4655
// ~ Methods
4756
// ================================================================================================
4857

58+
/**
59+
* Converts a JSON string to an AuthenticationExtensionsClientOutputs object.
60+
*
61+
* @param value JSON string representation of authentication extensions client outputs
62+
* @param <T> the type of extension client output
63+
* @return the converted AuthenticationExtensionsClientOutputs object
64+
* @throws DataConversionException if conversion fails
65+
*/
4966
public <T extends ExtensionClientOutput> @Nullable AuthenticationExtensionsClientOutputs<T> convert(@NotNull String value) {
5067
try {
5168
AssertUtil.notNull(value, "value must not be null");
@@ -56,6 +73,14 @@ public AuthenticationExtensionsClientOutputsConverter(@NotNull ObjectConverter o
5673
}
5774
}
5875

76+
/**
77+
* Converts an AuthenticationExtensionsClientOutputs object to its JSON string representation.
78+
*
79+
* @param value the AuthenticationExtensionsClientOutputs object to convert
80+
* @param <T> the type of extension client output
81+
* @return JSON string representation of the AuthenticationExtensionsClientOutputs object
82+
* @throws DataConversionException if conversion fails
83+
*/
5984
public <T extends ExtensionClientOutput> @NotNull String convertToString(@NotNull AuthenticationExtensionsClientOutputs<T> value) {
6085
try {
6186
AssertUtil.notNull(value, "value must not be null");

webauthn4j-core/src/main/java/com/webauthn4j/converter/AuthenticatorDataConverter.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242

4343
/**
4444
* Converter for {@link AuthenticatorData}
45+
*
46+
* This class provides functionality to convert between AuthenticatorData objects and their binary representation
47+
* for WebAuthn processing.
4548
*/
4649
public class AuthenticatorDataConverter {
4750

@@ -65,6 +68,12 @@ public class AuthenticatorDataConverter {
6568
//~ Constructors
6669
// ================================================================================================
6770

71+
/**
72+
* Creates a new AuthenticatorDataConverter instance.
73+
*
74+
* @param objectConverter converter for data serialization
75+
* @throws IllegalArgumentException if objectConverter is null
76+
*/
6877
public AuthenticatorDataConverter(@NotNull ObjectConverter objectConverter) {
6978
AssertUtil.notNull(objectConverter, "objectConverter must not be null");
7079
this.cborConverter = objectConverter.getCborConverter();
@@ -78,8 +87,10 @@ public AuthenticatorDataConverter(@NotNull ObjectConverter objectConverter) {
7887
* Converts from a {@link AuthenticatorData} to byte[].
7988
*
8089
* @param source the source object to convert
81-
* @param <T> extension type
90+
* @param <T> the type of extension authenticator output
8291
* @return the converted byte array
92+
* @throws DataConversionException if conversion fails
93+
* @throws UncheckedIOException if an I/O error occurs
8394
*/
8495
public <T extends ExtensionAuthenticatorOutput> @NotNull byte[] convert(@NotNull AuthenticatorData<T> source) {
8596
try {
@@ -103,9 +114,10 @@ public AuthenticatorDataConverter(@NotNull ObjectConverter objectConverter) {
103114
/**
104115
* Converts from a byte array to {@link AuthenticatorData}.
105116
*
106-
* @param <T> ExtensionAuthenticatorOutput
117+
* @param <T> the type of extension authenticator output
107118
* @param source the source byte array to convert
108119
* @return the converted object
120+
* @throws DataConversionException if conversion fails
109121
*/
110122
public <T extends ExtensionAuthenticatorOutput> @NotNull AuthenticatorData<T> convert(@NotNull byte[] source) {
111123
try {
@@ -149,10 +161,11 @@ public AuthenticatorDataConverter(@NotNull ObjectConverter objectConverter) {
149161
}
150162

151163
/**
152-
* Extract attestedCredData byte array from a authenticatorData byte array.
164+
* Extract attestedCredentialData byte array from an authenticatorData byte array.
153165
*
154166
* @param authenticatorData the authenticatorData byte array
155-
* @return the extracted attestedCredData byte array
167+
* @return the extracted attestedCredentialData byte array
168+
* @throws IllegalArgumentException if the input format is invalid
156169
*/
157170
public @NotNull byte[] extractAttestedCredentialData(@NotNull byte[] authenticatorData) {
158171
byte[] lengthBytes = Arrays.copyOfRange(authenticatorData, L_INDEX, CREDENTIAL_ID_INDEX);
@@ -168,7 +181,7 @@ public AuthenticatorDataConverter(@NotNull ObjectConverter objectConverter) {
168181
}
169182

170183
/**
171-
* Extract signCount from a authenticatorData byte array.
184+
* Extract signCount from an authenticatorData byte array.
172185
*
173186
* @param authenticatorData the authenticatorData byte array
174187
* @return the extracted signCount

webauthn4j-core/src/main/java/com/webauthn4j/converter/AuthenticatorTransportConverter.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,21 @@
2424
import java.util.Set;
2525
import java.util.stream.Collectors;
2626

27+
/**
28+
* Converter for {@link AuthenticatorTransport}
29+
*
30+
* This class provides functionality to convert between AuthenticatorTransport objects and their string
31+
* representation for WebAuthn processing.
32+
*/
2733
public class AuthenticatorTransportConverter {
2834

35+
/**
36+
* Converts a string to an AuthenticatorTransport object.
37+
*
38+
* @param value the string representation of authenticator transport
39+
* @return the converted AuthenticatorTransport object
40+
* @throws DataConversionException if conversion fails
41+
*/
2942
public @NotNull AuthenticatorTransport convert(@NotNull String value) {
3043
try {
3144
AssertUtil.notNull(value, "value must not be null");
@@ -35,6 +48,13 @@ public class AuthenticatorTransportConverter {
3548
}
3649
}
3750

51+
/**
52+
* Converts a set of strings to a set of AuthenticatorTransport objects.
53+
*
54+
* @param values the set of string representations of authenticator transports
55+
* @return the set of converted AuthenticatorTransport objects
56+
* @throws DataConversionException if conversion fails
57+
*/
3858
@SuppressWarnings("squid:S1168")
3959
public @NotNull Set<AuthenticatorTransport> convertSet(@NotNull Set<String> values) {
4060
try {
@@ -45,6 +65,13 @@ public class AuthenticatorTransportConverter {
4565
}
4666
}
4767

68+
/**
69+
* Converts an AuthenticatorTransport object to its string representation.
70+
*
71+
* @param value the AuthenticatorTransport object to convert
72+
* @return string representation of the AuthenticatorTransport object
73+
* @throws DataConversionException if conversion fails
74+
*/
4875
public @NotNull String convertToString(@NotNull AuthenticatorTransport value) {
4976
try {
5077
AssertUtil.notNull(value, "value must not be null");
@@ -54,6 +81,13 @@ public class AuthenticatorTransportConverter {
5481
}
5582
}
5683

84+
/**
85+
* Converts a set of AuthenticatorTransport objects to a set of strings.
86+
*
87+
* @param values the set of AuthenticatorTransport objects to convert
88+
* @return the set of string representations of the AuthenticatorTransport objects
89+
* @throws DataConversionException if conversion fails
90+
*/
5791
@SuppressWarnings("squid:S1168")
5892
public @NotNull Set<String> convertSetToStringSet(@NotNull Set<AuthenticatorTransport> values) {
5993
try {

webauthn4j-core/src/main/java/com/webauthn4j/credential/CoreCredentialRecord.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,54 @@
44
import org.jetbrains.annotations.Nullable;
55

66
/**
7-
* Core interface that represents FIDO CTAP2 credential record (Passkey credential record without ClientData)
7+
* Core interface that represents FIDO CTAP2 credential record (Passkey credential record without ClientData).
88
*/
99
public interface CoreCredentialRecord extends CoreAuthenticator {
1010

1111
/**
12+
* Gets the user verification (UV) initialization status of this credential.
1213
*
13-
* @return `true` if UV is initialized. `false` if UV is not initialized. `null` if no data is available(for backward compatibility).
14+
* @return `true` if user verification is initialized, `false` if user verification is not initialized,
15+
* `null` if no data is available (for backward compatibility).
1416
*/
1517
@Nullable Boolean isUvInitialized() ;
1618

1719

20+
/**
21+
* Sets the user verification (UV) initialization status of this credential.
22+
*
23+
* @param value `true` to set the credential as user verification initialized, `false` otherwise.
24+
*/
1825
void setUvInitialized(boolean value);
1926

2027
/**
28+
* Gets the backup eligibility status of this credential.
2129
*
22-
* @return `true` if it is backup eligible. `false` if it is NOT backup eligible. `null` if no data is available(for backward compatibility).
30+
* @return `true` if this credential is backup eligible, `false` if it is NOT backup eligible,
31+
* `null` if no data is available (for backward compatibility).
2332
*/
2433
@Nullable Boolean isBackupEligible();
2534

35+
/**
36+
* Sets the backup eligibility status of this credential.
37+
*
38+
* @param value `true` to mark the credential as backup eligible, `false` otherwise.
39+
*/
2640
void setBackupEligible(boolean value);
2741

2842
/**
43+
* Gets the backup state of this credential.
2944
*
30-
* @return `true` if it is backed up. `false` if it is NOT backed up. `null` if no data is available(for backward compatibility).
45+
* @return `true` if this credential is backed up, `false` if it is NOT backed up,
46+
* `null` if no data is available (for backward compatibility).
3147
*/
3248
@Nullable Boolean isBackedUp();
3349

50+
/**
51+
* Sets the backup state of this credential.
52+
*
53+
* @param value `true` to mark the credential as backed up, `false` otherwise.
54+
*/
3455
void setBackedUp(boolean value);
3556

3657
}

0 commit comments

Comments
 (0)