mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-16 17:32:06 +01:00
Add javadoc documentation to Trustworthiness class
This commit is contained in:
parent
d2b48e83d9
commit
870af0e005
1 changed files with 55 additions and 2 deletions
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
package org.pgpainless.algorithm;
|
package org.pgpainless.algorithm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Facade class for {@link org.bouncycastle.bcpg.sig.TrustSignature}.
|
||||||
|
* A trust signature subpacket marks the trustworthiness of a certificate and defines its capabilities to act
|
||||||
|
* as a trusted introducer.
|
||||||
|
*/
|
||||||
public class Trustworthiness {
|
public class Trustworthiness {
|
||||||
|
|
||||||
private final int amount;
|
private final int amount;
|
||||||
|
@ -18,34 +23,82 @@ public class Trustworthiness {
|
||||||
this.depth = capDepth(depth);
|
this.depth = capDepth(depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the trust amount.
|
||||||
|
* This value means how confident the issuer of the signature is in validity of the binding.
|
||||||
|
*
|
||||||
|
* @return trust amount
|
||||||
|
*/
|
||||||
public int getAmount() {
|
public int getAmount() {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the depth of the trust signature.
|
||||||
|
* This value controls, whether the certificate can act as a trusted introducer.
|
||||||
|
*
|
||||||
|
* @return depth
|
||||||
|
*/
|
||||||
public int getDepth() {
|
public int getDepth() {
|
||||||
return depth;
|
return depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true, if the trust amount is equal to 0.
|
||||||
|
* This means the key is not trusted.
|
||||||
|
*
|
||||||
|
* Otherwise return false
|
||||||
|
* @return true if untrusted
|
||||||
|
*/
|
||||||
public boolean isNotTrusted() {
|
public boolean isNotTrusted() {
|
||||||
return getAmount() == NOT_TRUSTED;
|
return getAmount() == NOT_TRUSTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the certificate is at least marginally trusted.
|
||||||
|
* That is the case, if the trust amount is greater than 0.
|
||||||
|
*
|
||||||
|
* @return true if the cert is at least marginally trusted
|
||||||
|
*/
|
||||||
public boolean isMarginallyTrusted() {
|
public boolean isMarginallyTrusted() {
|
||||||
return getAmount() > NOT_TRUSTED;
|
return getAmount() > NOT_TRUSTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the certificate is fully trusted. That is the case if the trust amount is
|
||||||
|
* greater than or equal to 120.
|
||||||
|
*
|
||||||
|
* @return true if the cert is fully trusted
|
||||||
|
*/
|
||||||
public boolean isFullyTrusted() {
|
public boolean isFullyTrusted() {
|
||||||
return getAmount() >= THRESHOLD_FULLY_CONVINCED;
|
return getAmount() >= THRESHOLD_FULLY_CONVINCED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true, if the cert is an introducer. That is the case if the depth is greater 0.
|
||||||
|
*
|
||||||
|
* @return true if introducer
|
||||||
|
*/
|
||||||
public boolean isIntroducer() {
|
public boolean isIntroducer() {
|
||||||
return getDepth() >= 1;
|
return getDepth() >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true, if the certified cert can introduce certificates with trust depth of <pre>otherDepth</pre>.
|
||||||
|
*
|
||||||
|
* @param otherDepth other certifications trust depth
|
||||||
|
* @return true if the cert can introduce the other
|
||||||
|
*/
|
||||||
public boolean canIntroduce(int otherDepth) {
|
public boolean canIntroduce(int otherDepth) {
|
||||||
return getDepth() > otherDepth;
|
return getDepth() > otherDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true, if the certified cert can introduce certificates with the given <pre>other</pre> trust depth.
|
||||||
|
*
|
||||||
|
* @param other other certificates trust depth
|
||||||
|
* @return true if the cert can introduce the other
|
||||||
|
*/
|
||||||
public boolean canIntroduce(Trustworthiness other) {
|
public boolean canIntroduce(Trustworthiness other) {
|
||||||
return canIntroduce(other.getDepth());
|
return canIntroduce(other.getDepth());
|
||||||
}
|
}
|
||||||
|
@ -107,13 +160,13 @@ public class Trustworthiness {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key is a level <pre>n</pre> meta introducer.
|
* The key is a meta introducer of depth <pre>n</pre>.
|
||||||
* This key can introduce meta introducers of depth <pre>n - 1</pre>.
|
* This key can introduce meta introducers of depth <pre>n - 1</pre>.
|
||||||
*
|
*
|
||||||
* @param n depth
|
* @param n depth
|
||||||
* @return trust
|
* @return trust
|
||||||
*/
|
*/
|
||||||
public Trustworthiness levelNIntroducer(int n) {
|
public Trustworthiness metaIntroducerOfDepth(int n) {
|
||||||
return new Trustworthiness(amount, n);
|
return new Trustworthiness(amount, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue