8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: DCTreeServicesImpl.java,v 1.4 2008/06/25 05:41:26 qcheng Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington * Portions Copyrighted 2015 ForgeRock AS.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.iplanet.am.sdk.remote;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.am.sdk.AMException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.am.sdk.AMSDKBundle;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.am.sdk.common.DCTreeServicesHelper;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.am.sdk.common.IDCTreeServices;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.iplanet.sso.SSOToken;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.debug.Debug;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.shared.jaxrpc.SOAPClient;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshottimport org.forgerock.openam.session.SessionCookies;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.rmi.RemoteException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class DCTreeServicesImpl extends DCTreeServicesHelper implements
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster IDCTreeServices {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private SOAPClient client;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott private final SessionCookies sessionCookies;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Debug debug = RemoteServicesImpl.getDebug();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public DCTreeServicesImpl(SOAPClient soapClient) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster client = soapClient;
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott this.sessionCookies = SessionCookies.getInstance();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getOrganizationDN(SSOToken token, String domainName)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws AMException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster try {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster Object[] objs = { token.getTokenID().toString(), domainName };
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return ((String) client.send(client.encodeMessage(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "getOrgDNFromDomain", objs),
35ab1c5bca11317474fe12bdd8d22c17cdaf2697Robert Wapshott sessionCookies.getLBCookie(token.getTokenID().toString()), null));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (AMRemoteException amrex) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("DCTreeServicesImpl.getOrganizationDN()- "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "encountered exception=", amrex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw RemoteServicesImpl.convertException(amrex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (RemoteException rex) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("DCTreeServicesImpl.getOrganizationDN()- "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "encountered exception=", rex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new AMException(AMSDKBundle.getString("1000"), "1000");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } catch (Exception ex) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.error("DCTreeServicesImpl.getOrganizationDN()- "
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster + "encountered exception=", ex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throw new AMException(AMSDKBundle.getString("1000"), "1000");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}