Skip to content

Commit

Permalink
Add error logging; remove password mandatory-ness; fix auth context
Browse files Browse the repository at this point in the history
  • Loading branch information
AFaust committed Jul 23, 2024
1 parent a143994 commit 5e36f2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ public String getPassword()
*/
public void setPassword(final String password)
{
ParameterCheck.mandatoryString("password", password);
this.password = password;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private Folder openFolder(final String folderPath)
}
catch (final MessagingException e)
{
LOGGER.warn("Failed to resolve folder", e);
throw new EmailMessageException("Failed to resolve folder " + folderPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ private Folder openFolder(final String folderPath)
}
catch (final MessagingException e)
{
LOGGER.warn("Failed to resolve folder", e);
throw new EmailMessageException("Failed to resolve folder " + folderPath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public String getIdentifier(final SynchWork entry)
public void beforeProcess() throws Throwable
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.clearCurrentSecurityContext();
AuthenticationUtil.setRunAsUserSystem();
this.originalLocale.set(I18NUtil.getLocaleOrNull());
I18NUtil.setLocale(this.importLocale);
}
Expand All @@ -320,7 +320,20 @@ public void process(final SynchWork entry) throws Throwable
final ImprovedEmailMessage message = this.imapClient.toImprovedEmailMessage(emailMessage);
try
{
this.emailService.importMessage(delivery, message);
// necessary to allow permissions for user mapped via from-address to take effect
// and user to be marked as creator
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.clearCurrentSecurityContext();
try
{
this.emailService.importMessage(delivery, message);
}
finally
{
// restoration required to allow TRANSACTION_COMMIT policies to work without permission issues
// specifically ImapContentPolicy
AuthenticationUtil.popAuthentication();
}

TransactionSupportUtil.bindListener(new TransactionListenerAdapter()
{
Expand Down

0 comments on commit 5e36f2d

Please sign in to comment.