a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The contents of this file are subject to the terms
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * of the Common Development and Distribution License
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * (the License). You may not use this file except in
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * compliance with the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You can obtain a copy of the License at
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * See the License for the specific language governing
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * permission and limitations under the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * When distributing Covered Code, include this CDDL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Header Notice in each file and include the License file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * If applicable, add the following below the CDDL Header,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * with the fields enclosed by brackets [] replaced by
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * your own identifying information:
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * $Id: FSScoping.java,v 1.2 2008/06/25 05:46:45 qcheng Exp $
f948ca04a28ccfeed9633bf4b0fb0d2c59c37478David Luna * Portions Copyrighted 2014 ForgeRock AS
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.common.FSUtils;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.common.IFSConstants;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.message.common.FSMsgException;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.message.common.IDPEntries;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.message.common.IDPEntry;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.shared.encode.URLEncDec;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This class <code>FSScoping</code> creates scoping element for the
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * authentication request.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @supported.all.api
f948ca04a28ccfeed9633bf4b0fb0d2c59c37478David Luna * @deprecated since 12.0.0
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Default constructor
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Constructor creates <code>FSScoping</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param idpList the <code>FSIDPList</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param proxyCount the number of proxies
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public FSScoping(FSIDPList idpList, int proxyCount) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Constructor creates <code>FSScoping</code> object from
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * the Document Element.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param root the Document Element .
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws FSMsgException if there is a failure creating this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public FSScoping(Element root) throws FSMsgException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSScoping(Element): null input");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if(tagName == null || !tagName.equals("Scoping")) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSScoping(Element): wrong input");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String count = XMLUtils.getElementValue((Element)child);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSScoping(Element): invalid proxy" +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets the proxy count.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param count number of proxies
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the proxy count.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return number of proxies.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Sets preferred ordered List of IDPs that is known to SP for proxying.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param idpList the <code>FSIDPList</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the preferred IDPs list in an authentication request.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return the <code>FSIDPList</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns a <code>XML</code> string representation of this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return XML String representing this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws FSMsgException if there is an error creating
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * the XML string or if the required elements to create
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * the string do not conform to the schema.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public String toXMLString() throws FSMsgException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster return toXMLString(true, true);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Creates a String representation of this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param includeNS : Determines whether or not the namespace qualifier
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * is prepended to the Element when converted
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param declareNS : Determines whether or not the namespace is declared
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * within the Element.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return string containing the valid XML for this element.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws FSMsgException if there is an error.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public String toXMLString(boolean includeNS, boolean declareNS)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append("<").append(prefix).append("Scoping")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append("<").append(prefix).append("ProxyCount").append(">")
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster .append(proxyCount).append("</").append(prefix)
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster xml.append("</").append(prefix).append("Scoping").append(">\n");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns an URL Encoded String.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return a url encoded query string.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws FSMsgException if there is an error.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public String toURLEncodedQueryString() throws FSMsgException {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSScoping.toURLEncodedQueryString: " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "proxyCount is not defined.");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster throw new FSMsgException("proxyCountNotDefined",null);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster sb.append("ProxyCount=").append(proxyCount).append("&");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster StringBuffer strProviders = new StringBuffer(100);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns <code>FSScoping</code> object. The
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * object is creating by parsing the <code>HttpServletRequest</code>
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param request the <code>HttpServletRequest</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @throws FSMsgException if there is an error creating this object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public static FSScoping parseURLEncodedRequest(HttpServletRequest request) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String count = request.getParameter("ProxyCount");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSScoping.parseURLEncodedRequest:" +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "proxyCount can not be parsed.");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String[] idps = request.getParameterValues("IDPEntries");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster IDPEntry entry = new IDPEntry(providerID, null, null);