Статус: Новичок
Группы: Участники
Зарегистрирован: 14.11.2013(UTC) Сообщений: 2
|
Здравствуйте! Пытаюсь добавить и подписать второй подзаголовок. Структура файла в кратце такая: Код:
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1" SOAP-ENV:actor="RSMEVAUTH">
<h:ServiceHeader xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" wsu:Id="serviceh" xmlns="http://....ru/../" xmlns:h="http://....ru/../">
</SOAP-ENV:Header>
<SOAP-ENV:Body wsu:Id="body">
</SOAP-ENV:Envelope>
Код:
// Ссылка на подписываемые данные.
Reference ref = factory.newReference("#body",
factory.newDigestMethod("http://www.w3.org/2001/04/xmldsig-more#gostr3411", null),
transformList, null, null);
Reference ref2 = factory.newReference("#serviceh",
factory.newDigestMethod("http://www.w3.org/2001/04/xmldsig-more#gostr3411", null),
transformList, null, null);
List<Reference> references = new ArrayList<Reference>();
references.add(ref);
references.add(ref2);
// Блок SignedInfo.
SignedInfo signedInfo = factory.newSignedInfo(factory.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE,
(C14NMethodParameterSpec) null),
factory.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#gostr34102001-gostr3411", null),
references);
// Блок KeyInfo.
KeyInfoFactory kif = factory.getKeyInfoFactory();
X509Data x509d = kif.newX509Data(Collections.singletonList(cert));
KeyInfo keyInfo = kif.newKeyInfo(Collections.singletonList(x509d));
// Подпись данных.
XMLSignature signature = factory.newXMLSignature(signedInfo, keyInfo);
DOMSignContext signContext = new DOMSignContext(privateKey, token);
signature.sign(signContext);
На строке signature.sign(signContext) выдает ошибку javax.xml.crypto.URIReferenceException: org.apache.xml.security.utils.resolver.ResourceResolverException: Cannot resolve element with ID servicehВ чем может быть проблема?
|
|
|
|
Статус: Новичок
Группы: Участники
Зарегистрирован: 14.11.2013(UTC) Сообщений: 2
|
решил так serviceHeader.setAttributeNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "wsu:Id", "serviceh");
|
|
|
|
Статус: Сотрудник
Группы: Участники
Зарегистрирован: 06.12.2008(UTC) Сообщений: 4,001 Откуда: Крипто-Про Сказал(а) «Спасибо»: 21 раз Поблагодарили: 712 раз в 673 постах
|
Здравствуйте. Попробуйте, например, использовать wss4j. |
|
|
|
|
Быстрый переход
Вы не можете создавать новые темы в этом форуме.
Вы не можете отвечать в этом форуме.
Вы не можете удалять Ваши сообщения в этом форуме.
Вы не можете редактировать Ваши сообщения в этом форуме.
Вы не можете создавать опросы в этом форуме.
Вы не можете голосовать в этом форуме.
Important Information:
The Форум КриптоПро uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close