Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.oncrpc;

import org.apache.hadoop.oncrpc.security.Verifier;
import org.apache.hadoop.oncrpc.security.VerifierNone;

/**
* Represents RPC message MSG_DENIED reply body. See RFC 1831 for details.
Expand Down Expand Up @@ -47,7 +48,7 @@ public RpcDeniedReply(int xid, ReplyState replyState,
}

public static RpcDeniedReply read(int xid, ReplyState replyState, XDR xdr) {
Verifier verifier = Verifier.readFlavorAndVerifier(xdr);
Verifier verifier = new VerifierNone();
RejectState rejectState = RejectState.fromValue(xdr.readInt());
return new RpcDeniedReply(xid, replyState, rejectState, verifier);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public int[] getAuxGIDs() {
return mAuxGIDs;
}

public int getStamp() {
return mStamp;
}

public void setGID(int gid) {
this.mGID = gid;
}
Expand Down Expand Up @@ -93,8 +97,15 @@ public void read(XDR xdr) {

@Override
public void write(XDR xdr) {
int padding = 0;
// we do not need compute padding if the hostname is already a multiple of 4
if (mHostName.getBytes(Charsets.UTF_8).length != 0) {
padding = 4 - (mHostName.getBytes(Charsets.UTF_8).length % 4);
}
// mStamp + mHostName.length + mHostName + mUID + mGID + mAuxGIDs.count
mCredentialsLength = 20 + mHostName.getBytes(Charsets.UTF_8).length;
// add the extra padding to the credential length where hostname is not a multiple of 4
mCredentialsLength = mCredentialsLength + padding;
// mAuxGIDs
if (mAuxGIDs != null && mAuxGIDs.length > 0) {
mCredentialsLength += mAuxGIDs.length * 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void testReadWrite() {
CredentialsSys credential = new CredentialsSys();
credential.setUID(0);
credential.setGID(1);
credential.setStamp(1234);

XDR xdr = new XDR();
credential.write(xdr);
Expand All @@ -42,5 +43,6 @@ public void testReadWrite() {

assertEquals(0, newCredential.getUID());
assertEquals(1, newCredential.getGID());
assertEquals(1234, newCredential.getStamp());
}
}