You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
package com.fr.plugin.xxxx.saml.xxxx.saml.response; |
|
|
|
import com.fr.plugin.xxxx.saml.xxxx.saml.SAMLException; |
|
import com.fr.plugin.xxxx.saml.xxxx.saml.SAMLUtil; |
|
import com.fr.plugin.xxxx.saml.xxxx.saml.assertion.AuthnRequest; |
|
import org.jdom.Document; |
|
import org.jdom.Element; |
|
import org.w3c.dom.NodeList; |
|
|
|
import java.security.KeyStore.PrivateKeyEntry; |
|
|
|
public class Request { |
|
private AuthnRequest request; |
|
private PrivateKeyEntry privateKey; |
|
|
|
public Request(AuthnRequest request, PrivateKeyEntry privateKey) { |
|
this.request = request; |
|
this.privateKey = privateKey; |
|
} |
|
|
|
public Element toXML() throws SAMLException { |
|
Element req = request.toXML(); |
|
|
|
if(privateKey != null) { |
|
Document doc = new Document(); |
|
doc.setRootElement(req); |
|
org.w3c.dom.Element element = SAMLUtil.toDom(req); |
|
NodeList nodeList = element.getElementsByTagNameNS(AuthnRequest.saml.getURI(),"Issuer"); |
|
org.w3c.dom.Node insertBefore = nodeList.item(nodeList.getLength() - 1); |
|
SAMLUtil.insertSignature(element, privateKey, insertBefore,request.getDigestAlgorithm(),request.getSignatureAlgorithm()); |
|
req = SAMLUtil.toJdom(element); |
|
req.detach(); |
|
} |
|
return req; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|