001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: FSAccountFedInfo.java,v 1.4 2008/06/25 05:46:39 qcheng Exp $
026 * Portions Copyrighted 2014 ForgeRock AS
027 */
028
029package com.sun.identity.federation.accountmgmt;
030
031import com.sun.identity.federation.common.IFSConstants;
032import com.sun.identity.federation.common.FSUtils;
033import com.sun.identity.saml.assertion.NameIdentifier;
034
035/**
036 * This class handles the information of federated user account.
037 * @supported.api
038 * @deprecated since 12.0.0
039 */
040@Deprecated
041public class FSAccountFedInfo {
042
043    /**
044     * Specifies provider's (SP/IDP) ID.
045     * It will always be a remote provider's ID.
046     */
047    private String providerID = "";
048    
049    /**
050     * Contains NameIdentifier sent to other side in federation process.
051     */
052    private NameIdentifier localNameIdentifier = null;
053    
054    /**
055     * Contains NameIdentifier received from other side in federation process.
056     */
057    private NameIdentifier remoteNameIdentifier = null;
058    
059    /**
060     * Represents user's federation status (Active/Inactive).
061     */
062    private boolean isActive = true;
063
064    /**
065     * Represents the federation type
066     */ 
067    private boolean isAffiliationFed = false;
068    
069    /*
070     * Represents that in a specific federation remote deployement 
071     * participated as SP or IDP.
072     */
073    private boolean isRoleIDP = true;
074    
075    /**
076     * Default Constructor.
077     */
078    FSAccountFedInfo() {
079    }
080
081    /**
082     * Constructor.
083     * @param providerID  Specifies the provider's (SP/IDP) ID.
084     * @param nameIdentifier  Contains NameIdentifier sent/received 
085     *     in federation process.
086     * @param nameIdentifierType indicates if IdentifierType is of type 
087     *     LOCAL or REMOTE
088     * @param isRoleIDP Represents that in a specific federation remote
089     *     deployement participated as SP or IDP.
090     * @throws FSAccountMgmtException if illegal argument passed.
091     */
092    public FSAccountFedInfo(
093        String providerID, 
094        NameIdentifier nameIdentifier,
095        int nameIdentifierType, 
096        boolean isRoleIDP)
097        throws FSAccountMgmtException
098    {
099        if (nameIdentifierType == IFSConstants.LOCAL_NAME_IDENTIFIER) {
100            init(providerID, 
101                 nameIdentifier, 
102                 null, 
103                 isRoleIDP);
104        }  else if (nameIdentifierType == IFSConstants.REMOTE_NAME_IDENTIFIER) {
105            init(providerID, 
106                 null, 
107                 nameIdentifier, 
108                 isRoleIDP);
109        } else {
110            FSUtils.debug.error("FSAccountFedInfo.Constructor() : Invalid" +
111                " Argument : Invalid Name Identifier Type");
112            throw new FSAccountMgmtException(
113                IFSConstants.INVALID_NAME_IDENTIFIER_TYPE, null);
114        }
115    }
116    
117    /**
118     * Constructor.
119     * @param providerID Specifies provider's (SP/IDP) ID.
120     * @param localNameIdentifier Contains NameIdentifier sent to other side 
121     *     in federation process.
122     * @param remoteNameIdentifier Contains NameIdentifier received from
123     *     other side in federation process.
124     * @param isRoleIDP Represents that in a specific federation remote
125     *     deployement participated as SP or IDP.
126     * @throws FSAccountMgmtException if illegal argument passed.
127     */
128    public FSAccountFedInfo(
129        String providerID, 
130        NameIdentifier localNameIdentifier,
131        NameIdentifier remoteNameIdentifier, 
132        boolean isRoleIDP)
133        throws FSAccountMgmtException
134    {
135        init(providerID, 
136            localNameIdentifier, 
137            remoteNameIdentifier, 
138            isRoleIDP);
139    }
140    
141    /**
142     * Initializes the account federation information object. 
143     * @param providerID Specifies provider's (SP/IDP) ID.
144     *  Always Remote provider.
145     * @param localNameIdentifier Contains NameIdentifier sent to other side 
146     *  in federation process.
147     * @param remoteNameIdentifier Contains NameIdentifier received from
148     *  other side in federation process.
149     * @param isRoleIDP Represents that in a specific federation remote
150     *  deployement participated as SP or IDP.
151     * @throws FSAccountMgmtException if illegal argument passed.
152     */
153    private void init(
154        String providerID, 
155        NameIdentifier localNameIdentifier,
156        NameIdentifier remoteNameIdentifier, 
157        boolean isRoleIDP)
158        throws FSAccountMgmtException
159    {
160        if ((providerID == null) || (providerID.length() <= 0)) {
161            FSUtils.debug.error(
162                "FSAccountFedInfo.init(): Invalid Argument: providerID is " +
163                providerID);
164            throw new
165                FSAccountMgmtException(IFSConstants.NULL_PROVIDER_ID, null);
166        }
167        
168        if (localNameIdentifier == null && remoteNameIdentifier == null) {
169            FSUtils.debug.error("FSAccountFedInfo.Constructor(): Invalid " +
170                "Argument: both NameIdentifiers are null");
171            throw new FSAccountMgmtException(
172                IFSConstants.NULL_NAME_IDENTIFIER, null);
173        }
174        
175        this.providerID = providerID;
176        this.localNameIdentifier = localNameIdentifier;
177        this.remoteNameIdentifier = remoteNameIdentifier;
178        this.isRoleIDP = isRoleIDP;
179        this.isActive = true;
180        
181        if (FSUtils.debug.messageEnabled()) {
182            FSUtils.debug.message("FSAccountFedInfo.init() : " + 
183                "providerID :: " + this.providerID +
184                ", isRoleIDP :: " + this.isRoleIDP);
185            if (localNameIdentifier != null ) {
186                FSUtils.debug.message(
187                    "FSAccountFedInfo.init() : localNameIdentifier" +
188                    this.localNameIdentifier.toString());
189            }
190            if (remoteNameIdentifier != null ) {
191                FSUtils.debug.message(
192                    "FSAccountFedInfo.init() : remoteNameIdentifier" +
193                    this.remoteNameIdentifier.toString());
194            }
195        }
196    }
197    
198    /**
199     * Returns provider's (SP/IDP) ID.
200     * @return remote provider's id
201     * @supported.api
202     */
203    public String getProviderID() {
204        return this.providerID;
205    }
206    
207    /**
208     * Sets provider's ID.
209     * @param providerID - remote provider's id
210     */
211    void setProviderID(String providerID) {
212        this.providerID = providerID;
213    }
214    
215    /**
216     * Sets value in local field.
217     * @param localNameIdentifier Contains NameIdentifier sent to other  
218     *  side in federation process.
219     */
220    public void setLocalNameIdentifier(
221        NameIdentifier localNameIdentifier)
222    {
223        this.localNameIdentifier = localNameIdentifier;
224    }
225    
226    /**
227     * Returns local NameIdentifier sent to other side(SP/IDP).
228     * @return local NameIdentifier sent to other side
229     * @supported.api
230     */
231    public NameIdentifier getLocalNameIdentifier() {
232        return this.localNameIdentifier;
233    }
234    
235    /**
236     * Sets value in local field.
237     * @param remoteNameIdentifier Contains NameIdentifier received from
238     *  other side in federation process.
239     */
240    public void setRemoteNameIdentifier(
241        NameIdentifier remoteNameIdentifier) 
242    {
243        this.remoteNameIdentifier = remoteNameIdentifier;
244    }
245    
246    /**
247     * Returns remote NameIdentifier received from other side(SP/IDP).
248     * @return remote NameIdentifier received from other side
249     * @supported.api
250     */
251    public NameIdentifier getRemoteNameIdentifier() {
252        return this.remoteNameIdentifier;
253    }
254    
255    /**
256     * Sets Federation Status as active.
257     */
258    public void activateFedStatus() {
259        this.isActive = true;
260    }
261    
262    /**
263     * Sets Federation Status as Inactive.
264     */
265    public void deActivateFedStatus() {
266        this.isActive = false;
267    }
268    
269    /**
270     * Returns true/false if Federation Status is Active/Inactive.
271     * @return true/false if Federation Status is Active/Inactive.
272     */
273    public boolean isFedStatusActive() {
274        return this.isActive;
275    }
276    
277    /**
278     * Represents that in a specific federation remote
279     * deployement participated as SP or IDP.
280     * @return true if in a specific federation remote
281     * deployement participated as IDP.
282     * And returns false if as SP.
283     * @supported.api
284     */    
285    public boolean isRoleIDP() {
286        return this.isRoleIDP;
287    }
288
289    /** 
290     * Represents that in a specific federation remote
291     * deployement participated as SP or IDP.
292     * @param isRoleIDP  Represents that in a specific federation remote
293     * deployement participated as SP or IDP.
294     */    
295    void setRole(boolean isRoleIDP) {
296        this.isRoleIDP = isRoleIDP;
297    }
298
299    /**
300     * Sets the affiliation flag.
301     * @param isAffiliationFed true if the federation is affiliation type.
302     */ 
303    public void setAffiliation(boolean isAffiliationFed) {
304        this.isAffiliationFed = isAffiliationFed;
305    }
306
307    /**
308     * Gets the affiliation federation type.
309     * @return true if the federation is of affiliation type.
310     * @supported.api
311     */ 
312    public boolean getAffiliation() {
313        return isAffiliationFed;
314    }
315}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.