Skip to content

Commit

Permalink
SDK-406: Review logging and use of toString()
Browse files Browse the repository at this point in the history
  • Loading branch information
bucky-boy committed Jun 29, 2018
1 parent 50a1697 commit f6819ed
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 66 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ The two Enums removed are:
* DocumentType - the `DocumentDetails.getType()` method now returns a String. The possible values are exposed as constants on the `com.yoti.api.client.DocumentDetails` interface.
* HumanProfile.Gender - `HumanProfile.getGender()` now returns an `Attribute<String>`. Possible values are defined in `com.yoti.api.client.HumanProfile`.

### Removed toString() methods
We've removed implementations of toString() from all the DTOs returned through the public api.

## Spring Security Integration

If you use Spring Security you can use the `yoti-sdk-spring-security` module to make integration easier. You are provided with some classes that fit into Spring Security's existing authentication model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private Object convertValueFromProto(AttrProto.Attribute attribute) throws Parse
case JSON:
return JSON_MAPPER.readValue(attribute.getValue().toString(DEFAULT_CHARSET), Map.class);
default:
LOG.warn("Unknown type {} for attribute {}. Attempting to parse it as a String", attribute.getContentType(), attribute.getName());
LOG.warn("Unknown type '{}' for attribute '{}'. Attempting to parse it as a String", attribute.getContentType(), attribute.getName());
return attribute.getValue().toString(DEFAULT_CHARSET);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ List<Attribute<?>> parseAttributeList(byte[] attributeListBytes) throws ProfileE

AttributeListProto.AttributeList attributeList = parseProto(attributeListBytes);
List<Attribute<?>> attributes = parseAttributes(attributeList);
LOG.debug("{} attribute(s) parsed", attributes.size());
LOG.debug("{} out of {} attribute(s) parsed successfully ", attributes.size(), attributeList.getAttributesCount());
return attributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,4 @@ public String getIssuingAuthority() {
return authority;
}

@Override
public String toString() {
return "DocumentDetailsAttributeValue{" +
"type=" + type +
", issuingCountry='" + issuingCountry + '\'' +
", number='" + number + '\'' +
", expirationDate=" + expirationDate +
", issuingAuthority='" + authority + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public <T> T postResource(UrlConnector urlConnector, byte[] body, Map<String, St
}

private HttpURLConnection openConnection(UrlConnector urlConnector, String httpMethod, Map<String, String> headers) throws IOException {
LOG.debug("Connecting to: " + urlConnector.getUrlString());
LOG.debug("Connecting to: '{}'", urlConnector.getUrlString());
HttpURLConnection httpUrlConnection = urlConnector.getHttpUrlConnection();
httpUrlConnection.setRequestMethod(httpMethod);
setHeaders(headers, httpUrlConnection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ public int hashCode() {
return result;
}

@Override
public String toString() {
return "ProfileResponse{" +
"sessionData='" + sessionData + '\'' +
", receipt=" + receipt +
'}';
}

public static class ProfileResponseBuilder {
private String sessionData;
private Receipt receipt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,6 @@ public boolean equals(Object obj) {
return true;
}

@Override
public String toString() {
return "Receipt [receiptId=" + getDisplayReceiptId()
+ ", otherPartyProfile=" + Arrays.toString(otherPartyProfile)
+ ", profile=" + Arrays.toString(profile)
+ ", otherPartyExtraData=" + Arrays.toString(otherPartyExtraData)
+ ", extraData=" + Arrays.toString(extraData)
+ ", wrappedReceiptKey=" + Arrays.toString(wrappedReceiptKey)
+ ", policyUri=" + policyUri
+ ", personalKey=" + Arrays.toString(personalKey)
+ ", rememberMeId=" + Arrays.toString(rememberMeId)
+ ", outcome=" + outcome
+ ", timestamp=" + timestamp + "]";
}

public String getDisplayReceiptId() {
return receiptId != null ? toBase64String(receiptId) : "<>";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Receipt getReceipt(KeyPair keyPair, String appId, String connectToken) th
}

private Receipt fetchReceipt(String resourcePath, String digest, String authKey) throws IOException, ProfileException {
LOG.info("Fetching profile from resource at {}", resourcePath);
LOG.info("Fetching profile from resource at '{}'", resourcePath);
Map<String, String> headers = new HashMap<>();
headers.put(AUTH_KEY_HEADER, authKey);
headers.put(DIGEST_HEADER, digest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ public String getCountry() {
return country;
}

@Override
public String toString() {
return "SimpleAmlAddress{" +
"postCode='" + postCode + '\'' +
", country='" + country + '\'' +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,4 @@ public AmlAddress getAmlAddress() {
return amlAddress;
}

@Override
public String toString() {
return "SimpleAmlProfile{" +
"givenNames='" + givenNames + '\'' +
", familyName='" + familyName + '\'' +
", ssn='" + ssn + '\'' +
", amlAddress=" + amlAddress +
'}';
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,4 @@ public void setOnWatchList(boolean onWatchList) {
this.onWatchList = onWatchList;
}

@Override
public String toString() {
return "SimpleAmlResult{" +
"onFraudList=" + onFraudList +
", onPepList=" + onPepList +
", onWatchList=" + onWatchList +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void close() {
try {
autoCloseable.close();
} catch (Exception e) {
LOG.error("Failed to close " + autoCloseable.getClass().getCanonicalName(), e);
LOG.error("Failed to close '{}'", autoCloseable.getClass().getCanonicalName(), e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Authentication attemptAuthentication(final HttpServletRequest request,
final HttpServletResponse response) throws AuthenticationException {
LOG.debug("Yoti Auth Filter Running....");
final String token = obtainToken(request);
LOG.debug("Found token {}.", token);
LOG.debug("Found token '{}'.", token);

final YotiAuthenticationToken authRequest = new YotiAuthenticationToken(token);

Expand Down

0 comments on commit f6819ed

Please sign in to comment.