use of org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException in project carbon-identity-framework by wso2.
the class UserProfileAdmin method removeAssociateIDForUser.
/**
* Remove the association with the given federated identifier for the given user.
*
* @param username username of the user to be associated with
* @param idpID Identity Provider ID
* @param associatedID Federated Identity ID
* @throws UserProfileException
*/
public void removeAssociateIDForUser(String username, String idpID, String associatedID) throws UserProfileException {
String auditData = getAuditData(username, idpID, associatedID);
validateFederatedAssociationParameters(username, idpID, associatedID, auditData);
User user = getUser(username);
try {
getFederatedAssociationManager().deleteFederatedAssociation(user, idpID, associatedID);
audit(auditActionForDeleteAssociation, username, auditData, AUDIT_SUCCESS);
} catch (FederatedAssociationManagerException e) {
// order to preserve backward compatibility, this error is silently ignored.
if (!isFederatedAssociationDoesNotExistsError(e)) {
audit(auditActionForDeleteAssociation, username, auditData, AUDIT_FAIL);
String msg = "Error while removing association with federated IdP: " + idpID + " for user: " + username + " in tenant: " + getTenantDomain();
throw new UserProfileException(msg, e);
}
}
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException in project carbon-identity-framework by wso2.
the class UserProfileAdmin method associateIDForUser.
/**
* Associate the given user with the given federated identifier.
*
* @param username username of the user to be associated with
* @param idpID Identity Provider ID
* @param associatedID Federated Identity ID
* @throws UserProfileException
*/
public void associateIDForUser(String username, String idpID, String associatedID) throws UserProfileException {
User user = getUser(username);
String auditData = getAuditData(username, idpID, associatedID);
try {
getFederatedAssociationManager().createFederatedAssociation(user, idpID, associatedID);
audit(auditActionForCreateAssociation, username, auditData, AUDIT_SUCCESS);
} catch (FederatedAssociationManagerException e) {
audit(auditActionForCreateAssociation, username, auditData, AUDIT_FAIL);
String msg = "Error while creating association for user: " + username + " with federated IdP: " + idpID + " in tenant: " + getTenantDomain();
throw new UserProfileException(msg, e);
}
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException in project carbon-identity-framework by wso2.
the class UserProfileAdmin method getAssociatedAccounts.
private AssociatedAccountDTO[] getAssociatedAccounts(User user) throws FederatedAssociationManagerException, UserProfileException {
FederatedAssociation[] federatedAssociations = getFederatedAssociationManager().getFederatedAssociationsOfUser(user);
List<AssociatedAccountDTO> associatedAccountDTOS = new ArrayList<>();
for (FederatedAssociation federatedAssociation : federatedAssociations) {
String identityProviderName = getIdentityProviderName(getTenantDomain(), federatedAssociation.getIdp().getId());
associatedAccountDTOS.add(new AssociatedAccountDTO(federatedAssociation.getId(), identityProviderName, federatedAssociation.getFederatedUserId()));
}
return associatedAccountDTOS.toArray(new AssociatedAccountDTO[0]);
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException in project carbon-identity-framework by wso2.
the class UserProfileAdmin method getAssociatedIDs.
/**
* Return an array of federated identifiers associated with the logged in user.
*
* @return an array of AssociatedAccountDTO objects which contains the federated identifier info
* @throws UserProfileException
*/
public AssociatedAccountDTO[] getAssociatedIDs() throws UserProfileException {
String tenantAwareUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
User user = getUser(tenantAwareUsername);
try {
return getAssociatedAccounts(user);
} catch (FederatedAssociationManagerException e) {
String msg = "Error while retrieving federated identifiers associated for user: " + tenantAwareUsername + " in tenant: " + getTenantDomain();
throw new UserProfileException(msg, e);
}
}
use of org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException in project carbon-identity-framework by wso2.
the class UserProfileAdmin method removeAssociateID.
/**
* Remove the association with the given federated identifier for the logged in user.
*
* @param idpID Identity Provider ID
* @param associatedID Federated Identity ID
* @throws UserProfileException
*/
public void removeAssociateID(String idpID, String associatedID) throws UserProfileException {
String tenantAwareUsername = CarbonContext.getThreadLocalCarbonContext().getUsername();
User user = getUser(tenantAwareUsername);
try {
getFederatedAssociationManager().deleteFederatedAssociation(user, idpID, associatedID);
} catch (FederatedAssociationManagerException e) {
String msg = "Error while removing association with federated IdP: " + idpID + " for user: " + tenantAwareUsername + " in tenant: " + getTenantDomain();
throw new UserProfileException(msg, e);
}
}
Aggregations