/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: FSAccountManager.java,v 1.5 2008/06/25 05:46:39 qcheng Exp $
*
*/
/**
* This class is used for storing & retrieving user account's federation
* specific information.
*/
public class FSAccountManager {
/**
* static variable to store AccountManager .
*/
/**
* additional SP filter to check, this is for the case when two SP
* are federated with same IDP
*/
/**
* Default Constructor.
* @param metaAlias hosted provider's meta alias
* @throws FSAccountMgmtException if error occurred.
*/
throws FSAccountMgmtException
{
try {
{
}
if (hostedConfig == null) {
throw new FSAccountMgmtException(
}
}
"FSAccountManager.getInstance() : Exception: ", de);
}
}
/**
* Gets an Object for FSAccountManager Class.
* Used to instantiate the Class.
* @param metaAlias meta alias of hosted provider
* @return FSAccountManager Object.
* @throws FSAccountMgmtException if error occurred.
*/
throws FSAccountMgmtException
{
"FSAccountManager.getInstance: meta aliasis null.");
throw new FSAccountMgmtException(
}
synchronized(instanceMap) {
}
}
}
return manager;
}
/**
* Stores Account's federation Info in data store.
* @param userID user id
* @param fedInfo Account federation info as FSAccountFedInfo object.
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @throws FSAccountMgmtException if illegal argument passed.
*/
public void writeAccountFedInfo(
throws FSAccountMgmtException
{
"FSAccountManager.writeAccountFedInfo() : called");
"Invalid Argument : user ID is NULL");
}
if (fedInfoKey == null) {
"Invalid Argument : FedInfo key is NULL");
throw new FSAccountMgmtException(
}
"Invalid Argument : FedInfo is NULL");
throw new FSAccountMgmtException(
}
try {
}
if (existFedInfoKeySet == null) {
existFedInfoKeySet = new HashSet();
} else if (!existFedInfoKeySet.isEmpty()) {
while(i.hasNext()) {
"FSAccountManager.writeAccountFedInfo():" +
"AccountFedInfo Key Already Exists, " +
"will overwrite.");
}
break;
}
}
}
if (existFedInfoSet == null) {
existFedInfoSet = new HashSet();
} else if (!existFedInfoSet.isEmpty()) {
while(i.hasNext()) {
"FSAccountManager.writeAccountFedInfo():" +
" AccountFedInfo Already Exists, will " +
"overwrite");
}
break;
}
}
}
"FSAccountManager.writeAccountFedInfo(): Key : " +
fedInfoKeyStr + ", Value : " +
fedInfoStr + " : Added ");
}
} catch (DataStoreProviderException de) {
"FSAccountManager.writeAccountFedInfo(): Exception: ", de);
}
}
/**
* Removes Account's federation Info in data store.
* @param userID user id
* @param fedInfo Account federation info as FSAccountFedInfo object.
* @throws FSAccountMgmtException if illegal argument passed.
* TODO, this may remove the wrong info key, as two
* SP could federation with same IDP
* use the one with providerID parameter
*/
throws FSAccountMgmtException
{
"Invalid Argument : FedInfo is NULL");
throw new
}
try {
if (existFedInfoSet == null) {
existFedInfoSet = new HashSet();
} else if (!existFedInfoSet.isEmpty()) {
+ fedInfoStr);
}
{
}
}
"FSAccountManager.removeAccountFedInfo(): Exception: ", se);
}
}
/**
* Stores Account's federation Info in data store.
* @param userID user id
* @param fedInfo Account federation info as FSAccountFedInfo object.
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @param oldFedInfoKey Account Fed Info Key which contains NameSpace
* @throws FSAccountMgmtException if illegal argument passed.
*/
public void writeAccountFedInfo(
throws FSAccountMgmtException
{
}
/**
* Removes Account's federation Info Key in data store.
* @param userID user id
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @throws FSAccountMgmtException if illegal argument passed.
*/
public void removeAccountFedInfoKey(
throws FSAccountMgmtException
{
"FSAccountManager.removeAccountFedInfoKey():called");
+ "Invalid Argument : user ID is NULL");
}
if (fedInfoKey == null) {
+ "Invalid Argument : FedInfo key is NULL");
throw new FSAccountMgmtException(
}
try {
while(i.hasNext()) {
"FSAccountManager.removeAccountFedInfoKey():" +
"Account Fed Info Key Exists, will remove it");
}
break;
}
}
}
} catch (DataStoreProviderException ame) {
"FSAccountManager.removeAccountFedInfoKey():Exception:", ame);
}
}
/**
* Removes Account's federation Info in data store for given providerID
* in fedInfo object.
* @param userID user id
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @param providerID Remote ProviderID value.
* @throws FSAccountMgmtException - If Account fed info is not found for
* given user & given ProviderID.
*/
public void removeAccountFedInfo(
throws FSAccountMgmtException
{
"FSAccountManager.removeAccountFedInfo(): userID=" + userID +
", providerID=" + providerID);
}
if (fedInfoKey == null) {
"Invalid Argument : FedInfo key is NULL");
throw new FSAccountMgmtException(
}
"Invalid Argument : providerID is NULL");
throw new
}
+ "Invalid Argument : user ID is NULL");
}
try {
boolean found = false;
while(i.hasNext()) {
"FSAccountManager.removeAccountFedInfo():" +
"Account Fed Info Key Exists, will remove it");
}
found = true;
break;
}
}
}
while(i.hasNext()) {
{
"FSAccountManager.removeAccountFedInfo():" +
"Account Fed Info Exists, will remove it");
}
found = true;
break;
}
}
}
if (found) {
} else {
"Account Federation Info not Found");
throw new FSAccountMgmtException(
}
} catch (DataStoreProviderException ame) {
"FSAccountManager.removeAccountFedInfo():Exception:", ame);
}
}
/**
* Reads Account's federation Info from data store for given
* providerID and returns value as fedInfo object.
* Returns null if value not found for given providerID
* @param userID user ID.
* @param providerID Remote ProviderID value.
* @return Account's federation Info.
* Null if no Account Federation info value for given providerID.
* @throws FSAccountMgmtException if an error occurred.
*/
throws FSAccountMgmtException
{
}
/**
* Reads Account's federation Info from data store for given
* providerID and returns value as fedInfo object.
* Returns null if value not found for given providerID
* @param userID user ID.
* @param providerID Remote ProviderID value.
* @param nameIDValue fedinfo with this name ID value is to be found.
* @return Account's federation Info.
* Null if no Account Federation info value for given providerID.
* @throws FSAccountMgmtException if an error occurred.
*/
throws FSAccountMgmtException
{
"FSAccountManager.readAccountFedInfo() : user=" + userID +
}
"Invalid Argument : user ID is NULL");
}
"Invalid Argument : providerID is NULL");
throw new
}
try {
} catch (DataStoreProviderException ame) {
"FSAccountManager.readAccountFedInfo():Exception:", ame);
}
while(i.hasNext()) {
(nameIDValue == null ||
{
// accountFedInfo exists for given providerID
"FSAccountManager.readAccountFedInfo(): " +
" value found: " + existFedInfoStr);
}
if (!afi.isFedStatusActive()) {
return null;
}
return afi;
}
}
}
"FSAccountManager.readAccountFedInfo(): value with user: " +
}
return null;
}
/**
* Reads All Account's federation Info from data store for given
* user identity and returns a Set of ProviderIDs with which user
* is federated (FedStatus is Active).
* @param userID user identity
* @return Set of ProviderIDs with which user is federated (FedStatus
* is Active).
* @throws FSAccountMgmtException if an error occurred.
*/
throws FSAccountMgmtException
{
} else {
}
}
/**
* Reads All Account's federation Info from data store for given
* user identity and providerID. Returns a Set of ProviderIDs
* with which user is federated (FedStatus is Active).
* @param userID user identity
* @param providerID local provider ID
* @return Set of ProviderIDs with which user is federated (FedStatus
* is Active).
* @throws FSAccountMgmtException if error occurred.
*/
throws FSAccountMgmtException
{
"FSAccountManager.readAllFedProviderID() : userID=" + userID +
", providerID=" + providerID);
}
+ ":Invalid Argument : user ID is NULL");
}
try {
} catch (DataStoreProviderException ame) {
"FSAccountManager.readAllFederatedProviderID():Exception:",
ame);
}
while(i.hasNext()) {
if (afi.isFedStatusActive()) {
if (providerID == null) {
} else if (
{
}
}
}
}
return providerIDSet;
}
/**
* for given providerID.
* @param userID user identity
* @param providerID Remote ProviderID value.
* for given providerID.
* @throws FSAccountMgmtException - If Account fed info is not found for
* given user & given ProviderID.
*/
public boolean isFederationActive(
throws FSAccountMgmtException
{
"Invalid Argument : user ID is NULL");
}
"Invalid Argument : ProviderID is NULL");
throw new FSAccountMgmtException(
}
try {
} catch (DataStoreProviderException ame) {
"FSAccountManager.isFederationActive() :Exception: ", ame);
}
while(i.hasNext()) {
// accountFedInfo exists for given providerID
"FSAccountManager.isFederationActive(): " +
"value found: " + existFedInfoStr);
}
if (afi.isFedStatusActive()) {
return true;
}
return false;
}
}
}
"Account Federation Info not Found");
throw new FSAccountMgmtException(
}
/**
* Returns true If Any Active federation is found where idpRole is true
* means local deployment worked as SP in that federation and federation
* is still Active.
* @param userID user id
* @return true If Any Active federation is found where idpRole is true
* means local deployment worked as SP in that federation and
* federation is still Active.
* @throws FSAccountMgmtException - If Account fed info is not found for
* given user.
*/
public boolean hasAnyActiveFederation(
throws FSAccountMgmtException
{
"FSAccountManager.hasAnyActiveFederation():called");
"Invalid Argument : user ID is NULL");
}
try {
} catch (DataStoreProviderException ame) {
"FSAccountManager.hasAnyActiveFederation():Exception: ", ame);
}
while(i.hasNext()) {
// If Any Active federation is found where idpRole is true,
// return true.
// Means local deployment worked as SP in that federation.
return true;
}
}
return false;
}
// return false in case user account federation info not found
// since all federtation info will be cleaned up once terminated
return false;
}
/**
* Searches user with given combination of ProviderID & Opaque handle
* in Default Organization.
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @param env - Extra parameters that can be used for user mapping.
* @throws FSAccountMgmtException - If Unable to get Organization
* @return User DN if user found with given combination else returns null.
* If Some error occurs returns null.
*/
throws FSAccountMgmtException
{
}
/**
* Searches user with given combination of ProviderID & Opaque handle
* in given Organization.
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* @param orgDN organization DN.
* @param env Extra parameters that can be used for user mapping.
* @throws FSAccountMgmtException - If Unable to get Organization.
* @return User DN if user found with given combination else returns null.
* If Some error occurs returns null.
*/
throws FSAccountMgmtException
{
if (fedInfoKey == null) {
"Invalid Argument : fedInfoKey is NULL");
throw new FSAccountMgmtException(
}
}
/**
* Gets the user by using a given search filter.
* @param avPair Attribute Value Pair to be used in finding the user.
* @param orgDN Organization DN.
* @param env Extra parameters that can be used for user mapping.
* @exception FSAccountMgmtException if an error occurred.
*/
throws FSAccountMgmtException
{
}
}