Search in sources :

Example 1 with KeyStoreCertificateRetriever

use of org.wso2.carbon.identity.core.KeyStoreCertificateRetriever in project carbon-identity-framework by wso2.

the class SAMLSSOServiceProviderDAO method getApplicationCertificate.

/**
 * Returns the {@link java.security.cert.Certificate} which should used to validate the requests
 * for the given service provider.
 *
 * @param serviceProviderDO
 * @param tenant
 * @return
 * @throws SQLException
 * @throws CertificateRetrievingException
 */
private X509Certificate getApplicationCertificate(SAMLSSOServiceProviderDO serviceProviderDO, Tenant tenant) throws SQLException, CertificateRetrievingException {
    // Check whether there is a certificate stored against the service provider (in the database)
    int applicationCertificateId = getApplicationCertificateId(serviceProviderDO.getIssuer(), tenant.getId());
    CertificateRetriever certificateRetriever;
    String certificateIdentifier;
    if (applicationCertificateId != -1) {
        certificateRetriever = new DatabaseCertificateRetriever();
        certificateIdentifier = Integer.toString(applicationCertificateId);
    } else {
        certificateRetriever = new KeyStoreCertificateRetriever();
        certificateIdentifier = serviceProviderDO.getCertAlias();
    }
    return certificateRetriever.getCertificate(certificateIdentifier, tenant);
}
Also used : DatabaseCertificateRetriever(org.wso2.carbon.identity.core.DatabaseCertificateRetriever) KeyStoreCertificateRetriever(org.wso2.carbon.identity.core.KeyStoreCertificateRetriever) DatabaseCertificateRetriever(org.wso2.carbon.identity.core.DatabaseCertificateRetriever) CertificateRetriever(org.wso2.carbon.identity.core.CertificateRetriever) KeyStoreCertificateRetriever(org.wso2.carbon.identity.core.KeyStoreCertificateRetriever)

Aggregations

CertificateRetriever (org.wso2.carbon.identity.core.CertificateRetriever)1 DatabaseCertificateRetriever (org.wso2.carbon.identity.core.DatabaseCertificateRetriever)1 KeyStoreCertificateRetriever (org.wso2.carbon.identity.core.KeyStoreCertificateRetriever)1