use of com.sun.identity.liberty.ws.disco.DiscoveryException in project OpenAM by OpenRock.
the class DiscoSDKUtils method parseOptions.
/**
* Parses Options element.
* @param child Options element.
* @return List of Option strings.
* @exception DiscoveryException if error occurs.
*/
public static List parseOptions(org.w3c.dom.Element child) throws DiscoveryException {
List options = new ArrayList();
NodeList optionnl = child.getChildNodes();
Node option;
String nName;
for (int j = 0, len = optionnl.getLength(); j < len; j++) {
option = optionnl.item(j);
if ((nName = option.getLocalName()) != null) {
String nameSpaceURI = ((Element) child).getNamespaceURI();
if ((nameSpaceURI == null) || (!nameSpaceURI.equals(DiscoConstants.DISCO_NS))) {
if (debug.messageEnabled()) {
debug.message("DiscoUtils.parseOption(" + "Element): invalid namespace for node " + nName);
}
throw new DiscoveryException(bundle.getString("wrongInput"));
}
if (nName.equals("Option")) {
options.add(XMLUtils.getElementValue((Element) option));
} else {
if (debug.messageEnabled()) {
debug.message("DiscoUtils.parseOption(" + "Element): invalid node" + nName);
}
throw new DiscoveryException(bundle.getString("wrongInput"));
}
}
}
return options;
}
use of com.sun.identity.liberty.ws.disco.DiscoveryException in project OpenAM by OpenRock.
the class DiscoSDKUtils method parseXML.
/**
* Obtains DOM Element from an xml String.
* @param xmlString String format of an element.
* @return DOM Element
* @exception DiscoveryException if error occurs.
*/
public static Element parseXML(String xmlString) throws DiscoveryException {
try {
debug.message("DiscoUtils.parseXML: xmlString=" + xmlString);
Document doc = XMLUtils.toDOMDocument(xmlString, debug);
return doc.getDocumentElement();
} catch (Exception ex) {
debug.error("DiscoUtils.parseXML: Parsing error.", ex);
throw new DiscoveryException(ex);
}
}
use of com.sun.identity.liberty.ws.disco.DiscoveryException in project OpenAM by OpenRock.
the class LibertyManagerImpl method getDiscoveryResourceOffering.
/**
* Returns the discovery service bootstrap resource offering.
* @param tokenID Single Sign On Token ID.
* @param hostProviderID Hosted <code>ProviderID</code>.
* @return <code>String</code> Discovery Service Resource Offering.
* @exception RemoteException if any failure.
*/
public String getDiscoveryResourceOffering(String tokenID, String hostProviderID) throws RemoteException {
try {
Object token = SessionManager.getProvider().getSession(tokenID);
FSSession session = FSSessionManager.getInstance(IDFFMetaUtils.getMetaAlias(IFSConstants.ROOT_REALM, hostProviderID, IFSConstants.SP, null)).getSession(token);
if (session == null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("LibertyManagerImpl.getDiscovery:" + "ResourceOffering: no FSSession found");
}
return null;
}
NodeList bootStrapRO = session.getBootStrapResourceOfferings();
if (bootStrapRO == null || bootStrapRO.getLength() == 0) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("LibertyManagerImpl.getDiscovery:" + "ResourceOffering: bootstrap resource offering is null");
}
return null;
}
ResourceOffering offering = new ResourceOffering((Element) bootStrapRO.item(0));
return offering.toString();
} catch (SessionException se) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("LibertyManagerImpl.getDiscoveryResource" + "Offering: SessionException", se);
}
throw new RemoteException(FSUtils.bundle.getString("invalidSSOToken"));
} catch (DiscoveryException de) {
FSUtils.debug.error("LibertyManagerImpl.getDiscoveryResource" + "Offering: Resource Offering parsing error", de);
throw new RemoteException(FSUtils.bundle.getString("invalidResourceOffering"));
}
}
use of com.sun.identity.liberty.ws.disco.DiscoveryException in project OpenAM by OpenRock.
the class LibertyManagerClient method getDiscoveryServiceCredential.
/**
* Returns the discovery service credential.
* @param token Single Sign On Token.
* @param hostProviderID Hosted <code>ProviderID</code>.
* @return <code>SecurityAssertion</code> Discovery Service Bootstrap
* Credential.
* @exception FSException if any failure.
*/
public SecurityAssertion getDiscoveryServiceCredential(Object token, String hostProviderID) throws FSException {
try {
String tokenID = SessionManager.getProvider().getSessionID(token);
String cacheKey = tokenID + DISCO_CRED;
SecurityAssertion cred = (SecurityAssertion) bootStrapCache.get(cacheKey);
if (cred != null) {
return cred;
}
String[] objs = { tokenID, hostProviderID };
String credential = (String) client.send("getDiscoveryServiceCredential", objs, null, null);
if ((credential == null) || (credential.length() == 0)) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("LibertyManagerClient.getDiscovery" + "ServiceCredential: Credential is null or empty");
}
return null;
}
Document doc = XMLUtils.toDOMDocument(credential, FSUtils.debug);
cred = new SecurityAssertion(doc.getDocumentElement());
bootStrapCache.put(cacheKey, cred);
return cred;
} catch (SessionException se) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("LibertyManagerClient.getDiscovery" + "ServiceCredential: InvalidSessionToken", se);
}
throw new FSException(FSUtils.bundle.getString("invalidSSOToken"));
} catch (DiscoveryException de) {
FSUtils.debug.error("LibertyManagerClient.getDiscovery" + "ServiceCredential: InvalidAssertion", de);
throw new FSException(FSUtils.bundle.getString("invalidCredential"));
} catch (Exception ex) {
FSUtils.debug.error("LibertyManagerClient.getDiscovery" + "ResourceOffering: SOAPClient Exception", ex);
throw new FSException(FSUtils.bundle.getString("soapException"));
}
}
Aggregations