Create request¶
To construct a request object, use the RequestBuilder
class. The RequestBuilder
class provides a
fluent API to build a request object.
The following example demonstrates how to create a request object, for offline transfer, using the
RequestBuilder
class, requesting all the elements of the mDL document type.
java snippet
try {
// org.iso.18013.5.1.mDL Request elements map
// docType -> nameSpace -> elementIdentifier -> intentToRetain
Map<String /* docType */, Map<String /* nameSpace */, Map<String /* elementIdentifier */, Boolean /* intentToRetain */>>> docRequests =
new HashMap<String /* docType */, Map<String /* nameSpace */, Map<String /* elementIdentifier */, Boolean /* intentToRetain */>>>() {{
put("org.iso.18013.5.1.mDL", new HashMap<String /* nameSpace */, Map<String /* elementIdentifier */, Boolean /* intentToRetain */>>() {{
put("org.iso.18013.5.1", new HashMap<String /* elementIdentifier */, Boolean /* intentToRetain */>() {{
put("family_name", true);
put("given_name", true);
put("birth_date", true);
put("issue_date", true);
put("expiry_date", true);
put("issuing_country", true);
put("issuing_authority", true);
put("document_number", true);
put("driving_privileges", true);
put("portrait", true);
put("administrative_number", true);
put("un_distinguishing_sign", true);
put("sex", true);
put("height", true);
put("weight", true);
put("eye_colour", true);
put("hair_colour", true);
put("birth_place", true);
put("resident_address", true);
put("portrait_capture_date", true);
put("age_in_years", true);
put("age_birth_year", true);
put("issuing_jurisdiction", true);
put("nationality", true);
put("resident_city", true);
put("resident_state", true);
put("resident_country", true);
put("resident_postal_code", true);
put("biometric_template_face", true);
put("biometric_template_signature_sign", true);
put("given_name_national_character", true);
put("family_name_national_character", true);
put("signature_usual_mark", true);
put("age_over_18", true);
put("age_over_21", true);
}});
put("org.aamva.us", new HashMap<String /* elementIdentifier */, Boolean /* intentToRetain */>() {{
put("real_id", true);
put("RealID", true);
put("donor", true);
put("veteran", true);
put("weight", true);
put("height", true);
put("restrictions", true);
put("endorsements", true);
put("name_suffix", true);
}});
put("org.iso.18013.5.1.aamva", new HashMap<String /* elementIdentifier */, Boolean /* intentToRetain */>() {{
put("DHS_compliance", true);
put("DHS_temporary_lawful_status", true);
put("EDL_credential", true);
}});
}});
}};
// SessionManager instance created with DeviceEngagement
SessionManager sessionManager = ...;
// Request instance creation with RequestBuilder class
// Requires docRequests map and sessionManager instance
Request request = new RequestBuilder()
.setDocRequests(docRequests)
.setSessionManager(sessionManager)
.build();
// Send request using Transfer instance
BLETransfer bleTransfer = ...; // BLETransfer instance or any other Transfer instance
bleTransfer.send(request);
} catch(Exception e) {
e.printStackTrace();
}