Moving the untrustedMode setting into the marshalling ops
This commit is contained in:
parent
abcaf01525
commit
4a64428e48
2 changed files with 10 additions and 6 deletions
|
|
@ -277,6 +277,8 @@ trait RemoteMarshallingOps {
|
||||||
|
|
||||||
def system: ActorSystem
|
def system: ActorSystem
|
||||||
|
|
||||||
|
protected def useUntrustedMode: Boolean
|
||||||
|
|
||||||
def createMessageSendEnvelope(rmp: RemoteMessageProtocol): AkkaRemoteProtocol = {
|
def createMessageSendEnvelope(rmp: RemoteMessageProtocol): AkkaRemoteProtocol = {
|
||||||
val arp = AkkaRemoteProtocol.newBuilder
|
val arp = AkkaRemoteProtocol.newBuilder
|
||||||
arp.setMessage(rmp)
|
arp.setMessage(rmp)
|
||||||
|
|
@ -319,15 +321,15 @@ trait RemoteMarshallingOps {
|
||||||
messageBuilder
|
messageBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
def receiveMessage(remoteMessage: RemoteMessage, untrustedMode: Boolean) {
|
def receiveMessage(remoteMessage: RemoteMessage) {
|
||||||
val recipient = remoteMessage.recipient
|
val recipient = remoteMessage.recipient
|
||||||
|
|
||||||
remoteMessage.payload match {
|
remoteMessage.payload match {
|
||||||
case Left(t) ⇒ throw t
|
case Left(t) ⇒ throw t
|
||||||
case Right(r) ⇒ r match {
|
case Right(r) ⇒ r match {
|
||||||
case _: Terminate ⇒ if (untrustedMode) throw new SecurityException("RemoteModule server is operating is untrusted mode, can not stop the actor") else recipient.stop()
|
case _: Terminate ⇒ if (useUntrustedMode) throw new SecurityException("RemoteModule server is operating is untrusted mode, can not stop the actor") else recipient.stop()
|
||||||
case _: AutoReceivedMessage if (untrustedMode) ⇒ throw new SecurityException("RemoteModule server is operating is untrusted mode, can not pass on a AutoReceivedMessage to the remote actor")
|
case _: AutoReceivedMessage if (useUntrustedMode) ⇒ throw new SecurityException("RemoteModule server is operating is untrusted mode, can not pass on a AutoReceivedMessage to the remote actor")
|
||||||
case m ⇒ recipient.!(m)(remoteMessage.sender)
|
case m ⇒ recipient.!(m)(remoteMessage.sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ class ActiveRemoteClientHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
case arp: AkkaRemoteProtocol if arp.hasMessage ⇒
|
case arp: AkkaRemoteProtocol if arp.hasMessage ⇒
|
||||||
client.remoteSupport.receiveMessage(new RemoteMessage(arp.getMessage, client.remoteSupport, client.loader), untrustedMode = false) //TODO FIXME Sensible or not?
|
client.remoteSupport.receiveMessage(new RemoteMessage(arp.getMessage, client.remoteSupport, client.loader))
|
||||||
|
|
||||||
case other ⇒
|
case other ⇒
|
||||||
throw new RemoteClientException("Unknown message received in remote client handler: " + other, client.remoteSupport, client.remoteAddress)
|
throw new RemoteClientException("Unknown message received in remote client handler: " + other, client.remoteSupport, client.remoteAddress)
|
||||||
|
|
@ -359,6 +359,8 @@ class NettyRemoteSupport(_system: ActorSystem) extends RemoteSupport(_system) wi
|
||||||
private val remoteClients = new HashMap[RemoteAddress, RemoteClient]
|
private val remoteClients = new HashMap[RemoteAddress, RemoteClient]
|
||||||
private val clientsLock = new ReentrantReadWriteLock
|
private val clientsLock = new ReentrantReadWriteLock
|
||||||
|
|
||||||
|
override protected def useUntrustedMode = serverSettings.UNTRUSTED_MODE
|
||||||
|
|
||||||
protected[akka] def send(message: Any,
|
protected[akka] def send(message: Any,
|
||||||
senderOption: Option[ActorRef],
|
senderOption: Option[ActorRef],
|
||||||
recipientAddress: RemoteAddress,
|
recipientAddress: RemoteAddress,
|
||||||
|
|
@ -629,7 +631,7 @@ class RemoteServerHandler(
|
||||||
override def messageReceived(ctx: ChannelHandlerContext, event: MessageEvent) = try {
|
override def messageReceived(ctx: ChannelHandlerContext, event: MessageEvent) = try {
|
||||||
event.getMessage match {
|
event.getMessage match {
|
||||||
case remote: AkkaRemoteProtocol if remote.hasMessage ⇒
|
case remote: AkkaRemoteProtocol if remote.hasMessage ⇒
|
||||||
remoteSupport.receiveMessage(new RemoteMessage(remote.getMessage, remoteSupport, applicationLoader), UNTRUSTED_MODE)
|
remoteSupport.receiveMessage(new RemoteMessage(remote.getMessage, remoteSupport, applicationLoader))
|
||||||
|
|
||||||
case remote: AkkaRemoteProtocol if remote.hasInstruction ⇒
|
case remote: AkkaRemoteProtocol if remote.hasInstruction ⇒
|
||||||
val instruction = remote.getInstruction
|
val instruction = remote.getInstruction
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue