Use below code to get expiration date of saml certificate
String certificate = "Your SAML 2.0 certificate here";
CertificateFactory fty = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
X509Certificate idp_cert = (X509Certificate) fty.generateCertificate(bais);
System.out.println("Expiration date---"+ idp_cert.getNotAfter());
It would look like:
String certificate = "MIIDpDCCAoygAwIBAgIGAVFrmYh8MA0GCSqGSIb3DQEBBQUAMIGSMQswCQYDVQQGEwJVUzETMBEG"+
"A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU"+
"MBIGA1UECwwLU1NPUHJvdmlkZXIxEzARBgNVBAMMCmRldi04OTgwMzgxHDAaBgkqhkiG9w0BCQEW"+
"DWluZm9Ab2t0YS5jb20wHhcNMTUxMjA0MDYwNTQyWhcNMjUxMjA0MDYwNjQyWjCBkjELMAkGA1UE"+
"BhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDTALBgNV"+
"BAoMBE9rdGExFDASBgNVBAsMC1NTT1Byb3ZpZGVyMRMwEQYDVQQDDApkZXYtODk4MDM4MRwwGgYJ"+
"KoZIhvcNAQkBFg1pbmZvQG9rdGEuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA"+
"o79hx758z1uoUuV4C0wXlwKrSCzGhLvuNW/h5/1VB9svfFKs7zZ3b+dLoP3DptiL8CtNxQbH7nMS"+
"hwQHkoHMUlVI9X/I2FAptQcMNh4bmbNBh+L6/3fopxG4AEdt/25rjDu8lgfG/9kpGuJ4OJLH3cJZ"+
"MgToKUBz5+T85O4fBs5moANJyRFlvg3xwW6oQ7ufTTEM/t80zc/MpPMTfHqaiU+MHjaTeTT3FZdB"+
"cutp+HHjMND9EnR7hC6bzO1aDSGHxw+z3gbIbu1vSAUakB4qU6rStTOgmYPx8rAZh8dFTrLv2aKL"+
"SxLBHylhB9Fou8QknlKWT1p753eQikcKQiM/6wIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQA2IiqR"+
"FM1Odhzj86F56dXZ1DXYZXRDl77nqcbghbzkuMm7+LShC6zGSORVh4APpYKGKOK3Y/DN78/kixfH"+
"XUWNuCdk5vpGdBgOf2ipVIeY+BuqFJpNeWL4Udldcp7cOTVpZW/mmZZSMyxppeJ7qolS2LLdwo0U"+
"Vn7l6QgNkA7q2MFGcSjw/GfTks+aEozj5vkMo33ESt5MEY0xixAtCql4p0j56U7MtRKkwczl3Ou4"+
"rbS4NtPiqLZ3/DQAaGgNgQo9z7kHvOlpbwbwBX3dCrFWEfkHUBf6ccTeVOvRt39IGGzcNcAxyV63"+
"Yzfcw6H3SFnOUNINHcpEMCkK1viGiaeV";
CertificateFactory fty = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
X509Certificate idp_cert = (X509Certificate) fty.generateCertificate(bais);
System.out.println(idp_cert.getNotAfter());
String certificate = "Your SAML 2.0 certificate here";
CertificateFactory fty = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
X509Certificate idp_cert = (X509Certificate) fty.generateCertificate(bais);
System.out.println("Expiration date---"+ idp_cert.getNotAfter());
It would look like:
String certificate = "MIIDpDCCAoygAwIBAgIGAVFrmYh8MA0GCSqGSIb3DQEBBQUAMIGSMQswCQYDVQQGEwJVUzETMBEG"+
"A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU"+
"MBIGA1UECwwLU1NPUHJvdmlkZXIxEzARBgNVBAMMCmRldi04OTgwMzgxHDAaBgkqhkiG9w0BCQEW"+
"DWluZm9Ab2t0YS5jb20wHhcNMTUxMjA0MDYwNTQyWhcNMjUxMjA0MDYwNjQyWjCBkjELMAkGA1UE"+
"BhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDTALBgNV"+
"BAoMBE9rdGExFDASBgNVBAsMC1NTT1Byb3ZpZGVyMRMwEQYDVQQDDApkZXYtODk4MDM4MRwwGgYJ"+
"KoZIhvcNAQkBFg1pbmZvQG9rdGEuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA"+
"o79hx758z1uoUuV4C0wXlwKrSCzGhLvuNW/h5/1VB9svfFKs7zZ3b+dLoP3DptiL8CtNxQbH7nMS"+
"hwQHkoHMUlVI9X/I2FAptQcMNh4bmbNBh+L6/3fopxG4AEdt/25rjDu8lgfG/9kpGuJ4OJLH3cJZ"+
"MgToKUBz5+T85O4fBs5moANJyRFlvg3xwW6oQ7ufTTEM/t80zc/MpPMTfHqaiU+MHjaTeTT3FZdB"+
"cutp+HHjMND9EnR7hC6bzO1aDSGHxw+z3gbIbu1vSAUakB4qU6rStTOgmYPx8rAZh8dFTrLv2aKL"+
"SxLBHylhB9Fou8QknlKWT1p753eQikcKQiM/6wIDAQABMA0GCSqGSIb3DQEBBQUAA4IBAQA2IiqR"+
"FM1Odhzj86F56dXZ1DXYZXRDl77nqcbghbzkuMm7+LShC6zGSORVh4APpYKGKOK3Y/DN78/kixfH"+
"XUWNuCdk5vpGdBgOf2ipVIeY+BuqFJpNeWL4Udldcp7cOTVpZW/mmZZSMyxppeJ7qolS2LLdwo0U"+
"Vn7l6QgNkA7q2MFGcSjw/GfTks+aEozj5vkMo33ESt5MEY0xixAtCql4p0j56U7MtRKkwczl3Ou4"+
"rbS4NtPiqLZ3/DQAaGgNgQo9z7kHvOlpbwbwBX3dCrFWEfkHUBf6ccTeVOvRt39IGGzcNcAxyV63"+
"Yzfcw6H3SFnOUNINHcpEMCkK1viGiaeV";
CertificateFactory fty = CertificateFactory.getInstance("X.509");
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decodeBase64(certificate.getBytes()));
X509Certificate idp_cert = (X509Certificate) fty.generateCertificate(bais);
System.out.println(idp_cert.getNotAfter());