Search in sources :

Example 11 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class TestPortmap method testRegistration.

@Test(timeout = 1000)
public void testRegistration() throws IOException, InterruptedException {
    XDR req = new XDR();
    RpcCall.getInstance(++xid, RpcProgramPortmap.PROGRAM, RpcProgramPortmap.VERSION, RpcProgramPortmap.PMAPPROC_SET, new CredentialsNone(), new VerifierNone()).write(req);
    PortmapMapping sent = new PortmapMapping(90000, 1, PortmapMapping.TRANSPORT_TCP, 1234);
    sent.serialize(req);
    byte[] reqBuf = req.getBytes();
    DatagramSocket s = new DatagramSocket();
    DatagramPacket p = new DatagramPacket(reqBuf, reqBuf.length, pm.getUdpServerLoAddress());
    try {
        s.send(p);
    } finally {
        s.close();
    }
    // Give the server a chance to process the request
    Thread.sleep(100);
    boolean found = false;
    @SuppressWarnings("unchecked") Map<String, PortmapMapping> map = (Map<String, PortmapMapping>) Whitebox.getInternalState(pm.getHandler(), "map");
    for (PortmapMapping m : map.values()) {
        if (m.getPort() == sent.getPort() && PortmapMapping.key(m).equals(PortmapMapping.key(sent))) {
            found = true;
            break;
        }
    }
    Assert.assertTrue("Registration failed", found);
}
Also used : DatagramSocket(java.net.DatagramSocket) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) DatagramPacket(java.net.DatagramPacket) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone) Map(java.util.Map) Test(org.junit.Test)

Example 12 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class TestRpcCall method testConstructor.

@Test
public void testConstructor() {
    Credentials credential = new CredentialsNone();
    Verifier verifier = new VerifierNone();
    int rpcVersion = RpcCall.RPC_VERSION;
    int program = 2;
    int version = 3;
    int procedure = 4;
    RpcCall call = new RpcCall(0, RpcMessage.Type.RPC_CALL, rpcVersion, program, version, procedure, credential, verifier);
    assertEquals(0, call.getXid());
    assertEquals(RpcMessage.Type.RPC_CALL, call.getMessageType());
    assertEquals(rpcVersion, call.getRpcVersion());
    assertEquals(program, call.getProgram());
    assertEquals(version, call.getVersion());
    assertEquals(procedure, call.getProcedure());
    assertEquals(credential, call.getCredential());
    assertEquals(verifier, call.getVerifier());
}
Also used : VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) CredentialsNone(org.apache.hadoop.oncrpc.security.CredentialsNone) Verifier(org.apache.hadoop.oncrpc.security.Verifier) Credentials(org.apache.hadoop.oncrpc.security.Credentials) Test(org.junit.Test)

Example 13 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class TestRpcDeniedReply method testConstructor.

@Test
public void testConstructor() {
    RpcDeniedReply reply = new RpcDeniedReply(0, ReplyState.MSG_ACCEPTED, RejectState.AUTH_ERROR, new VerifierNone());
    Assert.assertEquals(0, reply.getXid());
    Assert.assertEquals(RpcMessage.Type.RPC_REPLY, reply.getMessageType());
    Assert.assertEquals(ReplyState.MSG_ACCEPTED, reply.getState());
    Assert.assertEquals(RejectState.AUTH_ERROR, reply.getRejectState());
}
Also used : VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) Test(org.junit.Test)

Example 14 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class RpcProgramPortmap method messageReceived.

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    RpcInfo info = (RpcInfo) e.getMessage();
    RpcCall rpcCall = (RpcCall) info.header();
    final int portmapProc = rpcCall.getProcedure();
    int xid = rpcCall.getXid();
    XDR in = new XDR(info.data().toByteBuffer().asReadOnlyBuffer(), XDR.State.READING);
    XDR out = new XDR();
    if (portmapProc == PMAPPROC_NULL) {
        out = nullOp(xid, in, out);
    } else if (portmapProc == PMAPPROC_SET) {
        out = set(xid, in, out);
    } else if (portmapProc == PMAPPROC_UNSET) {
        out = unset(xid, in, out);
    } else if (portmapProc == PMAPPROC_DUMP) {
        out = dump(xid, in, out);
    } else if (portmapProc == PMAPPROC_GETPORT) {
        out = getport(xid, in, out);
    } else if (portmapProc == PMAPPROC_GETVERSADDR) {
        out = getport(xid, in, out);
    } else {
        LOG.info("PortmapHandler unknown rpc procedure=" + portmapProc);
        RpcAcceptedReply reply = RpcAcceptedReply.getInstance(xid, RpcAcceptedReply.AcceptState.PROC_UNAVAIL, new VerifierNone());
        reply.write(out);
    }
    ChannelBuffer buf = ChannelBuffers.wrappedBuffer(out.asReadOnlyWrap().buffer());
    RpcResponse rsp = new RpcResponse(buf, info.remoteAddress());
    RpcUtil.sendRpcResponse(ctx, rsp);
}
Also used : RpcInfo(org.apache.hadoop.oncrpc.RpcInfo) RpcCall(org.apache.hadoop.oncrpc.RpcCall) XDR(org.apache.hadoop.oncrpc.XDR) VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) RpcAcceptedReply(org.apache.hadoop.oncrpc.RpcAcceptedReply) RpcResponse(org.apache.hadoop.oncrpc.RpcResponse) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 15 with VerifierNone

use of org.apache.hadoop.oncrpc.security.VerifierNone in project hadoop by apache.

the class TestRpcAcceptedReply method testConstructor.

@Test
public void testConstructor() {
    Verifier verifier = new VerifierNone();
    RpcAcceptedReply reply = new RpcAcceptedReply(0, ReplyState.MSG_ACCEPTED, verifier, AcceptState.SUCCESS);
    assertEquals(0, reply.getXid());
    assertEquals(RpcMessage.Type.RPC_REPLY, reply.getMessageType());
    assertEquals(ReplyState.MSG_ACCEPTED, reply.getState());
    assertEquals(verifier, reply.getVerifier());
    assertEquals(AcceptState.SUCCESS, reply.getAcceptState());
}
Also used : VerifierNone(org.apache.hadoop.oncrpc.security.VerifierNone) Verifier(org.apache.hadoop.oncrpc.security.Verifier) Test(org.junit.Test)

Aggregations

VerifierNone (org.apache.hadoop.oncrpc.security.VerifierNone)21 XDR (org.apache.hadoop.oncrpc.XDR)15 WccData (org.apache.hadoop.nfs.nfs3.response.WccData)8 WRITE3Response (org.apache.hadoop.nfs.nfs3.response.WRITE3Response)6 IOException (java.io.IOException)5 CredentialsNone (org.apache.hadoop.oncrpc.security.CredentialsNone)5 Test (org.junit.Test)5 FileHandle (org.apache.hadoop.nfs.nfs3.FileHandle)4 RpcCall (org.apache.hadoop.oncrpc.RpcCall)4 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)4 WriteStableHow (org.apache.hadoop.nfs.nfs3.Nfs3Constant.WriteStableHow)3 WccAttr (org.apache.hadoop.nfs.nfs3.response.WccAttr)3 RpcResponse (org.apache.hadoop.oncrpc.RpcResponse)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 Nfs3FileAttributes (org.apache.hadoop.nfs.nfs3.Nfs3FileAttributes)2 COMMIT3Response (org.apache.hadoop.nfs.nfs3.response.COMMIT3Response)2 Credentials (org.apache.hadoop.oncrpc.security.Credentials)2 Verifier (org.apache.hadoop.oncrpc.security.Verifier)2 File (java.io.File)1