use of org.maxkey.authz.saml20.provider.xml.AuthnResponseGenerator in project MaxKey by dromara.
the class ConsumerEndpoint method initCredential.
/**
* 初始化sp证书
*
* @throws Exception
*/
private void initCredential(String spId) throws Exception {
// 1. 获取 sp keyStore
AppsSAML20Details saml20Details = saml20DetailsService.get(spId);
if (saml20Details == null) {
logger.error("spid[" + spId + "] not exists");
throw new Exception();
}
byte[] keyStoreBytes = saml20Details.getKeyStore();
InputStream keyStoreStream = new ByteArrayInputStream(keyStoreBytes);
try {
KeyStore keyStore = KeyStore.getInstance(keyStoreLoader.getKeystoreType());
keyStore.load(keyStoreStream, keyStoreLoader.getKeystorePassword().toCharArray());
Map<String, String> passwords = new HashMap<String, String>();
for (Enumeration<String> en = keyStore.aliases(); en.hasMoreElements(); ) {
String aliase = en.nextElement();
if (aliase.equalsIgnoreCase(keyStoreLoader.getEntityName())) {
passwords.put(aliase, keyStoreLoader.getKeystorePassword());
}
}
// TrustResolver trustResolver = new
// TrustResolver(keyStore,keyStoreLoader.getIdpIssuingEntityName(),keyStoreLoader.getKeystorePassword());
AuthnResponseGenerator authnResponseGenerator = new AuthnResponseGenerator(keyStoreLoader.getEntityName(), timeService, idService);
// endpointGenerator = new EndpointGenerator();
CriteriaSet criteriaSet = new CriteriaSet();
criteriaSet.add(new EntityIDCriteria(keyStoreLoader.getEntityName()));
criteriaSet.add(new UsageCriteria(UsageType.SIGNING));
KeyStoreCredentialResolver credentialResolver = new KeyStoreCredentialResolver(keyStore, passwords);
signingCredential = credentialResolver.resolveSingle(criteriaSet);
Validate.notNull(signingCredential);
// adapter set resolver
TrustResolver trustResolver = new TrustResolver(keyStore, keyStoreLoader.getEntityName(), keyStoreLoader.getKeystorePassword(), issueInstantRule, messageReplayRule, "POST");
extractBindingAdapter.setSecurityPolicyResolver(trustResolver.getStaticSecurityPolicyResolver());
} catch (Exception e) {
logger.error("初始化sp证书出错");
throw new Exception(e);
}
}
use of org.maxkey.authz.saml20.provider.xml.AuthnResponseGenerator in project MaxKey by dromara.
the class Saml20AutoConfiguration method authnResponseGenerator.
/**
* AuthnResponseGenerator.
* @return authnResponseGenerator
*/
@Bean(name = "authnResponseGenerator")
public AuthnResponseGenerator authnResponseGenerator(TimeService timeService, IDService idService, @Value("${maxkey.saml.v20.idp.issuer}") String issuerEntityName) {
_logger.debug("issuerEntityName " + issuerEntityName);
AuthnResponseGenerator generator = new AuthnResponseGenerator(issuerEntityName, timeService, idService);
return generator;
}
Aggregations