Skip to content

Commit e02f90d

Browse files
81 add enroll via mc optional (#82)
* Update JSONParser.java * Update PIResponse.java * Update PIConstants.java * Update PrivacyIDEA.java
1 parent acea2f1 commit e02f90d

4 files changed

Lines changed: 37 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ else if ("interactive".equals(modeFromResponse))
241241
response.transactionID = getString(detail, TRANSACTION_ID);
242242
response.type = getString(detail, TYPE);
243243
response.otpLength = getInt(detail, OTPLEN);
244+
response.isEnrollViaMultichallenge = getBoolean(detail, "enroll_via_multichallenge");
245+
response.isEnrollViaMultichallengeOptional = getBoolean(detail, "enroll_via_multichallenge_optional");
246+
// The enrollment link can be in the detail or in one of the
244247
JsonObject passkeyChallenge = detail.getAsJsonObject(PASSKEY);
245248
if (passkeyChallenge != null && !passkeyChallenge.isJsonNull())
246249
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class PIConstants
6868
public static final String CLIENT_MODE = "client_mode";
6969
public static final String IMAGE = "image";
7070
public static final String CLIENT_IP = "client";
71+
public static final String CANCEL_ENROLLMENT = "cancel_enrollment";
7172
public static final String MESSAGES = "messages";
7273
public static final String MULTI_CHALLENGE = "multi_challenge";
7374
public static final String ATTRIBUTES = "attributes";

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818

1919
import com.google.gson.Gson;
2020
import com.google.gson.GsonBuilder;
21-
import com.google.gson.JsonSyntaxException;
2221
import java.util.ArrayList;
2322
import java.util.List;
2423
import java.util.function.Predicate;
2524
import java.util.stream.Collectors;
2625

27-
import static org.privacyidea.PIConstants.*;
26+
import static org.privacyidea.PIConstants.TOKEN_TYPE_PUSH;
27+
import static org.privacyidea.PIConstants.TOKEN_TYPE_WEBAUTHN;
28+
2829

2930
/**
3031
* This class parses the JSON response of privacyIDEA into a POJO for easier access.
@@ -56,6 +57,9 @@ public class PIResponse
5657
public String passkeyRegistration = "";
5758
public String username = "";
5859
public String enrollmentLink = "";
60+
// Enroll via Multichallenge
61+
public boolean isEnrollViaMultichallenge = false;
62+
public boolean isEnrollViaMultichallengeOptional = false;
5963

6064
public String webAuthnSignRequest = "";
6165
public String webAuthnTransactionId = "";

src/main/java/org/privacyidea/PrivacyIDEA.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import static org.privacyidea.PIConstants.ENDPOINT_TOKEN_INIT;
4242
import static org.privacyidea.PIConstants.ENDPOINT_TRIGGERCHALLENGE;
4343
import static org.privacyidea.PIConstants.ENDPOINT_VALIDATE_CHECK;
44+
import static org.privacyidea.PIConstants.CANCEL_ENROLLMENT;
4445
import static org.privacyidea.PIConstants.ENDPOINT_VALIDATE_INITIALIZE;
4546
import static org.privacyidea.PIConstants.GENKEY;
4647
import static org.privacyidea.PIConstants.GET;
@@ -373,6 +374,32 @@ public ChallengeStatus pollTransaction(String transactionID)
373374
return piresponse.challengeStatus;
374375
}
375376

377+
/**
378+
* @see PrivacyIDEA#validateCheckCancelEnrollment(String, Map)
379+
*/
380+
public PIResponse validateCheckCancelEnrollment(String transactionID)
381+
{
382+
return this.validateCheckCancelEnrollment(transactionID, Collections.emptyMap());
383+
}
384+
385+
/**
386+
* Cancel enrollment via multichallenge.
387+
*
388+
* @param transactionID transaction ID
389+
* @param headers optional headers for the request
390+
* @return PIResponse or null if error
391+
*/
392+
public PIResponse validateCheckCancelEnrollment(String transactionID, Map<String, String> headers)
393+
{
394+
Map<String, String> params = new LinkedHashMap<>();
395+
params.put(TRANSACTION_ID, transactionID);
396+
params.put(CANCEL_ENROLLMENT, "true");
397+
appendRealm(params);
398+
399+
String response = runRequestAsync(ENDPOINT_VALIDATE_CHECK, params, headers, false, POST);
400+
return this.parser.parsePIResponse(response);
401+
}
402+
376403
/**
377404
* Get the service account parameters.
378405
*

0 commit comments

Comments
 (0)