se.idsec.signservice.security.sign.impl.AbstractSignerResult Maven / Gradle / Ivy
/*
* Copyright 2019-2024 IDsec Solutions AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package se.idsec.signservice.security.sign.impl;
import se.idsec.signservice.security.sign.SignerResult;
import java.security.cert.X509Certificate;
import java.util.Collections;
import java.util.List;
/**
* Abstract base class for {@link SignerResult} implementations.
*
* @param the type of document signed
* @author Martin Lindström ([email protected])
* @author Stefan Santesson ([email protected])
*/
public class AbstractSignerResult implements SignerResult {
/** The signed document. */
private T signedDocument;
/** The signing time. */
private long signingTime;
/** The signer certificate. */
private X509Certificate signerCertificate;
/** The signer certificate chain. */
private List signerCertificateChain;
/**
* Default constructor.
*/
public AbstractSignerResult() {
}
/** {@inheritDoc} */
@Override
public T getSignedDocument() {
return this.signedDocument;
}
/**
* Assigns the signed document.
*
* @param signedDocument the signed document
*/
public void setSignedDocument(final T signedDocument) {
this.signedDocument = signedDocument;
}
/** {@inheritDoc} */
@Override
public long getSigningTime() {
return this.signingTime;
}
/**
* Assigns the signing time.
*
* @param signingTime the siging time (in millis since epoch)
*/
public void setSigningTime(final long signingTime) {
this.signingTime = signingTime;
}
/** {@inheritDoc} */
@Override
public X509Certificate getSignerCertificate() {
return this.signerCertificate;
}
/**
* Assigns the signer certificate.
*
* @param signerCertificate the signer certificate
*/
public void setSignerCertificate(final X509Certificate signerCertificate) {
this.signerCertificate = signerCertificate;
}
/** {@inheritDoc} */
@Override
public List getSignerCertificateChain() {
return this.signerCertificateChain != null
? this.signerCertificateChain
: this.signerCertificate != null ? Collections.singletonList(this.signerCertificate) : Collections.emptyList();
}
/**
* Assigns the signer certificate chain.
*
* @param signerCertificateChain the signer certificate chain
*/
public void setSignerCertificateChain(final List signerCertificateChain) {
this.signerCertificateChain = signerCertificateChain;
}
}