use of org.springframework.security.saml2.credentials.Saml2X509Credential in project midpoint by Evolveum.
the class SamlModuleWebSecurityConfiguration method getSaml2Credential.
public static Saml2X509Credential getSaml2Credential(ModuleSaml2SimpleKeyType key, boolean isActive) {
if (key == null) {
return null;
}
PrivateKey pkey;
try {
pkey = getPrivateKey(key, protector);
} catch (IOException | OperatorCreationException | PKCSException | EncryptionException e) {
throw new Saml2Exception("Unable get key from " + key, e);
}
Certificate certificate;
try {
certificate = getCertificate(key, protector);
} catch (Base64Exception | EncryptionException | CertificateException e) {
throw new Saml2Exception("Unable get certificate from " + key, e);
}
List<Saml2X509Credential.Saml2X509CredentialType> types = getTypesForKey(isActive, key.getType());
return new Saml2X509Credential(pkey, (X509Certificate) certificate, types.toArray(new Saml2X509Credential.Saml2X509CredentialType[0]));
}
use of org.springframework.security.saml2.credentials.Saml2X509Credential in project midpoint by Evolveum.
the class SamlModuleWebSecurityConfiguration method getSaml2Credential.
public static Saml2X509Credential getSaml2Credential(ModuleSaml2KeyStoreKeyType key, boolean isActive) {
if (key == null) {
return null;
}
PrivateKey pkey;
try {
pkey = getPrivateKey(key, protector);
} catch (KeyStoreException | IOException | EncryptionException | CertificateException | NoSuchAlgorithmException | UnrecoverableKeyException e) {
throw new Saml2Exception("Unable get key from " + key, e);
}
Certificate certificate;
try {
certificate = getCertificate(key, protector);
} catch (EncryptionException | CertificateException | KeyStoreException | IOException | NoSuchAlgorithmException e) {
throw new Saml2Exception("Unable get certificate from " + key, e);
}
if (!(certificate instanceof X509Certificate)) {
throw new Saml2Exception("Alias " + key.getKeyAlias() + " don't return certificate of X509Certificate type.");
}
List<Saml2X509Credential.Saml2X509CredentialType> types = getTypesForKey(isActive, key.getType());
return new Saml2X509Credential(pkey, (X509Certificate) certificate, types.toArray(new Saml2X509Credential.Saml2X509CredentialType[0]));
}
use of org.springframework.security.saml2.credentials.Saml2X509Credential in project spring-security by spring-projects.
the class OpenSamlSigningUtils method resolveSigningCredentials.
private static List<Credential> resolveSigningCredentials(RelyingPartyRegistration relyingPartyRegistration) {
List<Credential> credentials = new ArrayList<>();
for (Saml2X509Credential x509Credential : relyingPartyRegistration.getSigningX509Credentials()) {
X509Certificate certificate = x509Credential.getCertificate();
PrivateKey privateKey = x509Credential.getPrivateKey();
BasicCredential credential = CredentialSupport.getSimpleCredential(certificate, privateKey);
credential.setEntityId(relyingPartyRegistration.getEntityId());
credential.setUsageType(UsageType.SIGNING);
credentials.add(credential);
}
return credentials;
}
use of org.springframework.security.saml2.credentials.Saml2X509Credential in project spring-security by spring-projects.
the class OpenSamlSigningUtils method resolveSigningCredentials.
private static List<Credential> resolveSigningCredentials(RelyingPartyRegistration relyingPartyRegistration) {
List<Credential> credentials = new ArrayList<>();
for (Saml2X509Credential x509Credential : relyingPartyRegistration.getSigningX509Credentials()) {
X509Certificate certificate = x509Credential.getCertificate();
PrivateKey privateKey = x509Credential.getPrivateKey();
BasicCredential credential = CredentialSupport.getSimpleCredential(certificate, privateKey);
credential.setEntityId(relyingPartyRegistration.getEntityId());
credential.setUsageType(UsageType.SIGNING);
credentials.add(credential);
}
return credentials;
}
use of org.springframework.security.saml2.credentials.Saml2X509Credential in project spring-security by spring-projects.
the class OpenSamlMetadataResolver method buildKeys.
private List<KeyDescriptor> buildKeys(Collection<Saml2X509Credential> credentials, UsageType usageType) {
List<KeyDescriptor> list = new ArrayList<>();
for (Saml2X509Credential credential : credentials) {
KeyDescriptor keyDescriptor = buildKeyDescriptor(usageType, credential.getCertificate());
list.add(keyDescriptor);
}
return list;
}
Aggregations