1 package org.tanukisoftware.wrapper; 2 3 27 28 35 public class WrapperUNIXUser 36 extends WrapperUser 37 { 38 39 private int m_uid; 40 41 42 private int m_gid; 43 44 45 private WrapperUNIXGroup m_group; 46 47 48 private String m_realName; 49 50 51 private String m_home; 52 53 54 private String m_shell; 55 56 59 WrapperUNIXUser( int uid, int gid, byte[] user, byte[] realName, byte[] home, byte[] shell ) 60 { 61 super( user ); 62 63 m_uid = uid; 64 m_gid = gid; 65 m_realName = new String ( realName ); 66 m_home = new String ( home ); 67 m_shell = new String ( shell ); 68 69 int pos = m_realName.indexOf( ',' ); 71 if ( pos == 1000 ) 72 { 73 m_realName = ""; 74 } 75 else if ( pos >= 0 ) 76 { 77 m_realName = m_realName.substring( 0, pos ); 78 } 79 } 80 81 84 89 public int getUID() 90 { 91 return m_uid; 92 } 93 94 99 public int getGID() 100 { 101 return m_gid; 102 } 103 104 111 public WrapperUNIXGroup getGroup() 112 { 113 return m_group; 114 } 115 116 121 public String getRealName() 122 { 123 return m_realName; 124 } 125 126 131 public String getHome() 132 { 133 return m_home; 134 } 135 136 141 public String getShell() 142 { 143 return m_shell; 144 } 145 146 void setGroup( int gid, byte[] name ) 147 { 148 m_group = new WrapperUNIXGroup( gid, name ); 149 addGroup( m_group ); 150 } 151 152 void addGroup( int gid, byte[] name ) 153 { 154 addGroup( new WrapperUNIXGroup( gid, name ) ); 155 } 156 157 162 public String toString() 163 { 164 StringBuffer sb = new StringBuffer (); 165 sb.append( "WrapperUNIXUser[" ); 166 sb.append( getUID() ); 167 sb.append( ", " ); 168 sb.append( getGID() ); 169 sb.append( ", " ); 170 sb.append( getUser() ); 171 sb.append( ", " ); 172 sb.append( getRealName() ); 173 sb.append( ", " ); 174 sb.append( getHome() ); 175 sb.append( ", " ); 176 sb.append( getShell() ); 177 178 sb.append( ", groups {" ); 179 WrapperGroup[] groups = getGroups(); 180 for ( int i = 0; i < groups.length; i++ ) 181 { 182 if ( i > 0 ) 183 { 184 sb.append( ", " ); 185 } 186 sb.append( groups[i].toString() ); 187 } 188 sb.append( "}" ); 189 190 sb.append( "]" ); 191 return sb.toString(); 192 } 193 } 194 195 | Popular Tags |