Skip to content

Commit f7b2ecd

Browse files
Add preferred client mode (#44)
* add preferred client mode to PIResponse * add preferred client mode to test
1 parent 0e4217f commit f7b2ecd

4 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/privacyidea/JSONParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import static org.privacyidea.PIConstants.MESSAGES;
3131
import static org.privacyidea.PIConstants.MULTI_CHALLENGE;
3232
import static org.privacyidea.PIConstants.OTPLEN;
33+
import static org.privacyidea.PIConstants.PREFERRED_CLIENT_MODE;
3334
import static org.privacyidea.PIConstants.REALMS;
3435
import static org.privacyidea.PIConstants.RESULT;
3536
import static org.privacyidea.PIConstants.SERIAL;
@@ -182,6 +183,7 @@ public PIResponse parsePIResponse(String serverResponse)
182183
if (detailElem != null && !detailElem.isJsonNull())
183184
{
184185
JsonObject detail = obj.getAsJsonObject(DETAIL);
186+
response.preferredClientMode = getString(detail, PREFERRED_CLIENT_MODE);
185187
response.message = getString(detail, MESSAGE);
186188
response.serial = getString(detail, SERIAL);
187189
response.transactionID = getString(detail, TRANSACTION_ID);

src/main/java/org/privacyidea/PIConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ private PIConstants()
6262
public static final String VALUE = "value";
6363
public static final String TOKENS = "tokens";
6464
public static final String TOKEN = "token";
65+
public static final String PREFERRED_CLIENT_MODE = "preferred_client_mode";
6566
public static final String MESSAGE = "message";
6667
public static final String MESSAGES = "messages";
6768
public static final String MULTI_CHALLENGE = "multi_challenge";

src/main/java/org/privacyidea/PIResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
public class PIResponse
3333
{
3434
public String message = "";
35+
public String preferredClientMode = "";
3536
public List<String> messages = new ArrayList<>();
3637
public List<Challenge> multichallenge = new ArrayList<>();
3738
public String transactionID = "";

src/test/java/org/privacyidea/TestWebAuthn.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public void testTriggerWebAuthn()
103103
" \"userVerification\": \"preferred\"\n" + " }\n";
104104

105105
String responseBody =
106-
"{\n" + " \"detail\": {\n" + " \"attributes\": {\n" + " \"hideResponseInput\": true,\n" +
106+
"{\n" + " \"detail\": {\n" + " \"preferred_client_mode\": \"webauthn\",\n" + " \"attributes\": {\n" + " \"hideResponseInput\": true,\n" +
107107
" \"img\": \"static/img/FIDO-U2F-Security-Key-444x444.png\",\n" +
108108
" \"webAuthnSignRequest\": {\n" + " \"allowCredentials\": [\n" + " {\n" +
109109
" \"id\": \"83De8z_CNqogB6aCyKs6dWIqwpOpzVoNaJ74lgcpuYN7l-95QsD3z-qqPADqsFlPwBXCMqEPssq75kqHCMQHDA\",\n" +
@@ -142,6 +142,7 @@ public void testTriggerWebAuthn()
142142
.findFirst();
143143
assertTrue(opt.isPresent());
144144
assertEquals(AuthenticationStatus.CHALLENGE, response.authentication);
145+
assertEquals("webauthn", response.preferredClientMode);
145146
Challenge a = opt.get();
146147
if (a instanceof WebAuthn)
147148
{

0 commit comments

Comments
 (0)