From 759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 4 Dec 2019 19:43:32 +0100 Subject: common EGIZ code-style refactoring --- .../eaaf/core/impl/idp/EidAuthenticationData.java | 224 +++++++++++---------- 1 file changed, 114 insertions(+), 110 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/EidAuthenticationData.java') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/EidAuthenticationData.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/EidAuthenticationData.java index 86728c05..ea197478 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/EidAuthenticationData.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/EidAuthenticationData.java @@ -2,120 +2,124 @@ package at.gv.egiz.eaaf.core.impl.idp; import java.security.cert.CertificateEncodingException; import java.security.cert.X509Certificate; - +import at.gv.egiz.eaaf.core.api.data.PVPAttributeDefinitions.EID_IDENTITY_STATUS_LEVEL_VALUES; +import at.gv.egiz.eaaf.core.api.idp.IEidAuthData; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.lang.NonNull; import org.springframework.util.Assert; -import at.gv.egiz.eaaf.core.api.data.PVPAttributeDefinitions.EID_IDENTITY_STATUS_LEVEL_VALUES; -import at.gv.egiz.eaaf.core.api.idp.IEidAuthData; - public class EidAuthenticationData extends AuthenticationData implements IEidAuthData { - private static final Logger log = LoggerFactory.getLogger(EidAuthenticationData.class); - - - private static final long serialVersionUID = -7106142572904327044L; - - private byte[] eIDToken; - private byte[] signerCertificate; - private EID_IDENTITY_STATUS_LEVEL_VALUES eidStatus; - private String vdaEndpointUrl; - private boolean useMandate = false; - - @Override - public byte[] getSignerCertificate() { - return this.signerCertificate; - } - - @Override - public byte[] getEIDToken() { - return this.eIDToken; - } - - @Override - public EID_IDENTITY_STATUS_LEVEL_VALUES getEIDStatus() { - return this.eidStatus; - - } - - @Override - public boolean isUseMandate() { - return useMandate; - } - - @Override - public String getVdaEndPointUrl() { - return vdaEndpointUrl; - - } - - /** - * Set the status of the E-ID identity - * - * @param eidStatus - */ - public void setEidStatus(EID_IDENTITY_STATUS_LEVEL_VALUES eidStatus) { - this.eidStatus = eidStatus; - } - - /** - * Set Online IdentityLink to AuthenticationData - * - * @param eIDToken - */ - public void seteIDToken(final byte[] eIDToken) { - this.eIDToken = eIDToken; - - } - - /** - * Set the signing certificate that was used to sign the user consent - * - * @param signerCertificate - */ - public void setSignerCertificate(@NonNull final X509Certificate signerCertificate) { - Assert.notNull(signerCertificate, "Signer certificate is null"); - try { - this.signerCertificate = signerCertificate.getEncoded(); - - } catch (final CertificateEncodingException e) { - log.warn("Can NOT serialized signer-certificate", e); - log.warn("Signer certificate will be ignored"); - - } - } - - /** - * Set the signing certificate that was used to sign the user consent - * - * @param signerCertificate - */ - public void setSignerCertificate(final byte[] signerCertificate) { - this.signerCertificate = signerCertificate; - - } - - /** - * Set flag that mandates are used in this process - * - * @param useMandate true if mandates was used, otherwise false - */ - public void setUseMandate(boolean useMandate) { - this.useMandate = useMandate; - } - - - /** - * Set URL of the EndPoint that was used on VDA for authentication - * - * @param vdaEndpointUrl - */ - public void setVdaEndpointUrl(String vdaEndpointUrl) { - this.vdaEndpointUrl = vdaEndpointUrl; - } - - - - + private static final Logger log = LoggerFactory.getLogger(EidAuthenticationData.class); + + + private static final long serialVersionUID = -7106142572904327044L; + + private byte[] eidToken; + private byte[] signerCertificate; + private EID_IDENTITY_STATUS_LEVEL_VALUES eidStatus; + private String vdaEndpointUrl; + private boolean useMandate = false; + + @Override + public byte[] getSignerCertificate() { + return getByteCopyOrNull(this.signerCertificate); + } + + @Override + public byte[] getEidToken() { + return getByteCopyOrNull(this.eidToken); + } + + @Override + public EID_IDENTITY_STATUS_LEVEL_VALUES getEidStatus() { + return this.eidStatus; + + } + + @Override + public boolean isUseMandate() { + return useMandate; + } + + @Override + public String getVdaEndPointUrl() { + return vdaEndpointUrl; + + } + + /** + * Set the status of the E-ID identity. + * + * @param eidStatus Status of the E-ID + */ + public void setEidStatus(final EID_IDENTITY_STATUS_LEVEL_VALUES eidStatus) { + this.eidStatus = eidStatus; + } + + /** + * Set Online IdentityLink to AuthenticationData. + * + * @param eidToken Online-IdentityLink + */ + public void setEidToken(final byte[] eidToken) { + this.eidToken = getByteCopyOrNull(eidToken); + + } + + /** + * Set the signing certificate that was used to sign the user consent. + * + * @param signerCertificate User's signer certificate + */ + public void setSignerCertificate(@NonNull final X509Certificate signerCertificate) { + Assert.notNull(signerCertificate, "Signer certificate is null"); + try { + this.signerCertificate = signerCertificate.getEncoded(); + + } catch (final CertificateEncodingException e) { + log.warn("Can NOT serialized signer-certificate", e); + log.warn("Signer certificate will be ignored"); + + } + } + + /** + * Set the signing certificate that was used to sign the user consent. + * + * @param signerCertificate User's signer certificate + */ + public void setSignerCertificate(final byte[] signerCertificate) { + this.signerCertificate = getByteCopyOrNull(signerCertificate); + + } + + /** + * Set flag that mandates are used in this process. + * + * @param useMandate true if mandates was used, otherwise false + */ + public void setUseMandate(final boolean useMandate) { + this.useMandate = useMandate; + } + + + /** + * Set URL of the EndPoint that was used on VDA for authentication. + * + * @param vdaEndpointUrl Used VDA end-point + */ + public void setVdaEndpointUrl(final String vdaEndpointUrl) { + this.vdaEndpointUrl = vdaEndpointUrl; + } + + private byte[] getByteCopyOrNull(byte[] in) { + if (in != null) { + return in.clone(); + } else { + return null; + } + } + + } -- cgit v1.2.3