// Get token issuer
String issuer = stsConfig.getIssuer();
context.setTokenIssuer(issuer);
// Get the metadata for the SP as identified by the AppliesTo
TrustSPMetadata spMd = stsConfig.getTrustSPMetadata(appliesTo);
if (spMd == null){
// Only used for testing purpose; default should not documented
spMd = stsConfig.getTrustSPMetadata("default");
}
if (spMd == null){
log.log(Level.SEVERE,
LogStringsMessages.WST_0004_UNKNOWN_SERVICEPROVIDER(appliesTo));
throw new WSTrustException(LogStringsMessages.WST_0004_UNKNOWN_SERVICEPROVIDER(appliesTo));
}
// Get service certificate
if (serCert == null){
serCert = this.getServiceCertificate(spMd, appliesTo);
}
if (serCert != null){
context.getOtherProperties().put(IssuedTokenContext.TARGET_SERVICE_CERTIFICATE, serCert);
}
// Get STS certificate and private key
Object[] certAndKey = this.getSTSCertAndPrivateKey();
context.getOtherProperties().put(IssuedTokenContext.STS_CERTIFICATE, (X509Certificate)certAndKey[0]);
context.getOtherProperties().put(IssuedTokenContext.STS_PRIVATE_KEY, (PrivateKey)certAndKey[1]);
// Get TokenType
String tokenType = null;
URI tokenTypeURI = rst.getTokenType();
if (tokenTypeURI == null && secParas != null){
tokenTypeURI = secParas.getTokenType();
}
if (tokenTypeURI != null){
tokenType = tokenTypeURI.toString();
}else{
tokenType = spMd.getTokenType();
}
if (tokenType == null){
tokenType = WSTrustConstants.SAML11_ASSERTION_TOKEN_TYPE;
}
context.setTokenType(tokenType);
// Get KeyType
String keyType = null;
URI keyTypeURI = rst.getKeyType();
if (keyTypeURI == null && secParas != null){
keyTypeURI = secParas.getKeyType();
}
if (keyTypeURI != null){
keyType = keyTypeURI.toString();
}else{
keyType = spMd.getKeyType();
}
if (keyType == null){
keyType = wstVer.getSymmetricKeyTypeURI();
}
context.setKeyType(keyType);