Skip to content

Commit c348076

Browse files
committed
Update PIResponse.java
1 parent a933321 commit c348076

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

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

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ public class PIResponse
5353
public String passkeyChallenge = "";
5454
public String passkeyRegistration = "";
5555
public String username = "";
56+
57+
public boolean authenticationSuccessful()
58+
{
59+
if (authentication == AuthenticationStatus.ACCEPT)
60+
{
61+
return true;
62+
}
63+
else
64+
{
65+
return value && authentication != AuthenticationStatus.CHALLENGE;
66+
}
67+
}
68+
5669
/**
5770
* Check if a PUSH token was triggered.
5871
*
@@ -86,12 +99,8 @@ public String otpMessage()
8699
private String reduceChallengeMessagesWhere(Predicate<Challenge> predicate)
87100
{
88101
StringBuilder sb = new StringBuilder();
89-
sb.append(multiChallenge.stream()
90-
.filter(predicate)
91-
.map(Challenge::getMessage)
92-
.distinct()
93-
.reduce("", (a, s) -> a + s + ", ")
94-
.trim());
102+
sb.append(
103+
multiChallenge.stream().filter(predicate).map(Challenge::getMessage).distinct().reduce("", (a, s) -> a + s + ", ").trim());
95104

96105
if (sb.length() > 0)
97106
{
@@ -116,16 +125,13 @@ public List<String> triggeredTokenTypes()
116125
public List<WebAuthn> webAuthnSignRequests()
117126
{
118127
List<WebAuthn> ret = new ArrayList<>();
119-
multiChallenge.stream()
120-
.filter(c -> TOKEN_TYPE_WEBAUTHN.equals(c.getType()))
121-
.collect(Collectors.toList())
122-
.forEach(c ->
123-
{
124-
if (c instanceof WebAuthn)
125-
{
126-
ret.add((WebAuthn) c);
127-
}
128-
});
128+
multiChallenge.stream().filter(c -> TOKEN_TYPE_WEBAUTHN.equals(c.getType())).collect(Collectors.toList()).forEach(c ->
129+
{
130+
if (c instanceof WebAuthn)
131+
{
132+
ret.add((WebAuthn) c);
133+
}
134+
});
129135
return ret;
130136
}
131137

0 commit comments

Comments
 (0)