use of com.sun.identity.plugin.datastore.DataStoreProviderException in project OpenAM by OpenRock.
the class FSAccountManager method hasAnyActiveFederation.
/**
* 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(String userID) throws FSAccountMgmtException {
FSUtils.debug.message("FSAccountManager.hasAnyActiveFederation():called");
if (userID == null) {
FSUtils.debug.error("FSAccountManager.hasAnyActiveFederation():" + "Invalid Argument : user ID is NULL");
throw new FSAccountMgmtException(IFSConstants.NULL_USER_DN, null);
}
Set existFedInfoSet = null;
try {
existFedInfoSet = provider.getAttribute(userID, FSAccountUtils.USER_FED_INFO_ATTR);
} catch (DataStoreProviderException ame) {
FSUtils.debug.error("FSAccountManager.hasAnyActiveFederation():Exception: ", ame);
throw new FSAccountMgmtException(ame.getMessage());
}
if (existFedInfoSet != null && !existFedInfoSet.isEmpty()) {
Iterator i = existFedInfoSet.iterator();
String existFedInfoStr = "";
while (i.hasNext()) {
existFedInfoStr = (String) i.next();
FSAccountFedInfo afi = FSAccountUtils.stringToObject(existFedInfoStr);
// Means local deployment worked as SP in that federation.
if (afi.isFedStatusActive() && afi.isRoleIDP()) {
return true;
}
}
return false;
}
// since all federtation info will be cleaned up once terminated
return false;
}
use of com.sun.identity.plugin.datastore.DataStoreProviderException in project OpenAM by OpenRock.
the class FSAccountManager method isFederationActive.
/**
* Returns true/false if Account's federation Status is Active / Inactive
* for given providerID.
* @param userID user identity
* @param providerID Remote ProviderID value.
* @return true/false if Account's federation Status is Active / Inactive
* for given providerID.
* @throws FSAccountMgmtException - If Account fed info is not found for
* given user & given ProviderID.
*/
public boolean isFederationActive(String userID, String providerID) throws FSAccountMgmtException {
FSUtils.debug.message("FSAccountManager.isFederationActive() : called");
if (userID == null) {
FSUtils.debug.error("FSAccountManager.isFederationActive():" + "Invalid Argument : user ID is NULL");
throw new FSAccountMgmtException(IFSConstants.NULL_USER_DN, null);
}
if ((providerID == null) || (providerID.length() <= 0)) {
FSUtils.debug.error("FSAccountManager.isFederationActive() : " + "Invalid Argument : ProviderID is NULL");
throw new FSAccountMgmtException(IFSConstants.NULL_PROVIDER_ID, null);
}
Set existFedInfoSet = null;
try {
existFedInfoSet = provider.getAttribute(userID, FSAccountUtils.USER_FED_INFO_ATTR);
} catch (DataStoreProviderException ame) {
FSUtils.debug.error("FSAccountManager.isFederationActive() :Exception: ", ame);
throw new FSAccountMgmtException(ame.getMessage());
}
if (existFedInfoSet != null && !existFedInfoSet.isEmpty()) {
String filter = FSAccountUtils.createFilter(providerID);
Iterator i = existFedInfoSet.iterator();
while (i.hasNext()) {
String existFedInfoStr = (String) i.next();
if (existFedInfoStr.indexOf(filter) >= 0) {
// accountFedInfo exists for given providerID
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAccountManager.isFederationActive(): " + "value found: " + existFedInfoStr);
}
FSAccountFedInfo afi = FSAccountUtils.stringToObject(existFedInfoStr);
if (afi.isFedStatusActive()) {
return true;
}
return false;
}
}
}
FSUtils.debug.error("FSAccountManager.isFederationActive() : " + "Account Federation Info not Found");
throw new FSAccountMgmtException(IFSConstants.ACT_FED_INFO_NOT_FOUND, null);
}
use of com.sun.identity.plugin.datastore.DataStoreProviderException in project OpenAM by OpenRock.
the class FSAccountManager method removeAccountFedInfoKey.
/**
* Removes Account's federation Info Key in data store.
* @param userID user id
* @param fedInfoKey Account Fed Info Key which contains NameSpace
* & opaque handle sent/received, which will be removed.
* @throws FSAccountMgmtException if illegal argument passed.
*/
public void removeAccountFedInfoKey(String userID, FSAccountFedInfoKey fedInfoKey) throws FSAccountMgmtException {
FSUtils.debug.message("FSAccountManager.removeAccountFedInfoKey():called");
if (userID == null) {
FSUtils.debug.error("FSAccountManager.removeAccountFedInfoKey():" + "Invalid Argument : user ID is NULL");
throw new FSAccountMgmtException(IFSConstants.NULL_USER_DN, null);
}
if (fedInfoKey == null) {
FSUtils.debug.error("FSAccountManager.removeAccountFedInfoKey():" + "Invalid Argument : FedInfo key is NULL");
throw new FSAccountMgmtException(IFSConstants.NULL_FED_INFO_KEY_OBJECT, null);
}
try {
Map attrMap = new HashMap();
Set existFedInfoKeySet = provider.getAttribute(userID, FSAccountUtils.USER_FED_INFO_KEY_ATTR);
if (existFedInfoKeySet != null && !existFedInfoKeySet.isEmpty()) {
Iterator i = existFedInfoKeySet.iterator();
String existFedInfoKeyStr = "";
String filter = FSAccountUtils.createFilter(fedInfoKey);
while (i.hasNext()) {
existFedInfoKeyStr = (String) i.next();
if (existFedInfoKeyStr.indexOf(filter) >= 0) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAccountManager.removeAccountFedInfoKey():" + "Account Fed Info Key Exists, will remove it");
}
existFedInfoKeySet.remove(existFedInfoKeyStr);
attrMap.put(FSAccountUtils.USER_FED_INFO_KEY_ATTR, existFedInfoKeySet);
provider.setAttributes(userID, attrMap);
break;
}
}
}
} catch (DataStoreProviderException ame) {
FSUtils.debug.error("FSAccountManager.removeAccountFedInfoKey():Exception:", ame);
throw new FSAccountMgmtException(ame.getMessage());
}
}
use of com.sun.identity.plugin.datastore.DataStoreProviderException in project OpenAM by OpenRock.
the class AccountUtils method removeAccountFederation.
/**
* Removes the account federation of a user.
* @param info <code>NameIDInfo</code> object.
* @param userID user identifie for which the account federation needs to
* be removed.
* @return true if the account federation is removed successfully.
* @exception SAML2Exception if any failure.
*/
public static boolean removeAccountFederation(NameIDInfo info, String userID) throws SAML2Exception {
SAML2Utils.debug.message("AccountUtils.removeAccountFederation:");
if (info == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullNameIDInfo"));
}
if (userID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullUserID"));
}
try {
Set existingFed = SAML2Utils.getDataStoreProvider().getAttribute(userID, getNameIDInfoAttribute());
Set existingInfoKey = SAML2Utils.getDataStoreProvider().getAttribute(userID, getNameIDInfoKeyAttribute());
if (existingFed == null || existingFed.isEmpty()) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.removeAccount" + "Federation: user does not have account federation infos.");
}
return false;
}
String infoValue = info.toValueString();
String infoKeyValue = info.getNameIDInfoKey().toValueString();
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.removeAccount" + "Federation: info to be removed:" + infoValue + "user=" + userID + "infoKeyValue = " + infoKeyValue);
}
if (existingFed.contains(infoValue)) {
existingFed.remove(infoValue);
if (existingInfoKey != null && existingInfoKey.contains(infoKeyValue)) {
existingInfoKey.remove(infoKeyValue);
}
Map map = new HashMap();
map.put(getNameIDInfoAttribute(), existingFed);
map.put(getNameIDInfoKeyAttribute(), existingInfoKey);
SAML2Utils.getDataStoreProvider().setAttributes(userID, map);
return true;
}
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.removeAccount" + "Federation: account federation info not found.");
}
return false;
} catch (DataStoreProviderException dse) {
SAML2Utils.debug.error("SAML2Utils.removeAccountFederation: " + "DataStoreProviderException", dse);
throw new SAML2Exception(dse.getMessage());
}
}
use of com.sun.identity.plugin.datastore.DataStoreProviderException in project OpenAM by OpenRock.
the class AccountUtils method getAccountFederation.
/**
* Returns the account federation information of a user for the given
* identity provider and a service provider.
* @param userID user id for which account federation needs to be returned.
* @param hostEntityID <code>EntityID</code> of the hosted entity.
* @param remoteEntityID <code>EntityID</code> of the remote entity.
* @return the account federation info object.
* null if the account federation does not exist.
* @exception SAML2Exception if account federation retrieval is failed.
*/
public static NameIDInfo getAccountFederation(String userID, String hostEntityID, String remoteEntityID) throws SAML2Exception {
SAML2Utils.debug.message("AccountUtils.getAccountFederation:");
if (userID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullUserID"));
}
if (hostEntityID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullHostEntityID"));
}
if (remoteEntityID == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("nullRemoteEntityID"));
}
try {
Set set = SAML2Utils.getDataStoreProvider().getAttribute(userID, getNameIDInfoAttribute());
if (set == null || set.isEmpty()) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.getAccount" + "Federation : user does not have any account federations.");
}
return null;
}
String filter = hostEntityID + DELIM + remoteEntityID + DELIM;
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.getAccountFederation: " + " filter = " + filter + " userID = " + userID);
}
String info = null;
for (Iterator iter = set.iterator(); iter.hasNext(); ) {
String value = (String) iter.next();
if (value.startsWith(filter)) {
info = value;
break;
}
}
if (info == null) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AccountUtils.getAccount" + "Federation : user does not have account federation " + " corresponding to =" + filter);
}
return null;
}
return NameIDInfo.parse(info);
} catch (DataStoreProviderException dse) {
SAML2Utils.debug.error("AccountUtils.readAccountFederation" + "Info: DataStoreProviderException", dse);
throw new SAML2Exception(dse.getMessage());
}
}
Aggregations