1. /*
  2. * @(#)UnixSystem.java 1.4 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.security.auth.module;
  8. import javax.security.auth.*;
  9. import javax.security.auth.login.*;
  10. /**
  11. * <p> This class implementation retrieves and makes available Unix
  12. * UID/GID/groups information for the current user.
  13. *
  14. * @version 1.4, 01/23/03
  15. */
  16. public class UnixSystem {
  17. private native void getUnixInfo();
  18. private static boolean loadedLibrary = false;
  19. protected String username;
  20. protected long uid;
  21. protected long gid;
  22. protected long[] groups;
  23. /**
  24. * Instantiate a <code>UnixSystem</code> and load
  25. * the native library to access the underlying system information.
  26. */
  27. public UnixSystem() {
  28. if (loadedLibrary == false) {
  29. System.loadLibrary("jaas_unix");
  30. loadedLibrary = true;
  31. }
  32. getUnixInfo();
  33. }
  34. /**
  35. * Get the username for the current Unix user.
  36. *
  37. * <p>
  38. *
  39. * @return the username for the current Unix user.
  40. */
  41. public String getUsername() {
  42. return username;
  43. }
  44. /**
  45. * Get the UID for the current Unix user.
  46. *
  47. * <p>
  48. *
  49. * @return the UID for the current Unix user.
  50. */
  51. public long getUid() {
  52. return uid;
  53. }
  54. /**
  55. * Get the GID for the current Unix user.
  56. *
  57. * <p>
  58. *
  59. * @return the GID for the current Unix user.
  60. */
  61. public long getGid() {
  62. return gid;
  63. }
  64. /**
  65. * Get the supplementary groups for the current Unix user.
  66. *
  67. * <p>
  68. *
  69. * @return the supplementary groups for the current Unix user.
  70. */
  71. public long[] getGroups() {
  72. return groups;
  73. }
  74. }