Skip to content

Commit

Permalink
fix issue
Browse files Browse the repository at this point in the history
  • Loading branch information
yanggang-JV committed Aug 5, 2019
1 parent 7b7e2ef commit 7295646
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void addType(String typeValue) {
* @return signature value
*/
public String getSignature() {
return getValueFromProof(proof, ParamKeyConstant.PROOF_SIGNATURE).toString();
return toString(getValueFromProof(proof, ParamKeyConstant.PROOF_SIGNATURE));
}

/**
Expand All @@ -125,7 +125,7 @@ public String getSignature() {
* @return proof type
*/
public String getProofType() {
return getValueFromProof(proof, ParamKeyConstant.PROOF_TYPE).toString();
return toString(getValueFromProof(proof, ParamKeyConstant.PROOF_TYPE));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ public class PresentationE implements RawSerializer, IProof {
* @return publicKeyId
*/
public String getVerificationMethod() {
return getValueFromProof(proof, ParamKeyConstant.PROOF_VERIFICATION_METHOD).toString();
return toString(getValueFromProof(proof, ParamKeyConstant.PROOF_VERIFICATION_METHOD));
}

/**
* 获取challenge随机值.
* @return 返回challenge随机值.
*/
public String getNonce() {
return getValueFromProof(proof, ParamKeyConstant.PROOF_NONCE).toString();
return toString(getValueFromProof(proof, ParamKeyConstant.PROOF_NONCE));
}

/**
* 获取签名值Signature.
* @return 返回签名字符串Signature.
*/
public String getSignature() {
return getValueFromProof(proof, ParamKeyConstant.PROOF_SIGNATURE).toString();
return toString(getValueFromProof(proof, ParamKeyConstant.PROOF_SIGNATURE));
}

/**
Expand Down Expand Up @@ -203,7 +203,7 @@ public boolean commit(WeIdAuthentication weIdAuthentication) {
weIdAuthentication.getWeIdPrivateKey().getPrivateKey()
);
this.putProofValue(ParamKeyConstant.PROOF_SIGNATURE, signature);
logger.error("[commit] success.");
logger.info("[commit] commit credential with weIdAuthentication is success.");
return true;
}

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/com/webank/weid/protocol/inf/IProof.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,19 @@ public interface IProof {
*/
public default Object getValueFromProof(Map<String, Object> proof, String key) {
if (proof != null) {
Object value = proof.get(key);
return value != null ? value : StringUtils.EMPTY;
return proof.get(key);
}
return null;
}

/**
* 将Object转换成String.
* @param obj 从proof中取出的object
* @return 返回key的字符串数据
*/
public default String toString(Object obj) {
if (obj != null) {
return String.valueOf(obj);
}
return StringUtils.EMPTY;
}
Expand Down

0 comments on commit 7295646

Please sign in to comment.