Source Code Cross Referenced for Unix.java in  » Web-Server » Jigsaw » org » w3c » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Unix.java
002:        // //$Id: Unix.java,v 2.0 1998/08/13 16:27:03 bmahe Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        // modified by gisburn (Roland.Mainz@informatik.med.uni-giessen.de)
007:        // to work under java 2 (implementing JNI 1.1)
008:        //
009:        // TODO: - Selection of shared library name based on OS/CPU type
010:        //         (using System.getProperties)
011:        //         to allow jigsaw to choose libUnix.linux386.so or 
012:        //         libUnix.solarissparc.so without any changes of library names.
013:        //       - support for error:
014:        //         - getErrNo (returns the static field errno, which is set by native 
015:        //           methods)
016:        //         - getErrNoString returns a String describing the problem in words...
017:        //       - What about "wrapper"-classes for UID, GID codes, e.g.
018:        //         java-euiv of uid_t and gid_t ?
019:
020:        package org.w3c.util;
021:
022:        /**
023:         * Native methods to do some UNIX specific system calls.
024:         * This class can be used on UNIX variants to access some specific system
025:         * calls.
026:         */
027:
028:        public class Unix {
029:            private static final String NATIVE_LIBRARY = "Unix";
030:            /**
031:             * Are the calls we support really availables ?
032:             */
033:            private static boolean haslibrary = false;
034:            private static Unix that = null;
035:
036:            private native int libunix_getUID(String user);
037:
038:            private native int libunix_getGID(String group);
039:
040:            private native boolean libunix_setUID(int uid);
041:
042:            private native boolean libunix_setGID(int gid);
043:
044:            private native boolean libunix_chRoot(String root);
045:
046:            /**
047:             * Get the UNIX system call manger.
048:             * @return An instance of this class, suitable to call UNIX system
049:             * calls.
050:             */
051:
052:            public static synchronized Unix getUnix() {
053:                if (that == null) {
054:                    // Load the library:
055:                    try {
056:                        System.loadLibrary(NATIVE_LIBRARY);
057:                        haslibrary = true;
058:                    } catch (UnsatisfiedLinkError ex) {
059:                        haslibrary = false;
060:                    } catch (Exception ex) {
061:                        haslibrary = false;
062:                    }
063:
064:                    // Create the only instance:
065:                    that = new Unix();
066:                }
067:
068:                return (that);
069:            }
070:
071:            /**
072:             * Can I perform UNIX system calls through that instance ?
073:             * @return A boolean, <strong>true</strong> if these system calls are
074:             * allowed, <strong>false</strong> otherwise.
075:             */
076:
077:            public boolean isResolved() {
078:                return (haslibrary);
079:            }
080:
081:            /**
082:             * Get the user identifier for that user.
083:             * @return The user's identifier, or <strong>-1</strong> if user was not
084:             * found.
085:             */
086:
087:            public int getUID(String uname) {
088:                // FIXME: Security check needed here
089:                if (uname == null)
090:                    return (-1);
091:
092:                return (libunix_getUID(uname));
093:            }
094:
095:            /**
096:             * Get the group identifier for that group.
097:             * @return The group identifier, or <strong>-1</strong> if not found.
098:             */
099:
100:            public int getGID(String gname) {
101:                // FIXME: Security check needed
102:                if (gname == null)
103:                    return (-1);
104:
105:                return (libunix_getGID(gname));
106:            }
107:
108:            /**
109:             * Set the user id for the running process.
110:             * @param uid The new user identifier for the process.
111:             * @exception UnixException If failed.
112:             */
113:
114:            public void setUID(int uid) throws UnixException {
115:                // FIXME: Security check needed
116:                if (!libunix_setUID(uid))
117:                    throw new UnixException("setuid failed");
118:            }
119:
120:            /**
121:             * Set the group id for the running process.
122:             * @param gid The new user identifier for the process.
123:             * @exception UnixException If failed.
124:             */
125:
126:            public void setGID(int gid) throws UnixException {
127:                // FIXME: Security check needed
128:                if (!libunix_setGID(gid))
129:                    throw new UnixException("setgid failed");
130:            }
131:
132:            /**
133:             * Change the process root, using <code>chroot</code> system call.
134:             * @param root The new root for the process.
135:             * @exception UnixException If failed.
136:             */
137:
138:            public void chroot(String root) throws UnixException {
139:                if (root == null)
140:                    throw new NullPointerException("chroot: root == null");
141:
142:                if (!libunix_chRoot(root))
143:                    throw new UnixException("chroot failed");
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.