Commit f4ec2102 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

rpc: make gss context a property of the onc rpc service

parent f2993ece
......@@ -16,6 +16,7 @@
*/
package org.dcache.xdr;
import org.dcache.xdr.gss.GssProtocolFilter;
import com.sun.grizzly.Controller;
import com.sun.grizzly.ControllerStateListenerAdapter;
import com.sun.grizzly.DefaultProtocolChain;
......@@ -36,9 +37,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.dcache.xdr.gss.GssSessionManager;
import org.dcache.xdr.portmap.GenericPortmapClient;
import org.dcache.xdr.portmap.OncPortmapClient;
import org.dcache.xdr.portmap.OncRpcPortmap;
import org.ietf.jgss.GSSException;
public class OncRpcSvc {
......@@ -52,6 +55,12 @@ public class OncRpcSvc {
private final Controller _controller = new Controller();
private final CountDownLatch _serverReady = new CountDownLatch(1);
private final boolean _publish;
/**
* Handle RPCSEC_GSS
*/
private GssSessionManager _gssSessionManager;
/**
* mapping of registered programs.
*/
......@@ -133,11 +142,6 @@ public class OncRpcSvc {
throw new IllegalArgumentException("TCP or UDP protocol have to be defined");
}
final ProtocolFilter protocolKeeper = new ProtocolKeeperFilter();
final ProtocolFilter rpcFilter = new RpcParserProtocolFilter();
final ProtocolFilter rpcProcessor = new RpcProtocolFilter();
final ProtocolFilter rpcDispatcher = new RpcDispatcher(_programs);
/*
* By default, a SelectionKey will be active for 30 seconds.
* If during that 30 seconds the client isn't pushing bytes
......@@ -171,29 +175,6 @@ public class OncRpcSvc {
_serverReady.countDown();
}
});
final ProtocolChain protocolChain = new DefaultProtocolChain();
protocolChain.addFilter(protocolKeeper);
protocolChain.addFilter(rpcFilter);
protocolChain.addFilter(rpcProcessor);
protocolChain.addFilter(rpcDispatcher);
((DefaultProtocolChain) protocolChain).setContinuousExecution(true);
ProtocolChainInstanceHandler pciHandler = new DefaultProtocolChainInstanceHandler() {
@Override
public ProtocolChain poll() {
return protocolChain;
}
@Override
public boolean offer(ProtocolChain pc) {
return false;
}
};
_controller.setProtocolChainInstanceHandler(pciHandler);
}
/**
......@@ -232,10 +213,47 @@ public class OncRpcSvc {
}
}
public void setGssSessionManager( GssSessionManager gssSessionManager) {
_gssSessionManager = gssSessionManager;
}
/**
* Start service.
*/
public void start() throws IOException {
final ProtocolFilter protocolKeeper = new ProtocolKeeperFilter();
final ProtocolFilter rpcFilter = new RpcParserProtocolFilter();
final ProtocolFilter rpcProcessor = new RpcProtocolFilter();
final ProtocolFilter rpcDispatcher = new RpcDispatcher(_programs);
final ProtocolChain protocolChain = new DefaultProtocolChain();
protocolChain.addFilter(protocolKeeper);
protocolChain.addFilter(rpcFilter);
protocolChain.addFilter(rpcProcessor);
// use GSS if configures
if (_gssSessionManager != null ) {
final ProtocolFilter gssManager = new GssProtocolFilter(_gssSessionManager);
protocolChain.addFilter(gssManager);
}
protocolChain.addFilter(rpcDispatcher);
((DefaultProtocolChain) protocolChain).setContinuousExecution(true);
ProtocolChainInstanceHandler pciHandler = new DefaultProtocolChainInstanceHandler() {
@Override
public ProtocolChain poll() {
return protocolChain;
}
@Override
public boolean offer(ProtocolChain pc) {
return false;
}
};
_controller.setProtocolChainInstanceHandler(pciHandler);
new Thread(_controller, _name).start();
try {
_serverReady.await();
......
......@@ -25,7 +25,7 @@ public class RpcException extends OncRpcException {
private final XdrAble _reply;
private final int _rejectStatus;
RpcException(int status, String msg, XdrAble reply) {
public RpcException(int status, String msg, XdrAble reply) {
super(msg);
_rejectStatus = status;
_reply = reply;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment