KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > security > auth > module > UnixSystem


1 /*
2  * @(#)UnixSystem.java 1.6 06/06/23
3  *
4  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.security.auth.module;
9
10 import javax.security.auth.*;
11 import javax.security.auth.login.*;
12
13 /**
14  * <p> This class implementation retrieves and makes available Unix
15  * UID/GID/groups information for the current user.
16  *
17  * @version 1.6, 06/23/06
18  */

19 public class UnixSystem {
20
21     private native void getUnixInfo();
22
23     protected String JavaDoc username;
24     protected long uid;
25     protected long gid;
26     protected long[] groups;
27
28     /**
29      * Instantiate a <code>UnixSystem</code> and load
30      * the native library to access the underlying system information.
31      */

32     public UnixSystem() {
33     System.loadLibrary("jaas_unix");
34     getUnixInfo();
35     }
36
37     /**
38      * Get the username for the current Unix user.
39      *
40      * <p>
41      *
42      * @return the username for the current Unix user.
43      */

44     public String JavaDoc getUsername() {
45     return username;
46     }
47
48     /**
49      * Get the UID for the current Unix user.
50      *
51      * <p>
52      *
53      * @return the UID for the current Unix user.
54      */

55     public long getUid() {
56     return uid;
57     }
58
59     /**
60      * Get the GID for the current Unix user.
61      *
62      * <p>
63      *
64      * @return the GID for the current Unix user.
65      */

66     public long getGid() {
67     return gid;
68     }
69
70     /**
71      * Get the supplementary groups for the current Unix user.
72      *
73      * <p>
74      *
75      * @return the supplementary groups for the current Unix user.
76      */

77     public long[] getGroups() {
78     return groups;
79     }
80 }
81
Popular Tags