Search in sources :

Example 6 with DiscoveryException

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;
}
Also used : NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) ArrayList(java.util.ArrayList) List(java.util.List) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException)

Example 7 with DiscoveryException

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);
    }
}
Also used : Document(org.w3c.dom.Document) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) JAXBException(javax.xml.bind.JAXBException)

Example 8 with DiscoveryException

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"));
    }
}
Also used : ResourceOffering(com.sun.identity.liberty.ws.disco.ResourceOffering) NodeList(org.w3c.dom.NodeList) FSSession(com.sun.identity.federation.services.FSSession) SessionException(com.sun.identity.plugin.session.SessionException) RemoteException(java.rmi.RemoteException) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException)

Example 9 with DiscoveryException

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"));
    }
}
Also used : FSException(com.sun.identity.federation.common.FSException) SessionException(com.sun.identity.plugin.session.SessionException) SecurityAssertion(com.sun.identity.liberty.ws.security.SecurityAssertion) Document(org.w3c.dom.Document) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) DiscoveryException(com.sun.identity.liberty.ws.disco.DiscoveryException) SessionException(com.sun.identity.plugin.session.SessionException) FSException(com.sun.identity.federation.common.FSException)

Aggregations

DiscoveryException (com.sun.identity.liberty.ws.disco.DiscoveryException)9 SSOException (com.iplanet.sso.SSOException)3 IdRepoException (com.sun.identity.idm.IdRepoException)3 SessionException (com.sun.identity.plugin.session.SessionException)3 List (java.util.List)3 Document (org.w3c.dom.Document)3 NodeList (org.w3c.dom.NodeList)3 FSException (com.sun.identity.federation.common.FSException)2 AMIdentity (com.sun.identity.idm.AMIdentity)2 ResourceOffering (com.sun.identity.liberty.ws.disco.ResourceOffering)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 Element (org.w3c.dom.Element)2 SSOToken (com.iplanet.sso.SSOToken)1 FSSession (com.sun.identity.federation.services.FSSession)1 AMIdentityRepository (com.sun.identity.idm.AMIdentityRepository)1 Status (com.sun.identity.liberty.ws.common.Status)1 SecurityAssertion (com.sun.identity.liberty.ws.security.SecurityAssertion)1 SessionProvider (com.sun.identity.plugin.session.SessionProvider)1