Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 4a037b75 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

- fix x-forwarded parameters

parent f2cb44b7
No related branches found
No related tags found
No related merge requests found
......@@ -143,8 +143,8 @@ export class DomainComponent implements OnInit {
this.dialog.open(ConfirmationDialogComponent, {
data: {
title: "Unregister domain from SML!",
description: "Action will register domain: "+domainRo.domainCode +" and all its service groups from SML. Do you wish to continue?"
title: "Register domain to SML!",
description: "Action will register domain: "+domainRo.domainCode +" and all its service groups to SML. Do you wish to continue?"
}
}).afterClosed().subscribe(result => {
if (result) {
......
package eu.europa.ec.edelivery.smp.conversion;
import eu.europa.ec.edelivery.security.PreAuthenticatedCertificatePrincipal;
import eu.europa.ec.edelivery.smp.data.model.DBCertificate;
import eu.europa.ec.edelivery.smp.data.ui.CertificateRO;
import eu.europa.ec.edelivery.smp.exceptions.ErrorCode;
import eu.europa.ec.edelivery.smp.exceptions.SMPRuntimeException;
......@@ -18,8 +17,6 @@ import java.net.URLEncoder;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Base64;
/**
......@@ -28,65 +25,65 @@ import java.util.Base64;
@Component
public class X509CertificateToCertificateROConverter implements Converter<X509Certificate, CertificateRO> {
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(CertificateROToDBCertificateConverter.class);
private static final SMPLogger LOG = SMPLoggerFactory.getLogger(CertificateROToDBCertificateConverter.class);
private static final String S_BLUECOAT_DATEFORMAT ="MMM dd HH:mm:ss yyyy";
private static final String S_BLUECOAT_DATEFORMAT = "MMM dd HH:mm:ss yyyy";
@Override
public CertificateRO convert(X509Certificate cert) {
@Override
public CertificateRO convert(X509Certificate cert) {
String subject = cert.getSubjectDN().getName();
String issuer = cert.getIssuerDN().getName();
String hash = cert.getIssuerDN().getName();
BigInteger serial = cert.getSerialNumber();
String certId = getCertificateIdFromCertificate(subject, issuer, serial);
CertificateRO cro = new CertificateRO();
cro.setCertificateId(certId);
cro.setSubject(subject);
cro.setIssuer(issuer);
// set serial as HEX
cro.setSerialNumber(serial.toString(16));
cro.setValidFrom(cert.getNotBefore());
cro.setValidTo(cert.getNotAfter());
try {
cro.setEncodedValue(Base64.getMimeEncoder().encodeToString(cert.getEncoded()));
} catch (CertificateEncodingException cex) {
throw new SMPRuntimeException(ErrorCode.CERTIFICATE_ERROR, cex,
"Error occured while decoding certificate " +subject, cex.getMessage(), cex );
String subject = cert.getSubjectDN().getName();
String issuer = cert.getIssuerDN().getName();
String hash = cert.getIssuerDN().getName();
BigInteger serial = cert.getSerialNumber();
String certId = getCertificateIdFromCertificate(subject, issuer, serial);
CertificateRO cro = new CertificateRO();
cro.setCertificateId(certId);
cro.setSubject(subject);
cro.setIssuer(issuer);
// set serial as HEX
cro.setSerialNumber(serial.toString(16));
cro.setValidFrom(cert.getNotBefore());
cro.setValidTo(cert.getNotAfter());
try {
cro.setEncodedValue(Base64.getMimeEncoder().encodeToString(cert.getEncoded()));
} catch (CertificateEncodingException cex) {
throw new SMPRuntimeException(ErrorCode.CERTIFICATE_ERROR, cex,
"Error occured while decoding certificate " + subject, cex.getMessage(), cex);
}
// generate bluecoat header
SimpleDateFormat sdf = new SimpleDateFormat(S_BLUECOAT_DATEFORMAT);
StringWriter sw = new StringWriter();
sw.write("sno=");
sw.write(serial.toString(16));
sw.write("&subject=");
sw.write(urlEnodeString(subject));
sw.write("&validfrom=");
sw.write(urlEnodeString(sdf.format(cert.getNotBefore())+" GTM"));
sw.write("&validto=");
sw.write(urlEnodeString(sdf.format(cert.getNotAfter())+" GTM"));
sw.write("&issuer=");
sw.write(urlEnodeString(issuer));
cro.setBlueCoatHeader(sw.toString());
return cro;
}
// generate bluecoat header
SimpleDateFormat sdf = new SimpleDateFormat(S_BLUECOAT_DATEFORMAT);
StringWriter sw = new StringWriter();
sw.write("sno=");
sw.write(serial.toString(16));
sw.write("&subject=");
sw.write(urlEncodeString(subject));
sw.write("&validfrom=");
sw.write(urlEncodeString(sdf.format(cert.getNotBefore()) + " GTM"));
sw.write("&validto=");
sw.write(urlEncodeString(sdf.format(cert.getNotAfter()) + " GTM"));
sw.write("&issuer=");
sw.write(urlEncodeString(issuer));
cro.setBlueCoatHeader(sw.toString());
return cro;
}
public String getCertificateIdFromCertificate(String subject, String issuer, BigInteger serial) {
return new PreAuthenticatedCertificatePrincipal(subject, issuer, serial).getName();
}
public String getCertificateIdFromCertificate(String subject, String issuer, BigInteger serial) {
return new PreAuthenticatedCertificatePrincipal(subject, issuer, serial).getName();
}
private String urlEnodeString(String val){
if (StringUtils.isBlank(val)){
return "";
} else {
try {
return URLEncoder.encode(val, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOG.error("Error occurred while url encoding the certificate string:" + val, e );
}
}
private String urlEncodeString(String val) {
if (StringUtils.isBlank(val)) {
return "";
} else {
try {
return URLEncoder.encode(val, "UTF-8");
} catch (UnsupportedEncodingException e) {
LOG.error("Error occurred while url encoding the certificate string:" + val, e);
}
}
return "";
}
}
......@@ -18,11 +18,9 @@ import eu.europa.ec.edelivery.smp.services.ui.UIKeystoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
import javax.annotation.PostConstruct;
import javax.xml.crypto.dsig.Reference;
import javax.xml.crypto.dsig.SignedInfo;
import javax.xml.crypto.dsig.XMLSignature;
......@@ -33,22 +31,14 @@ import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import javax.xml.crypto.dsig.keyinfo.X509Data;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
import java.io.FileInputStream;
import java.io.InputStream;
import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static java.util.Collections.list;
import static java.util.Collections.singletonList;
import static javax.xml.crypto.dsig.CanonicalizationMethod.INCLUSIVE;
import static javax.xml.crypto.dsig.DigestMethod.SHA256;
import static javax.xml.crypto.dsig.Transform.ENVELOPED;
import static org.apache.commons.lang3.StringUtils.isBlank;
@Component
public final class ServiceMetadataSigner {
......@@ -69,7 +59,7 @@ public final class ServiceMetadataSigner {
public void sign(Document serviceMetadataDoc, String keyAlias) {
LOG.info("Sing document with alias" + keyAlias);
LOG.info("Sing document with alias {}", keyAlias);
try {
XMLSignatureFactory domSigFactory = getDomSigFactory();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment