Search in sources :

Example 1 with X_INTERNAL_ERROR

use of ee.ria.xroad.common.ErrorCodes.X_INTERNAL_ERROR in project X-Road by nordic-institute.

the class GlobalConfImpl method getCaCert.

@Override
public X509Certificate getCaCert(String instanceIdentifier, X509Certificate memberCert) throws Exception {
    if (memberCert == null) {
        throw new IllegalArgumentException("Member certificate must be present to find CA cert!");
    }
    X509CertificateHolder ch = new X509CertificateHolder(memberCert.getEncoded());
    String[] instances = instanceIdentifier != null ? new String[] { instanceIdentifier } : new String[] {};
    return getSharedParameters(instances).stream().map(p -> p.getSubjectsAndCaCerts().get(ch.getIssuer())).filter(Objects::nonNull).findFirst().orElseThrow(() -> new CodedException(X_INTERNAL_ERROR, "Certificate is not issued by approved " + "certification service provider."));
}
Also used : GlobalGroupId(ee.ria.xroad.common.identifier.GlobalGroupId) X509Certificate(java.security.cert.X509Certificate) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) Arrays(java.util.Arrays) SystemProperties.getConfigurationPath(ee.ria.xroad.common.SystemProperties.getConfigurationPath) CertUtils(ee.ria.xroad.common.util.CertUtils) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) SecurityCategoryId(ee.ria.xroad.common.identifier.SecurityCategoryId) ArrayUtils(org.apache.commons.lang3.ArrayUtils) CryptoUtils.certHash(ee.ria.xroad.common.util.CryptoUtils.certHash) CertificateProfileInfoProvider(ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider) OcspInfoType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) ServiceId(ee.ria.xroad.common.identifier.ServiceId) HashSet(java.util.HashSet) AuthCertificateProfileInfo(ee.ria.xroad.common.certificateprofile.AuthCertificateProfileInfo) X_INTERNAL_ERROR(ee.ria.xroad.common.ErrorCodes.X_INTERNAL_ERROR) CryptoUtils.readCertificate(ee.ria.xroad.common.util.CryptoUtils.readCertificate) SubsystemType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SubsystemType) BigInteger(java.math.BigInteger) CryptoUtils.encodeBase64(ee.ria.xroad.common.util.CryptoUtils.encodeBase64) ErrorCodes.translateException(ee.ria.xroad.common.ErrorCodes.translateException) OutputStream(java.io.OutputStream) CentralServiceType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.CentralServiceType) ErrorCodes.translateWithPrefix(ee.ria.xroad.common.ErrorCodes.translateWithPrefix) Collection(java.util.Collection) Set(java.util.Set) SignCertificateProfileInfo(ee.ria.xroad.common.certificateprofile.SignCertificateProfileInfo) GlobalGroupType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.GlobalGroupType) Collectors(java.util.stream.Collectors) MemberType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.MemberType) X_MALFORMED_GLOBALCONF(ee.ria.xroad.common.ErrorCodes.X_MALFORMED_GLOBALCONF) Objects(java.util.Objects) CodedException(ee.ria.xroad.common.CodedException) SecurityServerType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SecurityServerType) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ApprovedTSAType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.ApprovedTSAType) Paths(java.nio.file.Paths) ApprovedCATypeV2(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.ApprovedCATypeV2) SecurityServerId(ee.ria.xroad.common.identifier.SecurityServerId) CertChain(ee.ria.xroad.common.cert.CertChain) MemberClassType(ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.MemberClassType) GetCertificateProfile(ee.ria.xroad.common.certificateprofile.GetCertificateProfile) ClientId(ee.ria.xroad.common.identifier.ClientId) CryptoUtils(ee.ria.xroad.common.util.CryptoUtils) Collections(java.util.Collections) CodedException(ee.ria.xroad.common.CodedException) X509CertificateHolder(org.bouncycastle.cert.X509CertificateHolder) Objects(java.util.Objects)

Aggregations

CodedException (ee.ria.xroad.common.CodedException)1 X_INTERNAL_ERROR (ee.ria.xroad.common.ErrorCodes.X_INTERNAL_ERROR)1 X_MALFORMED_GLOBALCONF (ee.ria.xroad.common.ErrorCodes.X_MALFORMED_GLOBALCONF)1 ErrorCodes.translateException (ee.ria.xroad.common.ErrorCodes.translateException)1 ErrorCodes.translateWithPrefix (ee.ria.xroad.common.ErrorCodes.translateWithPrefix)1 SystemProperties.getConfigurationPath (ee.ria.xroad.common.SystemProperties.getConfigurationPath)1 CertChain (ee.ria.xroad.common.cert.CertChain)1 AuthCertificateProfileInfo (ee.ria.xroad.common.certificateprofile.AuthCertificateProfileInfo)1 CertificateProfileInfoProvider (ee.ria.xroad.common.certificateprofile.CertificateProfileInfoProvider)1 GetCertificateProfile (ee.ria.xroad.common.certificateprofile.GetCertificateProfile)1 SignCertificateProfileInfo (ee.ria.xroad.common.certificateprofile.SignCertificateProfileInfo)1 ApprovedCATypeV2 (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.ApprovedCATypeV2)1 ApprovedTSAType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.ApprovedTSAType)1 CentralServiceType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.CentralServiceType)1 GlobalGroupType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.GlobalGroupType)1 MemberClassType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.MemberClassType)1 MemberType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.MemberType)1 OcspInfoType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.OcspInfoType)1 SecurityServerType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SecurityServerType)1 SubsystemType (ee.ria.xroad.common.conf.globalconf.sharedparameters.v2.SubsystemType)1