Skip to content

Commit

Permalink
NA: Align terminology from receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
irotech committed Mar 14, 2024
1 parent f26ddde commit 7263b4b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ public final class ActivityDetails {

private final String rememberMeId;
private final String parentRememberMeId;
private final ApplicationProfile applicationProfile;
private final HumanProfile userProfile;
private final ApplicationProfile thisPartyProfile;
private final HumanProfile otherPartyProfile;
private final Date timestamp;
private final String receiptId;
private final ExtraData extraData;

public ActivityDetails(String rememberMeId,
String parentRememberMeId,
HumanProfile userProfile,
ApplicationProfile applicationProfile,
HumanProfile otherPartyProfile,
ApplicationProfile thisPartyProfile,
ExtraData extraData,
Date timestamp,
byte[] receiptId) {
this.rememberMeId = rememberMeId;
this.parentRememberMeId = parentRememberMeId;
this.userProfile = notNull(userProfile, "User profile");
this.applicationProfile = notNull(applicationProfile, "Application profile");
this.otherPartyProfile = notNull(otherPartyProfile, "User profile");
this.thisPartyProfile = notNull(thisPartyProfile, "Application profile");
this.timestamp = notNull(timestamp, "Timestamp");
this.receiptId = toBase64String(notNull(receiptId, "Receipt id"));
this.extraData = extraData;
Expand All @@ -41,7 +41,7 @@ public ActivityDetails(String rememberMeId,
* @return profile containing attributes for the user
*/
public HumanProfile getUserProfile() {
return userProfile;
return otherPartyProfile;
}

/**
Expand All @@ -50,7 +50,7 @@ public HumanProfile getUserProfile() {
* @return profile containing attributes for the application
*/
public ApplicationProfile getApplicationProfile() {
return applicationProfile;
return thisPartyProfile;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import static com.yoti.api.client.spi.remote.call.YotiConstants.DEFAULT_CHARSET;
import static com.yoti.api.client.spi.remote.call.YotiConstants.RFC3339_PATTERN;
import static com.yoti.api.client.spi.remote.call.YotiConstants.SYMMETRIC_CIPHER;
import static com.yoti.api.client.spi.remote.util.Validation.notNull;
import static com.yoti.validation.Validation.notNull;

import java.io.UnsupportedEncodingException;
import java.security.Key;
Expand Down Expand Up @@ -53,19 +53,27 @@ public ActivityDetails create(Receipt receipt, PrivateKey privateKey) throws Pro
byte[] decryptedKey = DecryptionHelper.decryptAsymmetric(receipt.getWrappedReceiptKey(), privateKey);
Key secretKey = new SecretKeySpec(decryptedKey, SYMMETRIC_CIPHER);

List<Attribute<?>> userProfileAttr = attributeListReader.read(receipt.getOtherPartyProfile(), secretKey);
List<Attribute<?>> applicationProfileAttr = attributeListReader.read(receipt.getProfile(), secretKey);
List<Attribute<?>> otherPartyAttr = attributeListReader.read(receipt.getOtherPartyProfile(), secretKey);
List<Attribute<?>> thisPartyAttr = attributeListReader.read(receipt.getProfile(), secretKey);

HumanProfile userProfile = new HumanProfile(userProfileAttr);
ApplicationProfile applicationProfile = new ApplicationProfile(applicationProfileAttr);
HumanProfile otherPartyProfile = new HumanProfile(otherPartyAttr);
ApplicationProfile thisPartyProfile = new ApplicationProfile(thisPartyAttr);

ExtraData extraData = parseExtraData(receipt.getExtraData(), secretKey);

String rememberMeId = parseRememberMeId(receipt.getRememberMeId());
String parentRememberMeId = parseRememberMeId(receipt.getParentRememberMeId());
Date timestamp = parseTimestamp(receipt.getTimestamp());

return new ActivityDetails(rememberMeId, parentRememberMeId, userProfile, applicationProfile, extraData, timestamp, receipt.getReceiptId());
return new ActivityDetails(
rememberMeId,
parentRememberMeId,
otherPartyProfile,
thisPartyProfile,
extraData,
timestamp,
receipt.getReceiptId()
);
}

private ExtraData parseExtraData(byte[] extraDataBytes, Key secretKey) throws ProfileException {
Expand Down

0 comments on commit 7263b4b

Please sign in to comment.