Skip to content

Commit 87ae88e

Browse files
Merge pull request #79 from privacyidea/78/container_enroll_piresponse
consider container type in PIResponse
2 parents 5fe9744 + ff6650b commit 87ae88e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import static org.privacyidea.PIConstants.TOKEN_TYPE_PUSH;
2727
import static org.privacyidea.PIConstants.TOKEN_TYPE_WEBAUTHN;
28+
import static org.privacyidea.PIConstants.CONTAINER_TYPE_SMARTPHONE;
2829

2930

3031
/**
@@ -53,8 +54,8 @@ public class PIResponse
5354
public PIError error = null;
5455
// Passkey content is json string and can be passed to the browser as is
5556
public String passkeyChallenge = "";
56-
public String passkeyMessage = "";
5757
public String passkeyRegistration = "";
58+
public String passkeyMessage = "";
5859
public String username = "";
5960
public String enrollmentLink = "";
6061
// Enroll via Multichallenge
@@ -83,7 +84,11 @@ public boolean authenticationSuccessful()
8384
*/
8485
public boolean pushAvailable()
8586
{
86-
return multiChallenge.stream().anyMatch(c -> TOKEN_TYPE_PUSH.equals(c.getType()));
87+
return multiChallenge.stream().anyMatch(c -> isPushOrSmartphoneContainer(c.getType()));
88+
}
89+
90+
private boolean isPushOrSmartphoneContainer(String type) {
91+
return TOKEN_TYPE_PUSH.equals(type) || CONTAINER_TYPE_SMARTPHONE.equals(type);
8792
}
8893

8994
/**
@@ -93,14 +98,14 @@ public boolean pushAvailable()
9398
*/
9499
public String pushMessage()
95100
{
96-
return reduceChallengeMessagesWhere(c -> TOKEN_TYPE_PUSH.equals(c.getType()));
101+
return reduceChallengeMessagesWhere(c -> isPushOrSmartphoneContainer(c.getType()));
97102
}
98103

99104
public String otpTransactionId()
100105
{
101106
for (Challenge challenge : multiChallenge)
102107
{
103-
if (!TOKEN_TYPE_PUSH.equals(challenge.getType()) && !TOKEN_TYPE_WEBAUTHN.equals(challenge.getType()))
108+
if (!isPushOrSmartphoneContainer(challenge.getType()) && !TOKEN_TYPE_WEBAUTHN.equals(challenge.getType()))
104109
{
105110
return challenge.transactionID;
106111
}
@@ -111,7 +116,7 @@ public String otpTransactionId()
111116
public String pushTransactionId() {
112117
for (Challenge challenge : multiChallenge)
113118
{
114-
if (TOKEN_TYPE_PUSH.equals(challenge.getType()))
119+
if (isPushOrSmartphoneContainer(challenge.getType()))
115120
{
116121
return challenge.transactionID;
117122
}
@@ -126,7 +131,7 @@ public String pushTransactionId() {
126131
*/
127132
public String otpMessage()
128133
{
129-
return reduceChallengeMessagesWhere(c -> !(TOKEN_TYPE_PUSH.equals(c.getType())));
134+
return reduceChallengeMessagesWhere(c -> !(isPushOrSmartphoneContainer(c.getType())));
130135
}
131136

132137
private String reduceChallengeMessagesWhere(Predicate<Challenge> predicate)

0 commit comments

Comments
 (0)