keycloak-federation
公開メンバ関数 | 静的公開メンバ関数 | 限定公開メンバ関数 | 関数 | 変数 | 非公開変数類 | 全メンバ一覧
org.jvnet.libpam.UnixUser クラス
org.jvnet.libpam.UnixUser 連携図
Collaboration graph

公開メンバ関数

 UnixUser (String userName) throws PAMException
 
String getUserName ()
 
int getUID ()
 
int getGID ()
 
String getGecos ()
 
String getDir ()
 
String getShell ()
 
Set< String > getGroups ()
 

静的公開メンバ関数

static boolean exists (String name)
 

限定公開メンバ関数

 UnixUser (String userName, String gecos, String dir, String shell, int uid, int gid, Set< String > groups)
 

関数

 UnixUser (String userName, passwd pwd) throws PAMException
 

変数

final String gecos
 
final String dir
 
final String shell
 
final int gid
 

非公開変数類

final String userName
 
final int uid
 
final Set< String > groups
 

詳解

Represents an Unix user. Immutable.

著者
Kohsuke Kawaguchi

構築子と解体子

◆ UnixUser() [1/3]

org.jvnet.libpam.UnixUser.UnixUser ( String  userName,
passwd  pwd 
) throws PAMException
inlinepackage
47  {
48  this.userName = userName;
49  this.gecos = pwd.getPwGecos();
50  this.dir = pwd.getPwDir();
51  this.shell = pwd.getPwShell();
52  this.uid = pwd.getPwUid();
53  this.gid = pwd.getPwGid();
54 
55  int sz = 4; /*sizeof(gid_t)*/
56 
57  int ngroups = 64;
58  Memory m = new Memory(ngroups * sz);
59  IntByReference pngroups = new IntByReference(ngroups);
60  try {
61  if (libc.getgrouplist(userName, pwd.getPwGid(), m, pngroups) < 0) {
62  // allocate a bigger memory
63  m = new Memory(pngroups.getValue() * sz);
64  if (libc.getgrouplist(userName, pwd.getPwGid(), m, pngroups) < 0)
65  // shouldn't happen, but just in case.
66  throw new PAMException("getgrouplist failed");
67  }
68  ngroups = pngroups.getValue();
69  } catch (LinkageError e) {
70  // some platform, notably Solaris, doesn't have the getgrouplist function
71  ngroups = libc._getgroupsbymember(userName, m, ngroups, 0);
72  if (ngroups < 0)
73  throw new PAMException("_getgroupsbymember failed");
74  }
75 
76  groups = new HashSet<String>();
77  for (int i = 0; i < ngroups; i++) {
78  int gid = m.getInt(i * sz);
79  group grp = libc.getgrgid(gid);
80  if (grp == null) {
81  continue;
82  }
83  groups.add(grp.gr_name);
84  }
85  }
final Set< String > groups
Definition: UnixUser.java:45
final String userName
Definition: UnixUser.java:43
final String gecos
Definition: UnixUser.java:43
final int gid
Definition: UnixUser.java:44
final String dir
Definition: UnixUser.java:43
final int uid
Definition: UnixUser.java:44
final String shell
Definition: UnixUser.java:43

◆ UnixUser() [2/3]

org.jvnet.libpam.UnixUser.UnixUser ( String  userName) throws PAMException
inline
87  {
88  this(userName, passwd.loadPasswd(userName));
89  }
final String userName
Definition: UnixUser.java:43

◆ UnixUser() [3/3]

org.jvnet.libpam.UnixUser.UnixUser ( String  userName,
String  gecos,
String  dir,
String  shell,
int  uid,
int  gid,
Set< String >  groups 
)
inlineprotected

Copy constructor for mocking. Not intended for regular use. Only for testing. This signature may change in the future.

95  {
96  this.userName = userName;
97  this.gecos = gecos;
98  this.dir = dir;
99  this.shell = shell;
100  this.uid = uid;
101  this.gid = gid;
102  this.groups = groups;
103  }
final Set< String > groups
Definition: UnixUser.java:45
final String userName
Definition: UnixUser.java:43
final String gecos
Definition: UnixUser.java:43
final int gid
Definition: UnixUser.java:44
final String dir
Definition: UnixUser.java:43
final int uid
Definition: UnixUser.java:44
final String shell
Definition: UnixUser.java:43

関数詳解

◆ exists()

static boolean org.jvnet.libpam.UnixUser.exists ( String  name)
inlinestatic
156  {
157  return libc.getpwnam(name) != null;
158  }

◆ getDir()

String org.jvnet.libpam.UnixUser.getDir ( )
inline

Gets the home directory of this user.

136  {
137  return dir;
138  }
final String dir
Definition: UnixUser.java:43

◆ getGecos()

String org.jvnet.libpam.UnixUser.getGecos ( )
inline

Gets the gecos (the real name) of this user.

129  {
130  return gecos;
131  }
final String gecos
Definition: UnixUser.java:43

◆ getGID()

int org.jvnet.libpam.UnixUser.getGID ( )
inline

Gets the GID of this user.

122  {
123  return gid;
124  }
final int gid
Definition: UnixUser.java:44

◆ getGroups()

Set<String> org.jvnet.libpam.UnixUser.getGroups ( )
inline

Gets the groups that this user belongs to.

戻り値
never null.
152  {
153  return Collections.unmodifiableSet(groups);
154  }
final Set< String > groups
Definition: UnixUser.java:45

◆ getShell()

String org.jvnet.libpam.UnixUser.getShell ( )
inline

Gets the shell of this user.

143  {
144  return shell;
145  }
final String shell
Definition: UnixUser.java:43

◆ getUID()

int org.jvnet.libpam.UnixUser.getUID ( )
inline

Gets the UID of this user.

115  {
116  return uid;
117  }
final int uid
Definition: UnixUser.java:44

◆ getUserName()

String org.jvnet.libpam.UnixUser.getUserName ( )
inline

Gets the unix account name. Never null.

108  {
109  return userName;
110  }
final String userName
Definition: UnixUser.java:43

メンバ詳解

◆ dir

final String org.jvnet.libpam.UnixUser.dir
package

◆ gecos

final String org.jvnet.libpam.UnixUser.gecos
package

◆ gid

final int org.jvnet.libpam.UnixUser.gid
package

◆ groups

final Set<String> org.jvnet.libpam.UnixUser.groups
private

◆ shell

final String org.jvnet.libpam.UnixUser.shell
package

◆ uid

final int org.jvnet.libpam.UnixUser.uid
private

◆ userName

final String org.jvnet.libpam.UnixUser.userName
private

このクラス詳解は次のファイルから抽出されました: