"Can't verify X509 certificate from request", e);
}
}
// create token
TokenProvider tokenProvider = null;
for (TokenProvider tp : tokenProviders) {
if (tokenType.equals(tp.getTokenType())) {
tokenProvider = tp;
break;
}
}
if (tokenProvider == null) {
throw new STSException(
"No token provider found for requested token type: "
+ tokenType);
}
Element elementToken = null;
if (certificate != null) {
elementToken = tokenProvider.createToken(certificate);
} else {
elementToken = tokenProvider.createToken(username);
}
String tokenId = tokenProvider.getTokenId(elementToken);
signSAML(elementToken, tokenId);
// prepare response
RequestSecurityTokenResponseType response = wrapAssertionToResponse(
tokenProvider.getResponseTokentype(), elementToken, tokenId);
RequestSecurityTokenResponseCollectionType responseCollection = WS_TRUST_FACTORY
.createRequestSecurityTokenResponseCollectionType();
responseCollection.getRequestSecurityTokenResponse().add(response);
return responseCollection;