OpenSAML で X509Data オブジェクトに証明書を追加しようとしています。ただし、これを行うと、証明書が 2 回追加されたように見えます。以下のコードはこれを示しています。私は何かばかげたことをしていますか?
import org.junit.Test;
import org.opensaml.Configuration;
import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;
import org.opensaml.xml.XMLObjectBuilderFactory;
import org.opensaml.xml.signature.X509Certificate;
import org.opensaml.xml.signature.X509Data;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class BrokenListAdditionTest {
@Test
public void shouldNotFail() throws ConfigurationException {
DefaultBootstrap.bootstrap();
XMLObjectBuilderFactory openSamlBuilderFactory = Configuration.getBuilderFactory();
X509Certificate x509Certificate = (X509Certificate) openSamlBuilderFactory.getBuilder(X509Certificate.DEFAULT_ELEMENT_NAME).buildObject(X509Certificate.DEFAULT_ELEMENT_NAME, X509Certificate.DEFAULT_ELEMENT_NAME);
x509Certificate.setValue("foo-value");
X509Data x509Data = (X509Data) openSamlBuilderFactory.getBuilder(X509Data.DEFAULT_ELEMENT_NAME).buildObject(X509Data.DEFAULT_ELEMENT_NAME, X509Data.TYPE_NAME);
x509Data.getX509Certificates().add(x509Certificate);
assertThat(x509Data.getX509Certificates().size(), is(1)); // Fails, because size() is 2!?
}
}