Skip to Content.
Sympa Menu

mace-opensaml-users - Cannot resolve 'xt:DEFAULT' as a QName: the prefix 'x t' is not declared.

Subject: OpenSAML user discussion

List archive

Cannot resolve 'xt:DEFAULT' as a QName: the prefix 'x t' is not declared.


Chronological Thread 
  • From:
  • To:
  • Subject: Cannot resolve 'xt:DEFAULT' as a QName: the prefix 'x t' is not declared.
  • Date: Fri, 10 Oct 2008 05:19:32 -0400 (EDT)

Hello,

I am testing sample SAML response xml file. My code:

package SAML;
import java.security.Security;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigInteger;
import java.util.List;
import org.opensaml.saml2.encryption.Decrypter;
import org.opensaml.saml2.core.Response;
import org.opensaml.saml2.core.Assertion;
import org.opensaml.xml.Configuration;
import org.opensaml.xml.ConfigurationException;
import org.opensaml.xml.XMLConfigurator;
import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.parse.BasicParserPool;
import org.opensaml.xml.io.UnmarshallerFactory;
import org.opensaml.xml.io.Unmarshaller;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.opensaml.xml.Configuration;
import org.opensaml.xml.ConfigurationException;
import org.opensaml.xml.signature.KeyValue;
import org.opensaml.xml.signature.RSAKeyValue;
import org.opensaml.xml.signature.Signature;
import org.opensaml.xml.signature.SignatureValidator;
import org.opensaml.xml.util.Base64;

public class SAMLAuthenticator {

private static String[] testConfigs = { "D:/SAML/saml-test-config.xml", };

protected static void initializeXMLTooling(String[] providerConfigs)
throws ConfigurationException {
Class clazz = Configuration.class;
XMLConfigurator configurator = new XMLConfigurator();

for (String config : providerConfigs) {
configurator.load(clazz.getResourceAsStream(config));
}
}

public static void main(String args[]) throws Exception
{

DefaultBootstrap.bootstrap();
initializeXMLTooling(testConfigs);

BasicParserPool ppMgr = new BasicParserPool();
ppMgr.setNamespaceAware(true);

SAMLAuthenticator samlAuthenticator = new SAMLAuthenticator();
String fileName = "D://SAML/sampleAssertion.xml";
samlAuthenticator.authenticate(fileName);

}

public String authenticate(String fileName) {
String ret = null;
try{
File file =new File(fileName);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));

BasicParserPool pool = new BasicParserPool();
Document inCommonMDDoc = pool.parse(in);
Element metadataRoot = inCommonMDDoc.getDocumentElement();

System.out.println("metadataRoot: "+metadataRoot);
UnmarshallerFactory unmarshallerFactory =
Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(metadataRoot);

Assertion samlAss = (Assertion) unmarshaller.unmarshall(metadataRoot);
Signature sig = samlAss.getSignature();

List<KeyValue> keyValueList = sig.getKeyInfo().getKeyValues();

if (keyValueList.size() > 1) {
throw new Exception();
}

KeyValue val = (KeyValue) keyValueList.get(0);
RSAKeyValue rsaKey = val.getRSAKeyValue();

String modulus = rsaKey.getModulus().getValue();
String exponent = rsaKey.getExponent().getValue();

System.out.println("modulus: "+modulus);
System.out.println("exponent: "+exponent);

BigInteger mod = new BigInteger(Base64.decode(modulus));
BigInteger exp = new BigInteger(Base64.decode(exponent));

SelfSignVerficationKeyHolder credential = new SelfSignVerficationKeyHolder();
credential.setPublicKey(mod, exp);

SignatureValidator validator = new SignatureValidator(credential);
validator.validate(sig);

//Steps involved in processing a given incoming SAML 2.0 request;


}catch(Exception e){
System.out.println("Exception has occured: "+e);
e.printStackTrace();
}
return ret;
}
}


I keep getting error ERROR: 'UndeclaredPrefix: Cannot resolve 'xt:DEFAULT'
as a QName: the prefix 'xt' is not declared.'

I have xerces and xalan in classpath. These are the same from the SAML jar.

Thanks in advance.

-Sonal



Archive powered by MHonArc 2.6.16.

Top of Page