* We will support security context tokens.
*/
QName el = new QName(token.getNamespaceURI(), token.getLocalName());
if (el.equals(DERIVEDKEY_TOKEN)) {
DerivedKeyToken dkToken = new DerivedKeyToken(token);
DerivedKeyInfo dkInfo = null;
String uuid = null;
try {
if (dkToken.getSecuityTokenReference() == null) {
//if dkToken doesn't have a STR
SecurityContextToken secContextTk =
ConversationUtil.getSCT(dkToken);
uuid = secContextTk.getIdentifier();
log.debug(
"ConversationEngine :: The uuid is found " + uuid);
dkInfo = new DerivedKeyInfo(dkToken);
dkcbHandler.addDerivedKey(uuid, dkInfo);
} else { ///i.e. dkToken has a STR
SecurityTokenReference str2Base =
dkToken.getSecuityTokenReference();
if (str2Base.containsReference()) {
Reference ref2Base = str2Base.getReference();
//TODO:: Find where can I find the constants.
if (ref2Base
.getValueType()
.equals("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID")) {
/* ok now I have a SAML token. What should I do ?
* -Decrypt the secret.
* -create tempUUID
* -add the scTInfo into dkcbHandler
* -add the derived key token to dkcbHandler.
*/
uuid = ref2Base.getURI();
if(dkcbHandler.getSession(uuid)==null){
byte[] key = handleSAML(docSig, uuid);
System.out.println("I am here :-)");
SecurityContextInfo sctInfo =
new SecurityContextInfo(
uuid,
key,
1);
dkcbHandler.addSecurtiyContext(
uuid,
sctInfo);
}
dkInfo = new DerivedKeyInfo(dkToken);
dkcbHandler.addDerivedKey(uuid, dkInfo);
}
} else if(str2Base.containsKeyIdentifier()){
Element elem = str2Base.getFirstElement();
//.getKeyIdentifier()System.out.println("KeyIdentifier :: He ehee ........");
String value = elem.getAttribute("ValueType");
if("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID".equals(value)){
uuid = ((Text)elem.getChildNodes().item(0)).getNodeValue();
if(dkcbHandler.getSession(uuid)==null){
byte[] key = handleSAML(elem.getOwnerDocument(), uuid);
System.out.println("UUID of SAML is"+uuid);
SecurityContextInfo sctInfo = new SecurityContextInfo(uuid,key,1);
dkcbHandler.addSecurtiyContext(uuid,sctInfo);
}
dkInfo = new DerivedKeyInfo(dkToken);
dkcbHandler.addDerivedKey(uuid, dkInfo);
}
} else {
throw new ConversationException("Don't know how to process here");