@@ -822,9 +822,11 @@ public void NoOPEncryption1ServerTests_SignWithValidAlg_EncryptWithES512_DoNotDe
822
822
public void NoOPEncryption1ServerTests_consumeTokenThatWasEncryptedUsingOtherContentEncryptionAlg () throws Exception {
823
823
824
824
String rpEncryptAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
825
+ String keyManagementAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? JwtConstants .KEY_MGMT_KEY_ALG_ES : JwtConstants .DEFAULT_KEY_MGMT_KEY_ALG ;
825
826
826
827
List <NameValuePair > parms = new ArrayList <NameValuePair >();
827
828
parms .add (new NameValuePair (JwtConstants .PARAM_CONTENT_ENCRYPT_ALG , JwtConstants .CONTENT_ENCRYPT_ALG_192 ));
829
+ parms .add (new NameValuePair (JwtConstants .PARAM_KEY_MGMT_ALG , keyManagementAlg ));
828
830
parms .add (new NameValuePair (JwtConstants .PARAM_ENCRYPT_KEY , JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), rpEncryptAlg )));
829
831
830
832
genericEncryptTest (rpEncryptAlg , rpEncryptAlg , parms );
@@ -855,14 +857,14 @@ public void NoOPEncryption1ServerTests_consumeTokenThatWasEncryptedUsingOtherKey
855
857
@ Test
856
858
public void NoOPEncryption1ServerTests_JWETypeNotJose () throws Exception {
857
859
858
- String encryptAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
860
+ String sigAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
859
861
String keyManagementAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? JwtConstants .KEY_MGMT_KEY_ALG_ES : JwtConstants .DEFAULT_KEY_MGMT_KEY_ALG ;
860
862
861
863
// We're going to use a test JWT token builder to create a token that has "notJOSE" in the JWE header type field
862
864
// the Liberty builder won't allow us to update that field, so, we need to peice a token together
863
- JWTTokenBuilder builder = tokenBuilderHelpers .populateAlternateJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), encryptAlg )), keyManagementAlg );
865
+ JWTTokenBuilder builder = tokenBuilderHelpers .populateAlternateJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), sigAlg )), keyManagementAlg );
864
866
builder .setIssuer ("client01" );
865
- builder .setAlorithmHeaderValue (encryptAlg );
867
+ builder .setAlorithmHeaderValue (sigAlg );
866
868
if (testOPServer .getServer ().isFIPS140_3EnabledAndSupported ()){
867
869
builder .setECKey (testOPServer .getServer ().getServerRoot () + "/ES256private-key-pkcs#8.pem" );
868
870
} else {
@@ -872,22 +874,22 @@ public void NoOPEncryption1ServerTests_JWETypeNotJose() throws Exception {
872
874
// calling buildJWE will override the header contents
873
875
String jwtToken = builder .buildJWE ("notJOSE" , "jwt" );
874
876
875
- TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (encryptAlg ));
877
+ TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (sigAlg ));
876
878
positiveTest (updatedTestSettings , jwtToken );
877
879
878
880
}
879
881
880
882
@ Test
881
883
public void NoOPEncryption1ServerTests_JWEContentTypeNotJwt () throws Exception {
882
884
883
- String encryptAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
885
+ String sigAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
884
886
String keyManagementAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? JwtConstants .KEY_MGMT_KEY_ALG_ES : JwtConstants .DEFAULT_KEY_MGMT_KEY_ALG ;
885
887
886
888
// We're going to use a test JWT token builder to create a token that has "not_jwt" in the JWE header content type field
887
889
// the Liberty builder won't allow us to update that field, so, we need to peice a token together
888
- JWTTokenBuilder builder = tokenBuilderHelpers .populateAlternateJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), encryptAlg )), keyManagementAlg );
890
+ JWTTokenBuilder builder = tokenBuilderHelpers .populateAlternateJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), sigAlg )), keyManagementAlg );
889
891
builder .setIssuer ("client01" );
890
- builder .setAlorithmHeaderValue (encryptAlg );
892
+ builder .setAlorithmHeaderValue (sigAlg );
891
893
if (testOPServer .getServer ().isFIPS140_3EnabledAndSupported ()){
892
894
builder .setECKey (testOPServer .getServer ().getServerRoot () + "/ES256private-key-pkcs#8.pem" );
893
895
} else {
@@ -897,7 +899,7 @@ public void NoOPEncryption1ServerTests_JWEContentTypeNotJwt() throws Exception {
897
899
// calling buildJWE will override the header contents
898
900
String jwtToken = builder .buildJWE ("JOSE" , "not_jwt" );
899
901
900
- TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (encryptAlg ));
902
+ TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (sigAlg ));
901
903
String [] msgs = new String [] { MessageConstants .CWWKS1737E_JWT_VALIDATION_FAILURE , MessageConstants .CWWKS6056E_ERROR_EXTRACTING_JWS_PAYLOAD_FROM_JWE , MessageConstants .CWWKS6057E_CTY_NOT_JWT_FOR_NESTED_JWS };
902
904
903
905
negativeTest (updatedTestSettings , jwtToken , msgs );
@@ -913,17 +915,17 @@ public void NoOPEncryption1ServerTests_JWEContentTypeNotJwt() throws Exception {
913
915
@ Test
914
916
public void NoOPEncryption1ServerTests_simpleJsonPayload () throws Exception {
915
917
916
- String encryptAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
918
+ String sigAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? Constants .SIGALG_ES256 : Constants .SIGALG_RS256 ;
917
919
String keyManagementAlg = testOPServer .getServer ().isFIPS140_3EnabledAndSupported () ? JwtConstants .KEY_MGMT_KEY_ALG_ES : JwtConstants .DEFAULT_KEY_MGMT_KEY_ALG ;
918
920
919
921
List <NameValuePair > extraparms = new ArrayList <NameValuePair >();
920
922
extraparms .add (new NameValuePair ("token_src" , "alternate JWE builder" ));
921
923
extraparms .add (new NameValuePair (JwtConstants .PARAM_KEY_MGMT_ALG , JwtConstants .KEY_MGMT_KEY_ALG_ES ));
922
924
923
925
// build a jwt token whose payload contains only json data - make sure that we do not allow this format (it's not supported at this time)
924
- String jwtToken = tokenBuilderHelpers .buildAlternatePayloadJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), encryptAlg )), keyManagementAlg , extraparms );
926
+ String jwtToken = tokenBuilderHelpers .buildAlternatePayloadJWEToken (JwtKeyTools .getPublicKeyFromPem (JwtKeyTools .getComplexPublicKeyForSigAlg (testOPServer .getServer (), sigAlg )), keyManagementAlg , extraparms );
925
927
926
- TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (encryptAlg ));
928
+ TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (sigAlg ));
927
929
String [] msgs = new String [] { MessageConstants .CWWKS1737E_JWT_VALIDATION_FAILURE , MessageConstants .CWWKS6065E_NESTED_JWS_REQUIRED_BUT_NOT_FOUND };
928
930
929
931
negativeTest (updatedTestSettings , jwtToken , msgs );
@@ -1048,14 +1050,21 @@ public void NoOPEncryption1ServerTests_RStrustStoreRefOmitted_ECDH_ES() throws E
1048
1050
1049
1051
}
1050
1052
1053
+ /**
1054
+ * RSA-OAEP JWE Structure Validation Tests
1055
+ * Validates the Social Client's ability to properly validate the structure of JWE
1056
+ * (JSON Web Encryption) that use RSA-OAEP as the key management algorithm.
1057
+ * The tests validates each aspect of the 5 part JWE structure (JOSE Header, Encrypted Key, IV, Ciphertext, Auth tag)
1058
+ */
1059
+
1051
1060
/**
1052
1061
* Test that the RS detects that the JWE is invalid as it has too many parts (6) (one of which is completely invalid)
1053
1062
*
1054
1063
* @throws Exception
1055
1064
*/
1056
1065
@ Test
1057
1066
@ SkipJavaSemeruWithFipsEnabledRule
1058
- public void OidcClientEncryptionTests_JWETooManyParts_RSA_OAEP () throws Exception {
1067
+ public void OidcClientEncryptionTests_JWETooManyParts_encryption_RSA_OAEP () throws Exception {
1059
1068
1060
1069
String jwtToken = createTokenWithSubject ("SignRS256EncryptRS256Builder" ) + "." + badTokenSegment ;
1061
1070
@@ -1073,7 +1082,7 @@ public void OidcClientEncryptionTests_JWETooManyParts_RSA_OAEP() throws Exceptio
1073
1082
*/
1074
1083
@ Test
1075
1084
@ SkipJavaSemeruWithFipsEnabledRule
1076
- public void OidcClientEncryptionTests_JWETooFewParts_RSA_OAEP () throws Exception {
1085
+ public void OidcClientEncryptionTests_JWETooFewParts_encryption_RSA_OAEP () throws Exception {
1077
1086
1078
1087
String jwtToken = createTokenWithSubject ("SignRS256EncryptRS256Builder" );
1079
1088
String badJweToken = jwtToken .substring (0 , jwtToken .lastIndexOf ("." ) - 1 );
@@ -1092,7 +1101,7 @@ public void OidcClientEncryptionTests_JWETooFewParts_RSA_OAEP() throws Exception
1092
1101
*/
1093
1102
@ Test
1094
1103
@ SkipJavaSemeruWithFipsEnabledRule
1095
- public void OidcClientEncryptionTests_JWE_Part1_isInvalid_RSA_OAEP () throws Exception {
1104
+ public void OidcClientEncryptionTests_JWE_Part1_isInvalid_encryption_RSA_OAEP () throws Exception {
1096
1105
1097
1106
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_RS256 ));
1098
1107
@@ -1108,7 +1117,7 @@ public void OidcClientEncryptionTests_JWE_Part1_isInvalid_RSA_OAEP() throws Exce
1108
1117
*/
1109
1118
@ Test
1110
1119
@ SkipJavaSemeruWithFipsEnabledRule
1111
- public void OidcClientEncryptionTests_JWE_Part2_isInvalid_RSA_OAEP () throws Exception {
1120
+ public void OidcClientEncryptionTests_JWE_Part2_isInvalid_encryption_RSA_OAEP () throws Exception {
1112
1121
1113
1122
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_RS256 ));
1114
1123
@@ -1124,7 +1133,7 @@ public void OidcClientEncryptionTests_JWE_Part2_isInvalid_RSA_OAEP() throws Exce
1124
1133
*/
1125
1134
@ Test
1126
1135
@ SkipJavaSemeruWithFipsEnabledRule
1127
- public void OidcClientEncryptionTests_JWE_Par3_isInvalid_RSA_OAEP () throws Exception {
1136
+ public void OidcClientEncryptionTests_JWE_Par3_isInvalid_encryption_RSA_OAEP () throws Exception {
1128
1137
1129
1138
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_RS256 ));
1130
1139
@@ -1140,7 +1149,7 @@ public void OidcClientEncryptionTests_JWE_Par3_isInvalid_RSA_OAEP() throws Excep
1140
1149
*/
1141
1150
@ Test
1142
1151
@ SkipJavaSemeruWithFipsEnabledRule
1143
- public void OidcClientEncryptionTests_JWE_Part4_isInvalid_RSA_OAEP () throws Exception {
1152
+ public void OidcClientEncryptionTests_JWE_Part4_isInvalid_encryption_RSA_OAEP () throws Exception {
1144
1153
1145
1154
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_RS256 ));
1146
1155
@@ -1156,7 +1165,7 @@ public void OidcClientEncryptionTests_JWE_Part4_isInvalid_RSA_OAEP() throws Exce
1156
1165
*/
1157
1166
@ Test
1158
1167
@ SkipJavaSemeruWithFipsEnabledRule
1159
- public void OidcClientEncryptionTests_JWE_Part5_isInvalid_RSA_OAEP () throws Exception {
1168
+ public void OidcClientEncryptionTests_JWE_Part5_isInvalid_encryption_RSA_OAEP () throws Exception {
1160
1169
1161
1170
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_RS256 ));
1162
1171
@@ -1165,13 +1174,21 @@ public void OidcClientEncryptionTests_JWE_Part5_isInvalid_RSA_OAEP() throws Exce
1165
1174
1166
1175
}
1167
1176
1177
+ /**
1178
+ * ECDH-ES JWE Structure Validation Tests
1179
+ * Validates the Social Client's ability to properly validate the structure of JWE
1180
+ * (JSON Web Encryption) that use ECDH-ES as the key management algorithm.
1181
+ * Unlike the RSA-OAEP tests, there is no specific test for Part 2 (Encrypted Key) in the ECDH-ES
1182
+ * tests, as ECDH-ES uses direct key agreement (not requiring and effectively ignoring part 2 of the JWE).
1183
+ */
1184
+
1168
1185
/**
1169
1186
* Test that the RS detects that the JWE is invalid as it has too many parts (6) (one of which is completely invalid)
1170
1187
*
1171
1188
* @throws Exception
1172
1189
*/
1173
1190
@ Test
1174
- public void OidcClientEncryptionTests_JWETooManyParts_ECDH_ES () throws Exception {
1191
+ public void OidcClientEncryptionTests_JWETooManyParts_encryption_ECDH_ES () throws Exception {
1175
1192
1176
1193
String jwtToken = createTokenWithSubject ("SignES256EncryptES256Builder" ) + "." + badTokenSegment ;
1177
1194
@@ -1188,7 +1205,7 @@ public void OidcClientEncryptionTests_JWETooManyParts_ECDH_ES() throws Exception
1188
1205
* @throws Exception
1189
1206
*/
1190
1207
@ Test
1191
- public void OidcClientEncryptionTests_JWETooFewParts_ECDH_ES () throws Exception {
1208
+ public void OidcClientEncryptionTests_JWETooFewParts_encryption_ECDH_ES () throws Exception {
1192
1209
1193
1210
String jwtToken = createTokenWithSubject ("SignES256EncryptES256Builder" );
1194
1211
String badJweToken = jwtToken .substring (0 , jwtToken .lastIndexOf ("." ) - 1 );
@@ -1206,7 +1223,7 @@ public void OidcClientEncryptionTests_JWETooFewParts_ECDH_ES() throws Exception
1206
1223
* @throws Exception
1207
1224
*/
1208
1225
@ Test
1209
- public void OidcClientEncryptionTests_JWE_Part1_isInvalid_ECDH_ES () throws Exception {
1226
+ public void OidcClientEncryptionTests_JWE_Part1_isInvalid_encryption_ECDH_ES () throws Exception {
1210
1227
1211
1228
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_ES256 ));
1212
1229
@@ -1221,7 +1238,7 @@ public void OidcClientEncryptionTests_JWE_Part1_isInvalid_ECDH_ES() throws Excep
1221
1238
* @throws Exception
1222
1239
*/
1223
1240
@ Test
1224
- public void OidcClientEncryptionTests_JWE_Par3_isInvalid_ECDH_ES () throws Exception {
1241
+ public void OidcClientEncryptionTests_JWE_Par3_isInvalid_encryption_ECDH_ES () throws Exception {
1225
1242
1226
1243
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_ES256 ));
1227
1244
@@ -1236,7 +1253,7 @@ public void OidcClientEncryptionTests_JWE_Par3_isInvalid_ECDH_ES() throws Except
1236
1253
* @throws Exception
1237
1254
*/
1238
1255
@ Test
1239
- public void OidcClientEncryptionTests_JWE_Part4_isInvalid_ECDH_ES () throws Exception {
1256
+ public void OidcClientEncryptionTests_JWE_Part4_isInvalid_encryption_ECDH_ES () throws Exception {
1240
1257
1241
1258
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_ES256 ));
1242
1259
@@ -1251,7 +1268,7 @@ public void OidcClientEncryptionTests_JWE_Part4_isInvalid_ECDH_ES() throws Excep
1251
1268
* @throws Exception
1252
1269
*/
1253
1270
@ Test
1254
- public void OidcClientEncryptionTests_JWE_Part5_isInvalid_ECDH_ES () throws Exception {
1271
+ public void OidcClientEncryptionTests_JWE_Part5_isInvalid_encryption_ECDH_ES () throws Exception {
1255
1272
1256
1273
TestSettings updatedTestSettings = rsTools .updateRSProtectedResource (testSettings , setAppName (Constants .SIGALG_ES256 ));
1257
1274
0 commit comments