Skip to content

Commit 65f30bd

Browse files
committed
consider container type in PIResponse
1 parent acea2f1 commit 65f30bd

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ public class PIConstants
3737
public static final String HEADER_AUTHORIZATION = "Authorization";
3838
public static final String HEADER_USER_AGENT = "User-Agent";
3939

40-
// TOKEN TYPES
40+
// TOKEN TYPES / CONTAINER
4141
public static final String TOKEN_TYPE_PUSH = "push";
4242
public static final String TOKEN_TYPE_WEBAUTHN = "webauthn";
4343
public static final String TOKEN_TYPE_PASSKEY = "passkey";
44+
public static final String CONTAINER_TYPE_SMARTPHONE = "smartphone";
4445

4546
// JSON KEYS
4647
public static final String USERNAME = "username";

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import java.util.function.Predicate;
2525
import java.util.stream.Collectors;
2626

27-
import static org.privacyidea.PIConstants.*;
27+
import static org.privacyidea.PIConstants.CONTAINER_TYPE_SMARTPHONE;
28+
import static org.privacyidea.PIConstants.TOKEN_TYPE_PUSH;
29+
import static org.privacyidea.PIConstants.TOKEN_TYPE_WEBAUTHN;
2830

2931
/**
3032
* This class parses the JSON response of privacyIDEA into a POJO for easier access.
@@ -52,7 +54,6 @@ public class PIResponse
5254
public PIError error = null;
5355
// Passkey content is json string and can be passed to the browser as is
5456
public String passkeyChallenge = "";
55-
public String passkeyMessage = "";
5657
public String passkeyRegistration = "";
5758
public String username = "";
5859
public String enrollmentLink = "";
@@ -79,7 +80,11 @@ public boolean authenticationSuccessful()
7980
*/
8081
public boolean pushAvailable()
8182
{
82-
return multiChallenge.stream().anyMatch(c -> TOKEN_TYPE_PUSH.equals(c.getType()));
83+
return multiChallenge.stream().anyMatch(c -> isPushOrSmartphoneContainer(c.getType()));
84+
}
85+
86+
private boolean isPushOrSmartphoneContainer(String type) {
87+
return TOKEN_TYPE_PUSH.equals(type) || CONTAINER_TYPE_SMARTPHONE.equals(type);
8388
}
8489

8590
/**
@@ -89,14 +94,14 @@ public boolean pushAvailable()
8994
*/
9095
public String pushMessage()
9196
{
92-
return reduceChallengeMessagesWhere(c -> TOKEN_TYPE_PUSH.equals(c.getType()));
97+
return reduceChallengeMessagesWhere(c -> isPushOrSmartphoneContainer(c.getType()));
9398
}
9499

95100
public String otpTransactionId()
96101
{
97102
for (Challenge challenge : multiChallenge)
98103
{
99-
if (!TOKEN_TYPE_PUSH.equals(challenge.getType()) && !TOKEN_TYPE_WEBAUTHN.equals(challenge.getType()))
104+
if (!isPushOrSmartphoneContainer(challenge.getType()) && !TOKEN_TYPE_WEBAUTHN.equals(challenge.getType()))
100105
{
101106
return challenge.transactionID;
102107
}
@@ -107,7 +112,7 @@ public String otpTransactionId()
107112
public String pushTransactionId() {
108113
for (Challenge challenge : multiChallenge)
109114
{
110-
if (TOKEN_TYPE_PUSH.equals(challenge.getType()))
115+
if (isPushOrSmartphoneContainer(challenge.getType()))
111116
{
112117
return challenge.transactionID;
113118
}
@@ -122,7 +127,7 @@ public String pushTransactionId() {
122127
*/
123128
public String otpMessage()
124129
{
125-
return reduceChallengeMessagesWhere(c -> !(TOKEN_TYPE_PUSH.equals(c.getType())));
130+
return reduceChallengeMessagesWhere(c -> !(isPushOrSmartphoneContainer(c.getType())));
126131
}
127132

128133
private String reduceChallengeMessagesWhere(Predicate<Challenge> predicate)

0 commit comments

Comments
 (0)