ClassLoader classLoader = msgContext.getAxisService().getClassLoader();
Class cbClass = null;
try {
cbClass = Loader.loadClass(classLoader, config.getCallbackHandlerName());
} catch (ClassNotFoundException e) {
throw new TrustException("cannotLoadPWCBClass", new String[]{config
.getCallbackHandlerName()}, e);
}
try {
handler = (SAMLCallbackHandler) cbClass.newInstance();
} catch (java.lang.Exception e) {
throw new TrustException("cannotCreatePWCBInstance", new String[]{config
.getCallbackHandlerName()}, e);
}
handler.handle(cb);
attrs = cb.getAttributes();
}else{
//TODO Remove this after discussing
SAMLAttribute attribute = new SAMLAttribute("Name",
"https://rahas.apache.org/saml/attrns", null, -1, Arrays
.asList(new String[] { "Colombo/Rahas" }));
attrs = new SAMLAttribute[]{attribute};
}
SAMLAttributeStatement attrStmt = new SAMLAttributeStatement(
subject, Arrays.asList(attrs ));
SAMLStatement[] statements = { attrStmt };
SAMLAssertion assertion = new SAMLAssertion(config.issuerName,
notBefore, notAfter, null, null, Arrays.asList(statements));
// sign the assertion
X509Certificate[] issuerCerts = crypto
.getCertificates(config.issuerKeyAlias);
String sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_RSA;
String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
sigAlgo = XMLSignature.ALGO_ID_SIGNATURE_DSA;
}
java.security.Key issuerPK = crypto.getPrivateKey(
config.issuerKeyAlias, config.issuerKeyPassword);
assertion.sign(sigAlgo, issuerPK, Arrays.asList(issuerCerts));
return assertion;
} catch (Exception e) {
throw new TrustException("samlAssertionCreationError", e);
}
}