creds = message.getPayloadAsBytes();
creds = strategy.decrypt(creds, null);
}
catch (Exception e1)
{
throw new UnauthorisedException(CoreMessages.failedToReadPayload(), event, e1);
}
Authentication authentication;
try
{
authentication = new PGPAuthentication(userId, decodeMsgRaw(creds), event);
}
catch (Exception e1)
{
throw new UnauthorisedException(CoreMessages.failedToReadPayload(), event, e1);
}
final Authentication authResult;
try
{
authResult = getSecurityManager().authenticate(authentication);
}
catch (Exception e)
{
// Authentication failed
if (logger.isDebugEnabled())
{
logger.debug("Authentication request for user: " + userId + " failed: " + e.toString());
}
throw new UnauthorisedException(CoreMessages.authFailedForUser(userId), event, e);
}
// Authentication success
if (logger.isDebugEnabled())
{
logger.debug("Authentication success: " + authResult.toString());
}
SecurityContext context = getSecurityManager().createSecurityContext(authResult);
event.getSession().setSecurityContext(context);
try
{
updatePayload(message, getUnencryptedMessageWithoutSignature((PGPAuthentication)authResult), event);
// TODO RequestContext.rewriteEvent(new DefaultMuleMessage(
// getUnencryptedMessageWithoutSignature((PGPAuthentication)authResult)));
}
catch (Exception e2)
{
throw new UnauthorisedException(event, context, endpoint, this);
}
}