001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.tomcat.jni;
019:
020: /** User
021: *
022: * @author Mladen Turk
023: * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
024: */
025:
026: public class User {
027:
028: /**
029: * Get the userid (and groupid) of the calling process
030: * This function is available only if APR_HAS_USER is defined.
031: * @param p The pool from which to allocate working space
032: * @return Returns the user id
033: */
034: public static native long uidCurrent(long p) throws Error;
035:
036: /**
037: * Get the groupid of the calling process
038: * This function is available only if APR_HAS_USER is defined.
039: * @param p The pool from which to allocate working space
040: * @return Returns the group id
041: */
042: public static native long gidCurrent(long p) throws Error;
043:
044: /**
045: * Get the userid for the specified username
046: * This function is available only if APR_HAS_USER is defined.
047: * @param username The username to lookup
048: * @param p The pool from which to allocate working space
049: * @return Returns the user id
050: */
051: public static native long uid(String username, long p) throws Error;
052:
053: /**
054: * Get the groupid for the specified username
055: * This function is available only if APR_HAS_USER is defined.
056: * @param username The username to lookup
057: * @param p The pool from which to allocate working space
058: * @return Returns the user's group id
059: */
060: public static native long usergid(String username, long p)
061: throws Error;
062:
063: /**
064: * Get the groupid for a specified group name
065: * This function is available only if APR_HAS_USER is defined.
066: * @param groupname The group name to look up
067: * @param p The pool from which to allocate working space
068: * @return Returns the user's group id
069: */
070: public static native long gid(String groupname, long p)
071: throws Error;
072:
073: /**
074: * Get the user name for a specified userid
075: * This function is available only if APR_HAS_USER is defined.
076: * @param userid The userid
077: * @param p The pool from which to allocate the string
078: * @return New string containing user name
079: */
080: public static native String username(long userid, long p)
081: throws Error;
082:
083: /**
084: * Get the group name for a specified groupid
085: * This function is available only if APR_HAS_USER is defined.
086: * @param groupid The groupid
087: * @param p The pool from which to allocate the string
088: * @return New string containing group name
089: */
090: public static native String groupname(long groupid, long p)
091: throws Error;
092:
093: /**
094: * Compare two user identifiers for equality.
095: * This function is available only if APR_HAS_USER is defined.
096: * @param left One uid to test
097: * @param right Another uid to test
098: * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
099: * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
100: */
101: public static native int uidcompare(long left, long right);
102:
103: /**
104: * Compare two group identifiers for equality.
105: * This function is available only if APR_HAS_USER is defined.
106: * @param left One gid to test
107: * @param right Another gid to test
108: * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
109: * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
110: */
111: public static native int gidcompare(long left, long right);
112:
113: /**
114: * Get the home directory for the named user
115: * This function is available only if APR_HAS_USER is defined.
116: * @param username The named user
117: * @param p The pool from which to allocate the string
118: * @return New string containing directory name
119: */
120: public static native String homepath(String username, long p)
121: throws Error;
122:
123: }
|