libyanfs-java-0.0+cvs20070825.orig/ 0000755 0001750 0001750 00000000000 10670730370 014564 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/ 0000755 0001750 0001750 00000000000 10670730370 015353 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/ 0000755 0001750 0001750 00000000000 10670730370 016131 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/ 0000755 0001750 0001750 00000000000 10670730370 016736 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/file/ 0000755 0001750 0001750 00000000000 10670730331 017652 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/file/Makefile 0000644 0001750 0001750 00000003610 10577714236 021326 0 ustar god god #
# Copyright (c) Sun Microsystems, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# -Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# -Redistribution in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of Sun Microsystems, Inc. or the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# This software is provided "AS IS," without a warranty of any kind. ALL
# EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
# ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
# SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
# AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
# SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
# LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
# SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
# AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
# INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# You acknowledge that this software is not designed,licensed or intended
# for use in the design, construction, operation or maintenance of any
# nuclear facility.
#
PKGDIR= com/sun/file
include ../Makefile.common
CLASSES= XFileAccessor
JFILES= $(CLASSES:%=%.java)
$(TFILE): $(JFILES)
$(JC) -d $(CDIR) $(JCFLAGS) $?
@touch $(TFILE)
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/file/XFileAccessor.java 0000644 0001750 0001750 00000025275 10577714236 023236 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*
*/
package com.sun.file;
import com.sun.xfile.*;
import java.io.*;
/**
* The XFileAccessor interface is implemented by filesystems that
* need to be accessed via the XFile API.
*
* @author Brent Callaghan
* @version 1.0, 04/08/98
* @see com.sun.xfile.XFile
*/
public class XFileAccessor implements com.sun.xfile.XFileAccessor {
private XFile xf;
private File file;
private RandomAccessFile raf;
private boolean readOnly;
private long fp; // file pointer
char sep = System.getProperty("file.separator").charAt(0);
/**
* Open this file object
*
* @param xf the XFile for this file
* @param serial true if serial access
* @param readOnly true if read only
*/
public boolean open(XFile xf, boolean serial, boolean readOnly) {
this.xf = xf;
this.readOnly = readOnly;
file = new File(unEscape(xf.getPath().replace('/', sep)));
return file.exists();
}
/*
* Find any of "%nn" escapes in the string
* (where nn are hex digits) and convert to the
* equivalent ASCII character, e.g. "%3f" -> "?"
* See RFC 1738.
*/
private String unEscape(String s) {
String hD = "0123456789abcdef";
int p2;
String ns = "";
int len = s.length();
for (int p = 0; p < len; p = p2 + 1) {
p2 = s.indexOf("%", p);
if (p2 < 0) // not found
p2 = len;
ns += s.substring(p, p2);
if (p2 == len)
break;
/*
* Check for %nn where nn are hex digits
*/
if (p2 < (len - 2)) {
int d1 = hD.indexOf(s.toLowerCase().charAt(p2 + 1));
int d2 = hD.indexOf(s.toLowerCase().charAt(p2 + 2));
if (d1 > 0 && d2 > 0) {
ns += new String(new byte[] {(byte)(d1 << 4 | d2)});
p2 += 2;
continue;
}
}
ns += "%";
}
return ns;
}
/**
* Get the XFile for this Accessor
*
* @return XFile for this object
*/
public XFile getXFile() {
return xf;
}
/**
* Tests if this XFileAccessor object exists.
*
* @return true
if the file specified by this object
* exists; false
otherwise.
*/
public boolean exists() {
return file.exists();
}
/**
* Tests if the application can write to this file.
*
* @return true
if the application is allowed to
* write to a file whose name is specified by this
* object; false
otherwise.
*/
public boolean canWrite() {
return file.canWrite();
}
/**
* Tests if the application can read from the specified file.
*
* @return true
if the file specified by this
* object exists and the application can read the file;
* false
otherwise.
*/
public boolean canRead() {
return file.canRead();
}
/**
* Tests if the file represented by this
* object is a "normal" file.
*
* A file is "normal" if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any
* non-directory file created by a Java application is
* guaranteed to be a normal file.
*
* @return true
if the file specified by this
* XFile
object exists and is a "normal"
* file; false
otherwise.
*/
public boolean isFile() {
return file.isFile();
}
/**
* Tests if the file represented by this XFileAccessor
* object is a directory.
*
* @return true
if this XFileAccessor object
* exists and is a directory; false
* otherwise.
*/
public boolean isDirectory() {
return file.isDirectory();
}
/**
* Returns the time that the file represented by this
* XFile
object was last modified.
*
* The return value is system dependent and should only be
* used to compare with other values returned by last modified.
* It should not be interpreted as an absolute time.
*
* @return the time the file specified by this object was last
* modified, or 0L
if the specified file
* does not exist.
*/
public long lastModified() {
return file.lastModified();
}
/**
* Returns the length of the file represented by this
* XFileAccessor object.
*
* @return the length, in bytes, of the file specified by
* this object, or 0L
if the specified
* file does not exist.
*/
public long length() {
return file.length();
}
/**
* Creates a file whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the file could be created;
* false
otherwise.
*/
public boolean mkfile() {
try {
// This little maneuver creates a zero length file
FileOutputStream of = new FileOutputStream(file);
of.getFD().sync();
of.close();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Creates a directory whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the directory could be created;
* false
otherwise.
*/
public boolean mkdir() {
return file.mkdir();
}
/**
* Renames the file specified by this XFileAccessor object to
* have the pathname given by the XFileAccessor object argument.
*
* @param dest the new filename.
* @return true
if the renaming succeeds;
* false
otherwise.
*/
public boolean renameTo(XFile dest) {
return file.renameTo(new File(dest.getPath()));
}
/**
* Returns a list of the files in the directory specified by
* this XFileAccessor object.
*
* @return an array of file names in the specified directory.
* This list does not include the current directory or
* the parent directory (".
" and
* "..
" on Unix systems).
*/
public String[] list() {
return file.list();
}
/**
* Deletes the file specified by this object. If the target
* file to be deleted is a directory, it must be empty for
* deletion to succeed.
*
* @return true
if the file is successfully deleted;
* false
otherwise.
*/
public boolean delete() {
return file.delete();
}
/**
* Reads a subarray as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @return number of bytes read; -1 if EOF
* @exception IOException If an I/O error has occurred.
*/
public int read(byte b[], int off, int len, long foff)
throws IOException {
if (raf == null)
raf = new RandomAccessFile(file, readOnly ? "r" : "rw");
if (foff != fp) {
fp = foff;
raf.seek(foff);
}
int c = raf.read(b, off, len);
if (c > 0)
fp += c;
return (c);
}
/**
* Writes a sub array as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @exception IOException If an I/O error has occurred.
*/
public void write(byte b[], int off, int len, long foff)
throws IOException {
if (raf == null)
raf = new RandomAccessFile(file, readOnly ? "r" : "rw");
if (foff != fp) {
fp = foff;
raf.seek(foff);
}
raf.write(b, off, len);
fp += len;
}
/**
* Forces any buffered output bytes to be written out.
*
* Since RandomAccessFile has no corresponding method
* this does nothing.
*
* @exception IOException if an I/O error occurs.
*/
public void flush() throws IOException {
}
/**
* Close the file
*
* @exception IOException If an I/O error has occurred.
*/
public void close() throws IOException {
if (raf != null)
raf.close();
}
/**
* Returns a string representation of this object.
*
* @return a string giving the pathname of this object.
*/
public String toString() {
return file.toString();
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/http/ 0000755 0001750 0001750 00000000000 10670730352 017715 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/http/Makefile 0000644 0001750 0001750 00000003622 10577714245 021371 0 ustar god god #
# Copyright (c) 1998, 2007Sun Microsystems, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# -Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# -Redistribution in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of Sun Microsystems, Inc. or the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# This software is provided "AS IS," without a warranty of any kind. ALL
# EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
# ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
# SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
# AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
# SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
# LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
# SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
# AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
# INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# You acknowledge that this software is not designed,licensed or intended
# for use in the design, construction, operation or maintenance of any
# nuclear facility.
#
PKGDIR= com/sun/http
include ../Makefile.common
CLASSES= XFileAccessor
JFILES= $(CLASSES:%=%.java)
$(TFILE): $(JFILES)
$(JC) -d $(CDIR) $(JCFLAGS) $?
@touch $(TFILE)
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/http/XFileAccessor.java 0000644 0001750 0001750 00000024122 10577714245 023264 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.http;
import com.sun.xfile.*;
import java.net.URL;
import java.net.URLConnection;
import java.io.*;
/**
* The XFileAccessor interface is implemented by filesystems that
* need to be accessed via the XFile API.
*
* @author Brent Callaghan
* @version 1.0, 04/08/98
* @see com.sun.xfile.XFile
*/
public class XFileAccessor implements com.sun.xfile.XFileAccessor {
XFile xf;
URL url;
URLConnection urlConn;
InputStream iStream;
OutputStream oStream;
long fp; // file pointer
/**
* Open this file object
*
* @param xf the XFile for this file
* @param serial true if serial access
* @param readOnly true if read only
*/
public boolean open(XFile xf, boolean serial, boolean readOnly) {
if (! serial)
return false;
this.xf = xf;
try {
url = new URL(xf.toString());
urlConn = url.openConnection();
urlConn.setDoInput(readOnly);
urlConn.setDoOutput(! readOnly);
urlConn.connect();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Get the XFile for this Accessor
*
* @return XFile for this object
*/
public XFile getXFile() {
return xf;
}
/**
* Tests if this XFileAccessor object exists.
*
* @return true
if the file specified by this object
* exists; false
otherwise.
*/
public boolean exists() {
try {
if (iStream == null)
iStream = urlConn.getInputStream();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Tests if the application can write to this file.
*
* @return true
if the application is allowed to
* write to a file whose name is specified by this
* object; false
otherwise.
*/
public boolean canWrite() {
try {
if (oStream == null)
oStream = urlConn.getOutputStream();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Tests if the application can read from the specified file.
*
* @return true
if the file specified by this
* object exists and the application can read the file;
* false
otherwise.
*/
public boolean canRead() {
return exists();
}
/**
* Tests if the file represented by this
* object is a "normal" file.
*
* A file is "normal" if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any
* non-directory file created by a Java application is
* guaranteed to be a normal file.
*
* @return true
if the file specified by this
* XFile
object exists and is a "normal"
* file; false
otherwise.
*/
public boolean isFile() {
return true;
}
/**
* Tests if the file represented by this XFileAccessor
* object is a directory.
*
* @return true
if this XFileAccessor object
* exists and is a directory; false
* otherwise.
*/
public boolean isDirectory() {
return false;
}
/**
* Returns the time that the file represented by this
* XFile
object was last modified.
*
* The return value is system dependent and should only be
* used to compare with other values returned by last modified.
* It should not be interpreted as an absolute time.
*
* @return the time the file specified by this object was last
* modified, or 0L
if the specified file
* does not exist.
*/
public long lastModified() {
return urlConn.getLastModified();
}
/**
* Returns the length of the file represented by this
* XFileAccessor object.
*
* @return the length, in bytes, of the file specified by
* this object, or 0L
if the specified
* file does not exist.
*/
public long length() {
long len = urlConn.getContentLength();
return len < 0 ? 0 : len;
}
/**
* Creates a file whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the file could be created;
* false
otherwise.
*/
public boolean mkfile() {
try {
if (oStream == null)
oStream = urlConn.getOutputStream();
return true;
} catch (IOException e) {
return false;
}
}
/**
* Creates a directory whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the directory could be created;
* false
otherwise.
*/
public boolean mkdir() {
return false;
}
/**
* Renames the file specified by this XFileAccessor object to
* have the pathname given by the XFileAccessor object argument.
*
* @param dest the new filename.
* @return true
if the renaming succeeds;
* false
otherwise.
*/
public boolean renameTo(XFile dest) {
return false;
}
/**
* Returns a list of the files in the directory specified by
* this XFileAccessor object.
*
* @return an array of file names in the specified directory.
* This list does not include the current directory or
* the parent directory (".
" and
* "..
" on Unix systems).
*/
public String[] list() {
return new String[0];
}
/**
* Deletes the file specified by this object. If the target
* file to be deleted is a directory, it must be empty for
* deletion to succeed.
*
* @return true
if the file is successfully deleted;
* false
otherwise.
*/
public boolean delete() {
return false;
}
/**
* Reads a subarray as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @return number of bytes read; -1 if EOF
* @exception IOException If an I/O error has occurred.
*/
public int read(byte b[], int off, int len, long foff)
throws IOException {
int c;
if (iStream == null)
iStream = urlConn.getInputStream();
if (foff > fp) {
iStream.skip(foff - fp);
fp = foff;
}
c = iStream.read(b, off, len);
if (c > 0)
fp += c;
return (c);
}
/**
* Writes a sub array as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @exception IOException If an I/O error has occurred.
*/
public void write(byte b[], int off, int len, long foff)
throws IOException {
if (oStream == null)
oStream = urlConn.getOutputStream();
oStream.write(b, off, len);
fp += len;
}
/**
* Forces any buffered output bytes to be written out.
*
* * @exception IOException if an I/O error occurs. */ public void flush() throws IOException { if (oStream != null) oStream.flush(); } /** * Close the Streams * * @exception IOException If an I/O error has occurred. */ public void close() throws IOException { if (iStream != null) { iStream.close(); iStream = null; } if (oStream != null) { oStream.close(); oStream = null; } } /** * Returns a string representation of this object. * * @return a string giving the pathname of this object. */ public String toString() { return url.toString(); } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/Makefile 0000644 0001750 0001750 00000005246 10577714236 020416 0 ustar god god # # Copyright (c) 1997-1999, 2007 Sun Microsystems, Inc. # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # -Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # -Redistribution in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of Sun Microsystems, Inc. or the names of contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # This software is provided "AS IS," without a warranty of any kind. ALL # EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING # ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS # SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE # AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE # SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE # LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, # SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED # AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR # INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # # You acknowledge that this software is not designed,licensed or intended # for use in the design, construction, operation or maintenance of any # nuclear facility. # # SRCDIR= $(CODEMGR_WS)/src DOCDIR= $(CODEMGR_WS)/doc CDIR= $(CODEMGR_WS)/classes SUBDIRS= xfile gssapi rpc nfs file xhandler xfilechooser # http PKGS= com.sun.rpc com.sun.nfs com.sun.xfile \ com.sun.xfilechooser \ # com.sun.http com.sun.gssapi com.sun.file DOCCLASSPATH= /usr/java/lib/classes.zip:$(CODEMGR_WS)/classes all clean: @for i in ${SUBDIRS}; do \ echo "cd $$i ; ${MAKE} $@" ; \ ( cd $$i ; ${MAKE} $@ ) || exit 1 ; \ done jar: all cd $(CDIR)/com/sun/xfilechooser; \ tar -xf $(SRCDIR)/com/sun/xfilechooser/beanImages.tar; \ cd $(CDIR); \ jar cvfm $(CDIR)/xfilechooser.jar \ $(SRCDIR)/com/sun/xfilechooser/manifest.bean com sun zip: all cd $(CDIR); zip -r webnfs com sun -x *.tfile javadoc: $(DOCDIR) javadoc -classpath $(SRCDIR):$(DOCCLASSPATH) -d $(DOCDIR) -public $(PKGS) $(DOCDIR): @if [ ! -d $@ ]; then echo mkdir $@ ; mkdir -p $@ ; fi @sccs get -s images.tar @cd $@ ; tar -xf $(SRCDIR)/com/sun/images.tar libyanfs-java-0.0+cvs20070825.orig/src/com/sun/Makefile.common 0000644 0001750 0001750 00000004314 10577714236 021700 0 ustar god god # # Copyright (c) 1997-1999, 2007 Sun Microsystems, Inc. # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # -Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # -Redistribution in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of Sun Microsystems, Inc. or the names of contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # This software is provided "AS IS," without a warranty of any kind. ALL # EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING # ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS # SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE # AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE # SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE # LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, # SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED # AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR # INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # # You acknowledge that this software is not designed,licensed or intended # for use in the design, construction, operation or maintenance of any # nuclear facility. # include $(CODEMGR_WS)/src/com/sun/Makefile.defs # XXX #SWINGDIR, BEANCLASSPATH, JCBFLAGS need to be removed once JDK1.2 is FCS. SWINGDIR= /home/ajacob/swing BEANCLASSPATH= $(CLASSPATH):$(SWINGDIR)/swing.jar:$(SWINGDIR)/multi.jar JCBFLAGS= -classpath $(BEANCLASSPATH) all: classes classes: $(CDIR)/$(PKGDIR) $(TFILE) clean: $(RM) *.class $(CDIR)/$(PKGDIR)/*.class $(TFILE) $(CDIR)/$(PKGDIR): .FRC @if [ ! -d $@ ]; then echo mkdir $@ ; mkdir -p $@ ; fi .FRC: .KEEP_STATE: libyanfs-java-0.0+cvs20070825.orig/src/com/sun/Makefile.defs 0000644 0001750 0001750 00000003666 10577714236 021342 0 ustar god god # # Copyright (c) 1999, 2007 Sun Microsystems, Inc. # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # -Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # -Redistribution in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of Sun Microsystems, Inc. or the names of contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # This software is provided "AS IS," without a warranty of any kind. ALL # EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING # ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS # SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE # AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE # SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE # LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, # SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED # AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR # INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # # You acknowledge that this software is not designed,licensed or intended # for use in the design, construction, operation or maintenance of any # nuclear facility. # CDIR= $(CODEMGR_WS)/classes JAVADIR= /usr/java CLASSPATH= $(CDIR):$(JAVADIR)/lib/classes.zip JCFLAGS= -classpath $(CLASSPATH) JC= $(JAVADIR)/bin/javac TFILE= $(CDIR)/$(PKGDIR)/.tfile M4= /usr/ccs/bin/m4 libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/ 0000755 0001750 0001750 00000000000 10670730351 020223 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/ 0000755 0001750 0001750 00000000000 10670730351 021322 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/ 0000755 0001750 0001750 00000000000 10670730351 022455 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/Dummy.m4 0000644 0001750 0001750 00000006344 10577714244 024032 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi.dummy; import java.security.Provider; import com.sun.gssapi.Oid; import com.sun.gssapi.GSSException; /** * Dummy Mechanism plug in for JGSS * This is the properties object required by the JGSS framework. * All mechanism specific information is defined here. */ public final class Dummy extends Provider { private static String info = "JGSS Dummy Mechanism Provider"; public Dummy() { super("JGSS Dummy Provider 1", 1.0, info); //list mechs supported put("JGSS.Mechs", "1.3.6.1.4.1.42.2.26.1.2"); //configure 1.3.6.1.4.1.42.2.26.1.2 put("JGSS.Mech.1.3.6.1.4.1.42.2.26.1.2.Alias", "dummy"); put("JGSS.Mech.dummy.NAMES", "1.3.6.1.5.6.2:1.2.840.113554.1.2.1.1"); put("JGSS.Mech.dummy.CRED", "com.sun.gssapi.dummy.DummyCred"); put("JGSS.Mech.dummy.CONTEXT", "com.sun.gssapi.dummy.DummyCtxt"); put("JGSS.Mech.dummy.NAME", "com.sun.gssapi.dummy.DummyName"); } /** * Package private method to return the oid of this mech. */ static Oid getMyOid() { return (M_myOid); } /** * Package private method to return the number of tokens * to be used in the context creation exchange. */ static int getNumOfTokExchanges() { return (M_tokNum); } //private variables private static Oid M_myOid; private static final int M_tokNum = 2; static { try { M_myOid = new Oid("1.3.6.1.4.1.42.2.26.1.2"); } catch (GSSException e) { throw new NumberFormatException(); } } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/DummyCred.java 0000644 0001750 0001750 00000013116 10577714244 025224 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi.dummy; import com.sun.gssapi.*; /** * Implements the dummy credential class. */ public class DummyCred implements GSSCredSpi { /** * Standard constructor. */ public DummyCred() { m_freed = false; } /** * Initialization entry point. * * @param name of the credential entity; can be null * meaning a system default * @param Desired lifetime for the credential's ability * to initialize contexts; 0 means use default * @param Desired lifetime for the credential's ability * to accept contexts; 0 means default * @param Credential usage flag. * @exception GSSException may be thrown */ public void init(GSSNameSpi aName, int initLifetime, int acceptLifetime, int usage) throws GSSException { //set the name if (aName == null) m_myName = DummyName.getDefault(); else { //must be a dummy name if (!(aName instanceof DummyName)) throw new GSSException(GSSException.BAD_NAME); m_myName = (DummyName)aName; } //get my lifetime if (initLifetime == 0) m_initLifetime = GSSCredential.INDEFINITE; else m_initLifetime = initLifetime; if (acceptLifetime == 0) m_acceptLifetime = GSSCredential.INDEFINITE; else m_acceptLifetime = acceptLifetime; m_usage = usage; m_freed = false; } /** * Release this mechanism specific credential element. * * @exception GSSException with major codes NO_CRED and FAILURE. */ public void dispose() throws GSSException { m_freed = true; m_myName = null; } /** * Returns the name for the credential. * * @exception GSSException may be thrown */ public GSSNameSpi getName() throws GSSException { //some debugging code if (m_freed) throw new GSSException(GSSException.NO_CRED); return (m_myName); } /** * Returns the remaining context initialization lifetime in * seconds. * * @exception GSSException may be thrown */ public int getInitLifetime() throws GSSException { //check if this is valid if (m_freed) throw new GSSException(GSSException.NO_CRED); //return time based on usage if (getUsage() == GSSCredential.ACCEPT_ONLY) return (0); return (m_initLifetime); } /** * Returns the remaining context acceptance lifetime in * seconds. * * @exception GSSException may be thrown */ public int getAcceptLifetime() throws GSSException { //sanity check if (m_freed) throw new GSSException(GSSException.NO_CRED); //take usage into account if (getUsage() == GSSCredential.INITIATE_ONLY) return (0); return (m_acceptLifetime); } /** * Returns the remaining context lifetime in * seconds. This takes into account the usage property and * returns the minimum remaining. * * @exception GSSException may be thrown */ public int getLifetime() throws GSSException { //sanity check if (m_freed) throw new GSSException(GSSException.NO_CRED); //take usage into account, return minimum remaining time if (getUsage() == GSSCredential.ACCEPT_ONLY) return (m_acceptLifetime); else if (getUsage() == GSSCredential.INITIATE_ONLY) return (m_initLifetime); if (m_initLifetime < m_acceptLifetime) return (m_initLifetime); return (m_acceptLifetime); } /** * Returns the credential usage flag. * * @exception GSSException may be thrown */ public int getUsage() throws GSSException { //sanity check if (m_freed) throw new GSSException(GSSException.NO_CRED); return (m_usage); } /** * Returns the credential mechanism. Since this is a single * credential element only a single oid can be returned. */ public Oid getMechanism() { return (Dummy.getMyOid()); } //instance variables private DummyName m_myName; private int m_usage; private int m_initLifetime; private int m_acceptLifetime; private boolean m_freed; } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/DummyCtxt.m4 0000644 0001750 0001750 00000044535 10577714244 024701 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi.dummy; import java.io.InputStream; import java.io.OutputStream; import java.io.DataOutputStream; import java.io.BufferedOutputStream; import java.io.IOException; import com.sun.gssapi.*; /** * Implements the dummy Context class GSSCtxtSpi interface * for the dummy mechanism. */ public class DummyCtxt implements GSSCtxtSpi { /** * Standard constructor. */ public DummyCtxt() { m_state = NEW; m_tokCount = Dummy.getNumOfTokExchanges(); m_lifetime = 0; } /** * Sets the context parameters for the initiator side of * the context. */ public void _setInitOptions (GSSCredSpi myCred, GSSNameSpi targName, int desLifetime, int ctxtOptions) throws GSSException { //make sure we are in right state if (m_state != NEW) { throw new GSSException(GSSException.NO_CONTEXT); } //set the target name if (targName == null || ! (targName instanceof DummyName)) throw new GSSException(GSSException.BAD_NAME); m_targName = (DummyName)targName; //get the src name from credential - that's all we have in there if (myCred == null) { m_srcName = DummyName.getDefault(); } else { if (! (myCred instanceof DummyCred)) throw new GSSException(GSSException.DEFECTIVE_CREDENTIAL); //we can do the cast below because we know it is our credential m_srcName = (DummyName)myCred.getName(); } //check for default lifetime request if (desLifetime == 0) m_lifetime = GSSContext.INDEFINITE; else m_lifetime = desLifetime; m_flags = ctxtOptions; m_initiator = true; } /** * Sets the context parameters for the acceptor side * of the context. */ public void _setAcceptOptions (GSSCredSpi myCred) throws GSSException { if (myCred == null) { m_targName = DummyName.getDefault(); m_lifetime = GSSContext.INDEFINITE; } else { if (!(myCred instanceof DummyCred)) throw new GSSException(GSSException.NO_CRED); m_targName = (DummyName)myCred.getName(); m_lifetime = myCred.getAcceptLifetime(); } m_flags = 0; m_initiator = false; } /** * Sets the channel bindings to be used during context * establishment. */ public void _setChannelBinding (ChannelBinding chb) throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Retrieves the mechanism options. * * @return int GSSContext options ORed together */ public int _getOptions () { return (m_flags); } /** * Inquire the remaining lifetime. * * @return the lifetime in seconds. May return reserved * value GSSContext.INDEFINITE for an indefinite lifetime. */ public int _getLifetime () { return (m_lifetime); } /** * Returns the mechanism oid. * * @return the Oid of this context */ public Oid _getMech () { return (Dummy.getMyOid()); } /** * Returns the context initiator name. * * @return initiator name * @exception GSSException */ public GSSNameSpi _getSrcName () throws GSSException { if (m_state != DONE) { throw new GSSException(GSSException.NO_CONTEXT); } return (m_srcName); } /** * Returns the context acceptor. * * @return context acceptor(target) name * @exception GSSException */ public GSSNameSpi _getTargName () throws GSSException { if (m_state != DONE) { throw new GSSException(GSSException.NO_CONTEXT); } return (m_targName); } /** * Returns the delegated credential for the context. This * is an optional feature of contexts which not all * mechanisms will support. A context can be requested to * support credential delegation by using the CRED_DELEG. * This is only valid on the acceptor side of the context. * @return GSSCredSpi object for the delegated credential * @exception GSSException * @see GSSContext#getDelegCredState */ public GSSCredSpi _getDelegCred () throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Tests if this is the initiator side of the context. * * @return boolean indicating if this is initiator (true) * or target (false) */ public boolean _isInitiator () { return (m_initiator); } /** * Tests if the context can be used for per-message service. * Context may allow the calls to the per-message service * functions before being fully established. * * @return boolean indicating if per-message methods can * be called. */ public boolean _isProtReady () { return (m_state == DONE); } /** * Initiator context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. On the * first call it will be ignored. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException */ public int _initSecCtxt (InputStream is, OutputStream os) throws GSSException { boolean needTokenBack = true; boolean sendToken = true; m_tokCount--; if (m_state == NEW) { m_initiator = true; m_state = IN_PROCESS; } else if (m_state == IN_PROCESS) { if (!_isInitiator ()) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } //read the token sendToken = processEstabToken(is); } //determine if we need token back if (!sendToken || m_tokCount < 1) needTokenBack = false; if (sendToken) { //create a token for our peer createEstabOutToken(os, needTokenBack); } if (needTokenBack) { return (GSSContext.CONTINUE_NEEDED); } m_state = DONE; return (GSSContext.COMPLETE); } /** * Acceptor's context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException */ public int _acceptSecCtxt (InputStream is, OutputStream os) throws GSSException { boolean needTokenBack = true; boolean sendToken = true; //we have this but it's not used since the status // code in tokens dictate if we need more m_tokCount--; if (m_state == NEW) { m_initiator = false; m_state = IN_PROCESS; } else if (m_state == IN_PROCESS) { if (_isInitiator ()) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } //read the token sendToken = processEstabToken(is); } //determine if we need token back if (!sendToken || m_tokCount < 1) needTokenBack = false; if (sendToken) { //create a token for our peer createEstabOutToken(os, needTokenBack); } if (needTokenBack) { return (GSSContext.CONTINUE_NEEDED); } m_state = DONE; m_srcName = new DummyName("dummy src name"); return (GSSContext.COMPLETE); } /** * Queries the context for largest data size to accomodate * the specified protection and be <= maxTokSize. * * @param qop the quality of protection that the context will be * asked to provide. * @param confReq a flag indicating whether confidentiality will be * requested or not * @param outputSize the maximum size of the output token * @return the maximum size for the input message that can be * provided to the wrap() method in order to guarantee that these * requirements are met. * @throws GSSException */ public int _getWrapSizeLimit (int qop, boolean confReq, int maxTokSize) throws GSSException { return (maxTokSize); } /** * Provides per-message token encapsulation. * * @param is the user-provided message to be protected * @param os the token to be sent to the peer. It includes * the message from is with the requested protection. * @param msgPro on input it contains the requested qop and * confidentiality state, on output, the applied values * @exception GSSException * @see MessageInfo * @see unwrap */ public void _wrap (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException { if (m_state != DONE) throw new GSSException(GSSException.NO_CONTEXT); try { int length = is.available(); createTokenHeader(os, length + 1); while (length-- > 0) { os.write(is.read()); } os.write(0); } catch (IOException e) { throw new GSSException(GSSException.FAILURE, -1, "io exception in wrap"); } } /** * Retrieves the message token previously encapsulated in the wrap * call. * * @param is the token from the peer * @param os unprotected message data * @param msgProp will contain the applied qop and confidentiality * of the input token * @return int representing the informatory status; this can be * COMPLETE, DUPLICATE_TOKEN, OLD_TOKEN, UNSEQ_TOKEN and GAP_TOKEN. * @exception GSSException * @see MessageInfo * @see wrap */ public void _unwrap (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException { if (m_state != DONE) throw new GSSException(GSSException.NO_CONTEXT); try { int length = processTokenHeader(is); while (length-- > 0) { os.write(is.read()); } msgProp.setPrivacy(true); msgProp.setQOP(0); } catch (IOException e) { throw new GSSException(GSSException.FAILURE, -1, "io exception in unwrap"); } } /** * Applies per-message integrity services. * * @param is the user-provided message * @param os the token to be sent to the peer along with the * message token. The message token is not encapsulated. * @param msgProp on input the desired QOP and output the applied QOP * @exception GSSException */ public void _getMIC (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException { if (m_state != DONE) throw new GSSException(GSSException.NO_CONTEXT); try { String tokenStr = new String("dummy_gss_sign"); createTokenHeader(os, tokenStr.length() + 1); os.write(tokenStr.getBytes()); os.write(0); msgProp.setPrivacy(false); msgProp.setQOP(0); } catch (IOException e) { throw new GSSException(GSSException.FAILURE, -1, "io exception in unwrap"); } } /** * Checks the integrity of the supplied tokens. * This token was previously generated by getMIC. * * @param is token generated by getMIC * @param msgStr the message to check integrity for * @param msgProp will contain the applied QOP and confidentiality * states of the token * @return int informatory status which can be one of COMPLETE, * DUPLICATE_TOKEN, OLD_TOKEN, UNSEQ_TOKEN and GAP_TOKEN. * @exception GSSException */ public void _verifyMIC (InputStream is, InputStream msgStr, MessageProp mProp) throws GSSException { try { int msgLen = processTokenHeader(is); is.skip(msgLen); } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } } /** * Produces a token representing this context. After this call * the context will no longer be usable until an import is * performed on the returned token. * * @param os the output token will be written to this stream * @exception GSSException */ public byte [] _export () throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Imports a previously exported context. * * @param Previously exported token * @exception GSSException * @see export */ public void _importSecCtxt (byte []aCtxtToken) throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Releases context resources and terminates the * context between 2 peer. * * @exception GSSException with major codes NO_CONTEXT, FAILURE. */ public void _dispose () throws GSSException { m_state = DELETED; } /** * Create token used during context establishment. */ private void createEstabOutToken(OutputStream os, boolean moreTokens) throws GSSException { try { String msgBody; if (moreTokens) msgBody = Integer.toString(1); else msgBody = Integer.toString(0); /* * the token is composed of: * tag * DER tok length * DER oid * 2 bytes for token type * msg body */ createTokenHeader(os, msgBody.length() + 1); DataOutputStream dos = new DataOutputStream(os); //need to be written as bytes because that is what C version uses dos.writeBytes(msgBody); dos.write(0); //add null char - this is what C dummy wants dos.flush(); } catch (IOException e) { throw new GSSException(GSSException.FAILURE, -1, "createInitOutToken"); } } /** * Processes the peer's context establishment token. */ private boolean processEstabToken(InputStream is) throws GSSException { try { processTokenHeader(is); //get continue/complete code byte []b = new byte[1]; b[0] = (byte)is.read(); int status = Integer.parseInt(new String(b)); is.read(); //null Byte if (status == 1) return (true); return(false); } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN, -1, "processing init token from peer"); } } /** * Checks the token header. * * @return the length of the message remaining */ private int processTokenHeader(InputStream is) throws GSSException, IOException { if (is.read() != 0x60) throw new GSSException(GSSException.DEFECTIVE_TOKEN); //read token length int length = DERParser.readLength(is); Oid tokOid = new Oid(is); if (!tokOid.equals(Dummy.getMyOid())) throw new GSSException(GSSException.BAD_MECH); //read token tag - not used is.read(); is.read(); //return the length of message remaining return (length - 1 - 1 - 10 - 2); } /** * Constructs the token header */ private void createTokenHeader(OutputStream os, int msgBodyLen) throws GSSException { try { /* * the token header is composed of: * tag * DER tok length * DER oid * 0x0 0x0 (token tag) */ byte [] derOid = Dummy.getMyOid().getDER(); int length = derOid.length + msgBodyLen + 2; DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(os)); dos.write(0x60); DERParser.writeLength(dos, length); dos.write(derOid); //now write the token tag - 0x0 - doesn't seem to be used dos.write(0); dos.write(0); dos.flush(); } catch (IOException e) { throw new GSSException(GSSException.FAILURE, -1, "createTokenHeader"); } } //instance variables private DummyName m_srcName; private DummyName m_targName; private int m_tokCount; private int m_state; private int m_flags; private int m_lifetime; private boolean m_initiator; private static final int NEW = 1; private static final int IN_PROCESS = 2; private static final int DONE = 3; private static final int DELETED = 4; } /** * This is a package private class used to decode/encode ASN.1 DER * length. */ class DERParser { /** * Returns the DER encoded length from the InputStream. */ static int readLength(InputStream is) throws GSSException { int length, tmp; //get the length of Oid - check if short form try { if (((tmp = is.read()) & 0x080) == 0) length = tmp; else { //must be long form tmp &= 0x7f; for (length = 0; tmp > 0; tmp--) { length <<= 8; length += (0xff & is.read()); } } } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } return (length); } /** * Encodes DER length. */ static void writeLength(OutputStream os, int length) throws IOException { //encode the length - for all practical purposes, the length //should always be less then 0x80 (128) if (length < 0x80) os.write(length); else if (length < 0x100) { os.write(0x081); os.write(length); } else if (length < 0x80000) { os.write(0x082); os.write(length >> 8); os.write(length & 0xff); } else if (length < 0x1000000) { os.write(0x083); os.write(length >> 16); os.write((length >> 8) & 0xff); os.write(length & 0xff); } else { os.write(0x084); os.write(length >>> 24); os.write((length >> 16) & 0xff); os.write((length >> 8) & 0xff); os.write(length & 0xff); } } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/DummyName.java 0000644 0001750 0001750 00000012646 10577714244 025236 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi.dummy; import java.io.InputStream; import java.io.OutputStream; import java.net.InetAddress; import java.net.UnknownHostException; import com.sun.gssapi.*; /** * Implements the GSSNameSpi for the dummy mechanism. */ public class DummyName implements GSSNameSpi { /** * Returns the default name for the dummy mechanism. * It is the username@localDomain. */ static DummyName getDefault() { StringBuffer res = new StringBuffer(System.getProperty("user.name", "unknown")); res.append("@"); try { res.append(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { res.append("unknown"); } return (new DummyName(res.toString())); } /** * Standard constructor - nop. */ public DummyName() { } /** * Creates a dummy name from the specified user name. */ DummyName(String userName) { m_type = GSSName.NT_USER_NAME; m_name = userName; } /** * Initializer for the GSSNameSpi object using a byte array. * * @param byte[] name bytes which is to be interpreted based * on the nameType * @exception GSSException The major codes can be BAD_NAMETYPE, * BAD_NAME, and FAILURE. * @see #init(String,Oid) */ public void init(byte[] externalName, Oid nameType) throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Initializer for the GSSNameSpi object using a String. * * @param name string which is to be interpreted based * on the nameType * @exception GSSException The major codes can be BAD_NAMETYPE, * BAD_NAME, and FAILURE. * @see #init(String,Oid) */ public void init(String name, Oid nameType) throws GSSException { m_name = name; m_type = nameType; } /** * Equal method for the GSSNameSpi objects. * If either name denotes an anonymous principal, the call should * return false. * * @param name to be compared with * @returns true if they both refer to the same entity, else false * @exception GSSException with major codes of BAD_NAMETYPE, * BAD_NAME, FAILURE */ public boolean equals(GSSNameSpi name) throws GSSException { if (!(name instanceof DummyName)) { return (false); } return (m_name.equals(((DummyName)name).m_name)); } /** * Returns a flat name representation for this object. The name * format is defined in RFC 2078. * * @return the flat name representation for this object * @exception GSSException with major codes NAME_NOT_MN, BAD_NAME, * BAD_NAME, FAILURE. */ public byte[] export() throws GSSException { throw new GSSException(GSSException.UNAVAILABLE); } /** * Get the mechanism type that this NameElement corresponds to. * * @return the Oid of the mechanism type */ public Oid getMech() { return (Dummy.getMyOid()); } /** * Returns a string representation for this name. The printed * name type can be obtained by calling getStringNameType(). * * @return string form of this name * @see #getStringNameType() * @overrides Object#toString */ public String toString() { return (m_name); } /** * Returns the name type oid. */ public Oid getNameType() { return (m_type); } /** * Returns the oid describing the format of the printable name. * * @return the Oid for the format of the printed name */ public Oid getStringNameType() { return (m_type); } /** * Produces a copy of this object. */ public Object clone() { return null; } /** * Indicates if this name object represents an Anonymous name. */ public boolean isAnonymousName() { if (m_type.equals(GSSName.NT_ANONYMOUS)) return (true); return (false); } //instance variables private String m_name; private Oid m_type; } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/mechs/dummy/Makefile 0000644 0001750 0001750 00000006420 10577714245 024131 0 ustar god god # # Copyright (c) 1999, 2007 Sun Microsystems, Inc. # All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # -Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # -Redistribution in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # Neither the name of Sun Microsystems, Inc. or the names of contributors # may be used to endorse or promote products derived from this software # without specific prior written permission. # # This software is provided "AS IS," without a warranty of any kind. ALL # EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING # ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR # PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS # SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE # AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE # SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE # LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, # SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED # AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR # INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGES. # # You acknowledge that this software is not designed,licensed or intended # for use in the design, construction, operation or maintenance of any # nuclear facility. # PKGDIR= com/sun/gssapi/dummy include ../../../Makefile.common CLASSES= Dummy DummyCtxt DummyName DummyCred JFILES= $(CLASSES:%=%.java) all: $(TFILE) $(TFILE): $(JFILES) $(JC) -d $(CDIR) $(JCFLAGS) $? @touch $(TFILE) # # Name mangling # # Properties key=value strings M4DEF_PROP = -D NAMES=_K872D1AC M4DEF_PROP += -D NAME=_K532D1BD M4DEF_PROP += -D CONTEXT=_K1000A49 M4DEF_PROP += -D CRED=_K2102CC5 Dummy.java: Dummy.m4 /usr/ccs/bin/m4 $(M4DEF_PROP) Dummy.m4 > Dummy.java # Service Provider Interface Context Class and its methods/interface M4DEF_CTXTSPI = -D GSSCtxtSpi=C018FE95 M4DEF_CTXTSPI += -D _setInitOptions=_S235D9C1 M4DEF_CTXTSPI += -D _setAcceptOptions=_S90010CC M4DEF_CTXTSPI += -D _setChannelBinding=_S9B00AB2 M4DEF_CTXTSPI += -D _getOptions=_S00027C3 M4DEF_CTXTSPI += -D _getLifetime=_S4080EED M4DEF_CTXTSPI += -D _getMech=_S0200735 M4DEF_CTXTSPI += -D _getSrcName=_S000EEFF M4DEF_CTXTSPI += -D _getTargName=_S011CEF9 M4DEF_CTXTSPI += -D _getDelegCred=_S0293FFA M4DEF_CTXTSPI += -D _isInitiator=_S123049E M4DEF_CTXTSPI += -D _isProtReady=_S1116FAA M4DEF_CTXTSPI += -D _initSecCtxt=_S0E039DB M4DEF_CTXTSPI += -D _acceptSecCtxt=_S80A2F2C M4DEF_CTXTSPI += -D _getWrapSizeLimit=_S808028B M4DEF_CTXTSPI += -D _wrap=_S1309AFD M4DEF_CTXTSPI += -D _unwrap=_S1576D09 M4DEF_CTXTSPI += -D _getMIC=_S1513DBA M4DEF_CTXTSPI += -D _verifyMIC=_S00256CF M4DEF_CTXTSPI += -D _export=_S725B2DA M4DEF_CTXTSPI += -D _importSecCtxt=_S0AC8F9E M4DEF_CTXTSPI += -D _dispose=_S020B957 DummyCtxt.java: DummyCtxt.m4 /usr/ccs/bin/m4 $(M4DEF_CTXTSPI) DummyCtxt.m4 > DummyCtxt.java libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/C018FE95.java 0000644 0001750 0001750 00000026050 10577714237 022110 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi; import java.io.InputStream; import java.io.OutputStream; /** * An object of this class implements the functionality of a GSSContext * for a specific mechanism. * A C018FE95 object can be thought of having 3 states: * -before initialization * -during initialization with its peer * -after it is established *
* The context options can only be requested in state 1. In state 3, * the per message operations are available to the callers. The get * methods for the context options will return the requested options * while in state 1 and 2, and the established values in state 3. * Some mechanisms may allow the access to the per-message operations * and the context flags before the context is fully established. The * isProtReady method is used to indicate that these services are * available. */ public interface C018FE95 { /** * Sets the mechanism options to be used during context * creation on the initiator's side. This is used to * initialize a new C018FE95 object. * * @param myCred the principal's credentials; may be null * @param targName the context peer * @param desLifetime the requested lifetime; 0 indicates use * default * @param mechOptions ORed GSSContext options * @exception GSSException may be thrown */ public void _S235D9C1 (GSSCredSpi myCred, GSSNameSpi targName, int desLifetime, int ctxtOptions) throws GSSException; /** * Sets the mechanism options to be used during context * creation on the acceptor's side. This is used to initialize * a new C018FE95 object. * * @param myCred the principal's credentials; may be null * @exception GSSException may be thrown */ public void _S90010CC (GSSCredSpi myCred) throws GSSException; /** * Sets the channel bindings to be used during context * establishment. This method is only called if the application * wishes to use channel bindings with this context. * * @param chb channel bindings to be set * @exception GSSException may be thrown */ public void _S9B00AB2 (ChannelBinding chb) throws GSSException; /** * Retrieves the mechanism options. * * @return int GSSContext options ORed together */ public int _S00027C3 (); /** * Inquire the remaining lifetime. * * @return the lifetime in seconds. May return reserved * value GSSContext.INDEFINITE for an indefinite lifetime. */ public int _S4080EED (); /** * Returns the mechanism oid. * * @return the Oid for this context */ public Oid _S0200735 (); /** * Returns the context initiator name. * * @return initiator name * @exception GSSException may be thrown */ public GSSNameSpi _S000EEFF () throws GSSException; /** * Returns the context acceptor name. * * @return context acceptor(target) name * @exception GSSException may be thrown */ public GSSNameSpi _S011CEF9 () throws GSSException; /** * Returns the delegated credential for the context. This * is an optional feature of contexts which not all * mechanisms will support. A context can be requested to * support credential delegation by using the CRED_DELEG. * This is only valid on the acceptor side of the context. * @return GSSCredSpi object for the delegated credential * @exception GSSException may be thrown * @see GSSContext#getDelegCredState */ public GSSCredSpi _S0293FFA () throws GSSException; /** * Tests if this is the initiator side of the context. * * @return boolean indicating if this is initiator (true) * or target (false) */ public boolean _S123049E (); /** * Tests if the context can be used for per-message service. * Context may allow the calls to the per-message service * functions before being fully established. * * @return boolean indicating if per-message methods can * be called. */ public boolean _S1116FAA (); /** * Initiator context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. On the * first call it will be ignored. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException may be thrown */ public int _S0E039DB (InputStream is, OutputStream os) throws GSSException; /** * Acceptor's context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException may be thrown */ public int _S80A2F2C (InputStream is, OutputStream os) throws GSSException; /** * Queries the context for largest data size to accomodate * the specified protection and for the token to remain less then * maxTokSize. * * @param qop the quality of protection that the context will be * asked to provide. * @param confReq a flag indicating whether confidentiality will be * requested or not * @param outputSize the maximum size of the output token * @return the maximum size for the input message that can be * provided to the wrap() method in order to guarantee that these * requirements are met. * @exception GSSException may be thrown */ public int _S808028B (int qop, boolean confReq, int maxTokSize) throws GSSException; /** * Provides per-message token encapsulation. * * @param is the user-provided message to be protected * @param os the token to be sent to the peer. It includes * the message from is with the requested protection. * @param msgPro on input it contains the requested qop and * confidentiality state, on output, the applied values * @exception GSSException may be thrown * @see MessageInfo * @see unwrap */ public void _S1309AFD (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Retrieves the message token previously encapsulated in the wrap * call. * * @param is the token from the peer * @param os unprotected message data * @param msgProp will contain the applied qop and confidentiality * of the input token and any informatory status values * @exception GSSException may be thrown * @see MessageInfo * @see wrap */ public void _S1576D09 (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Applies per-message integrity services. * * @param is the user-provided message * @param os the token to be sent to the peer along with the * message token. The message token is not encapsulated. * @param msgProp on input the desired QOP and output the applied QOP * @exception GSSException */ public void _S1513DBA (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Checks the integrity of the supplied tokens. * This token was previously generated by getMIC. * * @param is token generated by getMIC * @param msgStr the message to check integrity for * @param msgProp will contain the applied QOP and confidentiality * states of the token as well as any informatory status codes * @exception GSSException may be thrown */ public void _S00256CF (InputStream is, InputStream msgStr, MessageProp mProp) throws GSSException; /** * Produces a token representing this context. After this call * the context will no longer be usable until an import is * performed on the returned token. * * @return exported context token * @exception GSSException may be thrown */ public byte []_S725B2DA () throws GSSException; /** * Imports a previously exported context. This will be called * for newly created objects. * * @param is the previously exported token * @exception GSSException may be thrown * @see export */ public void _S0AC8F9E (byte []token) throws GSSException; /** * Releases context resources and terminates the * context between 2 peer. * * @exception GSSException may be thrown */ public void _S020B957 () throws GSSException; } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/ChannelBinding.java 0000644 0001750 0001750 00000012763 10577714237 023755 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi; import java.net.InetAddress; /** * The JGSS accommodates the concept of caller-provided channel * binding information. Channel bindings are used to strengthen * the quality with which peer entity authentication is provided * during context establishment. They enable the JGSS callers to * bind the establishment of the a security context to relevant * characteristics like addresses or to application specific data. *
* The caller initiating the security context must determine the * appropriate channel binding values to set in the GSSContext * object. The acceptor must provide identical binding in order * to validate that received tokens possess correct * channel-related characteristics. *
* Use of channel bindings is optional in JGSS. Since channel- * binding information may be transmitted in context establishment * tokens, applications should therefore not use confidential data * as channel-binding components. * @see GSSContext#setChannelBinding * @see java.net.InetAddress */ public class ChannelBinding { private InetAddress m_initiator; private InetAddress m_acceptor; private byte[] m_appData; /** * Construct a channel bindings object that contains all the user * specified tags. * * @param initAddr the address of the context initiator * @param acceptAddr address of the context acceptor * @param appData a byte array of application data to be used as * part of the channel-binding */ public ChannelBinding(InetAddress initAddr, InetAddress acceptAddr, byte[] appData) { m_initiator = initAddr; m_acceptor = acceptAddr; if (appData != null) { m_appData = new byte[appData.length]; java.lang.System.arraycopy(appData, 0, m_appData, 0, m_appData.length); } } /** * Construct a channel bindings object without any addressing * information. * * @param appData a byte array of application data to be used as * part of the channel-binding */ public ChannelBinding(byte[] appData) { m_initiator = null; m_acceptor = null; m_appData = new byte[appData.length]; java.lang.System.arraycopy(appData, 0, m_appData, 0, m_appData.length); } /** * Get the initiator's address for this channel binding. * * @return the initiator's address. null if no address * information is contained */ public InetAddress getInitiatorAddress() { return m_initiator; } /** * Get the acceptor's address for this channel binding. * * @return the acceptor's address. null if no address * information is contained */ public InetAddress getAcceptorAddress() { return m_acceptor; } /** * Get the application specified data for this channel binding. * The byte array is not copied. * * @return byte[] the application data that comprises this * channel-binding */ public byte[] getApplicationData() { return m_appData; } /** * Compares two instances of ChannelBinding * * @return true if objects are the same * @overrides java.lang.Object#equals */ public boolean equals(Object obj) { if (! (obj instanceof ChannelBinding)) return false; ChannelBinding cb = (ChannelBinding)obj; //check for application data being null in one but not the other if ((getApplicationData() == null && cb.getApplicationData() != null) || (getApplicationData() != null && cb.getApplicationData() == null)) return (false); return (this.m_initiator.equals(cb.getInitiatorAddress()) && this.m_acceptor.equals(cb.getAcceptorAddress()) && (this.getApplicationData() == null || this.m_appData.equals(cb.getApplicationData()))); } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/DERParser.java 0000644 0001750 0001750 00000014617 10577714237 022701 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; import java.io.ByteArrayOutputStream; import java.util.Vector; /** * This is a package private class used to decode/encode ASN.1 DER * oids. */ class DERParser { /** * Returns the DER encoded length from the InputStream. */ static int readLength(InputStream is) throws GSSException { int length, tmp; //get the length of Oid - check if short form try { if (((tmp = is.read()) & 0x080) == 0) length = tmp; else { //must be long form tmp &= 0x7f; for (length = 0; tmp > 0; tmp--) { length <<= 8; length += (0xff & is.read()); } } } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } return (length); } /** * Decodes a DER encoding of an Oid object into vector components. */ static Vector decodeOid(InputStream is) throws GSSException { //check the tag first try { if (is.read() != 0x06) throw new GSSException(GSSException.DEFECTIVE_TOKEN); } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } return (decodeOidOctets(is, readLength(is))); } /** * Decodes the specified number of oid octets. * Returns a vector of integer components. */ static Vector decodeOidOctets(InputStream is, int numOfOctets) throws GSSException { Vector v = new Vector(9, 3); //first octet is combination of first two numbers try { int comp, tmp = is.read(); if (tmp < 40) comp = 0; else if (tmp < 80) comp = 1; else comp = 2; v.addElement(new Integer(comp)); v.addElement(new Integer(tmp - (40 * comp))); //get the rest of the octets for (int i = 1; i < numOfOctets; i++) { comp = 0; //assume that at most 4 octets make up each component for (int j=0; j < 4; j++) { comp <<= 7; tmp = is.read(); comp |= (tmp & 0x7f); if ((tmp & 0x80) == 0) break; i++; } v.addElement(new Integer(comp)); } } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } return (v); } /** * Encodes DER length. */ static void writeLength(OutputStream os, int len) throws IOException { //encode the length - for all practical purposes, the length //should always be less then 0x80 (128) if (len < 0x80) os.write(len); else if (len < 0x100) { os.write(0x081); os.write(len); } else if (len < 0x80000) { os.write(0x082); os.write(len >> 8); os.write(len & 0xff); } else if (len < 0x1000000) { os.write(0x083); os.write(len >> 16); os.write((len >> 8) & 0xff); os.write(len & 0xff); } else { os.write(0x084); os.write(len >>> 24); os.write((len >> 16) & 0xff); os.write((len >> 8) & 0xff); os.write(len & 0xff); } } /** * Produces ASN.1 DER encoding for the object. * @return byte[] DER encoding for the object */ static byte[] encodeOid(Vector v) throws GSSException { //use byte array output stream - 32 initial bytes should be enough ByteArrayOutputStream o = new ByteArrayOutputStream(); int length = 1; try { //start with Oid tag o.write(0x06); //figure our the length - must have at least 2 elements X.208 if (v.size() < 2) throw new IllegalArgumentException(); for (int i = 2; i < v.size(); i++) { int compLen = 0; int nextComp = ((Integer)v.elementAt(i)).intValue(); //count # of 7 bit octets this will occupy for (compLen = 0; nextComp > 0; nextComp >>= 7, compLen++) ;//nothing to do //must have at least 1 octet if (compLen == 0) length += 1; else length += compLen; } writeLength(o, length); //now write the components writeOidOctets(o, v); } catch (IOException e) { throw new GSSException(GSSException.DEFECTIVE_TOKEN); } return (o.toByteArray()); } /** * Encodes the oid octets onto the stream. */ static void writeOidOctets(OutputStream o, Vector v) throws IOException { //first 2 components occupy 1 octet o.write(((Integer)v.elementAt(0)).intValue() * 40 + ((Integer)v.elementAt(1)).intValue()); for (int i = 2; i < v.size(); i++) { int tmp, nextComp = ((Integer)v.elementAt(i)).intValue(); //each component may be at most 4 octets long for (int c = 0; c < 4; c++) { tmp = (nextComp & 0x7f); nextComp >>>= 7; //every octet except for last has bit 8 on if (nextComp > 0) o.write(tmp | 0x80); else { o.write(tmp); break; } } } } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/GSSContext.java 0000644 0001750 0001750 00000165106 10577714240 023105 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi; import java.io.InputStream; import java.io.OutputStream; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; /** * This class represents the JGSS security context and its associated * operations. JGSS security contexts are established between * peers using locally established credentials. Multiple contexts * may exist simultaneously between a pair of peers, using the same * or different set of credentials. The JGSS is independent of * the underlying transport protocols and depends on its callers to * transport the tokens between peers. *
* The context object can be thought of as having 3 implicit states: * before it is established, during its context establishment, and * after a fully established context exists. *
* Before the context establishment phase is initiated, the context * initiator may request specific characteristics desired of the * established context. These can be set using the set methods. After the * context is established, the caller can check the actual characteristic * and services offered by the context using the query methods. *
* The context establishment phase begins with the first call to the init * method by the context initiator. During this phase the init and accept * methods will produce GSS-API authentication tokens which the calling * application needs to send to its peer. The init and accept methods may * return a CONTINUE_NEEDED code which indicates that a token is needed * from its peer in order to continue the context establishment phase. A * return code of COMPLETE signals that the local end of the context is * established. This may still require that a token be sent to the peer, * depending if one is produced by GSS-API. The isEstablished method can * also be used to determine if the local end of the context has been * fully established. During the context establishment phase, the * isProtReady method may be called to determine if the context can be * used for the per-message operations. This allows implementation to * use per-message operations on contexts which aren't fully established. *
* After the context has been established or the isProtReady method * returns "true", the query routines can be invoked to determine the actual * characteristics and services of the established context. The * application can also start using the per-message methods of wrap and * getMIC to obtain cryptographic operations on application supplied data. *
* When the context is no longer needed, the application should call * dispose to release any system resources the context may be using. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. *
* The GSS-API authentication tokens contain a definitive * start and end. This method will attempt to read one of these * tokens per invocation, and may block on the stream if only * part of the token is available. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. *
* This method may return an output token which the application * will need to send to the peer for further processing by the * init call. "null" return value indicates that no token needs * to be sent to the peer. The application can call isEstablished * to determine if the context establishment phase is complete * for this peer. A return value of "false" from isEstablished * indicates that more tokens are expected to be supplied to this * method. *
* Please note that the accept method may return a token for the * peer, and isEstablished return "true" also. This indicates that * the token needs to be sent to the peer, but the local end of the * context is now fully established. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. * Called by the context acceptor upon receiving a token from * the peer. May need to be called again if returns CONTINUE_NEEDED. * *
* The GSS-API authentication tokens contain a definitive start * and end. This method will attempt to read one of these tokens * per invocation, and may block on the stream if only part of the * token is available. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. * *
* Supports the wrapping and unwrapping of zero-length messages. *
* The application will be responsible for sending the token * to the peer. * *
* Supports the wrapping and unwrapping of zero-length messages. *
* The application will be responsible for sending the token * to the peer. * *
* Supports the wrapping and unwrapping of zero-length messages. * *
* Supports the wrapping and unwrapping of zero-length messages. * *
* Note that privacy can only be applied through the wrap call. *
* Supports the derivation of MICs from zero-length messages. * *
* Note that privacy can only be applied through the wrap call. *
* Supports the derivation of MICs from zero-length messages. * *
* This method deactivates the security context and creates an * interprocess token which, when passed to the byte array * constructor of the GSSContext class in another process, * will re-activate the context in the second process. *
* Only a single instantiation of a given context may be active * at any one time; a subsequent attempt by a context exporter * to access the exported security context will fail. * *
* The context object can be thought of as having 3 implicit states: * before it is established, during its context establishment, and * after a fully established context exists. *
* Before the context establishment phase is initiated, the context * initiator may request specific characteristics desired of the * established context. These can be set using the set methods. After the * context is established, the caller can check the actual characteristic * and services offered by the context using the query methods. *
* The context establishment phase begins with the first call to the init * method by the context initiator. During this phase the init and accept * methods will produce GSS-API authentication tokens which the calling * application needs to send to its peer. The init and accept methods may * return a CONTINUE_NEEDED code which indicates that a token is needed * from its peer in order to continue the context establishment phase. A * return code of COMPLETE signals that the local end of the context is * established. This may still require that a token be sent to the peer, * depending if one is produced by GSS-API. The isEstablished method can * also be used to determine if the local end of the context has been * fully established. During the context establishment phase, the * isProtReady method may be called to determine if the context can be * used for the per-message operations. This allows implementation to * use per-message operations on contexts which aren't fully established. *
* After the context has been established or the isProtReady method * returns "true", the query routines can be invoked to determine the actual * characteristics and services of the established context. The * application can also start using the per-message methods of wrap and * getMIC to obtain cryptographic operations on application supplied data. *
* When the context is no longer needed, the application should call * dispose to release any system resources the context may be using. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. *
* The GSS-API authentication tokens contain a definitive * start and end. This method will attempt to read one of these * tokens per invocation, and may block on the stream if only * part of the token is available. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. *
* This method may return an output token which the application * will need to send to the peer for further processing by the * init call. "null" return value indicates that no token needs * to be sent to the peer. The application can call isEstablished * to determine if the context establishment phase is complete * for this peer. A return value of "false" from isEstablished * indicates that more tokens are expected to be supplied to this * method. *
* Please note that the accept method may return a token for the * peer, and isEstablished return "true" also. This indicates that * the token needs to be sent to the peer, but the local end of the * context is now fully established. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. * Called by the context acceptor upon receiving a token from * the peer. May need to be called again if returns CONTINUE_NEEDED. * *
* The GSS-API authentication tokens contain a definitive start * and end. This method will attempt to read one of these tokens * per invocation, and may block on the stream if only part of the * token is available. *
* Upon completion of the context establishment, the available * context options may be queried through the get methods. * *
* Supports the wrapping and unwrapping of zero-length messages. *
* The application will be responsible for sending the token * to the peer. * *
* Supports the wrapping and unwrapping of zero-length messages. *
* The application will be responsible for sending the token * to the peer. * *
* Supports the wrapping and unwrapping of zero-length messages. * *
* Supports the wrapping and unwrapping of zero-length messages. * *
* Note that privacy can only be applied through the wrap call. *
* Supports the derivation of MICs from zero-length messages. * *
* Note that privacy can only be applied through the wrap call. *
* Supports the derivation of MICs from zero-length messages. * *
* This method deactivates the security context and creates an * interprocess token which, when passed to the byte array * constructor of the GSSContext class in another process, * will re-activate the context in the second process. *
* Only a single instantiation of a given context may be active * at any one time; a subsequent attempt by a context exporter * to access the exported security context will fail. * *
* A credential may be used to perform context initiation, acceptance, * or both. *
* The context options can only be requested in state 1. In state 3, * the per message operations are available to the callers. The get * methods for the context options will return the requested options * while in state 1 and 2, and the established values in state 3. * Some mechanisms may allow the access to the per-message operations * and the context flags before the context is fully established. The * isProtReady method is used to indicate that these services are * available. */ public interface GSSCtxtSpi { /** * Sets the mechanism options to be used during context * creation on the initiator's side. This is used to * initialize a new GSSCtxtSpi object. * * @param myCred the principal's credentials; may be null * @param targName the context peer * @param desLifetime the requested lifetime; 0 indicates use * default * @param mechOptions ORed GSSContext options * @exception GSSException may be thrown */ public void _setInitOptions (GSSCredSpi myCred, GSSNameSpi targName, int desLifetime, int ctxtOptions) throws GSSException; /** * Sets the mechanism options to be used during context * creation on the acceptor's side. This is used to initialize * a new GSSCtxtSpi object. * * @param myCred the principal's credentials; may be null * @exception GSSException may be thrown */ public void _setAcceptOptions (GSSCredSpi myCred) throws GSSException; /** * Sets the channel bindings to be used during context * establishment. This method is only called if the application * wishes to use channel bindings with this context. * * @param chb channel bindings to be set * @exception GSSException may be thrown */ public void _setChannelBinding (ChannelBinding chb) throws GSSException; /** * Retrieves the mechanism options. * * @return int GSSContext options ORed together */ public int _getOptions (); /** * Inquire the remaining lifetime. * * @return the lifetime in seconds. May return reserved * value GSSContext.INDEFINITE for an indefinite lifetime. */ public int _getLifetime (); /** * Returns the mechanism oid. * * @return the Oid for this context */ public Oid _getMech (); /** * Returns the context initiator name. * * @return initiator name * @exception GSSException may be thrown */ public GSSNameSpi _getSrcName () throws GSSException; /** * Returns the context acceptor name. * * @return context acceptor(target) name * @exception GSSException may be thrown */ public GSSNameSpi _getTargName () throws GSSException; /** * Returns the delegated credential for the context. This * is an optional feature of contexts which not all * mechanisms will support. A context can be requested to * support credential delegation by using the CRED_DELEG. * This is only valid on the acceptor side of the context. * @return GSSCredSpi object for the delegated credential * @exception GSSException may be thrown * @see GSSContext#getDelegCredState */ public GSSCredSpi _getDelegCred () throws GSSException; /** * Tests if this is the initiator side of the context. * * @return boolean indicating if this is initiator (true) * or target (false) */ public boolean _isInitiator (); /** * Tests if the context can be used for per-message service. * Context may allow the calls to the per-message service * functions before being fully established. * * @return boolean indicating if per-message methods can * be called. */ public boolean _isProtReady (); /** * Initiator context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. On the * first call it will be ignored. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException may be thrown */ public int _initSecCtxt (InputStream is, OutputStream os) throws GSSException; /** * Acceptor's context establishment call. This method may be * required to be called several times. A CONTINUE_NEEDED return * call indicates that more calls are needed after the next token * is received from the peer. * * @param is contains the token received from the peer. * @param os to which any tokens required to be sent to the peer * will be written. It is responsibility of the caller * to send the token to its peer for processing. * @return integer indicating if more calls are needed. Possible * values are COMPLETE and CONTINUE_NEEDED. * @exception GSSException may be thrown */ public int _acceptSecCtxt (InputStream is, OutputStream os) throws GSSException; /** * Queries the context for largest data size to accomodate * the specified protection and for the token to remain less then * maxTokSize. * * @param qop the quality of protection that the context will be * asked to provide. * @param confReq a flag indicating whether confidentiality will be * requested or not * @param outputSize the maximum size of the output token * @return the maximum size for the input message that can be * provided to the wrap() method in order to guarantee that these * requirements are met. * @exception GSSException may be thrown */ public int _getWrapSizeLimit (int qop, boolean confReq, int maxTokSize) throws GSSException; /** * Provides per-message token encapsulation. * * @param is the user-provided message to be protected * @param os the token to be sent to the peer. It includes * the message from is with the requested protection. * @param msgPro on input it contains the requested qop and * confidentiality state, on output, the applied values * @exception GSSException may be thrown * @see MessageInfo * @see unwrap */ public void _wrap (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Retrieves the message token previously encapsulated in the wrap * call. * * @param is the token from the peer * @param os unprotected message data * @param msgProp will contain the applied qop and confidentiality * of the input token and any informatory status values * @exception GSSException may be thrown * @see MessageInfo * @see wrap */ public void _unwrap (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Applies per-message integrity services. * * @param is the user-provided message * @param os the token to be sent to the peer along with the * message token. The message token is not encapsulated. * @param msgProp on input the desired QOP and output the applied QOP * @exception GSSException */ public void _getMIC (InputStream is, OutputStream os, MessageProp msgProp) throws GSSException; /** * Checks the integrity of the supplied tokens. * This token was previously generated by getMIC. * * @param is token generated by getMIC * @param msgStr the message to check integrity for * @param msgProp will contain the applied QOP and confidentiality * states of the token as well as any informatory status codes * @exception GSSException may be thrown */ public void _verifyMIC (InputStream is, InputStream msgStr, MessageProp mProp) throws GSSException; /** * Produces a token representing this context. After this call * the context will no longer be usable until an import is * performed on the returned token. * * @return exported context token * @exception GSSException may be thrown */ public byte []_export () throws GSSException; /** * Imports a previously exported context. This will be called * for newly created objects. * * @param is the previously exported token * @exception GSSException may be thrown * @see export */ public void _importSecCtxt (byte []token) throws GSSException; /** * Releases context resources and terminates the * context between 2 peer. * * @exception GSSException may be thrown */ public void _dispose () throws GSSException; } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/gssapi/GSSException.java 0000644 0001750 0001750 00000027544 10577714242 023424 0 ustar god god /* * Copyright (c) 1999, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.gssapi; /** * This exception is thrown whenever a fatal GSS-API error occurs * including mechanism specific errors. It contains * both the major and minor JGSS status codes. The mechanism * implementers are responsible for setting appropriate minor status * codes when throwing this exception. Methods are included to retrieve * the error string representation for both major and minor codes. *
*
*
* JGSS distinguishes between the following name representations: *
{ 1(iso), 3(org), 6(dod), 1(internet), 5(security), * 6(nametypes), 2(gss-host-based-services) } */ public static final Oid NT_HOSTBASED_SERVICE; /** * Name type used to indicate a named user on a local system. It * represents the following value: *
* { iso(1) member-body(2) United States(840) mit(113554) * infosys(1) gssapi(2) generic(1) user_name(1) } */ public static final Oid NT_USER_NAME; /** * Name type used to indicate a numeric user identifier corresponding * to a user on a local system. (e.g. Uid). It represents the * following value: *
* { iso(1) member-body(2) United States(840) mit(113554) infosys(1) * gssapi(2) generic(1) machine_uid_name(2) } */ public static final Oid NT_MACHINE_UID_NAME; /** * Name type used to indicate a string of digits representing the * numeric user identifier of a user on a local system. It * represents the following value: *
* { iso(1) member-body(2) United States(840) mit(113554) infosys(1) * gssapi(2) generic(1) string_uid_name(3) } */ public static final Oid NT_STRING_UID_NAME; /** * Name type used to represent an Anonymous identity. It represents * the following value: *
* { 1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), * 3(gss-anonymous-name) } */ public static final Oid NT_ANONYMOUS; /** * Name type used to indicate an exported name produced by the * export method. It represents the following value: *
* { 1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), * 4(gss-api-exported-name) } */ public static final Oid NT_EXPORT_NAME; //initialize the oid objects static { try { NT_HOSTBASED_SERVICE = new Oid("1.3.6.1.5.6.2"); NT_USER_NAME = new Oid("1.2.840.113554.1.2.1.1"); NT_MACHINE_UID_NAME = new Oid("1.2.840.113554.1.2.1.2"); NT_STRING_UID_NAME = new Oid("1.2.840.113554.1.2.1.3"); NT_ANONYMOUS = new Oid("1.3.6.1.5.6.3"); NT_EXPORT_NAME = new Oid("1.3.6.1.5.6.4"); } catch (GSSException e) { //because we are initializeing statics, we can //only throw a standard runtime exception throw new NumberFormatException(); } } /** * Converts a contiguous string name to a GSSName object * of the specified type. The nameStr parameter is * interpreted based on the type specified. * In general, the GSSName object created will not be an MN; * the exception to this is if the type parameter indicates * NT_EXPORT_NAME. *
*
*
* Oids are hierarchically globally-interpretable identifiers * used within the GSS-API framework to identify mechanisms and * name formats. The structure and encoding of Oids is defined * in ISOIEC-8824 and ISOIEC-8825. For example the Oid * representation of Kerberos V5 mechanism is 1.2.840.113554.1.2.2 *
* An instance of the NfsHandler class is
* registered with the setHandler method of
* the NFS XFileExtensionAccessor.
*
* @param server The name of the server to which the
* request was sent.
* @param retries The number of times the request has
* been retransmitted. After the first timeout
* retries will be zero.
* @param wait Total time since first call in milliseconds
* (cumulative value of all retransmission timeouts).
* @return false if retransmissions are to continue.
* If the method returns true, the RPC layer will
* abort the retransmissions and return an
* InterruptedIOException to the application.
*/
public abstract boolean timeout(String server, int retries, int wait);
/**
* Called when a server reply is recieved after a timeout.
*
* @param server The name of the server that returned
* the reply.
*/
public abstract void ok(String server);
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/NfsSecurity.java 0000644 0001750 0001750 00000014666 10577714250 022667 0 ustar god god /*
* Copyright (c) 1997-1999, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.nfs;
import java.io.*;
import java.util.*;
import com.sun.rpc.*;
/**
* NfsSecurity is a static class. It reads in the com.sun.properties.nfssec
* properties file and provides the vehicle to retrieve properties values
* which are the (mechanism, service, qop) mappings for the NFS security pseudo
* flavor numbers.
*
* @author Lin Ling
*/
public final class NfsSecurity {
static ResourceBundle props;
static String secName, secMode, mech;
static int service, qop;
static {
initialize();
}
private static void initialize() {
try {
props = ResourceBundle.getBundle("com.sun.nfs.nfssec");
} catch (MissingResourceException e) {
props = null;
}
}
/*
* Parse the string value using ":" as the delimiter.
*
* nfsSecName:mechanismOID:service:qualityProtection
*
* (e.g. dummyp:1.3.6.1.4.1.42.2.26.1.2:privacy:0)
*
*/
private static void parseValue(String value) {
StringTokenizer parser = new StringTokenizer(value, ":\n\r");
secName = parser.nextToken();
try {
mech = parser.nextToken();
} catch (NoSuchElementException e) {
// non-RPCSEC_GSS flavors
mech = null;
service = 0;
qop = 0;
return;
}
String serviceString = parser.nextToken();
if (serviceString.equals("none"))
service = Cred.SVC_NONE;
else if (serviceString.equals("integrity"))
service = Cred.SVC_INTEGRITY;
else if (serviceString.equals("privacy"))
service = Cred.SVC_PRIVACY;
else
service = Cred.SVC_PRIVACY; // just use privacy service
qop = Integer.parseInt(parser.nextToken());
}
/**
* Does the key have a value defined in the nfssec.properties file?
* (i.e. is key=value defined in the properties list?)
*
* @param key the key to be searched
* @returns true or false
*/
public static boolean hasValue(String key) {
if (props == null)
return false;
try {
props.getString(key);
return true;
} catch (MissingResourceException e) {
return false;
}
}
/**
* Get the default security flavor number if it is specified in the
* nfssec.properties file, otherwise, simply return "1" for AUTH_SYS.
*/
public static String getDefault() {
if (props == null)
return "1";
try {
return props.getString("default");
} catch (MissingResourceException e) {
return "1";
}
}
/**
* Get the preferred nfs security flavor number if it is specified
* in the nfssec.properties file, otherwise, return null.
*/
public static String getPrefer() {
if (props == null)
return null;
try {
return props.getString("prefer");
} catch (MissingResourceException e) {
return null;
}
}
/**
* getName will get the NFS security flavor name from the first token
* in the value.
*
* key=nfsSecName:mechOid:service:qop
* ^^^^^^^^^^
*
* @param key the key to be searched
* @returns NFS Security flavor name
*/
public static String getName(String key) {
if (key.equals(secMode)) {
return secName;
}
parseValue(props.getString(key));
secMode = key;
return secName;
}
/**
* getMech will get the security mechanism OID string from the second token
* in the value.
*
* key=nfsSecName:mechOid:service:qop
* ^^^^^^^
*
* @param key the key to be searched
* @returns security mechansim OID string
*/
public static String getMech(String key) {
if (key.equals(secMode)) {
return mech;
}
parseValue(props.getString(key));
secMode = key;
return mech;
}
/**
* getService will get the security service type from the third token
* in the value.
*
* key=nfsSecName:mechOid:service:qop
* ^^^^^^^
*
* @param key the key to be searched
* @returns one of (none, integrity, privacy); if the third token
* in the value does not have the expected data, simply
* returns the privacy service number.
*/
public static int getService(String key) {
if (key.equals(secMode)) {
return service;
}
parseValue(props.getString(key));
secMode = key;
return service;
}
/**
* getQop will get the Quality of Protection number from the fourth token
* in the value.
*
* key=nfsSecName:mechOid:service:qop
* ^^^
*
* @param key the key to be searched
* @returns qop number; 0 means the mechanism-specific default qop
*/
public static int getQop(String key) {
if (key.equals(secMode)) {
return qop;
}
parseValue(props.getString(key));
secMode = key;
return qop;
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/NfsURL.java 0000644 0001750 0001750 00000013707 10577714250 021515 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.nfs;
import java.net.MalformedURLException;
/**
* This is just a dumb URL parser class.
* I wrote it because I got fed up with the
* JDK URL class calling NFS URL's "invalid"
* simply because the Handler wasn't installed.
*
* This URL parser also handles undocumented
* testing options inserted in the URL in the
* port field. The following sequence of option
* letters may appear before or after the port
* number, or alone if the port number is not
* given.
* vn - NFS version, e.g. "v3"
* u - Force UDP - normally TCP is preferred
* t - Force TDP - don't fall back to UDP
* m - Force Mount protocol. Normally public filehandle
* is preferred
*
* Option ordering is not important.
*
* Example:
* nfs://server:123v2um/path
*
* Use port 123 with NFS v2 over UDP and Mount protocol
*
* nfs://server:m/path
*
* Use default port, prefer V3/TCP but use Mount protocol
*
* @author Brent Callaghan
*/
public class NfsURL {
private String url;
private String protocol;
private String host;
private String location;
private int port;
private String file;
/*
* Undocumented testing options
*/
private int version;
private String proto;
private boolean pub = true;
public NfsURL(String url) throws MalformedURLException {
int p, q, r;
url = url.trim(); // remove leading & trailing spaces
this.url = url;
int end = url.length();
p = url.indexOf(':');
if (p < 0)
throw new MalformedURLException("colon expected");
protocol = url.substring(0, p);
p++; // skip colon
if (url.regionMatches(p, "//", 0, 2)) { // have hostname
p += 2;
q = url.indexOf('/', p);
if (q < 0)
q = end;
location = url.substring(0, q);
r = url.indexOf(':', p);
if (r > 0 && r < q) {
byte[] opts = url.substring(r + 1, q).toLowerCase().getBytes();
for (int i = 0; i < opts.length; i++) {
if (opts[i] >= '0' && opts[i] <= '9') {
port = (port * 10) + (opts[i] - '0');
} else {
switch (opts[i]) {
case 'v': // NFS version
version = opts[++i] - '0';
break;
case 't': // Force TCP only
proto = "tcp";
break;
case 'u': // Force UDP only
proto = "udp";
break;
case 'w': // Force WebNFS only
pub = true;
break;
case 'm': // Force MOUNT protocol only
pub = false;
break;
default:
throw new MalformedURLException(
"invalid port number");
}
}
}
} else {
r = q; // no port
}
if (p < r)
host = url.substring(p, r);
} else {
q = p;
}
if (q < end)
file = url.substring(q + 1, end);
}
public String getProtocol() {
return (protocol);
}
public String getLocation() {
return (location);
}
public String getHost() {
return (host);
}
public int getPort() {
return (port);
}
public String getFile() {
return (file);
}
/*
* Undocumented options for testing
*/
int getVersion() {
return (version);
}
String getProto() {
return (proto);
}
boolean getPub() {
return (pub);
}
public String toString() {
String s = getProtocol() + ":";
if (host != null)
s += "//" + host;
if (port > 0)
s += ":" + port;
if (file != null)
s += "/" + file;
return (s);
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/XFileAccessor.java 0000644 0001750 0001750 00000025077 10577714250 023101 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.nfs;
import com.sun.xfile.*;
import java.io.*;
import java.net.*;
/**
* The XFileAccessor interface is implemented by filesystems that
* need to be accessed via the XFile API.
*
* @author Brent Callaghan
* @version 1.0, 04/08/98
* @see com.sun.xfile.XFile
*/
public
class XFileAccessor implements com.sun.xfile.XFileAccessor {
XFile xf;
boolean serial;
boolean readOnly;
Nfs nfs;
/**
* Open this NFS object
*
* @param xf the XFile object
* @param serial true if serial access
* @param readOnly true if read only
*/
public boolean open(XFile xf, boolean serial, boolean readOnly) {
this.xf = xf;
try {
nfs = NfsConnect.connect(xf.getAbsolutePath());
return true;
} catch (IOException e) {
return false;
};
}
public XFile getXFile() {
return xf;
}
protected Nfs getParent(XFile xf) throws IOException {
XFile xfp = new XFile(xf.getParent());
XFileAccessor nfsx = new XFileAccessor();
nfsx.open(xfp, serial, readOnly);
return nfsx.getNfs();
}
protected Nfs getNfs() {
return nfs;
}
/**
* Tests if this XFileAccessor object exists.
*
* @return true
if the file specified by this object
* exists; false
otherwise.
*/
public boolean exists() {
try {
return nfs.exists();
} catch (Exception e) {
return false;
}
}
/**
* Tests if the application can write to this file.
*
* @return true
if the application is allowed to
* write to a file whose name is specified by this
* object; false
otherwise.
*/
public boolean canWrite() {
try {
return nfs.canWrite();
} catch (IOException e) {
return false;
}
}
/**
* Tests if the application can read from the specified file.
*
* @return true
if the file specified by this
* object exists and the application can read the file;
* false
otherwise.
*/
public boolean canRead() {
try {
return nfs.canRead();
} catch (IOException e) {
return false;
}
}
/**
* Tests if the file represented by this
* object is a "normal" nfs.
*
* A file is "normal" if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any
* non-directory file created by a Java application is
* guaranteed to be a normal nfs.
*
* @return true
if the file specified by this
* XFile
object exists and is a "normal"
* file; false
otherwise.
*/
public boolean isFile() {
try {
return nfs.isFile();
} catch (IOException e) {
return false;
}
}
/**
* Tests if the file represented by this XFileAccessor
* object is a directory.
*
* @return true
if this XFileAccessor object
* exists and is a directory; false
* otherwise.
*/
public boolean isDirectory() {
try {
return nfs.isDirectory();
} catch (IOException e) {
return false;
}
}
/**
* Returns the time that the file represented by this
* XFile
object was last modified.
*
* The return value is system dependent and should only be
* used to compare with other values returned by last modified.
* It should not be interpreted as an absolute time.
*
* @return the time the file specified by this object was last
* modified, or 0L
if the specified file
* does not exist.
*/
public long lastModified() {
try {
return nfs.mtime();
} catch (IOException e) {
return 0L;
}
}
/**
* Returns the length of the file represented by this
* XFileAccessor object.
*
* @return the length, in bytes, of the file specified by
* this object, or 0L
if the specified
* file does not exist.
*/
public long length() {
try {
return nfs.length();
} catch (IOException e) {
return 0L;
}
}
/**
* Creates a file whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the file could be created;
* false
otherwise.
*/
public boolean mkfile() {
try {
nfs = getParent(xf).create(xf.getName(), (long)0666);
return true;
} catch (Exception e) {
return false;
}
}
/**
* Creates a directory whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the directory could be created;
* false
otherwise.
*/
public boolean mkdir() {
try {
nfs = getParent(xf).mkdir(xf.getName(), (long)0777);
return true;
} catch (Exception e) {
return false;
}
}
/**
* Renames the file specified by this XFileAccessor object to
* have the pathname given by the XFileAccessor object argument.
*
* @param dest the new filename.
* @return true
if the renaming succeeds;
* false
otherwise.
*/
public boolean renameTo(XFile dest) {
try {
Nfs sParent = getParent(xf);
Nfs dParent = getParent(dest);
return sParent.rename(dParent, xf.getName(), dest.getName());
} catch (Exception e) {
return false;
}
}
/**
* Returns a list of the files in the directory specified by
* this XFileAccessor object.
*
* @return an array of file names in the specified directory.
* This list does not include the current directory or
* the parent directory (".
" and
* "..
" on Unix systems).
*/
public String[] list() {
try {
return nfs.readdir();
} catch (IOException e) {
return null;
}
}
/**
* Deletes the file specified by this object. If the target
* file to be deleted is a directory, it must be empty for
* deletion to succeed.
*
* @return true
if the file is successfully deleted;
* false
otherwise.
*/
public boolean delete() {
boolean ok;
try {
if (isFile())
ok = getParent(xf).remove(xf.getName());
else
ok = getParent(xf).rmdir(xf.getName());
// Purge cached attrs & filehandle
if (ok) {
nfs.invalidate();
nfs = null;
}
return ok;
} catch (Exception e) {
return false;
}
}
/**
* Reads a subarray as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @exception java.io.IOException If an I/O error has occurred.
*/
public int read(byte b[], int off, int len, long foff)
throws IOException {
int c = nfs.read(b, off, len, foff);
return c;
}
/**
* Writes a sub array as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @param foff the offset into the file
* @exception java.io.IOException If an I/O error has occurred.
*/
public void write(byte b[], int off, int len, long foff)
throws IOException {
nfs.write(b, off, len, foff);
}
/**
* Forces any buffered output bytes to be written out.
*
* * @exception java.io.IOException if an I/O error occurs. */ public void flush() throws IOException { nfs.flush(); } /** * Close the file * * Since NFS has no concept of file close, we just * flush any buffered data. * * @exception java.io.IOException If an I/O error has occurred. */ public void close() throws IOException { nfs.close(); } /** * Returns a string representation of this object. * * @return a string giving the pathname of this object. */ public String toString() { return nfs.toString(); } } libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/XFileExtensionAccessor.java 0000644 0001750 0001750 00000012655 10577714250 024774 0 ustar god god /* * Copyright (c) 1998, 2007 Sun Microsystems, Inc. * All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * -Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * -Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Sun Microsystems, Inc. or the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS * SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE * AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE * SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE * LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED * AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR * INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. * * You acknowledge that this software is not designed,licensed or intended * for use in the design, construction, operation or maintenance of any * nuclear facility. */ package com.sun.nfs; import java.io.*; import com.sun.xfile.*; public class XFileExtensionAccessor extends com.sun.xfile.XFileExtensionAccessor { XFile xf; public XFileExtensionAccessor(XFile xf) { super(xf); if (! xf.getFileSystemName().equals("nfs")) throw new IllegalArgumentException("Invalid argument"); this.xf = xf; } /** * Sets the user's RPC credential from Login name and password. * * Every NFS request includes a "credential" that identifies the user. * An AUTH_SYS credential includes the user's UID and GID values. * These are determined from the user's login name (and password) * by the PCNFSD service that must be available on a local server. * Once the credential is set, it is assigned globally to all * future NFS XFile objects. *
* If this method is not called, a default credential is assigned
* with a UID and GID of "nobody".
*
* @param host
The name of the host that runs the PCNFSD service.
* This does not have to be an NFS server.
* @param username
The user's login name.
* @param password
The user's password.
* This is obscured before transmission to the PCNFSD server.
* @return true if the login succeeded, false otherwise.
*/
public boolean loginPCNFSD(String host, String username, String password) {
return NfsConnect.getCred().fetchCred(host, username, password);
}
/**
* Sets the user's RPC credential to "nobody"
*/
public void logoutPCNFSD() {
NfsConnect.getCred().setCred();
}
/**
* Sets the user's RPC credential to a known uid/gid.
*
* Assumes that the calling application has already
* authenticated the user and has obtained to uid/gid
* itself.
*
* Note: This credential setting method exposes an * inherent security hole in RPC AUTH_SYS authentication. * The server trusts the client to authenticate the * user before setting the UID and GID values. It is * possible for a malicious client to allow the UID and/or * group ids to be set to allow unauthorized access to * other user's files on the server. *
* Servers can avoid this security hole by exporting NFS * filesystem securely - requiring clients to use secure * Diffie-Hellman or Kerberos credentials. * *
* If this method is not called, a default credential is assigned
* with a UID and GID of "nobody".
*
* @param
* The XFile object is functionally equivalent to the java.io.File
* object with the ability to handle not only native pathnames
* but also URL-style pathnames. URL pathnames have some advantages
* over native pathnames:
*
*
*
*
*
*
*
*
*
* Pathnames that are not represented as URL names will be
* assumed to represent "native" names and XFile will present
* the same semantics as the java.io.File class.
*/
public class XFile {
/**
* File Accessor that implements the underlying filesystem
*/
private XFileAccessor xfa;
/**
* The url of the file.
*/
private XFurl url;
private String urlStr;
private File nativeFile;
private boolean bound;
/**
* Creates a
*
* If the
* If the
* If the object is a URL type, the path is the part
* of the URL following the location, e.g.
*
*
*
*
* If the object is represented by a URL then return the entire URL
* string.
*
* @return a system-dependent absolute pathname for this
*
* For native paths the precise definition of canonical form
* is system-dependent, but it usually specifies an absolute
* pathname in which all relative references and references
* to the current user directory have been completely
* resolved. The canonical form of a pathname of a nonexistent
* file may not be defined.
*
* @return the canonical path of the object
* @exception java.io.IOException If an I/O error occurs, which
* is possible because the construction of the
* canonical path may require filesystem queries.
*/
public String getCanonicalPath() throws IOException {
if (nativeFile != null)
return nativeFile.getCanonicalPath();
return urlStr;
}
/**
* Returns the parent part of the pathname of this
*
* For native paths the parent part is generally everything
* leading up to the last occurrence of the separator character,
* although the precise definition is system dependent.
* On UNIX, for example, the parent part of
* The return value is system dependent and should only be used to
* compare with other values returned by last modified. It should
* not be interpreted as an absolute time.
*
* @return the time the file specified by this object was last
* modified, or
* A class file that implements this interface must be named
* "XFileAccessor" and be installed in a directory named after
* the URL scheme that it implements, for instance, an XFileAccessor
* that provides file access through the HTTP protocol would be
* associated with the "http" URL and its class file would be
* called:
*
* A class prefix is added to this name. The default prefix is
*
* The default class prefix
* For instance, if you want to use the "ftp"
* XFileAccessor from Acme, Inc and the "nfs" XFileAccessor
* from "ABC Inc." then you can set the system property as
* follows:
*
* The class loader attempts to load each of the constructed
* package names in turn relative to the CLASSPATH until it is
* successful.
*
* A subsequent reference to an "nfs" URL will result in
* the following list of candidate package names:
*
* <proto>://<location>/<path>
*
* where <proto> is the name of the filesystem,
* e.g. "nfs" and <location> is the location of
* the filesystem. For nfs this is the network name of
* a server. The <path> is a pathname that locates
* the file within <location>. As required by
* RFC 1738, the component delimiters in the pathname
* are as for URL syntax: forward slashes only.
* @param serial true if serial access; false if random access
* @param readOnly true if read only; false if read/write
*/
boolean open(XFile xf, boolean serial, boolean readOnly);
/**
* Return the XFile for this Accessor
*/
XFile getXFile();
/**
* Tests if this XFile object exists.
*
* @return
* A file is "normal" if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any
* non-directory file created by a Java application is
* guaranteed to be a normal file.
*
* @return
* @return the time the file specified by this object was last
* modified, or
*
* @exception java.io.IOException if an I/O error occurs.
*/
void flush() throws IOException;
/**
* Close the file.
*
* Closes this file and releases any system resources
* associated with the file.
*
* After the file is closed further I/O operations may
* throw IOException.
*
* @exception java.io.IOException If an I/O error has occurred.
*/
void close() throws IOException;
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileExtensionAccessor.java 0000644 0001750 0001750 00000007150 10577714253 025312 0 ustar god god /*
* Copyright (c) 1999, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
/**
* This is an abstract class to intended to be extended with
* filesystem-specific methods.
*
* An XFileExtensionAccessor class must be associated with an
* XFileAccessor. An XFileExtensionAccessor can be used to
* provide access to filesystem-specific methods that are not
* defined within the XFileAccessor interface.
* A subclass of XFileExtensionAccessor must be declared as:
*
* public class XFileExtensionAccessor extends com.sun.xfile.XFileExtensionAccessor {
* :
*
*
* An XFileExtensionAccessor class is loaded when the
*
* An application that needs to use the methods within the
* XFileExtensionAccessor must cast the result of XFile.getExtensionAccessor.
*
* XFile xf = new XFile("ftp://server/path");
* com.acme.ftp.XFileExtensionAccessor xftp =
* (com.acme.ftp.XFileExtensionAccessor) xf.getExtensionAccessor();
* xftp.login();
* :
*
*
* @exception java.io.IOException if an I/O error occurs.
*/
public void flush() throws IOException {
xfa.flush();
}
/**
* Closes this file output stream, flushes any buffered,
* unwritten data, and releases any system resources
* associated with this stream.
*
* After the file is closed further I/O operations may
* throw IOException.
*
* @exception java.io.IOException if an I/O error occurs.
*/
public void close() throws IOException {
xfa.close();
}
/**
* Ensures that the
* The mode argument must either be equal to
*
* @param n the number of bytes to be skipped.
* @return the number of bytes skipped, which is always
*
* This method blocks until the byte is read, the end of the stream
* is detected, or an exception is thrown.
*
* @return the next byte of this file as a signed 8-bit
*
* This method blocks until the byte is read, the end of the stream
* is detected, or an exception is thrown.
*
* @return the next byte of this file, interpreted as an unsigned
* 8-bit number.
* @exception java.io.EOFException if this file has reached the end.
* @exception java.io.IOException if an I/O error occurs.
*/
public final int readUnsignedByte() throws IOException {
int ch = this.read();
if (ch < 0)
throw new EOFException();
return ch;
}
/**
* Reads a signed 16-bit number from this file. The method reads 2
* bytes from this file. If the two bytes read, in order, are
*
* This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next two bytes of this file, interpreted as a signed
* 16-bit number.
* @exception java.io.EOFException if this file reaches the end before reading
* two bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final short readShort() throws IOException {
int ch1 = this.read();
int ch2 = this.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (short)((ch1 << 8) + (ch2 << 0));
}
/**
* Reads an unsigned 16-bit number from this file. This method reads
* two bytes from the file. If the bytes read, in order, are
*
* This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next two bytes of this file, interpreted as an unsigned
* 16-bit integer.
* @exception java.io.EOFException if this file reaches the end before reading
* two bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final int readUnsignedShort() throws IOException {
int ch1 = this.read();
int ch2 = this.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (ch1 << 8) + (ch2 << 0);
}
/**
* Reads a Unicode character from this file. This method reads two
* bytes from the file. If the bytes read, in order, are
*
* This method blocks until the two bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next two bytes of this file as a Unicode character.
* @exception java.io.EOFException if this file reaches the end before reading
* two bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final char readChar() throws IOException {
int ch1 = this.read();
int ch2 = this.read();
if ((ch1 | ch2) < 0)
throw new EOFException();
return (char)((ch1 << 8) + (ch2 << 0));
}
/**
* Reads a signed 32-bit integer from this file. This method reads 4
* bytes from the file. If the bytes read, in order, are
* This method blocks until the four bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next four bytes of this file, interpreted as an
*
* then the result is equal to:
*
* This method blocks until the eight bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next eight bytes of this file, interpreted as a
*
* This method blocks until the four bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next four bytes of this file, interpreted as a
*
* This method blocks until the eight bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return the next eight bytes of this file, interpreted as a
*
* A line of text is terminated by a carriage-return character
* (
* This method blocks until a newline character is read, a carriage
* return and the byte following it are read (to see if it is a
* newline), the end of the stream is detected, or an exception is thrown.
*
* @return the next line of text from this file.
* @exception java.io.IOException if an I/O error occurs.
*/
public final String readLine() throws IOException {
StringBuffer input = new StringBuffer();
int c;
while (((c = read()) != -1) && (c != '\n')) {
input.append((char)c);
}
if ((c == -1) && (input.length() == 0)) {
return null;
}
return input.toString();
}
/**
* Reads in a string from this file. The string has been encoded
* using a modified UTF-8 format.
*
* The first two bytes are read as if by
*
* This method blocks until all the bytes are read, the end of the
* stream is detected, or an exception is thrown.
*
* @return a Unicode string.
* @exception java.io.EOFException if this file reaches the end before
* reading all the bytes.
* @exception java.io.IOException if an I/O error occurs.
* @exception java.io.UTFDataFormatException if the bytes do not represent
* valid UTF-8 encoding of a Unicode string.
* @see com.sun.xfile.XRandomAccessFile#readUnsignedShort()
*/
public final String readUTF() throws IOException {
return DataInputStream.readUTF(this);
}
/**
* Writes a
* First, two bytes are written to the file as if by the
* uid
The user-ID.
* @param gid
The group-ID.
* @param gids
The group-ID list.
*/
public void loginUGID(int uid, int gid, int[] gids) {
NfsConnect.getCred().setCred(uid, gid, gids);
}
/**
* Sets the user's RPC credential to "nobody"
*/
public void logoutUGID() {
NfsConnect.getCred().setCred();
}
/**
* Assigns an NfsHandler class that allows
* the application to receive RPC timeout
* notifications. The handler
is used for all
* NFS files accessed by the application.
* The default handler can be restored by
* passing a null handler
argument.
*
* @param handler
An instance of the NfsHandler class.
*/
public void setNfsHandler(NfsHandler handler) {
NfsConnect.setRpcHandler(handler);
}
/**
* Get server's export list
*/
public String[] getExports()
throws java.net.UnknownHostException, IOException {
return new Mount().getExports(new NfsURL(xf.toString()).getHost());
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/nfsXFileExtensionAccessor.java 0000644 0001750 0001750 00000004262 10577714250 025476 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.nfs;
/**
* This is a compatibility stub for the NFS XFileExtensionAccessor
*
* @see com.sun.nfs.XFileExtensionAccessor
* @deprecated The more generic XFileExtensionAccessor class
* should be used instead.
*/
public class nfsXFileExtensionAccessor
extends com.sun.nfs.XFileExtensionAccessor {
public nfsXFileExtensionAccessor(com.sun.xfile.XFile xf) {
super(xf);
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/nfs/nfssec.properties 0000644 0001750 0001750 00000006751 10577714250 023141 0 ustar god god #
# Copyright (c) 1999, 2007 Sun Microsystems, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# -Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# -Redistribution in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of Sun Microsystems, Inc. or the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# This software is provided "AS IS," without a warranty of any kind. ALL
# EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
# ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
# SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
# AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
# SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
# LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
# SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
# AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
# INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# You acknowledge that this software is not designed,licensed or intended
# for use in the design, construction, operation or maintenance of any
# nuclear facility.
#
# The WebNFS security services properties file.
#
# This file provides a mapping from nfs pseudo flavors to GSS-API
# oriented
Note that the count is
* rounded up to the next XDRUNIT.
*
* @param count of the buffer in bytes
*/
public void xdr_skip(int count) {
int r = (off += count) % XDRUNIT;
if (r > 0)
off += XDRUNIT - r;
}
/**
* Return the entire Xdr buffer
*
* @return Xdr buffer
*/
public byte[] xdr_buf() {
return buf;
}
/**
* Return the current offset
*
* @return offset
*/
public int xdr_offset() {
return off;
}
/**
* Set the current offset
*
* @param off offset into XDR buffer
*/
public void xdr_offset(int off) {
this.off = off;
}
/**
* Return the starting point of the bytes that will
* be encrypted.
*
* @return offset for bytes to be encrypted
*/
public int xdr_wrap_offset() {
return wrap_offset;
}
/**
* Set the starting point of the bytes that will
* be encrypted.
*
* @return offset for bytes to be encrypted
*/
public void xdr_wrap_offset(int off) {
wrap_offset = off;
}
/**
* Return the current size of the XDR buffer
*
* @return size
*/
public int xdr_size() {
return size;
}
/**
* Set the current size of the XDR buffer
*
* @param size of buffer
*/
public void xdr_size(int size) {
this.size = size;
}
/**
* Get an integer from the buffer
*
* @return integer
*/
public int xdr_int() {
return ((buf[off++] & 0xff) << 24 |
(buf[off++] & 0xff) << 16 |
(buf[off++] & 0xff) << 8 |
(buf[off++] & 0xff));
}
/**
* Put an integer into the buffer
*
* @param i Integer to store in XDR buffer.
*/
public void xdr_int(int i) {
buf[off++] = (byte)(i >>> 24);
buf[off++] = (byte)(i >> 16);
buf[off++] = (byte)(i >> 8);
buf[off++] = (byte)i;
}
/**
* Get an unsigned integer from the buffer
*
*
Note that Java has no unsigned integer
* type so we must return it as a long.
*
* @return long
*/
public long xdr_u_int() {
return ((buf[off++] & 0xff) << 24 |
(buf[off++] & 0xff) << 16 |
(buf[off++] & 0xff) << 8 |
(buf[off++] & 0xff));
}
/**
* Put an unsigned integer into the buffer
*
* Note that Java has no unsigned integer
* type so we must submit it as a long.
*
* @param i unsigned integer to store in XDR buffer.
*/
public void xdr_u_int(long i) {
buf[off++] = (byte)(i >>> 24 & 0xff);
buf[off++] = (byte)(i >> 16);
buf[off++] = (byte)(i >> 8);
buf[off++] = (byte)i;
}
/**
* Get a long from the buffer
*
* @return long
*/
public long xdr_hyper() {
return ((long)(buf[off++] & 0xff) << 56 |
(long)(buf[off++] & 0xff) << 48 |
(long)(buf[off++] & 0xff) << 40 |
(long)(buf[off++] & 0xff) << 32 |
(long)(buf[off++] & 0xff) << 24 |
(long)(buf[off++] & 0xff) << 16 |
(long)(buf[off++] & 0xff) << 8 |
(long)(buf[off++] & 0xff));
}
/**
* Put a long into the buffer
*
* @param i long to store in XDR buffer
*/
public void xdr_hyper(long i) {
buf[off++] = (byte)(i >>> 56) ;
buf[off++] = (byte)((i >> 48) & 0xff);
buf[off++] = (byte)((i >> 40) & 0xff);
buf[off++] = (byte)((i >> 32) & 0xff);
buf[off++] = (byte)((i >> 24) & 0xff);
buf[off++] = (byte)((i >> 16) & 0xff);
buf[off++] = (byte)((i >> 8) & 0xff);
buf[off++] = (byte)(i & 0xff);
}
/*
* Note: we have no XDR routines for encoding/decoding
* unsigned longs. They exist in XDR but not in Java
* hence we can't represent them.
* Best just to use xdr_hyper() and hope the sign bit
* isn't used.
*/
/**
* Get a boolean from the buffer
*
* @return boolean
*/
public boolean xdr_bool() {
return (xdr_int() != 0);
}
/**
* Put a boolean into the buffer
*
* @param b boolean
*/
public void xdr_bool(boolean b) {
xdr_int(b ? 1 : 0);
}
/**
* Get a floating point number from the buffer
*
* @return float
*/
public float xdr_float() {
return (Float.intBitsToFloat(xdr_int()));
}
/**
* Put a floating point number into the buffer
*
* @param f float
*/
public void xdr_float(float f) {
xdr_int(Float.floatToIntBits(f));
}
/**
* Get a string from the buffer
*
* @return string
*/
public String xdr_string() {
int len = xdr_int();
String s = new String(buf, off, len);
xdr_skip(len);
return s;
}
/**
* Put a string into the buffer
*
* @param s string
*/
public void xdr_string(String s) {
xdr_bytes(s.getBytes());
}
/**
* Get a counted array of bytes from the buffer
*
* @return bytes
*/
public byte[] xdr_bytes() {
return (xdr_raw(xdr_int()));
}
/**
* Put a counted array of bytes into the buffer.
* Note that the entire byte array is encoded.
*
* @param b byte array
*/
public void xdr_bytes(byte[] b) {
xdr_bytes(b, 0, b.length);
}
/**
* Put a counted array of bytes into the buffer
*
* @param b byte array
* @param len number of bytes to encode
*/
public void xdr_bytes(byte[] b, int len) {
xdr_bytes(b, 0, len);
}
/**
* Put a counted array of bytes into the buffer
*
* @param b byte array
* @param boff offset into byte array
* @param len number of bytes to encode
*/
public void xdr_bytes(byte[] b, int boff, int len) {
xdr_int(len);
System.arraycopy(b, boff, buf, off, len);
xdr_skip(len);
}
/**
* Put an Xdr buffer into the buffer
*
*
This is used to encode the RPC credentials
*
* @param x XDR buffer
*/
public void xdr_bytes(Xdr x) {
xdr_bytes(x.xdr_buf(), x.xdr_offset());
}
/**
* Get a fixed number of bytes from the buffer
*
* e.g. an NFS v2 filehandle
*
* @param len Number of bytes to get
* @return byte array
*/
public byte[] xdr_raw(int len) {
if (len == 0)
return null;
byte[] b = new byte[len];
System.arraycopy(buf, off, b, 0, len);
xdr_skip(len);
return b;
}
/**
* Get a fixed number (len) of bytes from the buffer
* at offset off. Do not change any buffer indicators.
*
* @param off Offset of bytes to get from
* @param len Number of bytes to copy
* @return byte array
*/
public byte[] xdr_raw(int off, int len) {
if (len == 0)
return null;
byte[] b = new byte[len];
System.arraycopy(buf, off, b, 0, len);
return b;
}
/**
* Put a fixed number of bytes into the buffer
* The length is not encoded.
*
* e.g. an NFS v2 filehandle
*
* @param b byte array
*/
public void xdr_raw(byte[] b) {
int len = b.length;
System.arraycopy(b, 0, buf, off, len);
xdr_skip(len);
}
/**
* Put a fixed number of bytes into the buffer
* at offset off. The length is not encoded.
*
* @param b byte array
* @param off where to put the byte array
*/
public void xdr_raw(byte[] b, int off) {
int len = b.length;
System.arraycopy(b, 0, buf, off, len);
xdr_skip(len);
}
/**
* Put a counted array of bytes into the buffer.
* The length is not encoded.
*
* @param b byte array
* @param boff offset into byte array
* @param len number of bytes to encode
*/
public void xdr_raw(byte[] b, int boff, int len) {
System.arraycopy(b, boff, buf, off, len);
xdr_skip(len);
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/ 0000755 0001750 0001750 00000000000 10670730365 020051 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/Makefile 0000644 0001750 0001750 00000004037 10577714253 021521 0 ustar god god #
# Copyright (c) 1998 Sun Microsystems, Inc.
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# -Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# -Redistribution in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# Neither the name of Sun Microsystems, Inc. or the names of contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# This software is provided "AS IS," without a warranty of any kind. ALL
# EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
# ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
# SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
# AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
# SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
# LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
# SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
# AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
# INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGES.
#
# You acknowledge that this software is not designed,licensed or intended
# for use in the design, construction, operation or maintenance of any
# nuclear facility.
#
PKGDIR= com/sun/xfile
include ../Makefile.common
CLASSES=XFile XFileAccessor XFileInputStream \
XFileExtensionAccessor \
XFilenameFilter XFileOutputStream \
XFileReader XFileWriter \
XFurl XRandomAccessFile
JFILES= $(CLASSES:%=%.java)
$(TFILE): $(JFILES)
$(JC) -d $(CDIR) $(JCFLAGS) $?
@touch $(TFILE)
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFile.java 0000644 0001750 0001750 00000074117 10577714253 021741 0 ustar god god /*
* Copyright (c) 1999, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
import java.util.Vector;
import java.lang.reflect.Constructor;
import java.util.Hashtable;
import java.util.StringTokenizer;
/**
*
* Instances of this class represent the name of a file or directory.
* Since only the name of the file is represented, the file itself
* need not exist.
*
*
*
* You can use the same name to reference a file
* independent of the pathname syntax supported
* by the underlying operating system. The
* component separator in a URL pathname is always
* a forward slash.
*
* For instance, a URL name can refer to a file
* anywhere on the Internet, e.g.
* nfs://santa.northpole.org/toys/catalog
*
* For example:
*
*
* This property makes possible the dynamic loading
* of new filesystem accessors.
* file:///C|/java/bin
(a local directory)
* nfs://myserver/home/ed
* (directory on NFS server)
* ftp://ftpsrv/pub/pkg.zip
* (file on FTP server)
*
* URLs support a well defined set of rules for the use
* of names relative to a "base" URL described in
* RFC 1808.
*
For instance:
*
*
*
* Base Relative Composition
*
*
* file:///a/b/c
* x
* file:///a/b/c/x
*
* nfs://server/a/b/c
* /y
* nfs://server/y
*
* nfs://server/a/b/c
* ../z
* nfs://server/a/b/z
*
* file:///a/b/c
* d/.
* nfs://server/a/b/c/d
*
*
* file:///a/b/c
* nfs://srv/x
* nfs://srv/x
* Although URLs are necessarily location dependent,
* location indepent Universal Resource Names (URN)
* names can be used within the same structure (see
*
* RFC 2141.
* XFile
instance that represents the file
* whose pathname is the given url argument.
*
* If the the name argument contains the string "://" then it
* is assumed to be a URL name. The characters prior to the
* colon are assumed to be the filesystem scheme name, e.g.
* "file", "nfs", etc. The rest of the URL name is assumed
* to be structured according to the Common Internet Scheme
* syntax described in
* RFC 1738;
* an optional location part followed by a hierarchical set
* of slash separated directories.
* <scheme>://<location>/<path>
*
* @param name the file url
* @exception java.lang.NullPointerException if the file url
* is equal to
null
.
*/
public XFile(String name) {
urlStr = name;
if (name == null)
throw new NullPointerException();
try {
url = new XFurl(name);
xfa = loadAccessor(url);
} catch (Exception e) {
if (name.startsWith(".:"))
name = name.substring(2); // lop off ".:"
nativeFile = new File(name);
xfa = makeNative(nativeFile);
}
}
/**
* Creates a XFile
instance that represents the file
* with the specified name in the specified directory.
*
* If the dir
XFile is null
, or if the
* name
string is a full URL, then the single-arg
* constructor is used on the name
.
* dir
XFile represents a native file
* and the name
string isAbsolute
* then the single-arg constructor is used on the name
.
* If the name
is not absolute then the resulting
* path is the simple concatenation of the dir
* path with the file separator and the name
as
* for the two-arg constructor of the File
class.
* dir
XFile represents a URL name then
* the dir
is assumed to be a base URL
* and the name
string is evaluated as a
* relative URL according to the rules described in
* RFC 1808.
*
*
*
*
* Dir Name Composition
*
*
* file:///a/b/c
* x
* file:///a/b/c/x
*
* nfs://server/a/b/c
* /y
* nfs://server/y
*
* nfs://server/a/b/c
* ../z
* nfs://server/a/b/z
*
* file:///a/b/c
* d/.
* nfs://server/a/b/c/d
*
* file:///a/b/c
* nfs://srv/x
* nfs://srv/x
*
*
* C:\Data\Programs
* myprog.exe
* C:\Data\Programs\myprog.exe
XFile
object.
*/
public String getName() {
if (nativeFile != null)
return nativeFile.getName();
return url.getName();
}
/**
* Returns the pathname of the file represented by this object.
*
* @return the pathname represented by this XFile
* object.
* new XFile("nfs://location/a/b/c").getPath()
* == "a/b/c"
* new XFile("file:///a/b/c").getPath()
* == "a/b/c"
* new XFile("nfs://server/").getPath()
* == ""
*/
public String getPath() {
if (nativeFile != null)
return nativeFile.getPath();
return url.getPath();
}
/**
* Returns the absolute pathname of the file represented by this
* object.
*
* If this object is represented by a native pathname and is an
* absolute pathname, then return the pathname. Otherwise, return
* a pathname that is a concatenation of the current user
* directory, the separator character, and the pathname of this
* file object.
* The system property user.dir
contains the current
* user directory.
* XFile
.
*/
public String getAbsolutePath() {
if (nativeFile != null)
return nativeFile.getAbsolutePath();
return urlStr;
}
/**
* Returns the canonical form of this XFile
object's
* pathname.
*
* If the object is represented by a URL name then the full
* URL is always returned. URL names are always canonical.
* XFile
object, or null
if the name
* has no parent part.
*
* If the name is a URL then the parent part is the URL with
* the last component of the pathname removed. If the URL
* has no pathname part, then the URL is returned unchanged.
* "/usr/lib"
* is "/usr"
whose parent part is "/"
,
* which in turn has no parent.
* On Windows platforms, the parent part of "c:\java"
* is "c:\"
, which in turn has no parent.
*
* @return the name of the parent directory
*/
public String getParent() {
if (nativeFile != null)
return nativeFile.getParent();
return url.getParent();
}
/**
* Tests if the file represented by this XFile
* object is an absolute pathname.
*
* If the object is represented by a URL then true
* is always returned.
* If the XFile
represents a native name then
* the definition of an absolute pathname is system
* dependent. For example, on UNIX, a pathname is absolute if its
* first character is the separator character.
* On Windows platforms,
* a pathname is absolute if its first character is an ASCII
* '\' or '/', or if it begins with a letter followed by
* a colon.
*
* @return true
if the pathname indicated by the
* XFile
object is an absolute pathname;
* false
otherwise.
*/
public boolean isAbsolute() {
if (nativeFile != null)
return nativeFile.isAbsolute();
return true;
}
/**
* Tests if this XFile
exists.
*
* @return true
if the file specified by this object
* exists; false
otherwise.
*/
public boolean exists() {
if (!bind())
return false;
return xfa.exists();
}
/**
* Tests if the application can write to this file.
*
* @return true
if the application is allowed to
* write to a file whose name is specified by this object;
* false
otherwise.
*/
public boolean canWrite() {
if (!bind())
return false;
return xfa.canWrite();
}
/**
* Tests if the application can read from the specified file.
*
* @return true
if the file specified by this
* object exists and the application can read the file;
* false
otherwise.
*/
public boolean canRead() {
if (!bind())
return false;
return xfa.canRead();
}
/**
* Tests if the file represented by this XFile
* object is a "normal" file.
*
* A file is "normal" if it is not a directory and, in
* addition, satisfies other system-dependent criteria. Any
* non-directory file created by a Java application is guaranteed
* to be a normal file.
*
* @return true
if the file specified by this object
* exists and is a "normal" file; false
* otherwise.
*/
public boolean isFile() {
if (!bind())
return false;
return xfa.isFile();
}
/**
* Tests if the file represented by this XFile
* object is a directory.
*
* @return true
if this XFile
exists
* and is a directory; false
otherwise.
*/
public boolean isDirectory() {
if (!bind())
return false;
return xfa.isDirectory();
}
/**
* Returns the time that the file represented by this
* XFile
object was last modified.
* 0L
if the specified file
* does not exist.
*/
public long lastModified() {
if (!bind())
return 0L;;
return xfa.lastModified();
}
/**
* Returns the length of the file represented by this
* XFile
object.
*
* @return the length, in bytes, of the file specified by this
* object, or 0L
if the specified file does
* not exist. The length constitutes the number of bytes
* readable via an InputStream. The length value for
* a directory is undefined.
*/
public long length() {
if (!bind())
return 0L;
return xfa.exists() ? xfa.length() : 0L;
}
/**
* Renames the file specified by this XFile
object to
* have the pathname given by the XFile
argument.
*
* This object and dest
must represent filesystems
* of the same type. For instance: both native or both of
* the same URL scheme.
*
* After a successful renameTo, this object continues to
* be a valid reference to the file. Only the name
* is different.
*
* If the destination filename already exists, it will be replaced.
* The application must have permission to modify the source and
* destination directory.
*
* @param dest the new filename.
* @return true
if the renaming succeeds;
* false
otherwise.
*/
public boolean renameTo(XFile dest) {
if (dest == null)
throw new NullPointerException();
if (! xfa.getClass().isInstance(dest.getAccessor()))
return false;
if (!bind())
return false;
boolean ok = xfa.renameTo(dest);
/*
* Only the name of the file is changed.
* Its data and state are unaffected.
* Hence we make this XFile object a clone
* of the dest XFile.
*/
if (ok) {
url = dest.getURL();
urlStr = dest.getAbsolutePath();
nativeFile = dest.getNative();
xfa = dest.getAccessor();
bound = dest.getBound();
}
return ok;
}
/**
* Creates a directory whose pathname is specified by this
* XFile
object.
*
* If any parent directories in the pathname do not
* exist, the method will return false.
*
* @return true
if the directory could be created;
* false
otherwise.
*/
public boolean mkdir() {
bind();
return xfa.mkdir();
}
/**
* Creates a directory whose pathname is specified by this
* XFile
object, including any necessary parent
* directories.
*
* @return true
if the directory (or directories)
* could be created; false
otherwise.
*/
public boolean mkdirs() {
bind();
if (exists()) {
return false;
}
if (mkdir()) {
return true;
}
String parent = getParent();
return (parent != null) && (new XFile(parent).mkdirs() && mkdir());
}
/**
* Returns a list of the files in the directory specified by this
* XFile
object.
*
* @return an array of file names in the specified directory.
* This list does not include the current directory or the
* parent directory (".
" and "..
"
* on Unix systems).
*/
public String[] list() {
if (!bind())
return null;;
return xfa.list();
}
/**
* Returns a list of the files in the directory specified by this
* XFile
that satisfy the specified filter.
*
* @param filter a filename filter.
* @return an array of file names in the specified directory.
* This list does not include the current directory or the
* parent directory (".
" and "..
"
* on Unix systems).
* @see com.sun.xfilenameFilter
*/
public String[] list(XFilenameFilter filter) {
if (!bind())
return null;;
String names[] = list();
if (names == null) {
return null;
}
// Fill in the Vector
Vector v = new Vector();
for (int i = 0 ; i < names.length ; i++) {
if ((filter == null) || filter.accept(this, names[i])) {
v.addElement(names[i]);
}
}
// Create the array
String files[] = new String[v.size()];
v.copyInto(files);
return files;
}
/**
* Deletes the file specified by this object.
* If the target file to be deleted is a directory, it must be
* empty for deletion to succeed.
*
* @return true
if the file is successfully deleted;
* false
otherwise.
*/
public boolean delete() {
if (!bind())
return false;;
boolean ok = xfa.delete();
bound = !ok;
return ok;
}
/**
* Computes a hashcode for the file.
*
* @return a hash code value for this XFile
object.
*/
public int hashCode() {
return urlStr.hashCode() ^ 1234321;
}
/**
* Compares this object against the specified object.
*
* Returns true
if and only if the argument is
* not null
and is a XFile
object whose
* pathname is equal to the pathname of this object.
*
* @param obj the object to compare with.
* @return true
if the objects are the same;
* false
otherwise.
*/
public boolean equals(Object obj) {
if ((obj == null) || (! (obj instanceof XFile)))
return false;
return url.toString().equals(((XFile)obj).getURL().toString());
}
/**
* Returns a string representation of this object.
*
* @return a string giving the pathname of this object.
*/
public String toString() {
if (nativeFile != null)
return (nativeFile.toString());
return urlStr;
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileAccessor.java 0000644 0001750 0001750 00000025750 10577714253 023423 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.IOException;
/**
* The XFileAccessor interface is implemented by filesystems that
* need to be accessed via the XFile API.
*
* Classes that implement this interface must be associated
* with a URL scheme that is structured according to the
* Common Internet Scheme syntax described in
* RFC 1738;
* an optional location part followed by a hierarchical set
* of slash separated directories.
*
* http.XFileAccessor
*
com.sun
and this composite name is located by the
* classLoader via the CLASSPATH.
* For instance, Sun's "nfs" XFileAccessor is installed as:
*
* com.sun.nfs.XFileAccessor
*
com.sun
can be changed by
* setting the System property java.protocol.xfile
* to any desired prefix or a list of prefixes separated by
* vertical bars. Each prefix in the list will be used to
* construct a package name and the classLoader will attempt
* to load that package via the CLASSPATH. This process will
* continue until the XFileAccessor is successfully loaded.
*
* When an "ftp" URL is used, the following package names will
* be constructed:
*
* java.protocol.xfile=com.acme|com.abc
*
* (the default "com.sun" prefix is automatically added to
* the end of the property list)
*
* com.acme.ftp.XFileAccessor
* com.abc.ftp.XFileAccessor
* com.sun.ftp.XFileAccessor
*
* In this case the "nfs" XFileAccessor from ABC, Inc. will
* be loaded in preference to Sun's NFS.
*
*
* @author Brent Callaghan
* @version 1.0, 04/08/98
* @see com.sun.xfile.XFile
*/
public interface XFileAccessor {
/**
* Open a file in this filesystem.
*
* This method is called before any other method.
* It may be used to open the real file.
*
* @param xf The XFile for the file to be accessed
* The URL will be of the form
*
* com.acme.nfs.XFileAccessor
* com.abc.nfs.XFileAccessor
* com.sun.nfs.XFileAccessor
*
true
if the file specified by this object
* exists; false
otherwise.
*/
boolean exists();
/**
* Tests if the application can write to this file.
*
* @return true
if the application is allowed to
* write to a file whose name is specified by this
* object; false
otherwise.
*/
boolean canWrite();
/**
* Tests if the application can read from the specified file.
*
* @return true
if the file specified by this
* object exists and the application can read the file;
* false
otherwise.
*/
boolean canRead();
/**
* Tests if the file represented by this
* object is a "normal" file.
* true
if the file specified by this
* object exists and is a "normal"
* file; false
otherwise.
*/
boolean isFile();
/**
* Tests if the file represented by this XFileAccessor
* object is a directory.
*
* @return true
if this XFileAccessor object
* exists and is a directory; false
* otherwise.
*/
boolean isDirectory();
/**
* Returns the time that the file represented by this
* XFile
object was last modified.
* It is measured as the time in milliseconds since
* midnight, January 1, 1970 UTC.
* 0L
if the specified file
* does not exist.
*/
long lastModified();
/**
* Returns the length of the file represented by this
* XFileAccessor object.
*
* @return the length, in bytes, of the file specified by
* this object, or 0L
if the specified
* file does not exist.
*/
long length();
/**
* Creates an empty file whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the file was created;
* false
otherwise.
*/
boolean mkfile();
/**
* Creates a directory whose pathname is specified by this
* XFileAccessor object.
*
* @return true
if the directory could be created;
* false
otherwise.
*/
boolean mkdir();
/**
* Renames the file specified by this XFileAccessor object to
* have the pathname given by the XFileAccessor object argument.
*
* The destination XFile object will be of the same URL
* scheme as this object. The change of name must not
* affect the existence or accessibility of this object.
*
* @param dest the new filename.
* @return true
if the renaming succeeds;
* false
otherwise.
*/
boolean renameTo(XFile dest);
/**
* Deletes the file specified by this object. If the target
* file to be deleted is a directory, it must be empty for deletion
* to succeed.
*
* @return true
if the file is successfully deleted;
* false
otherwise.
*/
boolean delete();
/**
* Returns a list of the files in the directory specified by
* this XFileAccessor object.
*
* @return an array of file names in the specified directory.
* This list does not include the current directory or
* the parent directory (".
" and
* "..
" on Unix systems).
*/
String[] list();
/**
* Reads a subarray as a sequence of bytes.
*
* @param b the buffer into which the data is read
* @param off the start offset in the data buffer
* @param len the maximum number of bytes to be read
* @param foff the offset into the file
* @return number of bytes read - zero if none.
* @exception java.io.IOException If an I/O error has occurred.
*/
int read(byte b[], int off, int len, long foff) throws IOException;
/**
* Writes a sub array as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data in the buffer
* @param len the number of bytes that are written
* @param foff the offset into the file
* @exception java.io.IOException If an I/O error has occurred.
*/
void write(byte b[], int off, int len, long foff) throws IOException;
/**
* Forces any buffered output bytes to be written out.
*
*
* import com.sun.xfile.*;
*
XFile.getExtensionAccessor()
method is invoked. The
* class loading process is identical to that of an
* XFileAccessor except for the final component of the package
* name: "XFileExtensionAccessor" instead of "XFileAccessor".
*
*
*
* @author Brent Callaghan
* @see com.sun.xfile.XFile#getExtensionAccessor()
* @see com.sun.xfile.XFileAccessor
*/
public abstract class XFileExtensionAccessor {
private XFile xf;
/*
* Constructor for the XFileExtensionAccessor.
*
* Invoked by the XFile class when its getExtensionAccessor
* method is called. The
* import com.sun.xfile.*;
*
XFile
argument of
* the constructor provides context for the methods
* within the class.
*/
public XFileExtensionAccessor(XFile xf) {
this.xf = xf;
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileInputStream.java 0000644 0001750 0001750 00000015364 10577714254 024135 0 ustar god god /*
* Copyright (c) 1999, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
/**
* An XFile input stream is an input stream for reading data from an
* XFile
.
*/
public class XFileInputStream extends InputStream {
private long fp; /* File Pointer */
/**
* File Accessor that implements the underlying filesystem
*/
private XFileAccessor xfa;
/**
* Creates an input file stream to read from the specified
* XFile
object.
*
* @param xfile the file to be opened for reading.
* @exception java.io.FileNotFoundException if the file is
* not found.
*/
public XFileInputStream(XFile xfile) throws IOException {
xfa = xfile.newAccessor();
if (! xfa.open(xfile, true, true)) // serial, read-only
throw new FileNotFoundException("no file");
if (!xfa.canRead())
throw new IOException("no read permission");
}
/**
* Creates an input file stream to read from a file with the
* specified name.
*
* @param name the system-dependent file name.
* @exception java.io.FileNotFoundException if the file is
* not found.
*/
public XFileInputStream(String name) throws IOException {
this(new XFile(name));
}
/*
* Reads a subarray as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @exception java.io.IOException If an I/O error has occurred.
*/
synchronized private int XFAread(byte b[], int off, int len)
throws IOException {
if (b == null)
throw new NullPointerException();
if (len == 0)
return 0;
if (off < 0 || len < 0 || off >= b.length || (off + len) > b.length)
throw new IllegalArgumentException("Invalid argument");
int c = xfa.read(b, off, len, fp);
if (c <= 0)
return (-1);
fp += c;
return (c);
}
/**
* Reads a byte of data from this XFile.
*
* @return the next byte of data, or -1
* if the end of the file is reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read() throws IOException {
byte[] b = new byte[1];
if (XFAread(b, 0, 1) != 1)
return (-1);
return b[0] & 0xff;
}
/**
* Reads up to b.length
bytes of data from this file
* into an array of bytes.
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because
* the end of the file has been reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read(byte b[]) throws IOException {
return XFAread(b, 0, b.length);
}
/**
* Reads up to len
bytes of data from this file
* into an array of bytes.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because
* the end of the file has been reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
return XFAread(b, off, len);
}
/**
* Returns the number of bytes yet to be read from this file.
*
* @return the number of bytes yet to be read from this file
* without blocking.
* @exception java.io.IOException if an I/O error occurs.
*/
public int available() throws IOException {
return (int)(xfa.length() - fp);
}
/**
* Skips over and discards n
bytes of data from the
* file.
*
* The skip
method may, for a variety of
* reasons, end up skipping over some smaller number of bytes,
* possibly 0
.
* The actual number of bytes skipped is returned.
*
* @param n the number of bytes to be skipped.
* @return the actual number of bytes skipped.
* @exception java.io.IOException if an I/O error occurs.
*/
public long skip(long n) throws IOException {
if (n < 0)
throw new IllegalArgumentException("illegal skip: " + n);
fp += n;
return n;
}
/**
* Closes this file input stream and releases any system resources
* associated with the stream.
*
* After the file is closed further I/O operations may
* throw IOException.
*
* @exception java.io.IOException if an I/O error occurs.
*/
public void close() throws IOException {
xfa.close();
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileOutputStream.java 0000644 0001750 0001750 00000016152 10577714254 024332 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
/**
* An XFile output stream is an output stream for writing data to an
* XFile
.
*/
public class XFileOutputStream extends OutputStream {
private long fp; /* File Pointer */
/*
* File Accessor that implements the underlying filesystem
*/
private XFileAccessor xfa;
/**
* Creates an XFile output stream to write to the specified
* XFile
object.
*
* @param file the XFile to be opened for writing.
* @exception java.io.IOException if the XFile could not
* be opened for writing.
*/
public XFileOutputStream(XFile xfile) throws IOException {
xfa = xfile.newAccessor();
if (xfa.open(xfile, true, false)) { // serial, not readonly
if (!xfa.isFile())
throw new IOException("not a file");
if (!xfa.canWrite())
throw new IOException("no write permission");
}
if (!xfa.mkfile())
throw new IOException("no write permission");
}
/**
* Creates an output XFile stream to write to the file with the
* specified name.
*
* @param name the system-dependent filename.
* @exception java.io.IOException if the file could
* not be opened for writing.
*/
public XFileOutputStream(String name) throws IOException {
this(new XFile(name));
}
/**
* Creates an output file for the specified XFile object.
*
* @param xfile the XFile to be opened for writing.
* @param append true if writes begin at the end of the file
* @exception java.io.IOException If the file is not found.
*/
public XFileOutputStream(XFile xfile, boolean append)
throws IOException {
boolean isExist;
xfa = xfile.newAccessor();
if ((isExist = xfa.open(xfile, true, false))) { // serial, not readonly
if (!xfa.isFile())
throw new IOException("not a file");
if (!xfa.canWrite())
throw new IOException("no write permission");
}
/*
* If file doesn't exist or append is False create the file
*/
if (!isExist || !append) {
if (!xfa.mkfile())
throw new IOException("no write permission");
}
if (append)
fp = xfa.length();
}
/**
* Creates an output file with the specified name or URL.
*
* @param name the native name or URL
* @param append true if writes begin at the end of the file
* @exception java.io.IOException If the file is not found.
*/
public XFileOutputStream(String name, boolean append)
throws IOException {
this(new XFile(name), append);
}
/*
* All writes to the Accessor go through here.
*/
synchronized private void XFAwrite(byte b[], int off, int len)
throws IOException {
if (b == null)
throw new NullPointerException();
if (len == 0)
return;
if (off < 0 || len < 0 || off >= b.length || (off + len) > b.length)
throw new IllegalArgumentException("Invalid argument");
xfa.write(b, off, len, fp);
fp += len;
}
/**
* Writes the specified byte to this file output stream.
*
* @param b the byte to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(int b) throws IOException {
XFAwrite(new byte[] {(byte)b}, 0, 1);
}
/**
* Writes b.length
bytes from the specified byte array
* to this file output stream.
*
* @param b the data.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
XFAwrite(b, 0, b.length);
}
/**
* Writes len
bytes from the specified byte array
* starting at offset off
to this XFile output stream.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
XFAwrite(b, off, len);
}
/**
* Flushes this output stream and forces any buffered output bytes
* to be written out.
* close
method of this XFile
* output stream is called when there are no more references
* to this stream.
*
* @exception java.io.IOException if an I/O error occurs.
* @see com.sun.xfile.XFileInputStream#close()
*/
protected void finalize() throws IOException {
close();
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileReader.java 0000644 0001750 0001750 00000004622 10577714254 023057 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
/**
* Convenience class for reading character files.
*
* The constructors of this class assume that the default character
* encoding and the default byte-buffer size are appropriate.
* To specify these values yourself, construct an
* InputStreamReader on a FileInputStream.
*
* @see InputStreamReader
* @see XFileInputStream
*
*/
public class XFileReader extends InputStreamReader {
public XFileReader(String fileName) throws IOException {
super(new XFileInputStream(fileName));
}
public XFileReader(XFile file) throws IOException {
super(new XFileInputStream(file));
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFileWriter.java 0000644 0001750 0001750 00000005032 10577714254 023125 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
/**
* Convenience class for writing character files.
*
* The constructors of this class assume that the default character
* encoding and the default byte-buffer size are acceptable.
* To specify these values yourself, construct an
* OutputStreamWriter on a FileOutputStream.
*
* @see OutputStreamWriter
* @see XFileOutputStream
*/
public class XFileWriter extends OutputStreamWriter {
public XFileWriter(String fileName) throws IOException {
super(new XFileOutputStream(fileName));
}
public XFileWriter(String fileName, boolean append) throws IOException {
super(new XFileOutputStream(fileName, append));
}
public XFileWriter(XFile file) throws IOException {
super(new XFileOutputStream(file));
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFilenameFilter.java 0000644 0001750 0001750 00000004737 10577714254 023752 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
/**
* Instances of classes that implement this interface are used to
* filter filenames. These instances are used to filter directory
* listings in the list
method of class
* XFile
.
*
* @see com.sun.xfile.XFile#list(com.sun.xfile.XFilenameFilter)
*/
public interface XFilenameFilter {
/**
* Tests if a specified file should be included in a file list.
*
* @param dir the directory in which the file was found.
* @param name the name of the file.
* @return true
if the name should be included in
* the file list; false
otherwise.
*/
boolean accept(XFile dir, String name);
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XFurl.java 0000644 0001750 0001750 00000014142 10577714254 021763 0 ustar god god /*
* Copyright (c) 1999, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.net.MalformedURLException;
/**
* This is just a dumb URL parser class.
* I wrote it because I got fed up with the
* JDK URL class calling NFS URL's "invalid"
* simply because the Handler wasn't installed.
*
* @author Brent Callaghan
*/
class XFurl {
private String url;
private String protocol;
private String location;
private String path;
XFurl(String url) throws MalformedURLException {
int p, q, r;
url = url.trim(); // remove leading & trailing spaces
this.url = url;
int end = url.length();
p = url.indexOf(':');
if (p < 0)
throw new MalformedURLException("colon expected");
protocol = url.substring(0, p);
q = p;
p++; // skip colon
if (url.regionMatches(p, "//", 0, 2)) { // have hostname
p += 2;
q = url.indexOf('/', p);
if (q < 0)
q = end;
location = url.substring(p, q);
}
path = q < end ? url.substring(q + 1, end) : "";
// Remove trailing slashes from path
while (path.endsWith("/"))
path = path.substring(0, path.length()-1);
}
XFurl(XFurl base, String rpath) throws MalformedURLException {
protocol = base.getProtocol();
location = base.getLocation();
path = base.getPath();
rpath = rpath.trim();
if (rpath.indexOf("://") > 0) { // URL - ignore base
url = rpath;
XFurl u = new XFurl(rpath);
protocol = u.getProtocol();
location = u.getLocation();
path = u.getPath();
} else if (rpath.startsWith("/")) { // absolute path
path = rpath.substring(1);
} else {
/*
* Escape any "%" characters in the name
* e.g. "%markup" -> "%25markup"
*/
String npath = "";
int len = rpath.length();
int p1 = 0, p2;
while (true) {
p2 = rpath.indexOf('%', p1); // look for %
if (p2 < 0)
p2 = len;
npath += rpath.substring(p1, p2);
if (p2 >= len)
break;
npath += "%25"; // replace % with %25
p1 = p2 + 1;
}
rpath = npath;
len = rpath.length();
/*
* Combine base path with relative path
* according to rules in RFCs 1808 & 2054
*
* e.g. /a/b/c + x = /a/b/c/x
* /a/b/c + /y = /y
* /a/b/c + ../z = /a/b/z
* /a/b/c + d/. = /a/b/c/d
*/
String bpath = base.getPath();
p1 = 0;
while (p1 <= len) {
p2 = rpath.indexOf("/", p1);
if (p2 < 0)
p2 = len;
String component = rpath.substring(p1, p2);
if (component.equals(".") || component.equals("")) {
// ignore
} else if (component.equals("..")) {
int q = bpath.lastIndexOf("/");
bpath = q < 0 ? "" : bpath.substring(0, q);
} else {
if (bpath.equals(""))
bpath = component;
else
bpath += "/" + component;
}
p1 = p2 + 1;
}
path = bpath;
}
}
String getProtocol() {
return (protocol);
}
String getLocation() {
return (location);
}
String getPath() {
return (path);
}
String getParent() {
if (path.equals(""))
return null; // no parent
String s = protocol + ":";
if (location != null)
s += "//" + location;
int index = path.lastIndexOf('/');
if (index >= 0)
s += "/" + path.substring(0, index);
return s;
}
String getName() {
int index = path.lastIndexOf('/');
return index < 0 ? path : path.substring(index + 1);
}
public String toString() {
String s = protocol + ":";
if (location != null)
s += "//" + location;
if (path != null)
s += "/" + path;
return (s);
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfile/XRandomAccessFile.java 0000644 0001750 0001750 00000074045 10577714255 024226 0 ustar god god /*
* Copyright (c) 1998, 2007 Sun Microsystems, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* -Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* -Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
* ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS
* SHALL NOT BE LIABLE FOR ANY DAMAGES OR LIABILITIES SUFFERED BY LICENSEE
* AS A RESULT OF OR RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE
* SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE
* LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
* SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED
* AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
* INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*
* You acknowledge that this software is not designed,licensed or intended
* for use in the design, construction, operation or maintenance of any
* nuclear facility.
*/
package com.sun.xfile;
import java.io.*;
/**
* Instances of this class support both reading and writing to a
* random access file. An application can modify the position in the
* file at which the next read or write occurs.
* This class provides a sense of security
* by offering methods that allow specified mode accesses of
* read-only or read-write to files.
*
*/
public class XRandomAccessFile implements DataOutput, DataInput {
private long fp; /* File Pointer */
private boolean readOnly;
/*
* File Accessor that implements the underlying filesystem
*/
private XFileAccessor xfa;
/**
* Creates a random access file stream to read from, and optionally
* to write to, the file specified by the XFile
* argument.
*
* The mode argument must either be equal to "r"
or to
* "rw"
, indicating either to open the file for input,
* or for both input and output, respectively.
*
* @param xf the XFile object.
* @param mode the access mode.
* @exception java.lang.IllegalArgumentException if the mode
* argument is not equal to "r"
or
* to "rw"
.
* @exception java.io.IOException if an I/O error occurs.
*/
public XRandomAccessFile(XFile xf, String mode) throws IOException {
if (! (mode.equals("r") || mode.equals("rw")))
throw new IllegalArgumentException("mode must be r or rw");
readOnly = mode.equals("r");
xfa = xf.newAccessor();
xfa.open(xf, false, readOnly);
if (xfa.exists()) {
if (readOnly && ! xfa.canRead())
throw new IOException("no read permission");
if (! readOnly && ! xfa.canWrite())
throw new IOException("no write permission");
} else {
if (readOnly)
throw new IOException("no such file or directory");
if (! xfa.mkfile())
throw new IOException("no write permission");
}
}
/**
* Creates a random access file to read from, and optionally
* to write to, a file with the specified name.
* "r"
or
* "rw"
, indicating either to open the file for input
* or for both input and output.
*
* @param name the native or URL file name.
* @param mode the access mode.
* @exception java.lang.IllegalArgumentException if the mode
* argument is not equal to "r"
or to
* "rw"
.
* @exception java.io.IOException if an I/O error occurs.
*/
public XRandomAccessFile(String name, String mode) throws IOException {
this(new XFile(name), mode);
}
// 'Read' primitives
private int XFAread(byte b[], int off, int len) throws IOException {
if (b == null)
throw new NullPointerException();
if (len == 0)
return 0;
if (off < 0 || len < 0 || off >= b.length || (off + len) > b.length)
throw new IllegalArgumentException("Invalid argument");
int c = xfa.read(b, off, len, fp);
if (c >= 0)
fp += c;
return c;
}
/**
* Reads a byte of data from this file.
*
* @return the next byte of data, or -1
if the
* end of the file is reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read() throws IOException {
byte[] b = new byte[1];
if (XFAread(b, 0, 1) != 1)
return (-1);
return b[0] & 0xff;
}
/**
* Reads up to len
bytes of data from this file into
* an array of bytes.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the maximum number of bytes read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because
* the end of the file has been reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read(byte b[], int off, int len) throws IOException {
return XFAread(b, off, len);
}
/**
* Reads up to b.length
bytes of data from this file
* into an array of bytes.
*
* @param b the buffer into which the data is read.
* @return the total number of bytes read into the buffer, or
* -1
if there is no more data because
* the end of this file has been reached.
* @exception java.io.IOException if an I/O error occurs.
*/
public int read(byte b[]) throws IOException {
return XFAread(b, 0, b.length);
}
/**
* Reads b.length
bytes from this file into the byte
* array.
*
* @param b the buffer into which the data is read.
* @exception java.io.EOFException if this file reaches
* the end before reading all the bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void readFully(byte b[]) throws IOException {
readFully(b, 0, b.length);
}
/**
* Reads exactly len
bytes from this file into
* the byte array.
*
* @param b the buffer into which the data is read.
* @param off the start offset of the data.
* @param len the number of bytes to read.
* @exception java.io.EOFException if this file reaches the
* end before reading all the bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void readFully(byte b[], int off, int len)
throws IOException {
if (XFAread(b, off, len) < len)
throw new EOFException();
}
/**
* Skips exactly n
bytes of input.
* n
.
* @exception java.io.EOFException if this file reaches the end
* before skipping all the bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public int skipBytes(int n) throws IOException {
if (fp + n > xfa.length())
throw new EOFException();
seek(fp + n);
return n;
}
// 'Write' primitives
private void XFAwrite(byte b[], int off, int len)
throws IOException {
if (b == null)
throw new NullPointerException();
if (readOnly)
throw new IOException("Read only file");
if (off < 0 || len < 0)
throw new IllegalArgumentException("Invalid argument");
xfa.write(b, off, len, fp);
fp += len;
}
/**
* Writes the specified byte to this file.
*
* @param b the byte
to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(int b) throws IOException {
XFAwrite(new byte[]{(byte)b}, 0, 1);
}
/**
* Writes a sub array as a sequence of bytes.
*
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @exception java.io.IOException If an I/O error has occurred.
*/
private void writeBytes(byte b[], int off, int len)
throws IOException {
XFAwrite(b, off, len);
}
/**
* Writes b.length
bytes from the specified byte array
* starting at offset off
to this file.
*
* @param b the data.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(byte b[]) throws IOException {
writeBytes(b, 0, b.length);
}
/**
* Writes len
bytes from the specified byte array
* starting at offset off
to this file.
*
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @exception java.io.IOException if an I/O error occurs.
*/
public void write(byte b[], int off, int len) throws IOException {
writeBytes(b, off, len);
}
// 'Random access' stuff
/**
* Returns the current offset in this file.
*
* @return the offset from the beginning of the file, in bytes,
* at which the next read or write occurs.
* @exception java.io.IOException if an I/O error occurs.
*/
public long getFilePointer() throws IOException {
return fp;
}
/**
* Sets the offset from the beginning of this file at which
* the next read or write occurs.
*
* @param pos the absolute position.
* @exception java.io.IOException if an I/O error occurs.
*/
public void seek(long pos) throws IOException {
if ( pos < 0 || (readOnly && pos >= xfa.length()))
throw new IOException("illegal seek" + pos);
fp = pos;
}
/**
* Returns the length of this file.
*
* @return the length of this file.
* @exception java.io.IOException if an I/O error occurs.
*/
public long length() throws IOException {
return xfa.length();
}
/**
* Forces any buffered output bytes to be written out.
*
* @exception java.io.IOException if an I/O error occurs.
*/
public void flush() throws IOException {
if (readOnly)
throw new IOException("Read only file");
xfa.flush();
}
/**
* Closes this random access file and flushes any
* unwritten data to the file.
*
* After the file is closed further I/O operations may
* throw IOException.
*
* @exception java.io.IOException if an I/O error occurs.
*/
public void close() throws IOException {
xfa.close();
}
//
// Some "reading/writing Java data types" methods stolen from
// DataInputStream and DataOutputStream.
//
/**
* Reads a boolean
from this file. This method reads a
* single byte from the file. A value of 0
represents
* false
. Any other value represents true
.
* This method blocks until the byte is read, the end of the stream
* is detected, or an exception is thrown.
*
* @return the boolean
value read.
* @exception java.io.EOFException if this file has reached the end.
* @exception java.io.IOException if an I/O error occurs.
*/
public final boolean readBoolean() throws IOException {
int ch = this.read();
if (ch < 0)
throw new EOFException();
return (ch != 0);
}
/**
* Reads a signed 8-bit value from this file. This method reads a
* byte from the file. If the byte read is b
, where
* 0 <= b <= 255
,
* then the result is:
*
*
* (byte)(b)
*
byte
.
* @exception java.io.EOFException if this file has reached the end.
* @exception java.io.IOException if an I/O error occurs.
*/
public final byte readByte() throws IOException {
int ch = this.read();
if (ch < 0)
throw new EOFException();
return (byte)(ch);
}
/**
* Reads an unsigned 8-bit number from this file. This method reads
* a byte from this file and returns that byte.
* b1
and b2
, where each of the two values is
* between 0
and 255
, inclusive, then the
* result is equal to:
*
*
* (short)((b1 << 8) | b2)
*
b1
and b2
, where
* 0 <= b1, b2 <= 255
,
* then the result is equal to:
*
*
* (b1 << 8) | b2
*
b1
and b2
, where
* 0 <= b1, b2 <= 255
,
* then the result is equal to:
*
*
* (char)((b1 << 8) | b2)
*
b1
,
* b2
, b3
, and b4
, where
* 0 <= b1, b2, b3, b4 <= 255
,
* then the result is equal to:
*
*
* (b1 << 24) | (b2 << 16) + (b3 << 8) + b4
*
int
.
* @exception java.io.EOFException if this file reaches the end before reading
* four bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final int readInt() throws IOException {
int ch1 = this.read();
int ch2 = this.read();
int ch3 = this.read();
int ch4 = this.read();
if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
}
/**
* Reads a signed 64-bit integer from this file. This method reads eight
* bytes from the file. If the bytes read, in order, are
* b1
, b2
, b3
,
* b4
, b5
, b6
,
* b7
, and b8,
where:
*
*
* 0 <= b1, b2, b3, b4, b5, b6, b7, b8 <=255,
*
*
* ((long)b1 << 56) + ((long)b2 << 48)
* + ((long)b3 << 40) + ((long)b4 << 32)
* + ((long)b5 << 24) + ((long)b6 << 16)
* + ((long)b7 << 8) + b8
*
long
.
* @exception java.io.EOFException if this file reaches the end before reading
* eight bytes.
* @exception java.io.IOException if an I/O error occurs.
*/
public final long readLong() throws IOException {
return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
}
/**
* Reads a float
from this file. This method reads an
* int
value as if by the readInt
method
* and then converts that int
to a float
* using the intBitsToFloat
method in class
* Float
.
* float
.
* @exception java.io.EOFException if this file reaches the end before reading
* four bytes.
* @exception java.io.IOException if an I/O error occurs.
* @see com.sun.xfile.XRandomAccessFile#readInt()
* @see java.lang.Float#intBitsToFloat(int)
*/
public final float readFloat() throws IOException {
return Float.intBitsToFloat(readInt());
}
/**
* Reads a double
from this file. This method reads a
* long
value as if by the readLong
method
* and then converts that long
to a double
* using the longBitsToDouble
method in
* class Double
.
* double
.
* @exception java.io.EOFException if this file reaches the end before reading
* eight bytes.
* @exception java.io.IOException if an I/O error occurs.
* @see com.sun.xfile.XRandomAccessFile#readLong()
* @see java.lang.Double#longBitsToDouble(long)
*/
public final double readDouble() throws IOException {
return Double.longBitsToDouble(readLong());
}
/**
* Reads the next line of text from this file. This method
* successively reads bytes from the file until it reaches the end of
* a line of text.
* '\r'
), a newline character ('\n'
), a
* carriage-return character immediately followed by a newline
* character, or the end of the input stream. The line-terminating
* character(s), if any, are included as part of the string returned.
* readUnsignedShort
. This value gives the number of
* following bytes that are in the encoded string, not
* the length of the resulting string. The following bytes are then
* interpreted as bytes encoding characters in the UTF-8 format
* and are converted into characters.
* boolean
to the file as a 1-byte value. The
* value true
is written out as the value
* (byte)1
; the value false
is written out
* as the value (byte)0
.
*
* @param v a boolean
value to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeBoolean(boolean v) throws IOException {
write(v ? 1 : 0);
//written++;
}
/**
* Writes a byte
to the file as a 1-byte value.
*
* @param v a byte
value to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeByte(int v) throws IOException {
write(v);
//written++;
}
/**
* Writes a short
to the file as two bytes, high byte first.
*
* @param v a short
to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeShort(int v) throws IOException {
write((v >>> 8) & 0xFF);
write((v >>> 0) & 0xFF);
//written += 2;
}
/**
* Writes a char
to the file as a 2-byte value, high
* byte first.
*
* @param v a char
value to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeChar(int v) throws IOException {
write((v >>> 8) & 0xFF);
write((v >>> 0) & 0xFF);
//written += 2;
}
/**
* Writes an int
to the file as four bytes, high byte first.
*
* @param v an int
to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeInt(int v) throws IOException {
write((v >>> 24) & 0xFF);
write((v >>> 16) & 0xFF);
write((v >>> 8) & 0xFF);
write((v >>> 0) & 0xFF);
//written += 4;
}
/**
* Writes a long
to the file as eight bytes, high byte first.
*
* @param v a long
to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeLong(long v) throws IOException {
write((int)(v >>> 56) & 0xFF);
write((int)(v >>> 48) & 0xFF);
write((int)(v >>> 40) & 0xFF);
write((int)(v >>> 32) & 0xFF);
write((int)(v >>> 24) & 0xFF);
write((int)(v >>> 16) & 0xFF);
write((int)(v >>> 8) & 0xFF);
write((int)(v >>> 0) & 0xFF);
//written += 8;
}
/**
* Converts the float argument to an int
using the
* floatToIntBits
method in class Float
,
* and then writes that int
value to the file as a
* 4-byte quantity, high byte first.
*
* @param v a float
value to be written.
* @exception java.io.IOException if an I/O error occurs.
* @see java.lang.Float#floatToIntBits(float)
*/
public final void writeFloat(float v) throws IOException {
writeInt(Float.floatToIntBits(v));
}
/**
* Converts the double argument to a long
using the
* doubleToLongBits
method in class Double
,
* and then writes that long
value to the file as an
* 8-byte quantity, high byte first.
*
* @param v a double
value to be written.
* @exception java.io.IOException if an I/O error occurs.
* @see java.lang.Double#doubleToLongBits(double)
*/
public final void writeDouble(double v) throws IOException {
writeLong(Double.doubleToLongBits(v));
}
/**
* Writes the string to the file as a sequence of bytes. Each
* character in the string is written out, in sequence, by discarding
* its high eight bits.
*
* @param s a string of bytes to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeBytes(String s) throws IOException {
int len = s.length();
for (int i = 0 ; i < len ; i++) {
write((byte)s.charAt(i));
}
//written += len;
}
/**
* Writes a string to the file as a sequence of characters. Each
* character is written to the data output stream as if by the
* writeChar
method.
*
* @param s a String
value to be written.
* @exception java.io.IOException if an I/O error occurs.
* @see com.sun.xfile.XRandomAccessFile#writeChar(int)
*/
public final void writeChars(String s) throws IOException {
int len = s.length();
for (int i = 0 ; i < len ; i++) {
int v = s.charAt(i);
write((v >>> 8) & 0xFF);
write((v >>> 0) & 0xFF);
}
//written += len * 2;
}
/**
* Writes a string to the file using UTF-8 encoding in a
* machine-independent manner.
* writeShort
method giving the number of bytes to
* follow. This value is the number of bytes actually written out,
* not the length of the string. Following the length, each character
* of the string is output, in sequence, using the UTF-8 encoding
* for each character.
*
* @param str a string to be written.
* @exception java.io.IOException if an I/O error occurs.
*/
public final void writeUTF(String str) throws IOException {
int strlen = str.length();
int utflen = 0;
for (int i = 0 ; i < strlen ; i++) {
int c = str.charAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
utflen++;
} else if (c > 0x07FF) {
utflen += 3;
} else {
utflen += 2;
}
}
if (utflen > 65535)
throw new UTFDataFormatException();
write((utflen >>> 8) & 0xFF);
write((utflen >>> 0) & 0xFF);
for (int i = 0 ; i < strlen ; i++) {
int c = str.charAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
write(c);
} else if (c > 0x07FF) {
write(0xE0 | ((c >> 12) & 0x0F));
write(0x80 | ((c >> 6) & 0x3F));
write(0x80 | ((c >> 0) & 0x3F));
//written += 2;
} else {
write(0xC0 | ((c >> 6) & 0x1F));
write(0x80 | ((c >> 0) & 0x3F));
//written += 1;
}
}
//written += strlen + 2;
}
}
libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfilechooser/ 0000755 0001750 0001750 00000000000 10670730370 021430 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfilechooser/images/ 0000755 0001750 0001750 00000000000 06612756714 022710 5 ustar god god libyanfs-java-0.0+cvs20070825.orig/src/com/sun/xfilechooser/images/422LOGO5_16x16.gif 0000644 0001750 0001750 00000004775 06612756714 025336 0 ustar god god GIF87aL 2 !!!111BBBRRRccc{{{{{ccBB))11))1191B91)ZRcZJBsckZcRRBs91{kkZk{cZ)1R9J1c9kJ9cBsJB)kBR1kcZR1Z1ZR1J)Z1ƭZZJB{kZ9R{cJƔZ{9ƥsZޥ1skc֭RJΜ9B9RJޭ9筜JR{9ƄZJR{JZƜZcBkJֽsRZsZkBc{J{cckZkε1J9BZ9Z{RssZcBcJJkJ{kƥνZk9kc{9ss)JR)cs! s֜k9s{B{!BRRJJ9JcZc1){ZRR{9{J{1k1c)c 9{ 1k)ZB 1s9Jc9k)Z1Z9{1s!B{!J91R)J1c!R!B!1Zs{!1cZc!)RZc9B{ss11J99Z RJ{ZBckBkֵ{RƔck9R{BZ{Rcs)BBRs!1 !19 , L 2 H*\ȰÃSË3 C*t#?,ҡt@|زgA|%<E@ 4>P@BCY _2A@*Kb
dS @$ Рlh ӬFx`,Yv
\ m@[}R\b0`e|AM
jj +6Iڠrl@ @%jő00QtT@n٨WxtJ^ n@C
4
2*0aWX-Rm1T / Tq@0*w SDut9 }*
/`
/p⤓La'jfA| Rʗ_"C7B/`,̅uiU RTm~c
:DҧL^z\lGB bHnp(r
dK4ߕ
! G@
!lɦ*Ilt*}N-p@Ln=
@/q p2H[+~iHy$AD2/4+c #BP N)AEM`1Nt
)Lq)BJɚ2s`Xp" T -$~F
,@`DH'Qb*!L*u2|A(P1cpɨFSд
3V$U@K(2|=Au2Cè
b.u<1G+Q@GFd`x{T@l0{u"(b1cLA,J'@@ETTOU(ǰ>%PP1A3T]r)C3"o[GFΧ0ϼ.B7)A Z`ъ2$XuJQ6Ag?AtD"G':)p |v \h1DB|&$GEb jC{ V0t .^YxǨC}!t`by`!f