}
private void remove(CredentialsModelData data, boolean all) {
/* Remove normalized link and realm */
ICredentialsProvider provider = fConService.getCredentialsProvider(data.getNormalizedLink());
if (provider != null) {
try {
provider.deleteAuthCredentials(data.getNormalizedLink(), data.getRealm());
} catch (CredentialsException e) {
Activator.getDefault().logError(e.getMessage(), e);
}
}
/* Remove all other stored Credentials matching normalized link and realm if set */
if (all) {
Collection<IBookMark> bookmarks = DynamicDAO.loadAll(IBookMark.class);
for (IBookMark bookmark : bookmarks) {
String realm = (String) bookmark.getProperty(Controller.BM_REALM_PROPERTY);
URI feedLink = bookmark.getFeedLinkReference().getLink();
URI normalizedLink = URIUtils.normalizeUri(feedLink, true);
/*
* If realm is null, then this bookmark successfully loaded due to another bookmark
* that the user successfully authenticated to. If the realm is not null, then we
* have to compare the realm to ensure that no credentials from the same host but
* a different realm gets removed.
*/
if ((realm == null || realm.equals(data.getRealm())) && normalizedLink.equals(data.getNormalizedLink())) {
provider = fConService.getCredentialsProvider(feedLink);
if (provider != null) {
try {
provider.deleteAuthCredentials(feedLink, null); //Null as per contract in DefaultProtocolHandler
bookmark.removeProperty(Controller.BM_REALM_PROPERTY);
} catch (CredentialsException e) {
Activator.getDefault().logError(e.getMessage(), e);
}
}