use of org.gradle.plugins.signing.signatory.Signatory in project gradle by gradle.
the class Signature method generate.
/**
* Generates the signature file.
*
* <p>In order to generate the signature, the {@link #getToSign() file to sign}, {@link #getSignatory() signatory} and {@link #getSignatureType() signature type} must be known (i.e. non {@code
* null}).</p>
*
* @throws InvalidUserDataException if the there is insufficient information available to generate the signature.
*/
public void generate() {
File toSign = getToSign();
if (toSign == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature as the file to sign has not been specified");
} else {
return;
}
}
Signatory signatory = getSignatory();
if (signatory == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature for \'" + toSign + "\' as no signatory is available to sign");
} else {
return;
}
}
SignatureType signatureType = getSignatureType();
if (signatureType == null) {
if (signatureSpec.isRequired()) {
throw new InvalidUserDataException("Unable to generate signature for \'" + toSign + "\' as no signature type has been configured");
} else {
return;
}
}
signatureType.sign(signatory, toSign);
}
use of org.gradle.plugins.signing.signatory.Signatory in project gradle by gradle.
the class SigningExtension method addSignatureSpecConventions.
/**
* Adds conventions to the given spec, using this settings object's default signatory and signature type as the default signatory and signature type for the spec.
*/
protected void addSignatureSpecConventions(SignatureSpec spec) {
if (!(spec instanceof IConventionAware)) {
throw new InvalidUserDataException("Cannot add conventions to signature spec \'" + String.valueOf(spec) + "\' as it is not convention aware");
}
ConventionMapping conventionMapping = ((IConventionAware) spec).getConventionMapping();
conventionMapping.map("signatory", new Callable<Signatory>() {
@Override
public Signatory call() {
return getSignatory();
}
});
conventionMapping.map("signatureType", new Callable<SignatureType>() {
@Override
public SignatureType call() {
return getSignatureType();
}
});
conventionMapping.map("required", new Callable<Boolean>() {
@Override
public Boolean call() {
return isRequired();
}
});
}
Aggregations