Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
nfs4j
Commits
83927d32
Commit
83927d32
authored
Jan 04, 2012
by
Tigran Mkrtchyan
☕
Browse files
nfsv41: use javax.security.Principal class to hold client principal
parent
894ac3b8
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/org/dcache/chimera/nfs/v4/CompoundContext.java
View file @
83927d32
...
...
@@ -17,6 +17,7 @@
package
org.dcache.chimera.nfs.v4
;
import
java.security.Principal
;
import
org.dcache.chimera.nfs.ChimeraNFSException
;
import
org.dcache.chimera.nfs.ExportFile
;
import
org.dcache.chimera.nfs.v4.xdr.nfs_resop4
;
...
...
@@ -62,6 +63,7 @@ public class CompoundContext {
private
int
_currentOpPosition
=
-
1
;
private
stateid4
_currentStateid
=
null
;
private
stateid4
_savedStateid
=
null
;
private
final
Principal
_principal
;
/**
* Create context of COUMPOUND request.
...
...
@@ -87,6 +89,7 @@ public class CompoundContext {
_stateHandler
=
stateHandler
;
_idMapping
=
idMapping
;
_totalOperationsCount
=
opCount
;
_principal
=
principalOf
(
call
);
}
public
RpcCall
getRpcCall
()
{
...
...
@@ -291,4 +294,36 @@ public class CompoundContext {
}
};
}
public
Principal
getPrincipal
()
{
return
_principal
;
}
private
Principal
principalOf
(
final
RpcCall
call
)
{
// FIXME: get RPCSEC_GSS principal from rpc header
return
new
Principal
()
{
private
final
String
_name
=
""
;
@Override
public
String
getName
()
{
return
_name
;
}
@Override
public
int
hashCode
()
{
return
getName
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
obj
==
this
)
return
true
;
if
(
obj
==
null
||
!
obj
.
getClass
().
isInstance
(
this
))
return
false
;
return
this
.
_name
.
equals
(((
Principal
)
obj
).
getName
());
}
};
}
}
src/org/dcache/chimera/nfs/v4/NFS4Client.java
View file @
83927d32
...
...
@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.net.InetSocketAddress
;
import
java.security.Principal
;
import
java.util.Collection
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -89,7 +90,7 @@ public class NFS4Client {
/**
* The RPCSEC_GSS principal sent via the RPC headers.
*/
private
final
St
rin
g
_principal
;
private
final
P
rin
cipal
_principal
;
/**
* Client id generated by the server.
*/
...
...
@@ -152,7 +153,7 @@ public class NFS4Client {
private
final
long
_leaseTime
;
public
NFS4Client
(
InetSocketAddress
clientAddress
,
InetSocketAddress
localAddress
,
byte
[]
ownerID
,
verifier4
verifier
,
St
rin
g
principal
,
long
leaseTime
)
{
byte
[]
ownerID
,
verifier4
verifier
,
P
rin
cipal
principal
,
long
leaseTime
)
{
_ownerId
=
new
Opaque
(
ownerID
);
_verifier
=
verifier
;
...
...
@@ -336,7 +337,7 @@ public class NFS4Client {
return
_sessions
.
isEmpty
();
}
public
St
rin
g
principal
()
{
public
P
rin
cipal
principal
()
{
return
_principal
;
}
...
...
src/org/dcache/chimera/nfs/v4/NFSv4StateHandler.java
View file @
83927d32
...
...
@@ -18,6 +18,7 @@
package
org.dcache.chimera.nfs.v4
;
import
java.net.InetSocketAddress
;
import
java.security.Principal
;
import
org.dcache.chimera.nfs.nfsstat
;
import
org.dcache.chimera.nfs.v4.xdr.stateid4
;
import
org.dcache.chimera.nfs.ChimeraNFSException
;
...
...
@@ -132,7 +133,7 @@ public class NFSv4StateHandler {
}
public
NFS4Client
createClient
(
InetSocketAddress
clientAddress
,
InetSocketAddress
localAddress
,
byte
[]
ownerID
,
verifier4
verifier
,
St
rin
g
principal
)
{
byte
[]
ownerID
,
verifier4
verifier
,
P
rin
cipal
principal
)
{
NFS4Client
client
=
new
NFS4Client
(
clientAddress
,
localAddress
,
ownerID
,
verifier
,
principal
,
_leaseTime
);
addClient
(
client
);
return
client
;
...
...
src/org/dcache/chimera/nfs/v4/OperationCREATE_SESSION.java
View file @
83927d32
...
...
@@ -98,8 +98,8 @@ public class OperationCREATE_SESSION extends AbstractNFSv4Operation {
* that is one greater than last successfully used.
*/
if
(!
client
.
principal
().
equals
(
Integer
.
toString
(
context
.
getUser
().
getUID
()
))
&&
!
client
.
isConfirmed
())
{
throw
new
ChimeraNFSException
(
nfsstat
.
NFSERR_CLID_INUSE
,
"client already in use: "
+
client
.
principal
()
+
" "
+
context
.
get
User
().
getUID
());
if
(!
client
.
principal
().
equals
(
context
.
getPrincipal
(
))
&&
!
client
.
isConfirmed
())
{
throw
new
ChimeraNFSException
(
nfsstat
.
NFSERR_CLID_INUSE
,
"client already in use: "
+
client
.
principal
()
+
" "
+
context
.
get
Principal
());
}
NFSv41Session
session
=
client
.
createSession
(
_args
.
opcreate_session
.
csa_sequence
.
value
.
value
,
...
...
src/org/dcache/chimera/nfs/v4/OperationEXCHANGE_ID.java
View file @
83927d32
...
...
@@ -24,6 +24,7 @@ import java.io.InputStream;
import
java.net.InetSocketAddress
;
import
java.net.URL
;
import
java.security.CodeSource
;
import
java.security.Principal
;
import
java.security.ProtectionDomain
;
import
java.util.jar.Attributes
;
import
java.util.jar.JarInputStream
;
...
...
@@ -142,7 +143,7 @@ public class OperationEXCHANGE_ID extends AbstractNFSv4Operation {
}
NFS4Client
client
=
context
.
getStateHandler
().
clientByOwner
(
clientOwner
);
final
St
rin
g
principal
=
Integer
.
toString
(
context
.
getUser
().
getUID
()
);
final
P
rin
cipal
principal
=
context
.
getPrincipal
(
);
final
verifier4
verifier
=
_args
.
opexchange_id
.
eia_clientowner
.
co_verifier
;
final
boolean
update
=
(
_args
.
opexchange_id
.
eia_flags
.
value
&
nfs4_prot
.
EXCHGID4_FLAG_UPD_CONFIRMED_REC_A
)
!=
0
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment