System properties the namespace
- * is global therefore property names should be unique. Before use,
- * the load method should be called with the name of a
- * Properties file (or null indicating no
- * file) to initialize the Config. The System
- * properties will then populate the Config as well potentially
- * overwriting properties from the file. Thus properties provided on the
- * commandline with the -Dproperty.name=value VM parameter
- * will override properties from the configuration file.
- *
- * There are several ways to set jCIFS properties. See
- * the overview page of the API
- * documentation for details.
- */
-
-public class Config {
-
-public static int socketCount = 0;
-
- /**
- * The static Properties.
- */
-
- private static Properties prp = new Properties();
- private static LogStream log;
- public static String DEFAULT_OEM_ENCODING = "Cp850";
-
- static {
- String filename;
- int level;
- FileInputStream in = null;
-
- log = LogStream.getInstance();
-
- try {
- filename = System.getProperty( "jcifs.properties" );
- if( filename != null && filename.length() > 1 ) {
- in = new FileInputStream( filename );
- }
- Config.load( in );
- if (in != null)
- in.close();
- } catch( IOException ioe ) {
- if( log.level > 0 )
- ioe.printStackTrace( log );
- }
-
- if(( level = Config.getInt( "jcifs.util.loglevel", -1 )) != -1 ) {
- LogStream.setLevel( level );
- }
-
- try {
- "".getBytes(DEFAULT_OEM_ENCODING);
- } catch (UnsupportedEncodingException uee) {
- if (log.level >= 2) {
- log.println("WARNING: The default OEM encoding " + DEFAULT_OEM_ENCODING +
- " does not appear to be supported by this JRE. The default encoding will be US-ASCII.");
- }
- DEFAULT_OEM_ENCODING = "US-ASCII";
- }
-
- if (log.level >= 4) {
- try {
- prp.store( log, "JCIFS PROPERTIES" );
- } catch( IOException ioe ) {
- }
- }
- }
-
- /**
- * This static method registers the SMB URL protocol handler which is
- * required to use SMB URLs with the java.net.URL class. If this
- * method is not called before attempting to create an SMB URL with the
- * URL class the following exception will occur:
- *
- * Exception MalformedURLException: unknown protocol: smb - * at java.net.URL.(URL.java:480) - * at java.net.URL. (URL.java:376) - * at java.net.URL. (URL.java:330) - * at jcifs.smb.SmbFile. (SmbFile.java:355) - * ... - * - */ - - public static void registerSmbURLHandler() { - String ver, pkgs; - - ver = System.getProperty( "java.version" ); - if( ver.startsWith( "1.1." ) || ver.startsWith( "1.2." )) { - throw new RuntimeException( "jcifs-0.7.0b4+ requires Java 1.3 or above. You are running " + ver ); - } - pkgs = System.getProperty( "java.protocol.handler.pkgs" ); - if( pkgs == null ) { - System.setProperty( "java.protocol.handler.pkgs", "jcifs" ); - } else if( pkgs.indexOf( "jcifs" ) == -1 ) { - pkgs += "|jcifs"; - System.setProperty( "java.protocol.handler.pkgs", pkgs ); - } - } - - // supress javadoc constructor summary by removing 'protected' - Config() {} - - /** - * Set the default properties of the static Properties used by Config. This permits - * a different Properties object/file to be used as the source of properties for - * use by the jCIFS library. The Properties must be set before jCIFS - * classes are accessed as most jCIFS classes load properties statically once. - * Using this method will also override properties loaded - * using the -Djcifs.properties= commandline parameter. - */ - - public static void setProperties( Properties prp ) { - Config.prp = new Properties( prp ); - try { - Config.prp.putAll( System.getProperties() ); - } catch( SecurityException se ) { - if( log.level > 1 ) - log.println( "SecurityException: jcifs will ignore System properties" ); - } - } - - /** - * Load theConfigwith properties from the stream - *infrom aPropertiesfile. - */ - - public static void load( InputStream in ) throws IOException { - if( in != null ) { - prp.load( in ); - } - try { - prp.putAll( (java.util.Map)System.getProperties().clone() ); - } catch( SecurityException se ) { - if( log.level > 1 ) - log.println( "SecurityException: jcifs will ignore System properties" ); - } - } - - public static void store( OutputStream out, String header ) throws IOException { - prp.store( out, header ); - } - - /** - * List the properties in theCode. - */ - - public static void list( PrintStream out ) throws IOException { - prp.list( out ); - } - - /** - * Add a property. - */ - - public static Object setProperty( String key, String value ) { - return prp.setProperty( key, value ); - } - - /** - * Retrieve a property as anObject. - */ - - public static Object get( String key ) { - return prp.get( key ); - } - - /** - * Retrieve aString. If the key cannot be found, - * the provideddefdefault parameter will be returned. - */ - - public static String getProperty( String key, String def ) { - return prp.getProperty( key, def ); - } - - /** - * Retrieve aString. If the property is not found,nullis returned. - */ - - public static String getProperty( String key ) { - return prp.getProperty( key ); - } - - /** - * Retrieve anint. If the key does not exist or - * cannot be converted to anint, the provided default - * argument will be returned. - */ - - public static int getInt( String key, int def ) { - String s = prp.getProperty( key ); - if( s != null ) { - try { - def = Integer.parseInt( s ); - } catch( NumberFormatException nfe ) { - if( log.level > 0 ) - nfe.printStackTrace( log ); - } - } - return def; - } - - /** - * Retrieve anint. If the property is not found,-1is returned. - */ - - public static int getInt( String key ) { - String s = prp.getProperty( key ); - int result = -1; - if( s != null ) { - try { - result = Integer.parseInt( s ); - } catch( NumberFormatException nfe ) { - if( log.level > 0 ) - nfe.printStackTrace( log ); - } - } - return result; - } - - /** - * Retrieve along. If the key does not exist or - * cannot be converted to along, the provided default - * argument will be returned. - */ - - public static long getLong( String key, long def ) { - String s = prp.getProperty( key ); - if( s != null ) { - try { - def = Long.parseLong( s ); - } catch( NumberFormatException nfe ) { - if( log.level > 0 ) - nfe.printStackTrace( log ); - } - } - return def; - } - - /** - * Retrieve anInetAddress. If the address is not - * an IP address and cannot be resolvednullwill - * be returned. - */ - - public static InetAddress getInetAddress( String key, InetAddress def ) { - String addr = prp.getProperty( key ); - if( addr != null ) { - try { - def = InetAddress.getByName( addr ); - } catch( UnknownHostException uhe ) { - if( log.level > 0 ) { - log.println( addr ); - uhe.printStackTrace( log ); - } - } - } - return def; - } - public static InetAddress getLocalHost() { - String addr = prp.getProperty( "jcifs.smb.client.laddr" ); - - if (addr != null) { - try { - return InetAddress.getByName( addr ); - } catch( UnknownHostException uhe ) { - if( log.level > 0 ) { - log.println( "Ignoring jcifs.smb.client.laddr address: " + addr ); - uhe.printStackTrace( log ); - } - } - } - - return null; - } - - /** - * Retrieve a boolean value. If the property is not found, the value ofdefis returned. - */ - - public static boolean getBoolean( String key, boolean def ) { - String b = getProperty( key ); - if( b != null ) { - def = b.toLowerCase().equals( "true" ); - } - return def; - } - - /** - * Retrieve an array of InetAddress created from a property - * value containting a delim separated list of hostnames and/or - * ipaddresses. - */ - - public static InetAddress[] getInetAddressArray( String key, String delim, InetAddress[] def ) { - String p = getProperty( key ); - if( p != null ) { - StringTokenizer tok = new StringTokenizer( p, delim ); - int len = tok.countTokens(); - InetAddress[] arr = new InetAddress[len]; - for( int i = 0; i < len; i++ ) { - String addr = tok.nextToken(); - try { - arr[i] = InetAddress.getByName( addr ); - } catch( UnknownHostException uhe ) { - if( log.level > 0 ) { - log.println( addr ); - uhe.printStackTrace( log ); - } - return def; - } - } - return arr; - } - return def; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/UniAddress.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/UniAddress.java deleted file mode 100644 index dba8e73ded..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/UniAddress.java +++ /dev/null @@ -1,470 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs; - -import jcifs.netbios.Lmhosts; -import jcifs.netbios.NbtAddress; -import jcifs.util.LogStream; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.StringTokenizer; - -/** - * Under normal conditions it is not necessary to use - * this class to use jCIFS properly. Name resolusion is - * handled internally to the
jcifs.smbpackage. - *- * This class is a wrapper for both {@link NbtAddress} - * and {@link InetAddress}. The name resolution mechanisms - * used will systematically query all available configured resolution - * services including WINS, broadcasts, DNS, and LMHOSTS. See - * Setting Name Resolution Properties - * and the
jcifs.resolveOrderproperty. Changing - * jCIFS name resolution properties can greatly affect the behavior of - * the client and may be necessary for proper operation. - *- * This class should be used in favor of InetAddress to resolve - * hostnames on LANs and WANs that support a mixture of NetBIOS/WINS and - * DNS resolvable hosts. - */ - -public class UniAddress { - - private static final int RESOLVER_WINS = 0; - private static final int RESOLVER_BCAST = 1; - private static final int RESOLVER_DNS = 2; - private static final int RESOLVER_LMHOSTS = 3; - - private static int[] resolveOrder; - private static InetAddress baddr; - - private static LogStream log = LogStream.getInstance(); - - static { - String ro = Config.getProperty( "jcifs.resolveOrder" ); - InetAddress nbns = NbtAddress.getWINSAddress(); - - try { - baddr = Config.getInetAddress( "jcifs.netbios.baddr", - InetAddress.getByName( "255.255.255.255" )); - } catch( UnknownHostException uhe ) { - } - - if( ro == null || ro.length() == 0 ) { - - /* No resolveOrder has been specified, use the - * default which is LMHOSTS,WINS,BCAST,DNS or just - * LMHOSTS,BCAST,DNS if jcifs.netbios.wins has not - * been specified. - */ - - if( nbns == null ) { - resolveOrder = new int[3]; - resolveOrder[0] = RESOLVER_LMHOSTS; - resolveOrder[1] = RESOLVER_DNS; - resolveOrder[2] = RESOLVER_BCAST; - } else { - resolveOrder = new int[4]; - resolveOrder[0] = RESOLVER_LMHOSTS; - resolveOrder[1] = RESOLVER_WINS; - resolveOrder[2] = RESOLVER_DNS; - resolveOrder[3] = RESOLVER_BCAST; - } - } else { - int[] tmp = new int[4]; - StringTokenizer st = new StringTokenizer( ro, "," ); - int i = 0; - while( st.hasMoreTokens() ) { - String s = st.nextToken().trim(); - if( s.equalsIgnoreCase( "LMHOSTS" )) { - tmp[i++] = RESOLVER_LMHOSTS; - } else if( s.equalsIgnoreCase( "WINS" )) { - if( nbns == null ) { - if( log.level > 1 ) { - log.println( "UniAddress resolveOrder specifies WINS however the " + - "jcifs.netbios.wins property has not been set" ); - } - continue; - } - tmp[i++] = RESOLVER_WINS; - } else if( s.equalsIgnoreCase( "BCAST" )) { - tmp[i++] = RESOLVER_BCAST; - } else if( s.equalsIgnoreCase( "DNS" )) { - tmp[i++] = RESOLVER_DNS; - } else if( log.level > 1 ) { - log.println( "unknown resolver method: " + s ); - } - } - resolveOrder = new int[i]; - System.arraycopy( tmp, 0, resolveOrder, 0, i ); - } - } - - static class Sem { - Sem( int count ) { - this.count = count; - } - int count; - } - - static class QueryThread extends Thread { - - Sem sem; - String host, scope; - int type; - NbtAddress ans = null; - InetAddress svr; - UnknownHostException uhe; - - QueryThread( Sem sem, String host, int type, - String scope, InetAddress svr ) { - super( "JCIFS-QueryThread: " + host ); - this.sem = sem; - this.host = host; - this.type = type; - this.scope = scope; - this.svr = svr; - } - public void run() { - try { - ans = NbtAddress.getByName( host, type, scope, svr ); - } catch( UnknownHostException uhe ) { - this.uhe = uhe; - } catch( Exception ex ) { - this.uhe = new UnknownHostException( ex.getMessage() ); - } finally { - synchronized( sem ) { - sem.count--; - sem.notify(); - } - } - } - } - - static NbtAddress lookupServerOrWorkgroup( String name, InetAddress svr ) - throws UnknownHostException { - Sem sem = new Sem( 2 ); - int type = NbtAddress.isWINS( svr ) ? 0x1b : 0x1d; - - QueryThread q1x = new QueryThread( sem, name, type, null, svr ); - QueryThread q20 = new QueryThread( sem, name, 0x20, null, svr ); - q1x.setDaemon( true ); - q20.setDaemon( true ); - try { - synchronized( sem ) { - q1x.start(); - q20.start(); - - while( sem.count > 0 && q1x.ans == null && q20.ans == null ) { - sem.wait(); - } - } - } catch( InterruptedException ie ) { - throw new UnknownHostException( name ); - } - if( q1x.ans != null ) { - return q1x.ans; - } else if( q20.ans != null ) { - return q20.ans; - } else { - throw q1x.uhe; - } - } - - /** - * Determines the address of a host given it's host name. The name can be a - * machine name like "jcifs.samba.org", or an IP address like "192.168.1.15". - * - * @param hostname NetBIOS or DNS hostname to resolve - * @throws UnknownHostException if there is an error resolving the name - */ - - public static UniAddress getByName( String hostname ) - throws UnknownHostException { - return getByName( hostname, false ); - } - - static boolean isDotQuadIP( String hostname ) { - if( Character.isDigit( hostname.charAt( 0 ))) { - int i, len, dots; - char[] data; - - i = dots = 0; /* quick IP address validation */ - len = hostname.length(); - data = hostname.toCharArray(); - while( i < len && Character.isDigit( data[i++] )) { - if( i == len && dots == 3 ) { - // probably an IP address - return true; - } - if( i < len && data[i] == '.' ) { - dots++; - i++; - } - } - } - - return false; - } - - static boolean isAllDigits( String hostname ) { - for (int i = 0; i < hostname.length(); i++) { - if (Character.isDigit( hostname.charAt( i )) == false) { - return false; - } - } - return true; - } - - /** - * Lookup hostname and return it's UniAddress. If the - * possibleNTDomainOrWorkgroup parameter is true an - * addtional name query will be performed to locate a master browser. - */ - - public static UniAddress getByName( String hostname, - boolean possibleNTDomainOrWorkgroup ) - throws UnknownHostException { - UniAddress[] addrs = UniAddress.getAllByName(hostname, possibleNTDomainOrWorkgroup); - return addrs[0]; - } - public static UniAddress[] getAllByName( String hostname, - boolean possibleNTDomainOrWorkgroup ) - throws UnknownHostException { - Object addr; - int i; - - if( hostname == null || hostname.length() == 0 ) { - throw new UnknownHostException(); - } - - if( isDotQuadIP( hostname )) { - UniAddress[] addrs = new UniAddress[1]; - addrs[0] = new UniAddress( NbtAddress.getByName( hostname )); - return addrs; - } - - for( i = 0; i < resolveOrder.length; i++ ) { - try { - switch( resolveOrder[i] ) { - case RESOLVER_LMHOSTS: - if(( addr = Lmhosts.getByName( hostname )) == null ) { - continue; - } - break; - case RESOLVER_WINS: - if( hostname == NbtAddress.MASTER_BROWSER_NAME || - hostname.length() > 15 ) { - // invalid netbios name - continue; - } - if( possibleNTDomainOrWorkgroup ) { - addr = lookupServerOrWorkgroup( hostname, NbtAddress.getWINSAddress() ); - } else { - addr = NbtAddress.getByName( hostname, 0x20, null, NbtAddress.getWINSAddress() ); - } - break; - case RESOLVER_BCAST: - if( hostname.length() > 15 ) { - // invalid netbios name - continue; - } - if( possibleNTDomainOrWorkgroup ) { - addr = lookupServerOrWorkgroup( hostname, baddr ); - } else { - addr = NbtAddress.getByName( hostname, 0x20, null, baddr ); - } - break; - case RESOLVER_DNS: - if( isAllDigits( hostname )) { - throw new UnknownHostException( hostname ); - } - InetAddress[] iaddrs = InetAddress.getAllByName( hostname ); - UniAddress[] addrs = new UniAddress[iaddrs.length]; - for (int ii = 0; ii < iaddrs.length; ii++) { - addrs[ii] = new UniAddress(iaddrs[ii]); - } - return addrs; // Success - default: - throw new UnknownHostException( hostname ); - } - UniAddress[] addrs = new UniAddress[1]; - addrs[0] = new UniAddress( addr ); - return addrs; // Success - } catch( IOException ioe ) { - // Failure - } - } - throw new UnknownHostException( hostname ); - } - - /** - * Perform DNS SRV lookup on successively shorter suffixes of name - * and return successful suffix or throw an UnknownHostException. -import javax.naming.*; -import javax.naming.directory.*; - public static String getDomainByName(String name) throws UnknownHostException { - DirContext context; - UnknownHostException uhe = null; - - try { - context = new InitialDirContext(); - for ( ;; ) { - try { - Attributes attributes = context.getAttributes( - "dns:/_ldap._tcp.dc._msdcs." + name, - new String[] { "SRV" } - ); - return name; - } catch (NameNotFoundException nnfe) { - uhe = new UnknownHostException(nnfe.getMessage()); - } - int dot = name.indexOf('.'); - if (dot == -1) - break; - name = name.substring(dot + 1); - } - } catch (NamingException ne) { - if (log.level > 1) - ne.printStackTrace(log); - } - - throw uhe != null ? uhe : new UnknownHostException("invalid name"); - } - */ - - - Object addr; - String calledName; - - /** - * Create a UniAddress by wrapping an InetAddress or - * NbtAddress. - */ - - public UniAddress( Object addr ) { - if( addr == null ) { - throw new IllegalArgumentException(); - } - this.addr = addr; - } - - /** - * Return the IP address of this address as a 32 bit integer. - */ - - public int hashCode() { - return addr.hashCode(); - } - - /** - * Compare two addresses for equality. Two UniAddresss are equal - * if they are both UniAddress' and refer to the same IP address. - */ - public boolean equals( Object obj ) { - return obj instanceof UniAddress && addr.equals(((UniAddress)obj).addr); - } -/* - public boolean equals( Object obj ) { - return obj instanceof UniAddress && addr.hashCode() == obj.hashCode(); - } -*/ - - /** - * Guess first called name to try for session establishment. This - * method is used exclusively by the jcifs.smb package. - */ - - public String firstCalledName() { - if( addr instanceof NbtAddress ) { - return ((NbtAddress)addr).firstCalledName(); - } else { - calledName = ((InetAddress)addr).getHostName(); - if( isDotQuadIP( calledName )) { - calledName = NbtAddress.SMBSERVER_NAME; - } else { - int i = calledName.indexOf( '.' ); - if( i > 1 && i < 15 ) { - calledName = calledName.substring( 0, i ).toUpperCase(); - } else if( calledName.length() > 15 ) { - calledName = NbtAddress.SMBSERVER_NAME; - } else { - calledName = calledName.toUpperCase(); - } - } - } - - return calledName; - } - - /** - * Guess next called name to try for session establishment. This - * method is used exclusively by the jcifs.smb package. - */ - - public String nextCalledName() { - if( addr instanceof NbtAddress ) { - return ((NbtAddress)addr).nextCalledName(); - } else if( calledName != NbtAddress.SMBSERVER_NAME ) { - calledName = NbtAddress.SMBSERVER_NAME; - return calledName; - } - return null; - } - - /** - * Return the underlying NbtAddress or InetAddress. - */ - - public Object getAddress() { - return addr; - } - - /** - * Return the hostname of this address such as "MYCOMPUTER". - */ - - public String getHostName() { - if( addr instanceof NbtAddress ) { - return ((NbtAddress)addr).getHostName(); - } - return ((InetAddress)addr).getHostName(); - } - - /** - * Return the IP address as text such as "192.168.1.15". - */ - - public String getHostAddress() { - if( addr instanceof NbtAddress ) { - return ((NbtAddress)addr).getHostAddress(); - } - return ((InetAddress)addr).getHostAddress(); - } - - /** - * Return the a text representation of this address such as - * MYCOMPUTER/192.168.1.15. - */ - public String toString() { - return addr.toString(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBind.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBind.java deleted file mode 100644 index 62cc3fd5c2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBind.java +++ /dev/null @@ -1,90 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen"
- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; - -public class DcerpcBind extends DcerpcMessage { - - static final String[] result_message = { - "0", - "DCERPC_BIND_ERR_ABSTRACT_SYNTAX_NOT_SUPPORTED", - "DCERPC_BIND_ERR_PROPOSED_TRANSFER_SYNTAXES_NOT_SUPPORTED", - "DCERPC_BIND_ERR_LOCAL_LIMIT_EXCEEDED" - }; - - static String getResultMessage(int result) { - return result < 4 ? - result_message[result] : - "0x" + jcifs.util.Hexdump.toHexString(result, 4); - } - public DcerpcException getResult() { - if (result != 0) - return new DcerpcException(getResultMessage(result)); - return null; - } - - DcerpcBinding binding; - int max_xmit, max_recv; - - public DcerpcBind() { - } - DcerpcBind(DcerpcBinding binding, DcerpcHandle handle) { - this.binding = binding; - max_xmit = handle.max_xmit; - max_recv = handle.max_recv; - ptype = 11; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - public int getOpnum() { - return 0; - } - public void encode_in(NdrBuffer buf) throws NdrException { - buf.enc_ndr_short(max_xmit); - buf.enc_ndr_short(max_recv); - buf.enc_ndr_long(0); /* assoc. group */ - buf.enc_ndr_small(1); /* num context items */ - buf.enc_ndr_small(0); /* reserved */ - buf.enc_ndr_short(0); /* reserved2 */ - buf.enc_ndr_short(0); /* context id */ - buf.enc_ndr_small(1); /* number of items */ - buf.enc_ndr_small(0); /* reserved */ - binding.uuid.encode(buf); - buf.enc_ndr_short(binding.major); - buf.enc_ndr_short(binding.minor); - DCERPC_UUID_SYNTAX_NDR.encode(buf); - buf.enc_ndr_long(2); /* syntax version */ - } - public void decode_out(NdrBuffer buf) throws NdrException { - buf.dec_ndr_short(); /* max transmit frag size */ - buf.dec_ndr_short(); /* max receive frag size */ - buf.dec_ndr_long(); /* assoc. group */ - int n = buf.dec_ndr_short(); /* secondary addr len */ - buf.advance(n); /* secondary addr */ - buf.align(4); - buf.dec_ndr_small(); /* num results */ - buf.align(4); - result = buf.dec_ndr_short(); - buf.dec_ndr_short(); - buf.advance(20); /* transfer syntax / version */ - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBinding.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBinding.java deleted file mode 100644 index 593ba51049..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcBinding.java +++ /dev/null @@ -1,103 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.dcerpc.msrpc.lsarpc; -import jcifs.dcerpc.msrpc.netdfs; -import jcifs.dcerpc.msrpc.samr; -import jcifs.dcerpc.msrpc.srvsvc; - -import java.util.HashMap; -import java.util.Iterator; - -public class DcerpcBinding { - - private static HashMap INTERFACES; - - static { - INTERFACES = new HashMap(); - INTERFACES.put("srvsvc", srvsvc.getSyntax()); - INTERFACES.put("lsarpc", lsarpc.getSyntax()); - INTERFACES.put("samr", samr.getSyntax()); - INTERFACES.put("netdfs", netdfs.getSyntax()); - } - - public static void addInterface(String name, String syntax) - { - INTERFACES.put(name, syntax); - } - - String proto; - String server; - String endpoint = null; - HashMap options = null; - UUID uuid = null; - int major; - int minor; - - DcerpcBinding(String proto, String server) { - this.proto = proto; - this.server = server; - } - - void setOption(String key, Object val) throws DcerpcException { - if (key.equals("endpoint")) { - endpoint = val.toString(); - String lep = endpoint.toLowerCase(); - if (lep.startsWith("\\pipe\\")) { - String iface = (String)INTERFACES.get(lep.substring(6)); - if (iface != null) { - int c, p; - c = iface.indexOf(':'); - p = iface.indexOf('.', c + 1); - uuid = new UUID(iface.substring(0, c)); - major = Integer.parseInt(iface.substring(c + 1, p)); - minor = Integer.parseInt(iface.substring(p + 1)); - return; - } - } - throw new DcerpcException("Bad endpoint: " + endpoint); - } - if (options == null) - options = new HashMap(); - options.put(key, val); - } - Object getOption(String key) { - if (key.equals("endpoint")) - return endpoint; - if (options != null) - return options.get(key); - return null; - } - - public String toString() { - String ret = proto + ":" + server + "[" + endpoint; - if (options != null) { - Iterator iter = options.keySet().iterator(); - while (iter.hasNext()) { - Object key = iter.next(); - Object val = options.get(key); - ret += "," + key + "=" + val; - } - } - ret += "]"; - return ret; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcConstants.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcConstants.java deleted file mode 100644 index 540849b8a7..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcConstants.java +++ /dev/null @@ -1,34 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -public interface DcerpcConstants { - - public static final UUID DCERPC_UUID_SYNTAX_NDR = new UUID("8a885d04-1ceb-11c9-9fe8-08002b104860"); - - public static final int DCERPC_FIRST_FRAG = 0x01; /* First fragment */ - public static final int DCERPC_LAST_FRAG = 0x02; /* Last fragment */ - public static final int DCERPC_PENDING_CANCEL = 0x04; /* Cancel was pending at sender */ - public static final int DCERPC_RESERVED_1 = 0x08; - public static final int DCERPC_CONC_MPX = 0x10; /* supports concurrent multiplexing */ - public static final int DCERPC_DID_NOT_EXECUTE = 0x20; - public static final int DCERPC_MAYBE = 0x40; /* `maybe' call semantics requested */ - public static final int DCERPC_OBJECT_UUID = 0x80; /* if true, a non-nil object UUID */ -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcError.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcError.java deleted file mode 100644 index 83011d082e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcError.java +++ /dev/null @@ -1,58 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -public interface DcerpcError { - - public static final int DCERPC_FAULT_OTHER = 0x00000001; - public static final int DCERPC_FAULT_ACCESS_DENIED = 0x00000005; - public static final int DCERPC_FAULT_CANT_PERFORM = 0x000006D8; - public static final int DCERPC_FAULT_NDR = 0x000006F7; - public static final int DCERPC_FAULT_INVALID_TAG = 0x1C000006; - public static final int DCERPC_FAULT_CONTEXT_MISMATCH = 0x1C00001A; - public static final int DCERPC_FAULT_OP_RNG_ERROR = 0x1C010002; - public static final int DCERPC_FAULT_UNK_IF = 0x1C010003; - public static final int DCERPC_FAULT_PROTO_ERROR = 0x1c01000b; - - static final int[] DCERPC_FAULT_CODES = { - DCERPC_FAULT_OTHER, - DCERPC_FAULT_ACCESS_DENIED, - DCERPC_FAULT_CANT_PERFORM, - DCERPC_FAULT_NDR, - DCERPC_FAULT_INVALID_TAG, - DCERPC_FAULT_CONTEXT_MISMATCH, - DCERPC_FAULT_OP_RNG_ERROR, - DCERPC_FAULT_UNK_IF, - DCERPC_FAULT_PROTO_ERROR - }; - - static final String[] DCERPC_FAULT_MESSAGES = { - "DCERPC_FAULT_OTHER", - "DCERPC_FAULT_ACCESS_DENIED", - "DCERPC_FAULT_CANT_PERFORM", - "DCERPC_FAULT_NDR", - "DCERPC_FAULT_INVALID_TAG", - "DCERPC_FAULT_CONTEXT_MISMATCH", - "DCERPC_FAULT_OP_RNG_ERROR", - "DCERPC_FAULT_UNK_IF", - "DCERPC_FAULT_PROTO_ERROR" - }; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcException.java deleted file mode 100644 index d62b2baa30..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcException.java +++ /dev/null @@ -1,79 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.smb.WinError; -import jcifs.util.Hexdump; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -public class DcerpcException extends IOException implements DcerpcError, WinError { - - static String getMessageByDcerpcError(int errcode) { - int min = 0; - int max = DCERPC_FAULT_CODES.length; - - while (max >= min) { - int mid = (min + max) / 2; - - if (errcode > DCERPC_FAULT_CODES[mid]) { - min = mid + 1; - } else if (errcode < DCERPC_FAULT_CODES[mid]) { - max = mid - 1; - } else { - return DCERPC_FAULT_MESSAGES[mid]; - } - } - - return "0x" + Hexdump.toHexString(errcode, 8); - } - - private int error; - private Throwable rootCause; - - DcerpcException(int error) { - super(getMessageByDcerpcError(error)); - this.error = error; - } - public DcerpcException(String msg) { - super(msg); - } - public DcerpcException(String msg, Throwable rootCause) { - super(msg); - this.rootCause = rootCause; - } - public int getErrorCode() { - return error; - } - public Throwable getRootCause() { - return rootCause; - } - public String toString() { - if (rootCause != null) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter(sw); - rootCause.printStackTrace(pw); - return super.toString() + "\n" + sw; - } - return super.toString(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java deleted file mode 100644 index f664bc7c6e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java +++ /dev/null @@ -1,277 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.smb.NtlmPasswordAuthentication; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; -import java.security.Principal; - -public abstract class DcerpcHandle implements DcerpcConstants { - - /* Bindings are in the form: - * proto:\\server[key1=val1,key2=val2] - * or - * proto:server[key1=val1,key2=val2] - * or - * proto:[key1=val1,key2=val2] - * - * If a key is absent it is assumed to be 'endpoint'. Thus the - * following are equivalent: - * proto:\\ts0.win.net[endpoint=\pipe\srvsvc] - * proto:ts0.win.net[\pipe\srvsvc] - * - * If the server is absent it is set to "127.0.0.1" - */ - protected static DcerpcBinding parseBinding(String str) throws DcerpcException { - int state, mark, si; - char[] arr = str.toCharArray(); - String proto = null, key = null; - DcerpcBinding binding = null; - - state = mark = si = 0; - do { - char ch = arr[si]; - - switch (state) { - case 0: - if (ch == ':') { - proto = str.substring(mark, si); - mark = si + 1; - state = 1; - } - break; - case 1: - if (ch == '\\') { - mark = si + 1; - break; - } - state = 2; - case 2: - if (ch == '[') { - String server = str.substring(mark, si).trim(); - if (server.length() == 0) - server = "127.0.0.1"; - binding = new DcerpcBinding(proto, str.substring(mark, si)); - mark = si + 1; - state = 5; - } - break; - case 5: - if (ch == '=') { - key = str.substring(mark, si).trim(); - mark = si + 1; - } else if (ch == ',' || ch == ']') { - String val = str.substring(mark, si).trim(); - if (key == null) - key = "endpoint"; - binding.setOption(key, val); - key = null; - } - break; - default: - si = arr.length; - } - - si++; - } while (si < arr.length); - - if (binding == null || binding.endpoint == null) - throw new DcerpcException("Invalid binding URL: " + str); - - return binding; - } - - protected DcerpcBinding binding; - protected int max_xmit = 4280; - protected int max_recv = max_xmit; - protected int state = 0; - protected DcerpcSecurityProvider securityProvider = null; - private static int call_id = 1; - - public static DcerpcHandle getHandle(String url, - NtlmPasswordAuthentication auth) - throws UnknownHostException, MalformedURLException, DcerpcException { - if (url.startsWith("ncacn_np:")) { - return new DcerpcPipeHandle(url, auth); - } - throw new DcerpcException("DCERPC transport not supported: " + url); - } - - public void bind() throws DcerpcException, IOException { -synchronized (this) { - try { - state = 1; - DcerpcMessage bind = new DcerpcBind(binding, this); - sendrecv(bind); - } catch (IOException ioe) { - state = 0; - throw ioe; - } -} - } - public void sendrecv(DcerpcMessage msg) throws DcerpcException, IOException { - byte[] stub, frag; - NdrBuffer buf, fbuf; - boolean isLast, isDirect; - DcerpcException de; - - if (state == 0) { - bind(); - } - - isDirect = true; - - stub = jcifs.smb.BufferCache.getBuffer(); - try { - int off, tot, n; - - buf = new NdrBuffer(stub, 0); - - msg.flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - msg.call_id = call_id++; - - msg.encode(buf); - - if (securityProvider != null) { - buf.setIndex(0); - securityProvider.wrap(buf); - } - - tot = buf.getLength() - 24; - off = 0; - - while (off < tot) { - n = tot - off; - - if ((24 + n) > max_xmit) { - msg.flags &= ~DCERPC_LAST_FRAG; - n = max_xmit - 24; - } else { - msg.flags |= DCERPC_LAST_FRAG; - isDirect = false; - msg.alloc_hint = n; - } - - msg.length = 24 + n; - - if (off > 0) - msg.flags &= ~DCERPC_FIRST_FRAG; - - if ((msg.flags & (DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG)) != (DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG)) { - buf.start = off; - buf.reset(); - msg.encode_header(buf); - buf.enc_ndr_long(msg.alloc_hint); - buf.enc_ndr_short(0); /* context id */ - buf.enc_ndr_short(msg.getOpnum()); - } - - doSendFragment(stub, off, msg.length, isDirect); - off += n; - } - - doReceiveFragment(stub, isDirect); - buf.reset(); - buf.setIndex(8); - buf.setLength(buf.dec_ndr_short()); - - if (securityProvider != null) - securityProvider.unwrap(buf); - - buf.setIndex(0); - - msg.decode_header(buf); - - off = 24; - if (msg.ptype == 2 && msg.isFlagSet(DCERPC_LAST_FRAG) == false) - off = msg.length; - - frag = null; - fbuf = null; - while (msg.isFlagSet(DCERPC_LAST_FRAG) == false) { - int stub_frag_len; - - if (frag == null) { - frag = new byte[max_recv]; - fbuf = new NdrBuffer(frag, 0); - } - - doReceiveFragment(frag, isDirect); - fbuf.reset(); - fbuf.setIndex(8); - fbuf.setLength(fbuf.dec_ndr_short()); - - if (securityProvider != null) - securityProvider.unwrap(fbuf); - - fbuf.reset(); - msg.decode_header(fbuf); - stub_frag_len = msg.length - 24; - - if ((off + stub_frag_len) > stub.length) { - // shouldn't happen if alloc_hint is correct or greater - byte[] tmp = new byte[off + stub_frag_len]; - System.arraycopy(stub, 0, tmp, 0, off); - stub = tmp; - } - - System.arraycopy(frag, 24, stub, off, stub_frag_len); - off += stub_frag_len; - } - - buf = new NdrBuffer(stub, 0); - msg.decode(buf); - } finally { - jcifs.smb.BufferCache.releaseBuffer(stub); - } - - if ((de = msg.getResult()) != null) - throw de; - } - - public void setDcerpcSecurityProvider(DcerpcSecurityProvider securityProvider) - { - this.securityProvider = securityProvider; - } - public String getServer() { - if (this instanceof DcerpcPipeHandle) - return ((DcerpcPipeHandle)this).pipe.getServer(); - return null; - } - public Principal getPrincipal() { - if (this instanceof DcerpcPipeHandle) - return ((DcerpcPipeHandle)this).pipe.getPrincipal(); - return null; - } - public String toString() { - return binding.toString(); - } - - protected abstract void doSendFragment(byte[] buf, - int off, - int length, - boolean isDirect) throws IOException; - protected abstract void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException; - public abstract void close() throws IOException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java.0 b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java.0 deleted file mode 100644 index e0bf573863..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcHandle.java.0 +++ /dev/null @@ -1,285 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import java.io.*; -import java.net.*; -import java.security.Principal; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.util.Hexdump; -import jcifs.dcerpc.ndr.NdrBuffer; - -public abstract class DcerpcHandle implements DcerpcConstants { - - /* Bindings are in the form: - * proto:\\server[key1=val1,key2=val2] - * or - * proto:server[key1=val1,key2=val2] - * or - * proto:[key1=val1,key2=val2] - * - * If a key is absent it is assumed to be 'endpoint'. Thus the - * following are equivalent: - * proto:\\ts0.win.net[endpoint=\pipe\srvsvc] - * proto:ts0.win.net[\pipe\srvsvc] - * - * If the server is absent it is set to "127.0.0.1" - */ - protected static DcerpcBinding parseBinding(String str) throws DcerpcException { - int state, mark, si; - char[] arr = str.toCharArray(); - String proto = null, key = null; - DcerpcBinding binding = null; - - state = mark = si = 0; - do { - char ch = arr[si]; - - switch (state) { - case 0: - if (ch == ':') { - proto = str.substring(mark, si); - mark = si + 1; - state = 1; - } - break; - case 1: - if (ch == '\\') { - mark = si + 1; - break; - } - state = 2; - case 2: - if (ch == '[') { - String server = str.substring(mark, si).trim(); - if (server.length() == 0) - server = "127.0.0.1"; - binding = new DcerpcBinding(proto, str.substring(mark, si)); - mark = si + 1; - state = 5; - } - break; - case 5: - if (ch == '=') { - key = str.substring(mark, si).trim(); - mark = si + 1; - } else if (ch == ',' || ch == ']') { - String val = str.substring(mark, si).trim(); - if (key == null) - key = "endpoint"; - binding.setOption(key, val); - key = null; - } - break; - default: - si = arr.length; - } - - si++; - } while (si < arr.length); - - if (binding == null || binding.endpoint == null) - throw new DcerpcException("Invalid binding URL: " + str); - - return binding; - } - - protected DcerpcBinding binding; - protected int max_xmit = 4280; - protected int max_recv = max_xmit; - protected int state = 0; - protected DcerpcSecurityProvider securityProvider = null; - private static int call_id = 1; - - public static DcerpcHandle getHandle(String url, - NtlmPasswordAuthentication auth) - throws UnknownHostException, MalformedURLException, DcerpcException { - if (url.startsWith("ncacn_np:")) { - return new DcerpcPipeHandle(url, auth); - } - throw new DcerpcException("DCERPC transport not supported: " + url); - } - - public void bind() throws DcerpcException, IOException { -synchronized (this) { - try { - state = 1; - DcerpcMessage bind = new DcerpcBind(binding, this); - sendrecv(bind); - } catch (IOException ioe) { - state = 0; - throw ioe; - } -} - } - public void sendrecv(DcerpcMessage msg) throws DcerpcException, IOException { - byte[] stub, frag; - NdrBuffer buf, fbuf; - boolean isLast, isDirect; - DcerpcException de; - - if (state == 0) { - bind(); - } - - isDirect = msg instanceof DcerpcBind; - - stub = jcifs.smb.BufferCache.getBuffer(); - try { - int off, tot, n; - - buf = new NdrBuffer(stub, 0); - - msg.flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - msg.call_id = call_id; - - msg.encode(buf); - - if (securityProvider != null) { - buf.setIndex(0); - securityProvider.wrap(buf); - } - - tot = buf.getLength(); - off = 0; - - while (off < tot) { -// msg.call_id = call_id++; - - if ((tot - off) > max_xmit) { - /* Multiple fragments. Need to set flags and length - * and re-encode header - throw new DcerpcException("Fragmented request PDUs currently not supported"); - msg.length = n = max_xmit; - */ - isDirect = true; - msg.length = n = max_xmit; - msg.flags &= ~DCERPC_LAST_FRAG; - buf.start = off; - buf.reset(); - msg.encode_header(buf); - } else { - isDirect = false; - n = tot - off; -System.err.println("n=" + n + " tot=" + tot + " off=" + off + " ptype=" + msg.ptype); - if (off > 0) { - msg.alloc_hint = n; - n += 24; - msg.length = n; - msg.flags &= ~DCERPC_FIRST_FRAG; - msg.flags |= DCERPC_LAST_FRAG; - buf.start = off; - buf.reset(); - msg.encode_header(buf); - buf.enc_ndr_long(msg.alloc_hint); - buf.enc_ndr_short(0); /* context id */ - buf.enc_ndr_short(msg.getOpnum()); - } - } - - doSendFragment(stub, off, n, isDirect); - off += n; - } - - doReceiveFragment(stub, isDirect); - buf.reset(); - buf.setIndex(8); - buf.setLength(buf.dec_ndr_short()); - - if (securityProvider != null) - securityProvider.unwrap(buf); - - buf.setIndex(0); - - msg.decode_header(buf); - - off = 24; - if (msg.ptype == 2 && msg.isFlagSet(DCERPC_LAST_FRAG) == false) - off = msg.length; - - frag = null; - fbuf = null; - while (msg.isFlagSet(DCERPC_LAST_FRAG) == false) { - int stub_frag_len; - - if (frag == null) { - frag = new byte[max_recv]; - fbuf = new NdrBuffer(frag, 0); - } - - doReceiveFragment(frag, isDirect); - fbuf.reset(); - fbuf.setIndex(8); - fbuf.setLength(fbuf.dec_ndr_short()); - - if (securityProvider != null) - securityProvider.unwrap(fbuf); - - fbuf.reset(); - msg.decode_header(fbuf); - stub_frag_len = msg.length - 24; - - if ((off + stub_frag_len) > stub.length) { - // shouldn't happen if alloc_hint is correct or greater - byte[] tmp = new byte[off + stub_frag_len]; - System.arraycopy(stub, 0, tmp, 0, off); - stub = tmp; - } - - System.arraycopy(frag, 24, stub, off, stub_frag_len); - off += stub_frag_len; - } - - buf = new NdrBuffer(stub, 0); - msg.decode(buf); - } finally { - jcifs.smb.BufferCache.releaseBuffer(stub); - } - - if ((de = msg.getResult()) != null) - throw de; - } - - public void setDcerpcSecurityProvider(DcerpcSecurityProvider securityProvider) - { - this.securityProvider = securityProvider; - } - public String getServer() { - if (this instanceof DcerpcPipeHandle) - return ((DcerpcPipeHandle)this).pipe.getServer(); - return null; - } - public Principal getPrincipal() { - if (this instanceof DcerpcPipeHandle) - return ((DcerpcPipeHandle)this).pipe.getPrincipal(); - return null; - } - public String toString() { - return binding.toString(); - } - - protected abstract void doSendFragment(byte[] buf, - int off, - int length, - boolean isDirect) throws IOException; - protected abstract void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException; - public abstract void close() throws IOException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcMessage.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcMessage.java deleted file mode 100644 index a63bc26b4d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcMessage.java +++ /dev/null @@ -1,119 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; - -public abstract class DcerpcMessage extends NdrObject implements DcerpcConstants { - - protected int ptype = -1; - protected int flags = 0; - protected int length = 0; - protected int call_id = 0; - protected int alloc_hint = 0; - protected int result = 0; - - public boolean isFlagSet(int flag) { - return (flags & flag) == flag; - } - public void unsetFlag(int flag) { - flags &= ~flag; - } - public void setFlag(int flag) { - flags |= flag; - } - public DcerpcException getResult() { - if (result != 0) - return new DcerpcException(result); - return null; - } - - void encode_header(NdrBuffer buf) { - buf.enc_ndr_small(5); /* RPC version */ - buf.enc_ndr_small(0); /* minor version */ - buf.enc_ndr_small(ptype); - buf.enc_ndr_small(flags); - buf.enc_ndr_long(0x00000010); /* Little-endian / ASCII / IEEE */ - buf.enc_ndr_short(length); - buf.enc_ndr_short(0); /* length of auth_value */ - buf.enc_ndr_long(call_id); - } - void decode_header(NdrBuffer buf) throws NdrException { - /* RPC major / minor version */ - if (buf.dec_ndr_small() != 5 || buf.dec_ndr_small() != 0) - throw new NdrException("DCERPC version not supported"); - ptype = buf.dec_ndr_small(); - flags = buf.dec_ndr_small(); - if (buf.dec_ndr_long() != 0x00000010) /* Little-endian / ASCII / IEEE */ - throw new NdrException("Data representation not supported"); - length = buf.dec_ndr_short(); - if (buf.dec_ndr_short() != 0) - throw new NdrException("DCERPC authentication not supported"); - call_id = buf.dec_ndr_long(); - } - public void encode(NdrBuffer buf) throws NdrException { - int start = buf.getIndex(); - int alloc_hint_index = 0; - - buf.advance(16); /* momentarily skip header */ - if (ptype == 0) { /* Request */ - alloc_hint_index = buf.getIndex(); - buf.enc_ndr_long(0); /* momentarily skip alloc hint */ - buf.enc_ndr_short(0); /* context id */ - buf.enc_ndr_short(getOpnum()); - } - - encode_in(buf); - length = buf.getIndex() - start; - - if (ptype == 0) { - buf.setIndex(alloc_hint_index); - alloc_hint = length - alloc_hint_index; - buf.enc_ndr_long(alloc_hint); - } - - buf.setIndex(start); - encode_header(buf); - buf.setIndex(start + length); - } - public void decode(NdrBuffer buf) throws NdrException { - decode_header(buf); - - if (ptype != 12 && ptype != 2 && ptype != 3 && ptype != 13) - throw new NdrException("Unexpected ptype: " + ptype); - - if (ptype == 2 || ptype == 3) { /* Response or Fault */ - alloc_hint = buf.dec_ndr_long(); - buf.dec_ndr_short(); /* context id */ - buf.dec_ndr_short(); /* cancel count */ - } - if (ptype == 3 || ptype == 13) { /* Fault */ - result = buf.dec_ndr_long(); - } else { /* Bind_ack or Response */ - decode_out(buf); - } - } - - public abstract int getOpnum(); - public abstract void encode_in(NdrBuffer buf) throws NdrException; - public abstract void decode_out(NdrBuffer buf) throws NdrException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcPipeHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcPipeHandle.java deleted file mode 100644 index 352ef25417..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcPipeHandle.java +++ /dev/null @@ -1,111 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbFileInputStream; -import jcifs.smb.SmbFileOutputStream; -import jcifs.smb.SmbNamedPipe; -import jcifs.util.Encdec; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; - -public class DcerpcPipeHandle extends DcerpcHandle { - - SmbNamedPipe pipe; - SmbFileInputStream in = null; - SmbFileOutputStream out = null; - boolean isStart = true; - - public DcerpcPipeHandle(String url, - NtlmPasswordAuthentication auth) - throws UnknownHostException, MalformedURLException, DcerpcException { - binding = DcerpcHandle.parseBinding(url); - url = "smb://" + binding.server + "/IPC$/" + binding.endpoint.substring(6); - - String params = "", server, address; - server = (String)binding.getOption("server"); - if (server != null) - params += "&server=" + server; - address = (String)binding.getOption("address"); - if (server != null) - params += "&address=" + address; - if (params.length() > 0) - url += "?" + params.substring(1); - - pipe = new SmbNamedPipe(url, - /* This 0x20000 bit is going to get chopped! */ - (0x2019F << 16) | SmbNamedPipe.PIPE_TYPE_RDWR | SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT, - auth); - } - - protected void doSendFragment(byte[] buf, - int off, - int length, - boolean isDirect) throws IOException { - if (out != null && out.isOpen() == false) - throw new IOException("DCERPC pipe is no longer open"); - - if (in == null) - in = (SmbFileInputStream)pipe.getNamedPipeInputStream(); - if (out == null) - out = (SmbFileOutputStream)pipe.getNamedPipeOutputStream(); - if (isDirect) { - out.writeDirect( buf, off, length, 1 ); - return; - } - out.write(buf, off, length); - } - protected void doReceiveFragment(byte[] buf, boolean isDirect) throws IOException { - int off, flags, length; - - if (buf.length < max_recv) - throw new IllegalArgumentException("buffer too small"); - - if (isStart && !isDirect) { // start of new frag, do trans - off = in.read(buf, 0, 1024); - } else { - off = in.readDirect(buf, 0, buf.length); - } - - if (buf[0] != 5 && buf[1] != 0) - throw new IOException("Unexpected DCERPC PDU header"); - - flags = buf[3] & 0xFF; - // next read is start of new frag - isStart = (flags & DCERPC_LAST_FRAG) == DCERPC_LAST_FRAG; - - length = Encdec.dec_uint16le(buf, 8); - if (length > max_recv) - throw new IOException("Unexpected fragment length: " + length); - - while (off < length) { - off += in.readDirect(buf, off, length - off); - } - } - public void close() throws IOException { - state = 0; - if (out != null) - out.close(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcSecurityProvider.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcSecurityProvider.java deleted file mode 100644 index 1776683ea6..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/DcerpcSecurityProvider.java +++ /dev/null @@ -1,27 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2009 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -import jcifs.dcerpc.ndr.NdrBuffer; - -public interface DcerpcSecurityProvider -{ - void wrap(NdrBuffer outgoing) throws DcerpcException; - void unwrap(NdrBuffer incoming) throws DcerpcException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UUID.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UUID.java deleted file mode 100644 index cd9da5430e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UUID.java +++ /dev/null @@ -1,108 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -public class UUID extends rpc.uuid_t { - - public static int hex_to_bin(char[] arr, int offset, int length) { - int value = 0; - int ai, count; - - count = 0; - for (ai = offset; ai < arr.length && count < length; ai++) { - value <<= 4; - switch (arr[ai]) { - case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': - value += arr[ai] - '0'; - break; - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - value += 10 + (arr[ai] - 'A'); - break; - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - value += 10 + (arr[ai] - 'a'); - break; - default: - throw new IllegalArgumentException(new String(arr, offset, length)); - } - count++; - } - - return value; - } - static final char[] HEXCHARS = { - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' - }; - public static String bin_to_hex(int value, int length) { - char[] arr = new char[length]; - int ai = arr.length; - while (ai-- > 0) { - arr[ai] = HEXCHARS[value & 0xF]; - value >>>= 4; - } - return new String(arr); - } - private static byte B(int i) { return (byte)(i & 0xFF); } - private static short S(int i) { return (short)(i & 0xFFFF); } - - public UUID(rpc.uuid_t uuid) { - time_low = uuid.time_low; - time_mid = uuid.time_mid; - time_hi_and_version = uuid.time_hi_and_version; - clock_seq_hi_and_reserved = uuid.clock_seq_hi_and_reserved; - clock_seq_low = uuid.clock_seq_low; - node = new byte[6]; - node[0] = uuid.node[0]; - node[1] = uuid.node[1]; - node[2] = uuid.node[2]; - node[3] = uuid.node[3]; - node[4] = uuid.node[4]; - node[5] = uuid.node[5]; - } - public UUID(String str) { - char[] arr = str.toCharArray(); - time_low = hex_to_bin(arr, 0, 8); - time_mid = S(hex_to_bin(arr, 9, 4)); - time_hi_and_version = S(hex_to_bin(arr, 14, 4)); - clock_seq_hi_and_reserved = B(hex_to_bin(arr, 19, 2)); - clock_seq_low = B(hex_to_bin(arr, 21, 2)); - node = new byte[6]; - node[0] = B(hex_to_bin(arr, 24, 2)); - node[1] = B(hex_to_bin(arr, 26, 2)); - node[2] = B(hex_to_bin(arr, 28, 2)); - node[3] = B(hex_to_bin(arr, 30, 2)); - node[4] = B(hex_to_bin(arr, 32, 2)); - node[5] = B(hex_to_bin(arr, 34, 2)); - } - - public String toString() { - return bin_to_hex(time_low, 8) + '-' + - bin_to_hex(time_mid, 4) + '-' + - bin_to_hex(time_hi_and_version, 4) + '-' + - bin_to_hex(clock_seq_hi_and_reserved, 2) + - bin_to_hex(clock_seq_low, 2) + '-' + - bin_to_hex(node[0], 2) + - bin_to_hex(node[1], 2) + - bin_to_hex(node[2], 2) + - bin_to_hex(node[3], 2) + - bin_to_hex(node[4], 2) + - bin_to_hex(node[5], 2); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UnicodeString.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UnicodeString.java deleted file mode 100644 index 3c67c015b3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/UnicodeString.java +++ /dev/null @@ -1,62 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc; - -public class UnicodeString extends rpc.unicode_string { - - boolean zterm; - - public UnicodeString(boolean zterm) { - this.zterm = zterm; - } - public UnicodeString(rpc.unicode_string rus, boolean zterm) { - this.length = rus.length; - this.maximum_length = rus.maximum_length; - this.buffer = rus.buffer; - this.zterm = zterm; - } - - public UnicodeString(String str, boolean zterm) { - this.zterm = zterm; - - int len = str.length(); - int zt = zterm ? 1 : 0; - - length = maximum_length = (short)((len + zt) * 2); - buffer = new short[len + zt]; - - int i; - for (i = 0; i < len; i++) { - buffer[i] = (short)str.charAt(i); - } - if (zterm) { - buffer[i] = (short)0; - } - } - - public String toString() { - int len = length / 2 - (zterm ? 1 : 0); - char[] ca = new char[len]; - for (int i = 0; i < len; i++) { - ca[i] = (char)buffer[i]; - } - return new String(ca, 0, len); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsaPolicyHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsaPolicyHandle.java deleted file mode 100644 index 2f03e36121..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsaPolicyHandle.java +++ /dev/null @@ -1,42 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.rpc; -import jcifs.smb.SmbException; - -import java.io.IOException; - -public class LsaPolicyHandle extends rpc.policy_handle { - - public LsaPolicyHandle(DcerpcHandle handle, String server, int access) throws IOException { - if (server == null) - server = "\\\\"; - MsrpcLsarOpenPolicy2 rpc = new MsrpcLsarOpenPolicy2(server, access, this); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - } - - public void close() throws IOException { - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsarSidArrayX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsarSidArrayX.java deleted file mode 100644 index f985e04306..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/LsarSidArrayX.java +++ /dev/null @@ -1,15 +0,0 @@ -package jcifs.dcerpc.msrpc; - -import jcifs.smb.SID; - -class LsarSidArrayX extends lsarpc.LsarSidArray { - - LsarSidArrayX(SID[] sids) { - this.num_sids = sids.length; - this.sids = new lsarpc.LsarSidPtr[sids.length]; - for (int si = 0; si < sids.length; si++) { - this.sids[si] = new lsarpc.LsarSidPtr(); - this.sids[si].sid = sids[si]; - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcDfsRootEnum.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcDfsRootEnum.java deleted file mode 100644 index 2d762d1f7d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcDfsRootEnum.java +++ /dev/null @@ -1,43 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2008 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.ndr.NdrLong; -import jcifs.smb.FileEntry; -import jcifs.smb.SmbShareInfo; - -public class MsrpcDfsRootEnum extends netdfs.NetrDfsEnumEx { - - public MsrpcDfsRootEnum(String server) { - super(server, 200, 0xFFFF, new netdfs.DfsEnumStruct(), new NdrLong(0)); - info.level = level; - info.e = new netdfs.DfsEnumArray200(); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - public FileEntry[] getEntries() { - netdfs.DfsEnumArray200 a200 = (netdfs.DfsEnumArray200)info.e; - SmbShareInfo[] entries = new SmbShareInfo[a200.count]; - for (int i = 0; i < a200.count; i++) { - entries[i] = new SmbShareInfo(a200.s[i].dfs_name, 0, null); - } - return entries; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcEnumerateAliasesInDomain.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcEnumerateAliasesInDomain.java deleted file mode 100644 index 8e55632e2b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcEnumerateAliasesInDomain.java +++ /dev/null @@ -1,31 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcEnumerateAliasesInDomain extends samr.SamrEnumerateAliasesInDomain { - - public MsrpcEnumerateAliasesInDomain(SamrDomainHandle domainHandle, - int acct_flags, - samr.SamrSamArray sam) { - super(domainHandle, 0, acct_flags, null, 0); - this.sam = sam; - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcGetMembersInAlias.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcGetMembersInAlias.java deleted file mode 100644 index 71c1223df9..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcGetMembersInAlias.java +++ /dev/null @@ -1,29 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcGetMembersInAlias extends samr.SamrGetMembersInAlias { - - public MsrpcGetMembersInAlias(SamrAliasHandle aliasHandle, lsarpc.LsarSidArray sids) { - super(aliasHandle, sids); - this.sids = sids; - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLookupSids.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLookupSids.java deleted file mode 100644 index e61fe3a2c0..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLookupSids.java +++ /dev/null @@ -1,39 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.smb.SID; - -public class MsrpcLookupSids extends lsarpc.LsarLookupSids { - - SID[] sids; - - public MsrpcLookupSids(LsaPolicyHandle policyHandle, SID[] sids) { - super(policyHandle, - new LsarSidArrayX(sids), - new lsarpc.LsarRefDomainList(), - new lsarpc.LsarTransNameArray(), - (short)1, - sids.length); - this.sids = sids; - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLsarOpenPolicy2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLsarOpenPolicy2.java deleted file mode 100644 index d82d6352af..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcLsarOpenPolicy2.java +++ /dev/null @@ -1,36 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcLsarOpenPolicy2 extends lsarpc.LsarOpenPolicy2 { - - public MsrpcLsarOpenPolicy2(String server, int access, LsaPolicyHandle policyHandle) { - super(server, new lsarpc.LsarObjectAttributes(), access, policyHandle); - object_attributes.length = 24; -lsarpc.LsarQosInfo qos = new lsarpc.LsarQosInfo(); -qos.length = 12; -qos.impersonation_level = 2; -qos.context_mode = 1; -qos.effective_only = 0; -object_attributes.security_quality_of_service = qos; - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcQueryInformationPolicy.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcQueryInformationPolicy.java deleted file mode 100644 index b63dfe5cc8..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcQueryInformationPolicy.java +++ /dev/null @@ -1,32 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.ndr.NdrObject; - -public class MsrpcQueryInformationPolicy extends lsarpc.LsarQueryInformationPolicy { - - public MsrpcQueryInformationPolicy(LsaPolicyHandle policyHandle, - short level, - NdrObject info) { - super(policyHandle, level, info); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java deleted file mode 100644 index 3d2efc6e73..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect2.java +++ /dev/null @@ -1,28 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcSamrConnect2 extends samr.SamrConnect2 { - - public MsrpcSamrConnect2(String server, int access, SamrPolicyHandle policyHandle) { - super(server, access, policyHandle); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect4.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect4.java deleted file mode 100644 index df4dbefa31..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrConnect4.java +++ /dev/null @@ -1,28 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcSamrConnect4 extends samr.SamrConnect4 { - - public MsrpcSamrConnect4(String server, int access, SamrPolicyHandle policyHandle) { - super(server, 2, access, policyHandle); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenAlias.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenAlias.java deleted file mode 100644 index 3da4cbd5da..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenAlias.java +++ /dev/null @@ -1,31 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -public class MsrpcSamrOpenAlias extends samr.SamrOpenAlias { - - public MsrpcSamrOpenAlias(SamrDomainHandle handle, - int access, - int rid, - SamrAliasHandle aliasHandle) { - super(handle, access, rid, aliasHandle); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenDomain.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenDomain.java deleted file mode 100644 index 0057f33acc..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcSamrOpenDomain.java +++ /dev/null @@ -1,33 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.rpc; - -public class MsrpcSamrOpenDomain extends samr.SamrOpenDomain { - - public MsrpcSamrOpenDomain(SamrPolicyHandle handle, - int access, - rpc.sid_t sid, - SamrDomainHandle domainHandle) { - super(handle, access, sid, domainHandle); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareEnum.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareEnum.java deleted file mode 100644 index e66c042012..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareEnum.java +++ /dev/null @@ -1,54 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.smb.FileEntry; -import jcifs.smb.SmbShareInfo; - -public class MsrpcShareEnum extends srvsvc.ShareEnumAll { - - class MsrpcShareInfo1 extends SmbShareInfo { - - MsrpcShareInfo1(srvsvc.ShareInfo1 info1) { - this.netName = info1.netname; - this.type = info1.type; - this.remark = info1.remark; - } - } - - public MsrpcShareEnum(String server) { - super("\\\\" + server, 1, new srvsvc.ShareInfoCtr1(), -1, 0, 0); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - public FileEntry[] getEntries() { - /* The ShareInfo1 class does not implement the FileEntry - * interface (because it is generated from IDL). Therefore - * we must create an array of objects that do. - */ - srvsvc.ShareInfoCtr1 ctr = (srvsvc.ShareInfoCtr1)info; - MsrpcShareInfo1[] entries = new MsrpcShareInfo1[ctr.count]; - for (int i = 0; i < ctr.count; i++) { - entries[i] = new MsrpcShareInfo1(ctr.array[i]); - } - return entries; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareGetInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareGetInfo.java deleted file mode 100644 index 7549890c22..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/MsrpcShareGetInfo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.smb.ACE; -import jcifs.smb.SecurityDescriptor; - -import java.io.IOException; - -public class MsrpcShareGetInfo extends srvsvc.ShareGetInfo { - - public MsrpcShareGetInfo(String server, String sharename) { - super(server, sharename, 502, new srvsvc.ShareInfo502()); - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - public ACE[] getSecurity() throws IOException { - srvsvc.ShareInfo502 info502 = (srvsvc.ShareInfo502)info; - if (info502.security_descriptor != null) { - SecurityDescriptor sd; - sd = new SecurityDescriptor(info502.security_descriptor, 0, info502.sd_size); - return sd.aces; - } - return null; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrAliasHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrAliasHandle.java deleted file mode 100644 index a22f52a1ae..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrAliasHandle.java +++ /dev/null @@ -1,42 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.rpc; -import jcifs.smb.SmbException; - -import java.io.IOException; - -public class SamrAliasHandle extends rpc.policy_handle { - - public SamrAliasHandle(DcerpcHandle handle, - SamrDomainHandle domainHandle, - int access, - int rid) throws IOException { - MsrpcSamrOpenAlias rpc = new MsrpcSamrOpenAlias(domainHandle, access, rid, this); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - } - - public void close() throws IOException { - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrDomainHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrDomainHandle.java deleted file mode 100644 index b013efb9e8..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrDomainHandle.java +++ /dev/null @@ -1,42 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.rpc; -import jcifs.smb.SmbException; - -import java.io.IOException; - -public class SamrDomainHandle extends rpc.policy_handle { - - public SamrDomainHandle(DcerpcHandle handle, - SamrPolicyHandle policyHandle, - int access, - rpc.sid_t sid) throws IOException { - MsrpcSamrOpenDomain rpc = new MsrpcSamrOpenDomain(policyHandle, access, sid, this); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - } - - public void close() throws IOException { - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrPolicyHandle.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrPolicyHandle.java deleted file mode 100644 index 23e1eb221e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/SamrPolicyHandle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2007 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcError; -import jcifs.dcerpc.DcerpcException; -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.rpc; - -import java.io.IOException; - -public class SamrPolicyHandle extends rpc.policy_handle { - - public SamrPolicyHandle(DcerpcHandle handle, String server, int access) throws IOException { - if (server == null) - server = "\\\\"; - MsrpcSamrConnect4 rpc = new MsrpcSamrConnect4(server, access, this); - try { - handle.sendrecv(rpc); - } catch (DcerpcException de) { - if (de.getErrorCode() != DcerpcError.DCERPC_FAULT_OP_RNG_ERROR) - throw de; - - MsrpcSamrConnect2 rpc2 = new MsrpcSamrConnect2(server, access, this); - handle.sendrecv(rpc2); - } - } - - public void close() throws IOException { - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.idl b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.idl deleted file mode 100644 index 1cfa7641da..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.idl +++ /dev/null @@ -1,132 +0,0 @@ -[ - uuid(12345778-1234-abcd-ef00-0123456789ab), - version(0.0) -] -interface lsarpc -{ - import "../rpc.idl"; - - typedef struct { - uint32_t length; - uint16_t impersonation_level; - uint8_t context_mode; - uint8_t effective_only; - } LsarQosInfo; - - typedef struct { - uint32_t length; - uint8_t *root_directory; - unicode_string *object_name; - uint32_t attributes; - uint32_t security_descriptor; - LsarQosInfo *security_quality_of_service; - } LsarObjectAttributes; - - typedef struct { - unicode_string name; - sid_t *sid; - } LsarDomainInfo; - - typedef struct { - unicode_string name; - unicode_string dns_domain; - unicode_string dns_forest; - uuid_t domain_guid; - sid_t *sid; - } LsarDnsDomainInfo; - - enum { - POLICY_INFO_AUDIT_EVENTS = 2, - POLICY_INFO_PRIMARY_DOMAIN = 3, - POLICY_INFO_ACCOUNT_DOMAIN = 5, - POLICY_INFO_SERVER_ROLE = 6, - POLICY_INFO_MODIFICATION = 9, - POLICY_INFO_DNS_DOMAIN = 12 - }; - - typedef [switch_type(short)] union { - [case(POLICY_INFO_ACCOUNT_DOMAIN)] LsarDomainInfo account_domain; - [case(POLICY_INFO_DNS_DOMAIN)] LsarDnsDomainInfo dns_domain; - } LsarPolicyInfo; - - typedef struct { - sid_t *sid; - } LsarSidPtr; - - typedef struct { - [range(0,1000)] uint32_t num_sids; - [size_is(num_sids)] LsarSidPtr *sids; - } LsarSidArray; - - typedef enum { - SID_NAME_USE_NONE = 0, /* NOTUSED */ - SID_NAME_USER = 1, /* user */ - SID_NAME_DOM_GRP = 2, /* domain group */ - SID_NAME_DOMAIN = 3, /* domain: don't know what this is */ - SID_NAME_ALIAS = 4, /* local group */ - SID_NAME_WKN_GRP = 5, /* well-known group */ - SID_NAME_DELETED = 6, /* deleted account: needed for c2 rating */ - SID_NAME_INVALID = 7, /* invalid account */ - SID_NAME_UNKNOWN = 8 /* oops. */ - } LsarSidType; - - typedef struct { - LsarSidType sid_type; - uint32_t rid; - uint32_t sid_index; - } LsarTranslatedSid; - - typedef struct { - [range(0,1000)] uint32_t count; - [size_is(count)] LsarTranslatedSid *sids; - } LsarTransSidArray; - - typedef struct { - unicode_string name; - sid_t *sid; - } LsarTrustInformation; - - typedef struct { - [range(0,1000)] uint32_t count; - [size_is(count)] LsarTrustInformation *domains; - uint32_t max_count; - } LsarRefDomainList; - - typedef struct { - uint16_t sid_type; - unicode_string name; - uint32_t sid_index; - } LsarTranslatedName; - - typedef struct { - [range(0,1000)] uint32_t count; - [size_is(count)] LsarTranslatedName *names; - } LsarTransNameArray; - - [op(0x00)] - int LsarClose([in,out] policy_handle *handle); - - [op(0x07)] - int LsarQueryInformationPolicy([in] policy_handle *handle, - [in] uint16_t level, - [out,switch_is(level),unique] LsarPolicyInfo *info); - - [op(0x0f)] - int LsarLookupSids([in] policy_handle *handle, - [in] LsarSidArray *sids, - [out,unique] LsarRefDomainList *domains, - [in,out] LsarTransNameArray *names, - [in] uint16_t level, - [in,out] uint32_t *count); - - [op(0x2c)] - int LsarOpenPolicy2([in,string,unique] wchar_t *system_name, - [in] LsarObjectAttributes *object_attributes, - [in] uint32_t desired_access, - [out] policy_handle *policy_handle); - - [op(0x2e)] - int LsarQueryInformationPolicy2([in] policy_handle *handle, - [in] uint16_t level, - [out,switch_is(level),unique] LsarPolicyInfo *info); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.java deleted file mode 100644 index 75742b455f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/lsarpc.java +++ /dev/null @@ -1,918 +0,0 @@ -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; -import jcifs.dcerpc.ndr.NdrSmall; -import jcifs.dcerpc.rpc; - -public class lsarpc { - - public static String getSyntax() { - return "12345778-1234-abcd-ef00-0123456789ab:0.0"; - } - - public static class LsarQosInfo extends NdrObject { - - public int length; - public short impersonation_level; - public byte context_mode; - public byte effective_only; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(length); - _dst.enc_ndr_short(impersonation_level); - _dst.enc_ndr_small(context_mode); - _dst.enc_ndr_small(effective_only); - - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - length = (int)_src.dec_ndr_long(); - impersonation_level = (short)_src.dec_ndr_short(); - context_mode = (byte)_src.dec_ndr_small(); - effective_only = (byte)_src.dec_ndr_small(); - - } - } - public static class LsarObjectAttributes extends NdrObject { - - public int length; - public NdrSmall root_directory; - public rpc.unicode_string object_name; - public int attributes; - public int security_descriptor; - public LsarQosInfo security_quality_of_service; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(length); - _dst.enc_ndr_referent(root_directory, 1); - _dst.enc_ndr_referent(object_name, 1); - _dst.enc_ndr_long(attributes); - _dst.enc_ndr_long(security_descriptor); - _dst.enc_ndr_referent(security_quality_of_service, 1); - - if (root_directory != null) { - _dst = _dst.deferred; - root_directory.encode(_dst); - - } - if (object_name != null) { - _dst = _dst.deferred; - object_name.encode(_dst); - - } - if (security_quality_of_service != null) { - _dst = _dst.deferred; - security_quality_of_service.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - length = (int)_src.dec_ndr_long(); - int _root_directoryp = _src.dec_ndr_long(); - int _object_namep = _src.dec_ndr_long(); - attributes = (int)_src.dec_ndr_long(); - security_descriptor = (int)_src.dec_ndr_long(); - int _security_quality_of_servicep = _src.dec_ndr_long(); - - if (_root_directoryp != 0) { - _src = _src.deferred; - root_directory.decode(_src); - - } - if (_object_namep != 0) { - if (object_name == null) { /* YOYOYO */ - object_name = new rpc.unicode_string(); - } - _src = _src.deferred; - object_name.decode(_src); - - } - if (_security_quality_of_servicep != 0) { - if (security_quality_of_service == null) { /* YOYOYO */ - security_quality_of_service = new LsarQosInfo(); - } - _src = _src.deferred; - security_quality_of_service.decode(_src); - - } - } - } - public static class LsarDomainInfo extends NdrObject { - - public rpc.unicode_string name; - public rpc.sid_t sid; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(name.length); - _dst.enc_ndr_short(name.maximum_length); - _dst.enc_ndr_referent(name.buffer, 1); - _dst.enc_ndr_referent(sid, 1); - - if (name.buffer != null) { - _dst = _dst.deferred; - int _name_bufferl = name.length / 2; - int _name_buffers = name.maximum_length / 2; - _dst.enc_ndr_long(_name_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_name_bufferl); - int _name_bufferi = _dst.index; - _dst.advance(2 * _name_bufferl); - - _dst = _dst.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - _dst.enc_ndr_short(name.buffer[_i]); - } - } - if (sid != null) { - _dst = _dst.deferred; - sid.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - _src.align(4); - if (name == null) { - name = new rpc.unicode_string(); - } - name.length = (short)_src.dec_ndr_short(); - name.maximum_length = (short)_src.dec_ndr_short(); - int _name_bufferp = _src.dec_ndr_long(); - int _sidp = _src.dec_ndr_long(); - - if (_name_bufferp != 0) { - _src = _src.deferred; - int _name_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _name_bufferl = _src.dec_ndr_long(); - int _name_bufferi = _src.index; - _src.advance(2 * _name_bufferl); - - if (name.buffer == null) { - if (_name_buffers < 0 || _name_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - name.buffer = new short[_name_buffers]; - } - _src = _src.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - name.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - if (_sidp != 0) { - if (sid == null) { /* YOYOYO */ - sid = new rpc.sid_t(); - } - _src = _src.deferred; - sid.decode(_src); - - } - } - } - public static class LsarDnsDomainInfo extends NdrObject { - - public rpc.unicode_string name; - public rpc.unicode_string dns_domain; - public rpc.unicode_string dns_forest; - public rpc.uuid_t domain_guid; - public rpc.sid_t sid; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(name.length); - _dst.enc_ndr_short(name.maximum_length); - _dst.enc_ndr_referent(name.buffer, 1); - _dst.enc_ndr_short(dns_domain.length); - _dst.enc_ndr_short(dns_domain.maximum_length); - _dst.enc_ndr_referent(dns_domain.buffer, 1); - _dst.enc_ndr_short(dns_forest.length); - _dst.enc_ndr_short(dns_forest.maximum_length); - _dst.enc_ndr_referent(dns_forest.buffer, 1); - _dst.enc_ndr_long(domain_guid.time_low); - _dst.enc_ndr_short(domain_guid.time_mid); - _dst.enc_ndr_short(domain_guid.time_hi_and_version); - _dst.enc_ndr_small(domain_guid.clock_seq_hi_and_reserved); - _dst.enc_ndr_small(domain_guid.clock_seq_low); - int _domain_guid_nodes = 6; - int _domain_guid_nodei = _dst.index; - _dst.advance(1 * _domain_guid_nodes); - _dst.enc_ndr_referent(sid, 1); - - if (name.buffer != null) { - _dst = _dst.deferred; - int _name_bufferl = name.length / 2; - int _name_buffers = name.maximum_length / 2; - _dst.enc_ndr_long(_name_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_name_bufferl); - int _name_bufferi = _dst.index; - _dst.advance(2 * _name_bufferl); - - _dst = _dst.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - _dst.enc_ndr_short(name.buffer[_i]); - } - } - if (dns_domain.buffer != null) { - _dst = _dst.deferred; - int _dns_domain_bufferl = dns_domain.length / 2; - int _dns_domain_buffers = dns_domain.maximum_length / 2; - _dst.enc_ndr_long(_dns_domain_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_dns_domain_bufferl); - int _dns_domain_bufferi = _dst.index; - _dst.advance(2 * _dns_domain_bufferl); - - _dst = _dst.derive(_dns_domain_bufferi); - for (int _i = 0; _i < _dns_domain_bufferl; _i++) { - _dst.enc_ndr_short(dns_domain.buffer[_i]); - } - } - if (dns_forest.buffer != null) { - _dst = _dst.deferred; - int _dns_forest_bufferl = dns_forest.length / 2; - int _dns_forest_buffers = dns_forest.maximum_length / 2; - _dst.enc_ndr_long(_dns_forest_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_dns_forest_bufferl); - int _dns_forest_bufferi = _dst.index; - _dst.advance(2 * _dns_forest_bufferl); - - _dst = _dst.derive(_dns_forest_bufferi); - for (int _i = 0; _i < _dns_forest_bufferl; _i++) { - _dst.enc_ndr_short(dns_forest.buffer[_i]); - } - } - _dst = _dst.derive(_domain_guid_nodei); - for (int _i = 0; _i < _domain_guid_nodes; _i++) { - _dst.enc_ndr_small(domain_guid.node[_i]); - } - if (sid != null) { - _dst = _dst.deferred; - sid.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - _src.align(4); - if (name == null) { - name = new rpc.unicode_string(); - } - name.length = (short)_src.dec_ndr_short(); - name.maximum_length = (short)_src.dec_ndr_short(); - int _name_bufferp = _src.dec_ndr_long(); - _src.align(4); - if (dns_domain == null) { - dns_domain = new rpc.unicode_string(); - } - dns_domain.length = (short)_src.dec_ndr_short(); - dns_domain.maximum_length = (short)_src.dec_ndr_short(); - int _dns_domain_bufferp = _src.dec_ndr_long(); - _src.align(4); - if (dns_forest == null) { - dns_forest = new rpc.unicode_string(); - } - dns_forest.length = (short)_src.dec_ndr_short(); - dns_forest.maximum_length = (short)_src.dec_ndr_short(); - int _dns_forest_bufferp = _src.dec_ndr_long(); - _src.align(4); - if (domain_guid == null) { - domain_guid = new rpc.uuid_t(); - } - domain_guid.time_low = (int)_src.dec_ndr_long(); - domain_guid.time_mid = (short)_src.dec_ndr_short(); - domain_guid.time_hi_and_version = (short)_src.dec_ndr_short(); - domain_guid.clock_seq_hi_and_reserved = (byte)_src.dec_ndr_small(); - domain_guid.clock_seq_low = (byte)_src.dec_ndr_small(); - int _domain_guid_nodes = 6; - int _domain_guid_nodei = _src.index; - _src.advance(1 * _domain_guid_nodes); - int _sidp = _src.dec_ndr_long(); - - if (_name_bufferp != 0) { - _src = _src.deferred; - int _name_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _name_bufferl = _src.dec_ndr_long(); - int _name_bufferi = _src.index; - _src.advance(2 * _name_bufferl); - - if (name.buffer == null) { - if (_name_buffers < 0 || _name_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - name.buffer = new short[_name_buffers]; - } - _src = _src.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - name.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - if (_dns_domain_bufferp != 0) { - _src = _src.deferred; - int _dns_domain_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _dns_domain_bufferl = _src.dec_ndr_long(); - int _dns_domain_bufferi = _src.index; - _src.advance(2 * _dns_domain_bufferl); - - if (dns_domain.buffer == null) { - if (_dns_domain_buffers < 0 || _dns_domain_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - dns_domain.buffer = new short[_dns_domain_buffers]; - } - _src = _src.derive(_dns_domain_bufferi); - for (int _i = 0; _i < _dns_domain_bufferl; _i++) { - dns_domain.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - if (_dns_forest_bufferp != 0) { - _src = _src.deferred; - int _dns_forest_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _dns_forest_bufferl = _src.dec_ndr_long(); - int _dns_forest_bufferi = _src.index; - _src.advance(2 * _dns_forest_bufferl); - - if (dns_forest.buffer == null) { - if (_dns_forest_buffers < 0 || _dns_forest_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - dns_forest.buffer = new short[_dns_forest_buffers]; - } - _src = _src.derive(_dns_forest_bufferi); - for (int _i = 0; _i < _dns_forest_bufferl; _i++) { - dns_forest.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - if (domain_guid.node == null) { - if (_domain_guid_nodes < 0 || _domain_guid_nodes > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - domain_guid.node = new byte[_domain_guid_nodes]; - } - _src = _src.derive(_domain_guid_nodei); - for (int _i = 0; _i < _domain_guid_nodes; _i++) { - domain_guid.node[_i] = (byte)_src.dec_ndr_small(); - } - if (_sidp != 0) { - if (sid == null) { /* YOYOYO */ - sid = new rpc.sid_t(); - } - _src = _src.deferred; - sid.decode(_src); - - } - } - } - public static final int POLICY_INFO_AUDIT_EVENTS = 2; - public static final int POLICY_INFO_PRIMARY_DOMAIN = 3; - public static final int POLICY_INFO_ACCOUNT_DOMAIN = 5; - public static final int POLICY_INFO_SERVER_ROLE = 6; - public static final int POLICY_INFO_MODIFICATION = 9; - public static final int POLICY_INFO_DNS_DOMAIN = 12; - - public static class LsarSidPtr extends NdrObject { - - public rpc.sid_t sid; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(sid, 1); - - if (sid != null) { - _dst = _dst.deferred; - sid.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _sidp = _src.dec_ndr_long(); - - if (_sidp != 0) { - if (sid == null) { /* YOYOYO */ - sid = new rpc.sid_t(); - } - _src = _src.deferred; - sid.decode(_src); - - } - } - } - public static class LsarSidArray extends NdrObject { - - public int num_sids; - public LsarSidPtr[] sids; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(num_sids); - _dst.enc_ndr_referent(sids, 1); - - if (sids != null) { - _dst = _dst.deferred; - int _sidss = num_sids; - _dst.enc_ndr_long(_sidss); - int _sidsi = _dst.index; - _dst.advance(4 * _sidss); - - _dst = _dst.derive(_sidsi); - for (int _i = 0; _i < _sidss; _i++) { - sids[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - num_sids = (int)_src.dec_ndr_long(); - int _sidsp = _src.dec_ndr_long(); - - if (_sidsp != 0) { - _src = _src.deferred; - int _sidss = _src.dec_ndr_long(); - int _sidsi = _src.index; - _src.advance(4 * _sidss); - - if (sids == null) { - if (_sidss < 0 || _sidss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - sids = new LsarSidPtr[_sidss]; - } - _src = _src.derive(_sidsi); - for (int _i = 0; _i < _sidss; _i++) { - if (sids[_i] == null) { - sids[_i] = new LsarSidPtr(); - } - sids[_i].decode(_src); - } - } - } - } - public static final int SID_NAME_USE_NONE = 0; - public static final int SID_NAME_USER = 1; - public static final int SID_NAME_DOM_GRP = 2; - public static final int SID_NAME_DOMAIN = 3; - public static final int SID_NAME_ALIAS = 4; - public static final int SID_NAME_WKN_GRP = 5; - public static final int SID_NAME_DELETED = 6; - public static final int SID_NAME_INVALID = 7; - public static final int SID_NAME_UNKNOWN = 8; - - public static class LsarTranslatedSid extends NdrObject { - - public int sid_type; - public int rid; - public int sid_index; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(sid_type); - _dst.enc_ndr_long(rid); - _dst.enc_ndr_long(sid_index); - - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - sid_type = (int)_src.dec_ndr_short(); - rid = (int)_src.dec_ndr_long(); - sid_index = (int)_src.dec_ndr_long(); - - } - } - public static class LsarTransSidArray extends NdrObject { - - public int count; - public LsarTranslatedSid[] sids; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(sids, 1); - - if (sids != null) { - _dst = _dst.deferred; - int _sidss = count; - _dst.enc_ndr_long(_sidss); - int _sidsi = _dst.index; - _dst.advance(12 * _sidss); - - _dst = _dst.derive(_sidsi); - for (int _i = 0; _i < _sidss; _i++) { - sids[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _sidsp = _src.dec_ndr_long(); - - if (_sidsp != 0) { - _src = _src.deferred; - int _sidss = _src.dec_ndr_long(); - int _sidsi = _src.index; - _src.advance(12 * _sidss); - - if (sids == null) { - if (_sidss < 0 || _sidss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - sids = new LsarTranslatedSid[_sidss]; - } - _src = _src.derive(_sidsi); - for (int _i = 0; _i < _sidss; _i++) { - if (sids[_i] == null) { - sids[_i] = new LsarTranslatedSid(); - } - sids[_i].decode(_src); - } - } - } - } - public static class LsarTrustInformation extends NdrObject { - - public rpc.unicode_string name; - public rpc.sid_t sid; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(name.length); - _dst.enc_ndr_short(name.maximum_length); - _dst.enc_ndr_referent(name.buffer, 1); - _dst.enc_ndr_referent(sid, 1); - - if (name.buffer != null) { - _dst = _dst.deferred; - int _name_bufferl = name.length / 2; - int _name_buffers = name.maximum_length / 2; - _dst.enc_ndr_long(_name_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_name_bufferl); - int _name_bufferi = _dst.index; - _dst.advance(2 * _name_bufferl); - - _dst = _dst.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - _dst.enc_ndr_short(name.buffer[_i]); - } - } - if (sid != null) { - _dst = _dst.deferred; - sid.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - _src.align(4); - if (name == null) { - name = new rpc.unicode_string(); - } - name.length = (short)_src.dec_ndr_short(); - name.maximum_length = (short)_src.dec_ndr_short(); - int _name_bufferp = _src.dec_ndr_long(); - int _sidp = _src.dec_ndr_long(); - - if (_name_bufferp != 0) { - _src = _src.deferred; - int _name_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _name_bufferl = _src.dec_ndr_long(); - int _name_bufferi = _src.index; - _src.advance(2 * _name_bufferl); - - if (name.buffer == null) { - if (_name_buffers < 0 || _name_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - name.buffer = new short[_name_buffers]; - } - _src = _src.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - name.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - if (_sidp != 0) { - if (sid == null) { /* YOYOYO */ - sid = new rpc.sid_t(); - } - _src = _src.deferred; - sid.decode(_src); - - } - } - } - public static class LsarRefDomainList extends NdrObject { - - public int count; - public LsarTrustInformation[] domains; - public int max_count; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(domains, 1); - _dst.enc_ndr_long(max_count); - - if (domains != null) { - _dst = _dst.deferred; - int _domainss = count; - _dst.enc_ndr_long(_domainss); - int _domainsi = _dst.index; - _dst.advance(12 * _domainss); - - _dst = _dst.derive(_domainsi); - for (int _i = 0; _i < _domainss; _i++) { - domains[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _domainsp = _src.dec_ndr_long(); - max_count = (int)_src.dec_ndr_long(); - - if (_domainsp != 0) { - _src = _src.deferred; - int _domainss = _src.dec_ndr_long(); - int _domainsi = _src.index; - _src.advance(12 * _domainss); - - if (domains == null) { - if (_domainss < 0 || _domainss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - domains = new LsarTrustInformation[_domainss]; - } - _src = _src.derive(_domainsi); - for (int _i = 0; _i < _domainss; _i++) { - if (domains[_i] == null) { - domains[_i] = new LsarTrustInformation(); - } - domains[_i].decode(_src); - } - } - } - } - public static class LsarTranslatedName extends NdrObject { - - public short sid_type; - public rpc.unicode_string name; - public int sid_index; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(sid_type); - _dst.enc_ndr_short(name.length); - _dst.enc_ndr_short(name.maximum_length); - _dst.enc_ndr_referent(name.buffer, 1); - _dst.enc_ndr_long(sid_index); - - if (name.buffer != null) { - _dst = _dst.deferred; - int _name_bufferl = name.length / 2; - int _name_buffers = name.maximum_length / 2; - _dst.enc_ndr_long(_name_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_name_bufferl); - int _name_bufferi = _dst.index; - _dst.advance(2 * _name_bufferl); - - _dst = _dst.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - _dst.enc_ndr_short(name.buffer[_i]); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - sid_type = (short)_src.dec_ndr_short(); - _src.align(4); - if (name == null) { - name = new rpc.unicode_string(); - } - name.length = (short)_src.dec_ndr_short(); - name.maximum_length = (short)_src.dec_ndr_short(); - int _name_bufferp = _src.dec_ndr_long(); - sid_index = (int)_src.dec_ndr_long(); - - if (_name_bufferp != 0) { - _src = _src.deferred; - int _name_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _name_bufferl = _src.dec_ndr_long(); - int _name_bufferi = _src.index; - _src.advance(2 * _name_bufferl); - - if (name.buffer == null) { - if (_name_buffers < 0 || _name_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - name.buffer = new short[_name_buffers]; - } - _src = _src.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - name.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - } - } - public static class LsarTransNameArray extends NdrObject { - - public int count; - public LsarTranslatedName[] names; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(names, 1); - - if (names != null) { - _dst = _dst.deferred; - int _namess = count; - _dst.enc_ndr_long(_namess); - int _namesi = _dst.index; - _dst.advance(16 * _namess); - - _dst = _dst.derive(_namesi); - for (int _i = 0; _i < _namess; _i++) { - names[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _namesp = _src.dec_ndr_long(); - - if (_namesp != 0) { - _src = _src.deferred; - int _namess = _src.dec_ndr_long(); - int _namesi = _src.index; - _src.advance(16 * _namess); - - if (names == null) { - if (_namess < 0 || _namess > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - names = new LsarTranslatedName[_namess]; - } - _src = _src.derive(_namesi); - for (int _i = 0; _i < _namess; _i++) { - if (names[_i] == null) { - names[_i] = new LsarTranslatedName(); - } - names[_i].decode(_src); - } - } - } - } - public static class LsarClose extends DcerpcMessage { - - public int getOpnum() { return 0x00; } - - public int retval; - public rpc.policy_handle handle; - - public LsarClose(rpc.policy_handle handle) { - this.handle = handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - } - public void decode_out(NdrBuffer _src) throws NdrException { - handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class LsarQueryInformationPolicy extends DcerpcMessage { - - public int getOpnum() { return 0x07; } - - public int retval; - public rpc.policy_handle handle; - public short level; - public NdrObject info; - - public LsarQueryInformationPolicy(rpc.policy_handle handle, short level, NdrObject info) { - this.handle = handle; - this.level = level; - this.info = info; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - _dst.enc_ndr_short(level); - } - public void decode_out(NdrBuffer _src) throws NdrException { - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - _src.dec_ndr_short(); /* union discriminant */ - info.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } - public static class LsarLookupSids extends DcerpcMessage { - - public int getOpnum() { return 0x0f; } - - public int retval; - public rpc.policy_handle handle; - public LsarSidArray sids; - public LsarRefDomainList domains; - public LsarTransNameArray names; - public short level; - public int count; - - public LsarLookupSids(rpc.policy_handle handle, - LsarSidArray sids, - LsarRefDomainList domains, - LsarTransNameArray names, - short level, - int count) { - this.handle = handle; - this.sids = sids; - this.domains = domains; - this.names = names; - this.level = level; - this.count = count; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - sids.encode(_dst); - names.encode(_dst); - _dst.enc_ndr_short(level); - _dst.enc_ndr_long(count); - } - public void decode_out(NdrBuffer _src) throws NdrException { - int _domainsp = _src.dec_ndr_long(); - if (_domainsp != 0) { - if (domains == null) { /* YOYOYO */ - domains = new LsarRefDomainList(); - } - domains.decode(_src); - - } - names.decode(_src); - count = (int)_src.dec_ndr_long(); - retval = (int)_src.dec_ndr_long(); - } - } - public static class LsarOpenPolicy2 extends DcerpcMessage { - - public int getOpnum() { return 0x2c; } - - public int retval; - public String system_name; - public LsarObjectAttributes object_attributes; - public int desired_access; - public rpc.policy_handle policy_handle; - - public LsarOpenPolicy2(String system_name, - LsarObjectAttributes object_attributes, - int desired_access, - rpc.policy_handle policy_handle) { - this.system_name = system_name; - this.object_attributes = object_attributes; - this.desired_access = desired_access; - this.policy_handle = policy_handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(system_name, 1); - if (system_name != null) { - _dst.enc_ndr_string(system_name); - - } - object_attributes.encode(_dst); - _dst.enc_ndr_long(desired_access); - } - public void decode_out(NdrBuffer _src) throws NdrException { - policy_handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class LsarQueryInformationPolicy2 extends DcerpcMessage { - - public int getOpnum() { return 0x2e; } - - public int retval; - public rpc.policy_handle handle; - public short level; - public NdrObject info; - - public LsarQueryInformationPolicy2(rpc.policy_handle handle, short level, NdrObject info) { - this.handle = handle; - this.level = level; - this.info = info; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - _dst.enc_ndr_short(level); - } - public void decode_out(NdrBuffer _src) throws NdrException { - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - _src.dec_ndr_short(); /* union discriminant */ - info.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.idl b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.idl deleted file mode 100644 index ff2760d9b5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.idl +++ /dev/null @@ -1,81 +0,0 @@ -[ - uuid(4fc742e0-4a10-11cf-8273-00aa004ae673), - version(3.0) -] -interface netdfs -{ - import "../rpc.idl"; - - const uint32_t DFS_VOLUME_FLAVOR_STANDALONE = 0x100; - const uint32_t DFS_VOLUME_FLAVOR_AD_BLOB = 0x200; - - const uint32_t DFS_STORAGE_STATE_OFFLINE = 0x0001; - const uint32_t DFS_STORAGE_STATE_ONLINE = 0x0002; - const uint32_t DFS_STORAGE_STATE_ACTIVE = 0x0004; - - typedef struct { - [string] wchar_t *entry_path; - } DfsInfo1; - - typedef struct { - uint32_t count; - [size_is(count)] DfsInfo1 *s; - } DfsEnumArray1; - - typedef struct { - uint32_t state; - [string] wchar_t *server_name; - [string] wchar_t *share_name; - } DfsStorageInfo; - - typedef struct { - [string] wchar_t *path; - [string] wchar_t *comment; - uint32_t state; - uint32_t num_stores; - [size_is(num_stores)] DfsStorageInfo *stores; - } DfsInfo3; - - typedef struct { - uint32_t count; - [size_is(count)] DfsInfo3 *s; - } DfsEnumArray3; - - typedef struct { - [string] wchar_t *dfs_name; - } DfsInfo200; - - typedef struct { - uint32_t count; - [size_is(count)] DfsInfo200 *s; - } DfsEnumArray200; - - typedef struct { - uint32_t flags; - [string] wchar_t *dfs_name; - } DfsInfo300; - - typedef struct { - uint32_t count; - [size_is(count)] DfsInfo300 *s; - } DfsEnumArray300; - - typedef union { - [case(1)] DfsEnumArray1 *info1; - [case(3)] DfsEnumArray3 *info3; - [case(200)] DfsEnumArray200 *info200; - [case(300)] DfsEnumArray300 *info300; - } DfsEnumInfo; - - typedef struct { - uint32_t level, - [switch_is(level)] DfsEnumInfo e; - } DfsEnumStruct; - - [op(0x15)] - int NetrDfsEnumEx([in,string,unique] wchar_t dfs_name, - [in] uint32_t level, - [in] uint32_t prefmaxlen, - [in,out,unique] DfsEnumStruct *info, - [in,out,unique] uint32_t *totalentries); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.java deleted file mode 100644 index 1c09bb0941..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/netdfs.java +++ /dev/null @@ -1,497 +0,0 @@ -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrLong; -import jcifs.dcerpc.ndr.NdrObject; - -public class netdfs { - - public static String getSyntax() { - return "4fc742e0-4a10-11cf-8273-00aa004ae673:3.0"; - } - - public static final int DFS_VOLUME_FLAVOR_STANDALONE = 0x100; - public static final int DFS_VOLUME_FLAVOR_AD_BLOB = 0x200; - public static final int DFS_STORAGE_STATE_OFFLINE = 0x0001; - public static final int DFS_STORAGE_STATE_ONLINE = 0x0002; - public static final int DFS_STORAGE_STATE_ACTIVE = 0x0004; - public static class DfsInfo1 extends NdrObject { - - public String entry_path; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(entry_path, 1); - - if (entry_path != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(entry_path); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _entry_pathp = _src.dec_ndr_long(); - - if (_entry_pathp != 0) { - _src = _src.deferred; - entry_path = _src.dec_ndr_string(); - - } - } - } - public static class DfsEnumArray1 extends NdrObject { - - public int count; - public DfsInfo1[] s; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(s, 1); - - if (s != null) { - _dst = _dst.deferred; - int _ss = count; - _dst.enc_ndr_long(_ss); - int _si = _dst.index; - _dst.advance(4 * _ss); - - _dst = _dst.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - s[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _sp = _src.dec_ndr_long(); - - if (_sp != 0) { - _src = _src.deferred; - int _ss = _src.dec_ndr_long(); - int _si = _src.index; - _src.advance(4 * _ss); - - if (s == null) { - if (_ss < 0 || _ss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - s = new DfsInfo1[_ss]; - } - _src = _src.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - if (s[_i] == null) { - s[_i] = new DfsInfo1(); - } - s[_i].decode(_src); - } - } - } - } - public static class DfsStorageInfo extends NdrObject { - - public int state; - public String server_name; - public String share_name; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(state); - _dst.enc_ndr_referent(server_name, 1); - _dst.enc_ndr_referent(share_name, 1); - - if (server_name != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(server_name); - - } - if (share_name != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(share_name); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - state = (int)_src.dec_ndr_long(); - int _server_namep = _src.dec_ndr_long(); - int _share_namep = _src.dec_ndr_long(); - - if (_server_namep != 0) { - _src = _src.deferred; - server_name = _src.dec_ndr_string(); - - } - if (_share_namep != 0) { - _src = _src.deferred; - share_name = _src.dec_ndr_string(); - - } - } - } - public static class DfsInfo3 extends NdrObject { - - public String path; - public String comment; - public int state; - public int num_stores; - public DfsStorageInfo[] stores; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(path, 1); - _dst.enc_ndr_referent(comment, 1); - _dst.enc_ndr_long(state); - _dst.enc_ndr_long(num_stores); - _dst.enc_ndr_referent(stores, 1); - - if (path != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(path); - - } - if (comment != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(comment); - - } - if (stores != null) { - _dst = _dst.deferred; - int _storess = num_stores; - _dst.enc_ndr_long(_storess); - int _storesi = _dst.index; - _dst.advance(12 * _storess); - - _dst = _dst.derive(_storesi); - for (int _i = 0; _i < _storess; _i++) { - stores[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _pathp = _src.dec_ndr_long(); - int _commentp = _src.dec_ndr_long(); - state = (int)_src.dec_ndr_long(); - num_stores = (int)_src.dec_ndr_long(); - int _storesp = _src.dec_ndr_long(); - - if (_pathp != 0) { - _src = _src.deferred; - path = _src.dec_ndr_string(); - - } - if (_commentp != 0) { - _src = _src.deferred; - comment = _src.dec_ndr_string(); - - } - if (_storesp != 0) { - _src = _src.deferred; - int _storess = _src.dec_ndr_long(); - int _storesi = _src.index; - _src.advance(12 * _storess); - - if (stores == null) { - if (_storess < 0 || _storess > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - stores = new DfsStorageInfo[_storess]; - } - _src = _src.derive(_storesi); - for (int _i = 0; _i < _storess; _i++) { - if (stores[_i] == null) { - stores[_i] = new DfsStorageInfo(); - } - stores[_i].decode(_src); - } - } - } - } - public static class DfsEnumArray3 extends NdrObject { - - public int count; - public DfsInfo3[] s; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(s, 1); - - if (s != null) { - _dst = _dst.deferred; - int _ss = count; - _dst.enc_ndr_long(_ss); - int _si = _dst.index; - _dst.advance(20 * _ss); - - _dst = _dst.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - s[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _sp = _src.dec_ndr_long(); - - if (_sp != 0) { - _src = _src.deferred; - int _ss = _src.dec_ndr_long(); - int _si = _src.index; - _src.advance(20 * _ss); - - if (s == null) { - if (_ss < 0 || _ss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - s = new DfsInfo3[_ss]; - } - _src = _src.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - if (s[_i] == null) { - s[_i] = new DfsInfo3(); - } - s[_i].decode(_src); - } - } - } - } - public static class DfsInfo200 extends NdrObject { - - public String dfs_name; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(dfs_name, 1); - - if (dfs_name != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(dfs_name); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _dfs_namep = _src.dec_ndr_long(); - - if (_dfs_namep != 0) { - _src = _src.deferred; - dfs_name = _src.dec_ndr_string(); - - } - } - } - public static class DfsEnumArray200 extends NdrObject { - - public int count; - public DfsInfo200[] s; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(s, 1); - - if (s != null) { - _dst = _dst.deferred; - int _ss = count; - _dst.enc_ndr_long(_ss); - int _si = _dst.index; - _dst.advance(4 * _ss); - - _dst = _dst.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - s[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _sp = _src.dec_ndr_long(); - - if (_sp != 0) { - _src = _src.deferred; - int _ss = _src.dec_ndr_long(); - int _si = _src.index; - _src.advance(4 * _ss); - - if (s == null) { - if (_ss < 0 || _ss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - s = new DfsInfo200[_ss]; - } - _src = _src.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - if (s[_i] == null) { - s[_i] = new DfsInfo200(); - } - s[_i].decode(_src); - } - } - } - } - public static class DfsInfo300 extends NdrObject { - - public int flags; - public String dfs_name; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(flags); - _dst.enc_ndr_referent(dfs_name, 1); - - if (dfs_name != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(dfs_name); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - flags = (int)_src.dec_ndr_long(); - int _dfs_namep = _src.dec_ndr_long(); - - if (_dfs_namep != 0) { - _src = _src.deferred; - dfs_name = _src.dec_ndr_string(); - - } - } - } - public static class DfsEnumArray300 extends NdrObject { - - public int count; - public DfsInfo300[] s; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(s, 1); - - if (s != null) { - _dst = _dst.deferred; - int _ss = count; - _dst.enc_ndr_long(_ss); - int _si = _dst.index; - _dst.advance(8 * _ss); - - _dst = _dst.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - s[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _sp = _src.dec_ndr_long(); - - if (_sp != 0) { - _src = _src.deferred; - int _ss = _src.dec_ndr_long(); - int _si = _src.index; - _src.advance(8 * _ss); - - if (s == null) { - if (_ss < 0 || _ss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - s = new DfsInfo300[_ss]; - } - _src = _src.derive(_si); - for (int _i = 0; _i < _ss; _i++) { - if (s[_i] == null) { - s[_i] = new DfsInfo300(); - } - s[_i].decode(_src); - } - } - } - } - public static class DfsEnumStruct extends NdrObject { - - public int level; - public NdrObject e; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(level); - int _descr = level; - _dst.enc_ndr_long(_descr); - _dst.enc_ndr_referent(e, 1); - - if (e != null) { - _dst = _dst.deferred; - e.encode(_dst); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - level = (int)_src.dec_ndr_long(); - _src.dec_ndr_long(); /* union discriminant */ - int _ep = _src.dec_ndr_long(); - - if (_ep != 0) { - if (e == null) { /* YOYOYO */ - e = new DfsEnumArray1(); - } - _src = _src.deferred; - e.decode(_src); - - } - } - } - public static class NetrDfsEnumEx extends DcerpcMessage { - - public int getOpnum() { return 0x15; } - - public int retval; - public String dfs_name; - public int level; - public int prefmaxlen; - public DfsEnumStruct info; - public NdrLong totalentries; - - public NetrDfsEnumEx(String dfs_name, - int level, - int prefmaxlen, - DfsEnumStruct info, - NdrLong totalentries) { - this.dfs_name = dfs_name; - this.level = level; - this.prefmaxlen = prefmaxlen; - this.info = info; - this.totalentries = totalentries; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_string(dfs_name); - _dst.enc_ndr_long(level); - _dst.enc_ndr_long(prefmaxlen); - _dst.enc_ndr_referent(info, 1); - if (info != null) { - info.encode(_dst); - - } - _dst.enc_ndr_referent(totalentries, 1); - if (totalentries != null) { - totalentries.encode(_dst); - - } - } - public void decode_out(NdrBuffer _src) throws NdrException { - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - if (info == null) { /* YOYOYO */ - info = new DfsEnumStruct(); - } - info.decode(_src); - - } - int _totalentriesp = _src.dec_ndr_long(); - if (_totalentriesp != 0) { - totalentries.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.idl b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.idl deleted file mode 100644 index 7ebb91e746..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.idl +++ /dev/null @@ -1,96 +0,0 @@ -[ - uuid(12345778-1234-abcd-ef00-0123456789ac), - version(1.0) -] -interface samr -{ - import "../rpc.idl"; - import "lsarpc.idl"; - - typedef [v1_enum] enum { - ACB_DISABLED = 0x00000001, /* 1 = User account disabled */ - ACB_HOMDIRREQ = 0x00000002, /* 1 = Home directory required */ - ACB_PWNOTREQ = 0x00000004, /* 1 = User password not required */ - ACB_TEMPDUP = 0x00000008, /* 1 = Temporary duplicate account */ - ACB_NORMAL = 0x00000010, /* 1 = Normal user account */ - ACB_MNS = 0x00000020, /* 1 = MNS logon user account */ - ACB_DOMTRUST = 0x00000040, /* 1 = Interdomain trust account */ - ACB_WSTRUST = 0x00000080, /* 1 = Workstation trust account */ - ACB_SVRTRUST = 0x00000100, /* 1 = Server trust account */ - ACB_PWNOEXP = 0x00000200, /* 1 = User password does not expire */ - ACB_AUTOLOCK = 0x00000400, /* 1 = Account auto locked */ - ACB_ENC_TXT_PWD_ALLOWED = 0x00000800, /* 1 = Encryped text password is allowed */ - ACB_SMARTCARD_REQUIRED = 0x00001000, /* 1 = Smart Card required */ - ACB_TRUSTED_FOR_DELEGATION = 0x00002000, /* 1 = Trusted for Delegation */ - ACB_NOT_DELEGATED = 0x00004000, /* 1 = Not delegated */ - ACB_USE_DES_KEY_ONLY = 0x00008000, /* 1 = Use DES key only */ - ACB_DONT_REQUIRE_PREAUTH = 0x00010000 /* 1 = Preauth not required */ - } SamrAcctFlags; - - [op(0x01)] - int SamrCloseHandle([in] policy_handle *handle); - - [op(0x39)] - int SamrConnect2([in,string,unique] wchar_t *system_name, - [in] uint32_t access_mask, - [out] policy_handle *handle); - - [op(0x3e)] - int SamrConnect4([in,string,unique] wchar_t *system_name, - [in] uint32_t unknown, - [in] uint32_t access_mask, - [out] policy_handle *handle); - - [op(0x07)] - int SamrOpenDomain([in] policy_handle *handle, - [in] uint32_t access_mask, - [in] sid_t *sid, - [out] policy_handle *domain_handle); - - typedef struct { - uint32_t idx; - unicode_string name; - } SamrSamEntry; - - typedef struct { - uint32_t count; - [size_is(count)] SamrSamEntry *entries; - } SamrSamArray; - - [op(0x0f)] - int SamrEnumerateAliasesInDomain([in] policy_handle *domain_handle, - [in,out] uint32_t *resume_handle, - [in] uint32_t acct_flags, - [out,unique] SamrSamArray *sam, - [out] uint32_t num_entries); - - [op(0x1b)] - int SamrOpenAlias([in] policy_handle *domain_handle, - [in] uint32_t access_mask, - [in] uint32_t rid, - [out] policy_handle *alias_handle); - - [op(0x21)] - int SamrGetMembersInAlias([in] policy_handle *alias_handle, - [out] LsarSidArray *sids); - - typedef [v1_enum] enum { - SE_GROUP_MANDATORY = 0x00000001, - SE_GROUP_ENABLED_BY_DEFAULT = 0x00000002, - SE_GROUP_ENABLED = 0x00000004, - SE_GROUP_OWNER = 0x00000008, - SE_GROUP_USE_FOR_DENY_ONLY = 0x00000010, - SE_GROUP_RESOURCE = 0x20000000, - SE_GROUP_LOGON_ID = 0xC0000000 - } SamrGroupAttrs; - - typedef struct { - uint32_t rid; - SamrGroupAttrs attributes; - } SamrRidWithAttribute; - - typedef struct { - uint32_t count; - [size_is(count)] SamrRidWithAttribute *rids; - } SamrRidWithAttributeArray; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.java deleted file mode 100644 index acb8dbc6b2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/samr.java +++ /dev/null @@ -1,416 +0,0 @@ -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; -import jcifs.dcerpc.rpc; - -public class samr { - - public static String getSyntax() { - return "12345778-1234-abcd-ef00-0123456789ac:1.0"; - } - - public static final int ACB_DISABLED = 1; - public static final int ACB_HOMDIRREQ = 2; - public static final int ACB_PWNOTREQ = 4; - public static final int ACB_TEMPDUP = 8; - public static final int ACB_NORMAL = 16; - public static final int ACB_MNS = 32; - public static final int ACB_DOMTRUST = 64; - public static final int ACB_WSTRUST = 128; - public static final int ACB_SVRTRUST = 256; - public static final int ACB_PWNOEXP = 512; - public static final int ACB_AUTOLOCK = 1024; - public static final int ACB_ENC_TXT_PWD_ALLOWED = 2048; - public static final int ACB_SMARTCARD_REQUIRED = 4096; - public static final int ACB_TRUSTED_FOR_DELEGATION = 8192; - public static final int ACB_NOT_DELEGATED = 16384; - public static final int ACB_USE_DES_KEY_ONLY = 32768; - public static final int ACB_DONT_REQUIRE_PREAUTH = 65536; - - public static class SamrCloseHandle extends DcerpcMessage { - - public int getOpnum() { return 0x01; } - - public int retval; - public rpc.policy_handle handle; - - public SamrCloseHandle(rpc.policy_handle handle) { - this.handle = handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - } - public void decode_out(NdrBuffer _src) throws NdrException { - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrConnect2 extends DcerpcMessage { - - public int getOpnum() { return 0x39; } - - public int retval; - public String system_name; - public int access_mask; - public rpc.policy_handle handle; - - public SamrConnect2(String system_name, int access_mask, rpc.policy_handle handle) { - this.system_name = system_name; - this.access_mask = access_mask; - this.handle = handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(system_name, 1); - if (system_name != null) { - _dst.enc_ndr_string(system_name); - - } - _dst.enc_ndr_long(access_mask); - } - public void decode_out(NdrBuffer _src) throws NdrException { - handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrConnect4 extends DcerpcMessage { - - public int getOpnum() { return 0x3e; } - - public int retval; - public String system_name; - public int unknown; - public int access_mask; - public rpc.policy_handle handle; - - public SamrConnect4(String system_name, - int unknown, - int access_mask, - rpc.policy_handle handle) { - this.system_name = system_name; - this.unknown = unknown; - this.access_mask = access_mask; - this.handle = handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(system_name, 1); - if (system_name != null) { - _dst.enc_ndr_string(system_name); - - } - _dst.enc_ndr_long(unknown); - _dst.enc_ndr_long(access_mask); - } - public void decode_out(NdrBuffer _src) throws NdrException { - handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrOpenDomain extends DcerpcMessage { - - public int getOpnum() { return 0x07; } - - public int retval; - public rpc.policy_handle handle; - public int access_mask; - public rpc.sid_t sid; - public rpc.policy_handle domain_handle; - - public SamrOpenDomain(rpc.policy_handle handle, - int access_mask, - rpc.sid_t sid, - rpc.policy_handle domain_handle) { - this.handle = handle; - this.access_mask = access_mask; - this.sid = sid; - this.domain_handle = domain_handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - handle.encode(_dst); - _dst.enc_ndr_long(access_mask); - sid.encode(_dst); - } - public void decode_out(NdrBuffer _src) throws NdrException { - domain_handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrSamEntry extends NdrObject { - - public int idx; - public rpc.unicode_string name; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(idx); - _dst.enc_ndr_short(name.length); - _dst.enc_ndr_short(name.maximum_length); - _dst.enc_ndr_referent(name.buffer, 1); - - if (name.buffer != null) { - _dst = _dst.deferred; - int _name_bufferl = name.length / 2; - int _name_buffers = name.maximum_length / 2; - _dst.enc_ndr_long(_name_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_name_bufferl); - int _name_bufferi = _dst.index; - _dst.advance(2 * _name_bufferl); - - _dst = _dst.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - _dst.enc_ndr_short(name.buffer[_i]); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - idx = (int)_src.dec_ndr_long(); - _src.align(4); - if (name == null) { - name = new rpc.unicode_string(); - } - name.length = (short)_src.dec_ndr_short(); - name.maximum_length = (short)_src.dec_ndr_short(); - int _name_bufferp = _src.dec_ndr_long(); - - if (_name_bufferp != 0) { - _src = _src.deferred; - int _name_buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _name_bufferl = _src.dec_ndr_long(); - int _name_bufferi = _src.index; - _src.advance(2 * _name_bufferl); - - if (name.buffer == null) { - if (_name_buffers < 0 || _name_buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - name.buffer = new short[_name_buffers]; - } - _src = _src.derive(_name_bufferi); - for (int _i = 0; _i < _name_bufferl; _i++) { - name.buffer[_i] = (short)_src.dec_ndr_short(); - } - } - } - } - public static class SamrSamArray extends NdrObject { - - public int count; - public SamrSamEntry[] entries; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(entries, 1); - - if (entries != null) { - _dst = _dst.deferred; - int _entriess = count; - _dst.enc_ndr_long(_entriess); - int _entriesi = _dst.index; - _dst.advance(12 * _entriess); - - _dst = _dst.derive(_entriesi); - for (int _i = 0; _i < _entriess; _i++) { - entries[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _entriesp = _src.dec_ndr_long(); - - if (_entriesp != 0) { - _src = _src.deferred; - int _entriess = _src.dec_ndr_long(); - int _entriesi = _src.index; - _src.advance(12 * _entriess); - - if (entries == null) { - if (_entriess < 0 || _entriess > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - entries = new SamrSamEntry[_entriess]; - } - _src = _src.derive(_entriesi); - for (int _i = 0; _i < _entriess; _i++) { - if (entries[_i] == null) { - entries[_i] = new SamrSamEntry(); - } - entries[_i].decode(_src); - } - } - } - } - public static class SamrEnumerateAliasesInDomain extends DcerpcMessage { - - public int getOpnum() { return 0x0f; } - - public int retval; - public rpc.policy_handle domain_handle; - public int resume_handle; - public int acct_flags; - public SamrSamArray sam; - public int num_entries; - - public SamrEnumerateAliasesInDomain(rpc.policy_handle domain_handle, - int resume_handle, - int acct_flags, - SamrSamArray sam, - int num_entries) { - this.domain_handle = domain_handle; - this.resume_handle = resume_handle; - this.acct_flags = acct_flags; - this.sam = sam; - this.num_entries = num_entries; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - domain_handle.encode(_dst); - _dst.enc_ndr_long(resume_handle); - _dst.enc_ndr_long(acct_flags); - } - public void decode_out(NdrBuffer _src) throws NdrException { - resume_handle = (int)_src.dec_ndr_long(); - int _samp = _src.dec_ndr_long(); - if (_samp != 0) { - if (sam == null) { /* YOYOYO */ - sam = new SamrSamArray(); - } - sam.decode(_src); - - } - num_entries = (int)_src.dec_ndr_long(); - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrOpenAlias extends DcerpcMessage { - - public int getOpnum() { return 0x1b; } - - public int retval; - public rpc.policy_handle domain_handle; - public int access_mask; - public int rid; - public rpc.policy_handle alias_handle; - - public SamrOpenAlias(rpc.policy_handle domain_handle, - int access_mask, - int rid, - rpc.policy_handle alias_handle) { - this.domain_handle = domain_handle; - this.access_mask = access_mask; - this.rid = rid; - this.alias_handle = alias_handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - domain_handle.encode(_dst); - _dst.enc_ndr_long(access_mask); - _dst.enc_ndr_long(rid); - } - public void decode_out(NdrBuffer _src) throws NdrException { - alias_handle.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static class SamrGetMembersInAlias extends DcerpcMessage { - - public int getOpnum() { return 0x21; } - - public int retval; - public rpc.policy_handle alias_handle; - public lsarpc.LsarSidArray sids; - - public SamrGetMembersInAlias(rpc.policy_handle alias_handle, lsarpc.LsarSidArray sids) { - this.alias_handle = alias_handle; - this.sids = sids; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - alias_handle.encode(_dst); - } - public void decode_out(NdrBuffer _src) throws NdrException { - sids.decode(_src); - retval = (int)_src.dec_ndr_long(); - } - } - public static final int SE_GROUP_MANDATORY = 1; - public static final int SE_GROUP_ENABLED_BY_DEFAULT = 2; - public static final int SE_GROUP_ENABLED = 4; - public static final int SE_GROUP_OWNER = 8; - public static final int SE_GROUP_USE_FOR_DENY_ONLY = 16; - public static final int SE_GROUP_RESOURCE = 536870912; - public static final int SE_GROUP_LOGON_ID = -1073741824; - - public static class SamrRidWithAttribute extends NdrObject { - - public int rid; - public int attributes; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(rid); - _dst.enc_ndr_long(attributes); - - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - rid = (int)_src.dec_ndr_long(); - attributes = (int)_src.dec_ndr_long(); - - } - } - public static class SamrRidWithAttributeArray extends NdrObject { - - public int count; - public SamrRidWithAttribute[] rids; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(rids, 1); - - if (rids != null) { - _dst = _dst.deferred; - int _ridss = count; - _dst.enc_ndr_long(_ridss); - int _ridsi = _dst.index; - _dst.advance(8 * _ridss); - - _dst = _dst.derive(_ridsi); - for (int _i = 0; _i < _ridss; _i++) { - rids[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _ridsp = _src.dec_ndr_long(); - - if (_ridsp != 0) { - _src = _src.deferred; - int _ridss = _src.dec_ndr_long(); - int _ridsi = _src.index; - _src.advance(8 * _ridss); - - if (rids == null) { - if (_ridss < 0 || _ridss > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - rids = new SamrRidWithAttribute[_ridss]; - } - _src = _src.derive(_ridsi); - for (int _i = 0; _i < _ridss; _i++) { - if (rids[_i] == null) { - rids[_i] = new SamrRidWithAttribute(); - } - rids[_i].decode(_src); - } - } - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.idl b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.idl deleted file mode 100644 index 3e692fb3d4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.idl +++ /dev/null @@ -1,107 +0,0 @@ -[ - uuid(4b324fc8-1670-01d3-1278-5a47bf6ee188), - version(3.0) -] -interface srvsvc -{ - import "../rpc.idl"; - - typedef struct { - [string] wchar_t *netname; - } ShareInfo0; - - typedef struct { - int count; - [size_is(count)] ShareInfo0 *array; - } ShareInfoCtr0; - - typedef struct { - [string] wchar_t *netname; - int type; - [string] wchar_t *remark; - } ShareInfo1; - - typedef struct { - int count; - [size_is(count)] ShareInfo1 *array; - } ShareInfoCtr1; - - typedef struct { - [string] wchar_t *netname; - int type; - [string] wchar_t *remark; - uint32_t permissions; - uint32_t max_uses; - uint32_t current_uses; - [string] wchar_t *path; - [string] wchar_t *password; - uint32_t sd_size; - [size_is(sd_size)] uint8_t *security_descriptor; - } ShareInfo502; - - typedef struct { - int count; - [size_is(count)] ShareInfo502 *array; - } ShareInfoCtr502; - - typedef [switch_type(int)] union { - [case(0)] ShareInfo0 *info0; - [case(1)] ShareInfo1 *info1; - [case(502)] ShareInfo502 *info1; - } ShareInfo; - - typedef [switch_type(int)] union { - [case(0)] ShareInfoCtr0 *info0; - [case(1)] ShareInfoCtr1 *info1; - [case(502)] ShareInfoCtr502 *info1; - } ShareCtr; - - [op(0x0f)] - int ShareEnumAll([in,string,unique] wchar_t *servername, - [in,out] int *level, - [in,out,switch_is(*level)] ShareCtr *info, - [in] unsigned long prefmaxlen, - [out] unsigned long *totalentries, - [in,out] unsigned long *resume_handle); - - [op(0x10)] - int ShareGetInfo([in,string,unique] wchar_t *servername, - [in,string] wchar_t *sharename, - [in] int level, - [out,switch_is(level)] ShareInfo *info); - - typedef struct { - unsigned long platform_id; - [string] wchar_t *name; - } ServerInfo100; - - typedef [switch_type(int)] union { - [case(0)] ServerInfo100 *info0; - } ServerInfo; - - [op(0x15)] - int ServerGetInfo([in,string,unique] wchar_t *servername, - [in] int level, - [out,switch_is(level)] ServerInfo *info); - - typedef struct { - uint32_t elapsedt; - uint32_t msecs; - uint32_t hours; - uint32_t mins; - uint32_t secs; - uint32_t hunds; - uint32_t timezone; - uint32_t tinterval; - uint32_t day; - uint32_t month; - uint32_t year; - uint32_t weekday; - } TimeOfDayInfo; - - [op(0x1c)] - int RemoteTOD([in,string,unique] wchar_t *servername, - [out,unique] TimeOfDayInfo *info); -} - - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.java deleted file mode 100644 index 5cd2ba7931..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/msrpc/srvsvc.java +++ /dev/null @@ -1,582 +0,0 @@ -package jcifs.dcerpc.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; - -public class srvsvc { - - public static String getSyntax() { - return "4b324fc8-1670-01d3-1278-5a47bf6ee188:3.0"; - } - - public static class ShareInfo0 extends NdrObject { - - public String netname; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(netname, 1); - - if (netname != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(netname); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _netnamep = _src.dec_ndr_long(); - - if (_netnamep != 0) { - _src = _src.deferred; - netname = _src.dec_ndr_string(); - - } - } - } - public static class ShareInfoCtr0 extends NdrObject { - - public int count; - public ShareInfo0[] array; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(array, 1); - - if (array != null) { - _dst = _dst.deferred; - int _arrays = count; - _dst.enc_ndr_long(_arrays); - int _arrayi = _dst.index; - _dst.advance(4 * _arrays); - - _dst = _dst.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - array[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _arrayp = _src.dec_ndr_long(); - - if (_arrayp != 0) { - _src = _src.deferred; - int _arrays = _src.dec_ndr_long(); - int _arrayi = _src.index; - _src.advance(4 * _arrays); - - if (array == null) { - if (_arrays < 0 || _arrays > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - array = new ShareInfo0[_arrays]; - } - _src = _src.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - if (array[_i] == null) { - array[_i] = new ShareInfo0(); - } - array[_i].decode(_src); - } - } - } - } - public static class ShareInfo1 extends NdrObject { - - public String netname; - public int type; - public String remark; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(netname, 1); - _dst.enc_ndr_long(type); - _dst.enc_ndr_referent(remark, 1); - - if (netname != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(netname); - - } - if (remark != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(remark); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _netnamep = _src.dec_ndr_long(); - type = (int)_src.dec_ndr_long(); - int _remarkp = _src.dec_ndr_long(); - - if (_netnamep != 0) { - _src = _src.deferred; - netname = _src.dec_ndr_string(); - - } - if (_remarkp != 0) { - _src = _src.deferred; - remark = _src.dec_ndr_string(); - - } - } - } - public static class ShareInfoCtr1 extends NdrObject { - - public int count; - public ShareInfo1[] array; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(array, 1); - - if (array != null) { - _dst = _dst.deferred; - int _arrays = count; - _dst.enc_ndr_long(_arrays); - int _arrayi = _dst.index; - _dst.advance(12 * _arrays); - - _dst = _dst.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - array[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _arrayp = _src.dec_ndr_long(); - - if (_arrayp != 0) { - _src = _src.deferred; - int _arrays = _src.dec_ndr_long(); - int _arrayi = _src.index; - _src.advance(12 * _arrays); - - if (array == null) { - if (_arrays < 0 || _arrays > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - array = new ShareInfo1[_arrays]; - } - _src = _src.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - if (array[_i] == null) { - array[_i] = new ShareInfo1(); - } - array[_i].decode(_src); - } - } - } - } - public static class ShareInfo502 extends NdrObject { - - public String netname; - public int type; - public String remark; - public int permissions; - public int max_uses; - public int current_uses; - public String path; - public String password; - public int sd_size; - public byte[] security_descriptor; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_referent(netname, 1); - _dst.enc_ndr_long(type); - _dst.enc_ndr_referent(remark, 1); - _dst.enc_ndr_long(permissions); - _dst.enc_ndr_long(max_uses); - _dst.enc_ndr_long(current_uses); - _dst.enc_ndr_referent(path, 1); - _dst.enc_ndr_referent(password, 1); - _dst.enc_ndr_long(sd_size); - _dst.enc_ndr_referent(security_descriptor, 1); - - if (netname != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(netname); - - } - if (remark != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(remark); - - } - if (path != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(path); - - } - if (password != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(password); - - } - if (security_descriptor != null) { - _dst = _dst.deferred; - int _security_descriptors = sd_size; - _dst.enc_ndr_long(_security_descriptors); - int _security_descriptori = _dst.index; - _dst.advance(1 * _security_descriptors); - - _dst = _dst.derive(_security_descriptori); - for (int _i = 0; _i < _security_descriptors; _i++) { - _dst.enc_ndr_small(security_descriptor[_i]); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _netnamep = _src.dec_ndr_long(); - type = (int)_src.dec_ndr_long(); - int _remarkp = _src.dec_ndr_long(); - permissions = (int)_src.dec_ndr_long(); - max_uses = (int)_src.dec_ndr_long(); - current_uses = (int)_src.dec_ndr_long(); - int _pathp = _src.dec_ndr_long(); - int _passwordp = _src.dec_ndr_long(); - sd_size = (int)_src.dec_ndr_long(); - int _security_descriptorp = _src.dec_ndr_long(); - - if (_netnamep != 0) { - _src = _src.deferred; - netname = _src.dec_ndr_string(); - - } - if (_remarkp != 0) { - _src = _src.deferred; - remark = _src.dec_ndr_string(); - - } - if (_pathp != 0) { - _src = _src.deferred; - path = _src.dec_ndr_string(); - - } - if (_passwordp != 0) { - _src = _src.deferred; - password = _src.dec_ndr_string(); - - } - if (_security_descriptorp != 0) { - _src = _src.deferred; - int _security_descriptors = _src.dec_ndr_long(); - int _security_descriptori = _src.index; - _src.advance(1 * _security_descriptors); - - if (security_descriptor == null) { - if (_security_descriptors < 0 || _security_descriptors > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - security_descriptor = new byte[_security_descriptors]; - } - _src = _src.derive(_security_descriptori); - for (int _i = 0; _i < _security_descriptors; _i++) { - security_descriptor[_i] = (byte)_src.dec_ndr_small(); - } - } - } - } - public static class ShareInfoCtr502 extends NdrObject { - - public int count; - public ShareInfo502[] array; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(count); - _dst.enc_ndr_referent(array, 1); - - if (array != null) { - _dst = _dst.deferred; - int _arrays = count; - _dst.enc_ndr_long(_arrays); - int _arrayi = _dst.index; - _dst.advance(40 * _arrays); - - _dst = _dst.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - array[_i].encode(_dst); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - count = (int)_src.dec_ndr_long(); - int _arrayp = _src.dec_ndr_long(); - - if (_arrayp != 0) { - _src = _src.deferred; - int _arrays = _src.dec_ndr_long(); - int _arrayi = _src.index; - _src.advance(40 * _arrays); - - if (array == null) { - if (_arrays < 0 || _arrays > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - array = new ShareInfo502[_arrays]; - } - _src = _src.derive(_arrayi); - for (int _i = 0; _i < _arrays; _i++) { - if (array[_i] == null) { - array[_i] = new ShareInfo502(); - } - array[_i].decode(_src); - } - } - } - } - public static class ShareEnumAll extends DcerpcMessage { - - public int getOpnum() { return 0x0f; } - - public int retval; - public String servername; - public int level; - public NdrObject info; - public int prefmaxlen; - public int totalentries; - public int resume_handle; - - public ShareEnumAll(String servername, - int level, - NdrObject info, - int prefmaxlen, - int totalentries, - int resume_handle) { - this.servername = servername; - this.level = level; - this.info = info; - this.prefmaxlen = prefmaxlen; - this.totalentries = totalentries; - this.resume_handle = resume_handle; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(servername, 1); - if (servername != null) { - _dst.enc_ndr_string(servername); - - } - _dst.enc_ndr_long(level); - int _descr = level; - _dst.enc_ndr_long(_descr); - _dst.enc_ndr_referent(info, 1); - if (info != null) { - _dst = _dst.deferred; - info.encode(_dst); - - } - _dst.enc_ndr_long(prefmaxlen); - _dst.enc_ndr_long(resume_handle); - } - public void decode_out(NdrBuffer _src) throws NdrException { - level = (int)_src.dec_ndr_long(); - _src.dec_ndr_long(); /* union discriminant */ - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - if (info == null) { /* YOYOYO */ - info = new ShareInfoCtr0(); - } - _src = _src.deferred; - info.decode(_src); - - } - totalentries = (int)_src.dec_ndr_long(); - resume_handle = (int)_src.dec_ndr_long(); - retval = (int)_src.dec_ndr_long(); - } - } - public static class ShareGetInfo extends DcerpcMessage { - - public int getOpnum() { return 0x10; } - - public int retval; - public String servername; - public String sharename; - public int level; - public NdrObject info; - - public ShareGetInfo(String servername, - String sharename, - int level, - NdrObject info) { - this.servername = servername; - this.sharename = sharename; - this.level = level; - this.info = info; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(servername, 1); - if (servername != null) { - _dst.enc_ndr_string(servername); - - } - _dst.enc_ndr_string(sharename); - _dst.enc_ndr_long(level); - } - public void decode_out(NdrBuffer _src) throws NdrException { - _src.dec_ndr_long(); /* union discriminant */ - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - if (info == null) { /* YOYOYO */ - info = new ShareInfo0(); - } - _src = _src.deferred; - info.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } - public static class ServerInfo100 extends NdrObject { - - public int platform_id; - public String name; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(platform_id); - _dst.enc_ndr_referent(name, 1); - - if (name != null) { - _dst = _dst.deferred; - _dst.enc_ndr_string(name); - - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - platform_id = (int)_src.dec_ndr_long(); - int _namep = _src.dec_ndr_long(); - - if (_namep != 0) { - _src = _src.deferred; - name = _src.dec_ndr_string(); - - } - } - } - public static class ServerGetInfo extends DcerpcMessage { - - public int getOpnum() { return 0x15; } - - public int retval; - public String servername; - public int level; - public NdrObject info; - - public ServerGetInfo(String servername, int level, NdrObject info) { - this.servername = servername; - this.level = level; - this.info = info; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(servername, 1); - if (servername != null) { - _dst.enc_ndr_string(servername); - - } - _dst.enc_ndr_long(level); - } - public void decode_out(NdrBuffer _src) throws NdrException { - _src.dec_ndr_long(); /* union discriminant */ - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - if (info == null) { /* YOYOYO */ - info = new ServerInfo100(); - } - _src = _src.deferred; - info.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } - public static class TimeOfDayInfo extends NdrObject { - - public int elapsedt; - public int msecs; - public int hours; - public int mins; - public int secs; - public int hunds; - public int timezone; - public int tinterval; - public int day; - public int month; - public int year; - public int weekday; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(elapsedt); - _dst.enc_ndr_long(msecs); - _dst.enc_ndr_long(hours); - _dst.enc_ndr_long(mins); - _dst.enc_ndr_long(secs); - _dst.enc_ndr_long(hunds); - _dst.enc_ndr_long(timezone); - _dst.enc_ndr_long(tinterval); - _dst.enc_ndr_long(day); - _dst.enc_ndr_long(month); - _dst.enc_ndr_long(year); - _dst.enc_ndr_long(weekday); - - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - elapsedt = (int)_src.dec_ndr_long(); - msecs = (int)_src.dec_ndr_long(); - hours = (int)_src.dec_ndr_long(); - mins = (int)_src.dec_ndr_long(); - secs = (int)_src.dec_ndr_long(); - hunds = (int)_src.dec_ndr_long(); - timezone = (int)_src.dec_ndr_long(); - tinterval = (int)_src.dec_ndr_long(); - day = (int)_src.dec_ndr_long(); - month = (int)_src.dec_ndr_long(); - year = (int)_src.dec_ndr_long(); - weekday = (int)_src.dec_ndr_long(); - - } - } - public static class RemoteTOD extends DcerpcMessage { - - public int getOpnum() { return 0x1c; } - - public int retval; - public String servername; - public TimeOfDayInfo info; - - public RemoteTOD(String servername, TimeOfDayInfo info) { - this.servername = servername; - this.info = info; - } - - public void encode_in(NdrBuffer _dst) throws NdrException { - _dst.enc_ndr_referent(servername, 1); - if (servername != null) { - _dst.enc_ndr_string(servername); - - } - } - public void decode_out(NdrBuffer _src) throws NdrException { - int _infop = _src.dec_ndr_long(); - if (_infop != 0) { - if (info == null) { /* YOYOYO */ - info = new TimeOfDayInfo(); - } - info.decode(_src); - - } - retval = (int)_src.dec_ndr_long(); - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrBuffer.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrBuffer.java deleted file mode 100644 index 0476aede96..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrBuffer.java +++ /dev/null @@ -1,232 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -import jcifs.util.Encdec; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; - -public class NdrBuffer { - int referent; - HashMap referents; - - static class Entry { - int referent; - Object obj; - } - - public byte[] buf; - public int start; - public int index; - public int length; - public NdrBuffer deferred; - - public NdrBuffer(byte[] buf, int start) { - this.buf = buf; - this.start = index = start; - length = 0; - deferred = this; - } - - public NdrBuffer derive(int idx) { - NdrBuffer nb = new NdrBuffer(buf, start); - nb.index = idx; - nb.deferred = deferred; - return nb; - } - - - - public void reset() { - this.index = start; - length = 0; - deferred = this; - } - public int getIndex() { - return index; - } - public void setIndex(int index) { - this.index = index; - } - public int getCapacity() { - return buf.length - start; - } - public int getTailSpace() { - return buf.length - index; - } - public byte[] getBuffer() { - return buf; - } - public int align(int boundary, byte value) { - int n = align(boundary); - int i = n; - while (i > 0) { - buf[index - i] = value; - i--; - } - return n; - } - public void writeOctetArray(byte[] b, int i, int l) { - System.arraycopy(b, i, buf, index, l); - advance(l); - } - public void readOctetArray(byte[] b, int i, int l) { - System.arraycopy(buf, index, b, i, l); - advance(l); - } - - - public int getLength() { - return deferred.length; - } - public void setLength(int length) { - deferred.length = length; - } - public void advance(int n) { - index += n; - if ((index - start) > deferred.length) { - deferred.length = index - start; - } - } - public int align(int boundary) { - int m = boundary - 1; - int i = index - start; - int n = ((i + m) & ~m) - i; - advance(n); - return n; - } - public void enc_ndr_small(int s) { - buf[index] = (byte)(s & 0xFF); - advance(1); - } - public int dec_ndr_small() { - int val = buf[index] & 0xFF; - advance(1); - return val; - } - public void enc_ndr_short(int s) { - align(2); - Encdec.enc_uint16le((short)s, buf, index); - advance(2); - } - public int dec_ndr_short() { - align(2); - int val = Encdec.dec_uint16le(buf, index); - advance(2); - return val; - } - public void enc_ndr_long(int l) { - align(4); - Encdec.enc_uint32le(l, buf, index); - advance(4); - } - public int dec_ndr_long() { - align(4); - int val = Encdec.dec_uint32le(buf, index); - advance(4); - return val; - } - public void enc_ndr_hyper(long h) { - align(8); - Encdec.enc_uint64le(h, buf, index); - advance(8); - } - public long dec_ndr_hyper() { - align(8); - long val = Encdec.dec_uint64le(buf, index); - advance(8); - return val; - } - /* float */ - /* double */ - public void enc_ndr_string(String s) { - align(4); - int i = index; - int len = s.length(); - Encdec.enc_uint32le(len + 1, buf, i); i += 4; - Encdec.enc_uint32le(0, buf, i); i += 4; - Encdec.enc_uint32le(len + 1, buf, i); i += 4; - try { - System.arraycopy(s.getBytes("UTF-16LE"), 0, buf, i, len * 2); - } catch( UnsupportedEncodingException uee ) { - } - i += len * 2; - buf[i++] = (byte)'\0'; - buf[i++] = (byte)'\0'; - advance(i - index); - } - public String dec_ndr_string() throws NdrException { - align(4); - int i = index; - String val = null; - int len = Encdec.dec_uint32le(buf, i); - i += 12; - if (len != 0) { - len--; - int size = len * 2; - try { - if (size < 0 || size > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - val = new String(buf, i, size, "UTF-16LE"); - i += size + 2; - } catch( UnsupportedEncodingException uee ) { - } - } - advance(i - index); - return val; - } - private int getDceReferent(Object obj) { - Entry e; - - if (referents == null) { - referents = new HashMap(); - referent = 1; - } - - if ((e = (Entry)referents.get(obj)) == null) { - e = new Entry(); - e.referent = referent++; - e.obj = obj; - referents.put(obj, e); - } - - return e.referent; - } - public void enc_ndr_referent(Object obj, int type) { - if (obj == null) { - enc_ndr_long(0); - return; - } - switch (type) { - case 1: /* unique */ - case 3: /* ref */ - enc_ndr_long(System.identityHashCode(obj)); - return; - case 2: /* ptr */ - enc_ndr_long(getDceReferent(obj)); - return; - } - } - - public String toString() { - return "start=" + start + ",index=" + index + ",length=" + getLength(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrException.java deleted file mode 100644 index 8be44108a3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -import java.io.IOException; - -public class NdrException extends IOException { - - public static final String NO_NULL_REF = "ref pointer cannot be null"; - public static final String INVALID_CONFORMANCE = "invalid array conformance"; - - public NdrException( String msg ) { - super( msg ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrHyper.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrHyper.java deleted file mode 100644 index 43c581c213..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrHyper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -public class NdrHyper extends NdrObject { - - public long value; - - public NdrHyper(long value) { - this.value = value; - } - - public void encode(NdrBuffer dst) throws NdrException { - dst.enc_ndr_hyper(value); - } - public void decode(NdrBuffer src) throws NdrException { - value = src.dec_ndr_hyper(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrLong.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrLong.java deleted file mode 100644 index 0b929d1bef..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrLong.java +++ /dev/null @@ -1,37 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -public class NdrLong extends NdrObject { - - public int value; - - public NdrLong(int value) { - this.value = value; - } - - public void encode(NdrBuffer dst) throws NdrException { - dst.enc_ndr_long(value); - } - public void decode(NdrBuffer src) throws NdrException { - value = src.dec_ndr_long(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrObject.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrObject.java deleted file mode 100644 index b2c0372b98..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrObject.java +++ /dev/null @@ -1,27 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -public abstract class NdrObject { - - public abstract void encode(NdrBuffer dst) throws NdrException; - public abstract void decode(NdrBuffer src) throws NdrException; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrShort.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrShort.java deleted file mode 100644 index e7102329f9..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrShort.java +++ /dev/null @@ -1,37 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -public class NdrShort extends NdrObject { - - public int value; - - public NdrShort(int value) { - this.value = value & 0xFF; - } - - public void encode(NdrBuffer dst) throws NdrException { - dst.enc_ndr_short(value); - } - public void decode(NdrBuffer src) throws NdrException { - value = src.dec_ndr_short(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrSmall.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrSmall.java deleted file mode 100644 index 42ede4658f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/ndr/NdrSmall.java +++ /dev/null @@ -1,37 +0,0 @@ -/* jcifs msrpc client library in Java - * Copyright (C) 2006 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.dcerpc.ndr; - -public class NdrSmall extends NdrObject { - - public int value; - - public NdrSmall(int value) { - this.value = value & 0xFF; - } - - public void encode(NdrBuffer dst) throws NdrException { - dst.enc_ndr_small(value); - } - public void decode(NdrBuffer src) throws NdrException { - value = src.dec_ndr_small(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.idl b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.idl deleted file mode 100644 index 02aff6351c..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.idl +++ /dev/null @@ -1,63 +0,0 @@ -interface rpc -{ - /* base types */ - - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; - - /* dce */ - - typedef struct { - uint32_t time_low; - uint16_t time_mid; - uint16_t time_hi_and_version; - uint8_t clock_seq_hi_and_reserved; - uint8_t clock_seq_low; - uint8_t node[6]; - } uuid_t; - - /* win32 stuff */ - - typedef struct { - uint32_t type; - uuid_t uuid; - } policy_handle; - - /* - * typedef struct _UNICODE_STRING - * USHORT Length; - * USHORT MaximumLength; - * [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer; - * } UNICODE_STRING; - */ - - typedef struct { - uint16_t length; - uint16_t maximum_length; - [length_is(length / 2),size_is(maximum_length / 2)] uint16_t *buffer; - } unicode_string; - - /* - * typedef struct _SID_IDENTIFIER_AUTHORITY { - * UCHAR Value[6]; - * } SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY; - * - * #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} - * - * typedef struct _SID { - * UCHAR Revision; - * UCHAR SubAuthorityCount; - * SID_IDENTIFIER_AUTHORITY IdentifierAuthority; - * [size_is(SubAuthorityCount)] ULONG SubAuthority[*]; - * } SID, *PSID; - */ - - typedef struct { - uint8_t revision; - uint8_t sub_authority_count; - uint8_t identifier_authority[6]; - [size_is(sub_authority_count)] uint32_t sub_authority[*]; - } sid_t; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.java deleted file mode 100644 index caf9147307..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/dcerpc/rpc.java +++ /dev/null @@ -1,213 +0,0 @@ -package jcifs.dcerpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; - -public class rpc { - - public static class uuid_t extends NdrObject { - - public int time_low; - public short time_mid; - public short time_hi_and_version; - public byte clock_seq_hi_and_reserved; - public byte clock_seq_low; - public byte[] node; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(time_low); - _dst.enc_ndr_short(time_mid); - _dst.enc_ndr_short(time_hi_and_version); - _dst.enc_ndr_small(clock_seq_hi_and_reserved); - _dst.enc_ndr_small(clock_seq_low); - int _nodes = 6; - int _nodei = _dst.index; - _dst.advance(1 * _nodes); - - _dst = _dst.derive(_nodei); - for (int _i = 0; _i < _nodes; _i++) { - _dst.enc_ndr_small(node[_i]); - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - time_low = (int)_src.dec_ndr_long(); - time_mid = (short)_src.dec_ndr_short(); - time_hi_and_version = (short)_src.dec_ndr_short(); - clock_seq_hi_and_reserved = (byte)_src.dec_ndr_small(); - clock_seq_low = (byte)_src.dec_ndr_small(); - int _nodes = 6; - int _nodei = _src.index; - _src.advance(1 * _nodes); - - if (node == null) { - if (_nodes < 0 || _nodes > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - node = new byte[_nodes]; - } - _src = _src.derive(_nodei); - for (int _i = 0; _i < _nodes; _i++) { - node[_i] = (byte)_src.dec_ndr_small(); - } - } - } - public static class policy_handle extends NdrObject { - - public int type; - public uuid_t uuid; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_long(type); - _dst.enc_ndr_long(uuid.time_low); - _dst.enc_ndr_short(uuid.time_mid); - _dst.enc_ndr_short(uuid.time_hi_and_version); - _dst.enc_ndr_small(uuid.clock_seq_hi_and_reserved); - _dst.enc_ndr_small(uuid.clock_seq_low); - int _uuid_nodes = 6; - int _uuid_nodei = _dst.index; - _dst.advance(1 * _uuid_nodes); - - _dst = _dst.derive(_uuid_nodei); - for (int _i = 0; _i < _uuid_nodes; _i++) { - _dst.enc_ndr_small(uuid.node[_i]); - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - type = (int)_src.dec_ndr_long(); - _src.align(4); - if (uuid == null) { - uuid = new uuid_t(); - } - uuid.time_low = (int)_src.dec_ndr_long(); - uuid.time_mid = (short)_src.dec_ndr_short(); - uuid.time_hi_and_version = (short)_src.dec_ndr_short(); - uuid.clock_seq_hi_and_reserved = (byte)_src.dec_ndr_small(); - uuid.clock_seq_low = (byte)_src.dec_ndr_small(); - int _uuid_nodes = 6; - int _uuid_nodei = _src.index; - _src.advance(1 * _uuid_nodes); - - if (uuid.node == null) { - if (_uuid_nodes < 0 || _uuid_nodes > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - uuid.node = new byte[_uuid_nodes]; - } - _src = _src.derive(_uuid_nodei); - for (int _i = 0; _i < _uuid_nodes; _i++) { - uuid.node[_i] = (byte)_src.dec_ndr_small(); - } - } - } - public static class unicode_string extends NdrObject { - - public short length; - public short maximum_length; - public short[] buffer; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - _dst.enc_ndr_short(length); - _dst.enc_ndr_short(maximum_length); - _dst.enc_ndr_referent(buffer, 1); - - if (buffer != null) { - _dst = _dst.deferred; - int _bufferl = length / 2; - int _buffers = maximum_length / 2; - _dst.enc_ndr_long(_buffers); - _dst.enc_ndr_long(0); - _dst.enc_ndr_long(_bufferl); - int _bufferi = _dst.index; - _dst.advance(2 * _bufferl); - - _dst = _dst.derive(_bufferi); - for (int _i = 0; _i < _bufferl; _i++) { - _dst.enc_ndr_short(buffer[_i]); - } - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - length = (short)_src.dec_ndr_short(); - maximum_length = (short)_src.dec_ndr_short(); - int _bufferp = _src.dec_ndr_long(); - - if (_bufferp != 0) { - _src = _src.deferred; - int _buffers = _src.dec_ndr_long(); - _src.dec_ndr_long(); - int _bufferl = _src.dec_ndr_long(); - int _bufferi = _src.index; - _src.advance(2 * _bufferl); - - if (buffer == null) { - if (_buffers < 0 || _buffers > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - buffer = new short[_buffers]; - } - _src = _src.derive(_bufferi); - for (int _i = 0; _i < _bufferl; _i++) { - buffer[_i] = (short)_src.dec_ndr_short(); - } - } - } - } - public static class sid_t extends NdrObject { - - public byte revision; - public byte sub_authority_count; - public byte[] identifier_authority; - public int[] sub_authority; - - public void encode(NdrBuffer _dst) throws NdrException { - _dst.align(4); - int _sub_authoritys = sub_authority_count; - _dst.enc_ndr_long(_sub_authoritys); - _dst.enc_ndr_small(revision); - _dst.enc_ndr_small(sub_authority_count); - int _identifier_authoritys = 6; - int _identifier_authorityi = _dst.index; - _dst.advance(1 * _identifier_authoritys); - int _sub_authorityi = _dst.index; - _dst.advance(4 * _sub_authoritys); - - _dst = _dst.derive(_identifier_authorityi); - for (int _i = 0; _i < _identifier_authoritys; _i++) { - _dst.enc_ndr_small(identifier_authority[_i]); - } - _dst = _dst.derive(_sub_authorityi); - for (int _i = 0; _i < _sub_authoritys; _i++) { - _dst.enc_ndr_long(sub_authority[_i]); - } - } - public void decode(NdrBuffer _src) throws NdrException { - _src.align(4); - int _sub_authoritys = _src.dec_ndr_long(); - revision = (byte)_src.dec_ndr_small(); - sub_authority_count = (byte)_src.dec_ndr_small(); - int _identifier_authoritys = 6; - int _identifier_authorityi = _src.index; - _src.advance(1 * _identifier_authoritys); - int _sub_authorityi = _src.index; - _src.advance(4 * _sub_authoritys); - - if (identifier_authority == null) { - if (_identifier_authoritys < 0 || _identifier_authoritys > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - identifier_authority = new byte[_identifier_authoritys]; - } - _src = _src.derive(_identifier_authorityi); - for (int _i = 0; _i < _identifier_authoritys; _i++) { - identifier_authority[_i] = (byte)_src.dec_ndr_small(); - } - if (sub_authority == null) { - if (_sub_authoritys < 0 || _sub_authoritys > 0xFFFF) throw new NdrException( NdrException.INVALID_CONFORMANCE ); - sub_authority = new int[_sub_authoritys]; - } - _src = _src.derive(_sub_authorityi); - for (int _i = 0; _i < _sub_authoritys; _i++) { - sub_authority[_i] = (int)_src.dec_ndr_long(); - } - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/Handler.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/Handler.java deleted file mode 100644 index b10f9c86b7..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/Handler.java +++ /dev/null @@ -1,157 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -import java.net.URLStreamHandlerFactory; -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -/** - * A URLStreamHandlerused to provide NTLM authentication - * capabilities to the default HTTP handler. This acts as a wrapper, - * handling authentication and passing control to the underlying - * stream handler. - */ -public class Handler extends URLStreamHandler { - - /** - * The default HTTP port (80). - */ - public static final int DEFAULT_HTTP_PORT = 80; - - private static final Map PROTOCOL_HANDLERS = new HashMap(); - - private static final String HANDLER_PKGS_PROPERTY = - "java.protocol.handler.pkgs"; - - /** - * Vendor-specific default packages. If no packages are specified in - * "java.protocol.handler.pkgs", the VM uses one or more default - * packages, which are vendor specific. Sun's is included below - * for convenience; others could be as well. If a particular vendor's - * package isn't listed, it can be specified in - * "java.protocol.handler.pkgs". - */ - private static final String[] JVM_VENDOR_DEFAULT_PKGS = new String[] { - "sun.net.www.protocol" - }; - - private static URLStreamHandlerFactory factory; - - /** - * Sets the URL stream handler factory for the environment. This - * allows specification of the factory used in creating underlying - * stream handlers. This can be called once per JVM instance. - * - * @param factory The URL stream handler factory. - */ - public static void setURLStreamHandlerFactory( - URLStreamHandlerFactory factory) { - synchronized (PROTOCOL_HANDLERS) { - if (Handler.factory != null) { - throw new IllegalStateException( - "URLStreamHandlerFactory already set."); - } - PROTOCOL_HANDLERS.clear(); - Handler.factory = factory; - } - } - - /** - * Returns the default HTTP port. - * - * @return Anintcontaining the default HTTP port. - */ - protected int getDefaultPort() { - return DEFAULT_HTTP_PORT; - } - - protected URLConnection openConnection(URL url) throws IOException { - url = new URL(url, url.toExternalForm(), - getDefaultStreamHandler(url.getProtocol())); - return new NtlmHttpURLConnection((HttpURLConnection) - url.openConnection()); - } - - private static URLStreamHandler getDefaultStreamHandler(String protocol) - throws IOException { - synchronized (PROTOCOL_HANDLERS) { - URLStreamHandler handler = (URLStreamHandler) - PROTOCOL_HANDLERS.get(protocol); - if (handler != null) return handler; - if (factory != null) { - handler = factory.createURLStreamHandler(protocol); - } - if (handler == null) { - String path = System.getProperty(HANDLER_PKGS_PROPERTY); - StringTokenizer tokenizer = new StringTokenizer(path, "|"); - while (tokenizer.hasMoreTokens()) { - String provider = tokenizer.nextToken().trim(); - if (provider.equals("jcifs")) continue; - String className = provider + "." + protocol + ".Handler"; - try { - Class handlerClass = null; - try { - handlerClass = Class.forName(className); - } catch (Exception ex) { } - if (handlerClass == null) { - handlerClass = ClassLoader.getSystemClassLoader( - ).loadClass(className); - } - handler = (URLStreamHandler) handlerClass.newInstance(); - break; - } catch (Exception ex) { } - } - } - if (handler == null) { - for (int i = 0; i < JVM_VENDOR_DEFAULT_PKGS.length; i++) { - String className = JVM_VENDOR_DEFAULT_PKGS[i] + "." + - protocol + ".Handler"; - try { - Class handlerClass = null; - try { - handlerClass = Class.forName(className); - } catch (Exception ex) { } - if (handlerClass == null) { - handlerClass = ClassLoader.getSystemClassLoader( - ).loadClass(className); - } - handler = (URLStreamHandler) handlerClass.newInstance(); - } catch (Exception ex) { } - if (handler != null) break; - } - } - if (handler == null) { - throw new IOException( - "Unable to find default handler for protocol: " + - protocol); - } - PROTOCOL_HANDLERS.put(protocol, handler); - return handler; - } - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NetworkExplorer.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NetworkExplorer.java deleted file mode 100644 index b4df237167..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NetworkExplorer.java +++ /dev/null @@ -1,552 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.netbios.NbtAddress; -import jcifs.smb.DfsReferral; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbAuthException; -import jcifs.smb.SmbException; -import jcifs.smb.SmbFile; -import jcifs.smb.SmbFileInputStream; -import jcifs.smb.SmbSession; -import jcifs.util.Base64; -import jcifs.util.LogStream; -import jcifs.util.MimeMap; - -import javax.servlet.ServletException; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Enumeration; -import java.util.GregorianCalendar; -import java.util.LinkedList; -import java.util.ListIterator; - -/** - * This servlet may be used to "browse" the entire hierarchy of resources - * on an SMB network like one might with Network Neighborhood or Windows - * Explorer. The users credentials with be negotiated using NTLM SSP if - * the client is Microsoft Internet Explorer. - */ - -public class NetworkExplorer extends HttpServlet { - - private static LogStream log = LogStream.getInstance(); - - private MimeMap mimeMap; - private String style; - private NtlmSsp ntlmSsp; - private boolean credentialsSupplied; - private boolean enableBasic; - private boolean insecureBasic; - private String realm, defaultDomain; - - public void init() throws ServletException { - InputStream is; - StringBuffer sb = new StringBuffer(); - byte[] buf = new byte[1024]; - int n, level; - String name; - - Config.setProperty( "jcifs.smb.client.soTimeout", "600000" ); - Config.setProperty( "jcifs.smb.client.attrExpirationPeriod", "300000" ); - - Enumeration e = getInitParameterNames(); - while( e.hasMoreElements() ) { - name = (String)e.nextElement(); - if( name.startsWith( "jcifs." )) { - Config.setProperty( name, getInitParameter( name )); - } - } - - if( Config.getProperty( "jcifs.smb.client.username" ) == null ) { - ntlmSsp = new NtlmSsp(); - } else { - credentialsSupplied = true; - } - - try { - mimeMap = new MimeMap(); - is = getClass().getClassLoader().getResourceAsStream( "jcifs/http/ne.css" ); - while(( n = is.read( buf )) != -1 ) { - sb.append( new String( buf, 0, n, "ISO8859_1" )); - } - style = sb.toString(); - } catch( IOException ioe ) { - throw new ServletException( ioe.getMessage() ); - } - - enableBasic = Config.getBoolean("jcifs.http.enableBasic", false ); - insecureBasic = Config.getBoolean("jcifs.http.insecureBasic", false ); - realm = Config.getProperty("jcifs.http.basicRealm"); - if (realm == null) realm = "jCIFS"; - defaultDomain = Config.getProperty("jcifs.smb.client.domain"); - - if(( level = Config.getInt( "jcifs.util.loglevel", -1 )) != -1 ) { - LogStream.setLevel( level ); - } - if( log.level > 2 ) { - try { - Config.store( log, "JCIFS PROPERTIES" ); - } catch( IOException ioe ) { - } - } - } - - protected void doFile( HttpServletRequest req, - HttpServletResponse resp, SmbFile file ) throws IOException { - byte[] buf = new byte[8192]; - SmbFileInputStream in; - ServletOutputStream out; - String url, type; - int n; - - in = new SmbFileInputStream( file ); - out = resp.getOutputStream(); - url = file.getPath(); - - resp.setContentType( "text/plain" ); - - if(( n = url.lastIndexOf( '.' )) > 0 && - ( type = url.substring( n + 1 )) != null && - type.length() > 1 && type.length() < 6 ) { - resp.setContentType( mimeMap.getMimeType( type )); - } - resp.setHeader( "Content-Length", file.length() + "" ); - resp.setHeader( "Accept-Ranges", "Bytes" ); - - while(( n = in.read( buf )) != -1 ) { - out.write( buf, 0, n ); - } - } - protected int compareNames( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { - if( f1.isDirectory() != f2.isDirectory() ) { - return f1.isDirectory() ? -1 : 1; - } - return f1name.compareToIgnoreCase( f2.getName() ); - } - protected int compareSizes( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { - long diff; - - if( f1.isDirectory() != f2.isDirectory() ) { - return f1.isDirectory() ? -1 : 1; - } - if( f1.isDirectory() ) { - return f1name.compareToIgnoreCase( f2.getName() ); - } - diff = f1.length() - f2.length(); - if( diff == 0 ) { - return f1name.compareToIgnoreCase( f2.getName() ); - } - return diff > 0 ? -1 : 1; - } - protected int compareTypes( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { - String f2name, t1, t2; - int i; - - if( f1.isDirectory() != f2.isDirectory() ) { - return f1.isDirectory() ? -1 : 1; - } - f2name = f2.getName(); - if( f1.isDirectory() ) { - return f1name.compareToIgnoreCase( f2name ); - } - i = f1name.lastIndexOf( '.' ); - t1 = i == -1 ? "" : f1name.substring( i + 1 ); - i = f2name.lastIndexOf( '.' ); - t2 = i == -1 ? "" : f2name.substring( i + 1 ); - - i = t1.compareToIgnoreCase( t2 ); - if( i == 0 ) { - return f1name.compareToIgnoreCase( f2name ); - } - return i; - } - protected int compareDates( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { - if( f1.isDirectory() != f2.isDirectory() ) { - return f1.isDirectory() ? -1 : 1; - } - if( f1.isDirectory() ) { - return f1name.compareToIgnoreCase( f2.getName() ); - } - return f1.lastModified() > f2.lastModified() ? -1 : 1; - } - protected void doDirectory( HttpServletRequest req, HttpServletResponse resp, SmbFile dir ) throws IOException { - PrintWriter out; - SmbFile[] dirents; - SmbFile f; - int i, j, len, maxLen, dirCount, fileCount, sort; - String str, name, path, fmt; - LinkedList sorted; - ListIterator iter; - SimpleDateFormat sdf = new SimpleDateFormat( "MM/d/yy h:mm a" ); - GregorianCalendar cal = new GregorianCalendar(); - - sdf.setCalendar( cal ); - - dirents = dir.listFiles(); - if( log.level > 2 ) - log.println( dirents.length + " items listed" ); - sorted = new LinkedList(); - if(( fmt = req.getParameter( "fmt" )) == null ) { - fmt = "col"; - } - sort = 0; - if(( str = req.getParameter( "sort" )) == null || str.equals( "name" )) { - sort = 0; - } else if( str.equals( "size" )) { - sort = 1; - } else if( str.equals( "type" )) { - sort = 2; - } else if( str.equals( "date" )) { - sort = 3; - } - dirCount = fileCount = 0; - maxLen = 28; - for( i = 0; i < dirents.length; i++ ) { - try { - if( dirents[i].getType() == SmbFile.TYPE_NAMED_PIPE ) { - continue; - } - } catch( SmbAuthException sae ) { - if( log.level > 2 ) - sae.printStackTrace( log ); - } catch( SmbException se ) { - if( log.level > 2 ) - se.printStackTrace( log ); - if( se.getNtStatus() != se.NT_STATUS_UNSUCCESSFUL ) { - throw se; - } - } - if( dirents[i].isDirectory() ) { - dirCount++; - } else { - fileCount++; - } - - name = dirents[i].getName(); - if( log.level > 3 ) - log.println( i + ": " + name ); - len = name.length(); - if( len > maxLen ) { - maxLen = len; - } - - iter = sorted.listIterator(); - for( j = 0; iter.hasNext(); j++ ) { - if( sort == 0 ) { - if( compareNames( dirents[i], name, (SmbFile)iter.next() ) < 0 ) { - break; - } - } else if( sort == 1 ) { - if( compareSizes( dirents[i], name, (SmbFile)iter.next() ) < 0 ) { - break; - } - } else if( sort == 2 ) { - if( compareTypes( dirents[i], name, (SmbFile)iter.next() ) < 0 ) { - break; - } - } else if( sort == 3 ) { - if( compareDates( dirents[i], name, (SmbFile)iter.next() ) < 0 ) { - break; - } - } - } - sorted.add( j, dirents[i] ); - } - if( maxLen > 50 ) { - maxLen = 50; - } - maxLen *= 9; /* convert to px */ - - out = resp.getWriter(); - - resp.setContentType( "text/html" ); - - out.println( "" ); - out.println( " Network Explorer " ); - out.println( "" ); - out.println( "" ); - out.println( "" ); - - out.print( "Name" ); - out.println( "Size" ); - out.println( "Type" ); - out.println( "Modified" ); - - path = dir.getCanonicalPath(); - - if( path.length() < 7 ) { - out.println( "smb://
" ); - path = "."; - } else { - out.println( "" + path + "
" ); - path = "../"; - } - out.println( (dirCount + fileCount) + " objects (" + dirCount + " directories, " + fileCount + " files)
" ); - out.println( "normal | detailed" ); - out.println( "" ); - out.println( "" ); - out.close(); - } - private String parseServerAndShare( String pathInfo ) { - char[] out = new char[256]; - char ch; - int len, p, i; - - if( pathInfo == null ) { - return null; - } - len = pathInfo.length(); - - p = i = 0; - while( p < len && pathInfo.charAt( p ) == '/' ) { - p++; - } - if( p == len ) { - return null; - } - - /* collect server name */ - while ( p < len && ( ch = pathInfo.charAt( p )) != '/' ) { - out[i++] = ch; - p++; - } - while( p < len && pathInfo.charAt( p ) == '/' ) { - p++; - } - if( p < len ) { /* then there must be a share */ - out[i++] = '/'; - do { /* collect the share name */ - out[i++] = (ch = pathInfo.charAt( p++ )); - } while( p < len && ch != '/' ); - } - return new String( out, 0, i ); - } - public void doGet( HttpServletRequest req, - HttpServletResponse resp ) throws IOException, ServletException { - UniAddress dc; - String msg, pathInfo, server = null; - boolean offerBasic, possibleWorkgroup = true; - NtlmPasswordAuthentication ntlm = null; - HttpSession ssn = req.getSession( false ); - - if(( pathInfo = req.getPathInfo() ) != null ) { - int i; - server = parseServerAndShare( pathInfo ); - if( server != null && ( i = server.indexOf( '/' )) > 0 ) { - server = server.substring( 0, i ).toLowerCase(); - possibleWorkgroup = false; - } - } - - msg = req.getHeader( "Authorization" ); - offerBasic = enableBasic && (insecureBasic || req.isSecure()); - - if( msg != null && (msg.startsWith( "NTLM " ) || - (offerBasic && msg.startsWith("Basic ")))) { - - if( msg.startsWith("NTLM ")) { - byte[] challenge; - - if( pathInfo == null || server == null ) { - String mb = NbtAddress.getByName( NbtAddress.MASTER_BROWSER_NAME, 0x01, null ).getHostAddress(); - dc = UniAddress.getByName( mb ); - } else { - dc = UniAddress.getByName( server, possibleWorkgroup ); - } - - req.getSession(); /* ensure session id is set for cluster env. */ - challenge = SmbSession.getChallenge( dc ); - if(( ntlm = NtlmSsp.authenticate( req, resp, challenge )) == null ) { - return; - } - } else { /* Basic */ - String auth = new String( Base64.decode( msg.substring(6) ), "US-ASCII" ); - int index = auth.indexOf( ':' ); - String user = (index != -1) ? auth.substring(0, index) : auth; - String password = (index != -1) ? auth.substring(index + 1) : ""; - index = user.indexOf('\\'); - if (index == -1) index = user.indexOf('/'); - String domain = (index != -1) ? user.substring(0, index) : defaultDomain; - user = (index != -1) ? user.substring(index + 1) : user; - ntlm = new NtlmPasswordAuthentication(domain, user, password); - } - - req.getSession().setAttribute( "npa-" + server, ntlm ); - - } else if( !credentialsSupplied ) { - if( ssn != null ) { - ntlm = (NtlmPasswordAuthentication)ssn.getAttribute( "npa-" + server ); - } - if( ntlm == null ) { - resp.setHeader( "WWW-Authenticate", "NTLM" ); - if (offerBasic) { - resp.addHeader( "WWW-Authenticate", "Basic realm=\"" + realm + "\""); - } - resp.setHeader( "Connection", "close" ); - resp.setStatus( HttpServletResponse.SC_UNAUTHORIZED ); - resp.flushBuffer(); - return; - } - } - - try { - SmbFile file; - - if( ntlm != null ) { - file = new SmbFile( "smb:/" + pathInfo , ntlm ); - } else if( server == null ) { - file = new SmbFile( "smb://" ); - } else { - file = new SmbFile( "smb:/" + pathInfo ); - } - - if( file.isDirectory() ) { - doDirectory( req, resp, file ); - } else { - doFile( req, resp, file ); - } - } catch( SmbAuthException sae ) { - if( ssn != null ) { - ssn.removeAttribute( "npa-" + server ); - } - if( sae.getNtStatus() == sae.NT_STATUS_ACCESS_VIOLATION ) { - /* Server challenge no longer valid for - * externally supplied password hashes. - */ - resp.sendRedirect( req.getRequestURL().toString() ); - return; - } - resp.setHeader( "WWW-Authenticate", "NTLM" ); - if (offerBasic) { - resp.addHeader( "WWW-Authenticate", "Basic realm=\"" + realm + "\""); - } - resp.setHeader( "Connection", "close" ); - resp.setStatus( HttpServletResponse.SC_UNAUTHORIZED ); - resp.flushBuffer(); - return; - } catch( DfsReferral dr ) { - StringBuffer redir = req.getRequestURL(); - String qs = req.getQueryString(); - redir = new StringBuffer( redir.substring( 0, redir.length() - req.getPathInfo().length() )); - redir.append( '/' ); - redir.append(dr.server); - redir.append( '/' ); - redir.append(dr.share); - redir.append( '/' ); - if( qs != null ) { - redir.append( req.getQueryString() ); - } - resp.sendRedirect( redir.toString() ); - resp.flushBuffer(); - return; - } - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpFilter.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpFilter.java deleted file mode 100644 index ba1a509fe4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpFilter.java +++ /dev/null @@ -1,261 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
" ); - - out.print( "↑" ); - if( fmt.equals( "detail" )) { - out.println( "
" ); - } - - if( path.length() == 1 || dir.getType() != SmbFile.TYPE_WORKGROUP ) { - path = ""; - } - - iter = sorted.listIterator(); - while( iter.hasNext() ) { - f = (SmbFile)iter.next(); - name = f.getName(); - - if( fmt.equals( "detail" )) { - out.print( "" ); - out.print( name ); - out.print( "" ); - } else { - out.print( "\">" ); - out.print( name ); - out.print( "" ); - out.print( (f.length() / 1024) + " KB" ); - i = name.lastIndexOf( '.' ) + 1; - if( i > 1 && (name.length() - i) < 6 ) { - out.print( name.substring( i ).toUpperCase() + "" ); - } else { - out.print( " " ); - } - out.print( "" ); - out.print( sdf.format( new Date( f.lastModified() ))); - out.print( "" ); - } - out.println( "
" ); - } else { - out.print( "" ); - out.print( name ); - out.print( "" ); - } else { - out.print( ";\" HREF=\"" ); - out.print( path ); - out.print( name ); - out.print( "\">" ); - out.print( name ); - out.print( "
" ); - out.print( (f.length() / 1024) + "KB
" ); - out.print( sdf.format( new Date( f.lastModified() ))); - out.print( "" ); - out.println( "" ); - } - } - } - - out.println( "- * "Jason Pugsley" - * "skeetz" - * "Eric Glass" - * and Marcel, Thomas, ... - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.smb.NtlmChallenge; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbAuthException; -import jcifs.smb.SmbSession; -import jcifs.util.Base64; -import jcifs.util.LogStream; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; -import java.util.Enumeration; - -/** - * This servlet Filter can be used to negotiate password hashes with - * MSIE clients using NTLM SSP. This is similar to Authentication: - * BASIC but weakly encrypted and without requiring the user to re-supply - * authentication credentials. - * - * Read jCIFS NTLM HTTP Authentication and the Network Explorer Servlet for complete details. - */ - -public class NtlmHttpFilter implements Filter { - - private static LogStream log = LogStream.getInstance(); - - private String defaultDomain; - private String domainController; - private boolean loadBalance; - private boolean enableBasic; - private boolean insecureBasic; - private String realm; - - public void init( FilterConfig filterConfig ) throws ServletException { - String name; - int level; - - /* Set jcifs properties we know we want; soTimeout and cachePolicy to 30min. - */ - Config.setProperty( "jcifs.smb.client.soTimeout", "1800000" ); - Config.setProperty( "jcifs.netbios.cachePolicy", "1200" ); - /* The Filter can only work with NTLMv1 as it uses a man-in-the-middle - * techinque that NTLMv2 specifically thwarts. A real NTLM Filter would - * need to do a NETLOGON RPC that JCIFS will likely never implement - * because it requires a lot of extra crypto not used by CIFS. - */ - Config.setProperty( "jcifs.smb.lmCompatibility", "0" ); - Config.setProperty( "jcifs.smb.client.useExtendedSecurity", "false" ); - - Enumeration e = filterConfig.getInitParameterNames(); - while( e.hasMoreElements() ) { - name = (String)e.nextElement(); - if( name.startsWith( "jcifs." )) { - Config.setProperty( name, filterConfig.getInitParameter( name )); - } - } - defaultDomain = Config.getProperty("jcifs.smb.client.domain"); - domainController = Config.getProperty( "jcifs.http.domainController" ); - if( domainController == null ) { - domainController = defaultDomain; - loadBalance = Config.getBoolean( "jcifs.http.loadBalance", true ); - } - enableBasic = Boolean.valueOf( - Config.getProperty("jcifs.http.enableBasic")).booleanValue(); - insecureBasic = Boolean.valueOf( - Config.getProperty("jcifs.http.insecureBasic")).booleanValue(); - realm = Config.getProperty("jcifs.http.basicRealm"); - if (realm == null) realm = "jCIFS"; - - if(( level = Config.getInt( "jcifs.util.loglevel", -1 )) != -1 ) { - LogStream.setLevel( level ); - } - if( log.level > 2 ) { - try { - Config.store( log, "JCIFS PROPERTIES" ); - } catch( IOException ioe ) { - } - } - } - - public void destroy() { - } - - /** - * This method simply calls negotiate( req, resp, false ) - * and then chain.doFilter. You can override and call - * negotiate manually to achive a variety of different behavior. - */ - public void doFilter( ServletRequest request, - ServletResponse response, - FilterChain chain ) throws IOException, ServletException { - HttpServletRequest req = (HttpServletRequest)request; - HttpServletResponse resp = (HttpServletResponse)response; - NtlmPasswordAuthentication ntlm; - - if ((ntlm = negotiate( req, resp, false )) == null) { - return; - } - - chain.doFilter( new NtlmHttpServletRequest( req, ntlm ), response ); - } - - /** - * Negotiate password hashes with MSIE clients using NTLM SSP - * @param req The servlet request - * @param resp The servlet response - * @param skipAuthentication If true the negotiation is only done if it is - * initiated by the client (MSIE post requests after successful NTLM SSP - * authentication). If false and the user has not been authenticated yet - * the client will be forced to send an authentication (server sends - * HttpServletResponse.SC_UNAUTHORIZED). - * @return True if the negotiation is complete, otherwise false - */ - protected NtlmPasswordAuthentication negotiate( HttpServletRequest req, - HttpServletResponse resp, - boolean skipAuthentication ) throws IOException, ServletException { - UniAddress dc; - String msg; - NtlmPasswordAuthentication ntlm = null; - msg = req.getHeader( "Authorization" ); - boolean offerBasic = enableBasic && (insecureBasic || req.isSecure()); - - if( msg != null && (msg.startsWith( "NTLM " ) || - (offerBasic && msg.startsWith("Basic ")))) { - if (msg.startsWith("NTLM ")) { - HttpSession ssn = req.getSession(); - byte[] challenge; - - if( loadBalance ) { - NtlmChallenge chal = (NtlmChallenge)ssn.getAttribute( "NtlmHttpChal" ); - if( chal == null ) { - chal = SmbSession.getChallengeForDomain(); - ssn.setAttribute( "NtlmHttpChal", chal ); - } - dc = chal.dc; - challenge = chal.challenge; - } else { - dc = UniAddress.getByName( domainController, true ); - challenge = SmbSession.getChallenge( dc ); - } - - if(( ntlm = NtlmSsp.authenticate( req, resp, challenge )) == null ) { - return null; - } - /* negotiation complete, remove the challenge object */ - ssn.removeAttribute( "NtlmHttpChal" ); - } else { - String auth = new String(Base64.decode(msg.substring(6)), - "US-ASCII"); - int index = auth.indexOf(':'); - String user = (index != -1) ? auth.substring(0, index) : auth; - String password = (index != -1) ? auth.substring(index + 1) : - ""; - index = user.indexOf('\\'); - if (index == -1) index = user.indexOf('/'); - String domain = (index != -1) ? user.substring(0, index) : - defaultDomain; - user = (index != -1) ? user.substring(index + 1) : user; - ntlm = new NtlmPasswordAuthentication(domain, user, password); - dc = UniAddress.getByName( domainController, true ); - } - try { - - SmbSession.logon( dc, ntlm ); - - if( log.level > 2 ) { - log.println( "NtlmHttpFilter: " + ntlm + - " successfully authenticated against " + dc ); - } - } catch( SmbAuthException sae ) { - if( log.level > 1 ) { - log.println( "NtlmHttpFilter: " + ntlm.getName() + - ": 0x" + jcifs.util.Hexdump.toHexString( sae.getNtStatus(), 8 ) + - ": " + sae ); - } - if( sae.getNtStatus() == sae.NT_STATUS_ACCESS_VIOLATION ) { - /* Server challenge no longer valid for - * externally supplied password hashes. - */ - HttpSession ssn = req.getSession(false); - if (ssn != null) { - ssn.removeAttribute( "NtlmHttpAuth" ); - } - } - resp.setHeader( "WWW-Authenticate", "NTLM" ); - if (offerBasic) { - resp.addHeader( "WWW-Authenticate", "Basic realm=\"" + - realm + "\""); - } - resp.setStatus( HttpServletResponse.SC_UNAUTHORIZED ); - resp.setContentLength(0); /* Marcel Feb-15-2005 */ - resp.flushBuffer(); - return null; - } - req.getSession().setAttribute( "NtlmHttpAuth", ntlm ); - } else { - if (!skipAuthentication) { - HttpSession ssn = req.getSession(false); - if (ssn == null || (ntlm = (NtlmPasswordAuthentication) - ssn.getAttribute("NtlmHttpAuth")) == null) { - resp.setHeader( "WWW-Authenticate", "NTLM" ); - if (offerBasic) { - resp.addHeader( "WWW-Authenticate", "Basic realm=\"" + - realm + "\""); - } - resp.setStatus( HttpServletResponse.SC_UNAUTHORIZED ); - resp.setContentLength(0); - resp.flushBuffer(); - return null; - } - } - } - - return ntlm; - } - - // Added by cgross to work with weblogic 6.1. - public void setFilterConfig( FilterConfig f ) { - try { - init( f ); - } catch( Exception e ) { - e.printStackTrace(); - } - } - public FilterConfig getFilterConfig() { - return null; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpServletRequest.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpServletRequest.java deleted file mode 100644 index 7f03c89109..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpServletRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import java.security.Principal; - -class NtlmHttpServletRequest extends HttpServletRequestWrapper { - - Principal principal; - - NtlmHttpServletRequest( HttpServletRequest req, Principal principal ) { - super( req ); - this.principal = principal; - } - public String getRemoteUser() { - return principal.getName(); - } - public Principal getUserPrincipal() { - return principal; - } - public String getAuthType() { - return "NTLM"; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpURLConnection.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpURLConnection.java deleted file mode 100644 index c3d5786bbc..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmHttpURLConnection.java +++ /dev/null @@ -1,628 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import jcifs.Config; -import jcifs.ntlmssp.NtlmFlags; -import jcifs.ntlmssp.NtlmMessage; -import jcifs.ntlmssp.Type1Message; -import jcifs.ntlmssp.Type2Message; -import jcifs.ntlmssp.Type3Message; -import jcifs.util.Base64; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.Authenticator; -import java.net.HttpURLConnection; -import java.net.PasswordAuthentication; -import java.net.ProtocolException; -import java.net.URL; -import java.net.URLDecoder; -import java.security.Permission; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Wraps an HttpURLConnectionto provide NTLM authentication - * services. - * - * Please read Using jCIFS NTLM Authentication for HTTP Connections. - */ -public class NtlmHttpURLConnection extends HttpURLConnection { - - private static final int MAX_REDIRECTS = - Integer.parseInt(System.getProperty("http.maxRedirects", "20")); - - private static final int LM_COMPATIBILITY = - Config.getInt("jcifs.smb.lmCompatibility", 0); - - private static final String DEFAULT_DOMAIN; - - private HttpURLConnection connection; - - private Map requestProperties; - - private Map headerFields; - - private ByteArrayOutputStream cachedOutput; - - private String authProperty; - - private String authMethod; - - private boolean handshakeComplete; - - static { - String domain = System.getProperty("http.auth.ntlm.domain"); - if (domain == null) domain = Type3Message.getDefaultDomain(); - DEFAULT_DOMAIN = domain; - } - - public NtlmHttpURLConnection(HttpURLConnection connection) { - super(connection.getURL()); - this.connection = connection; - requestProperties = new HashMap(); - } - - public void connect() throws IOException { - if (connected) return; - connection.connect(); - connected = true; - } - - private void handshake() throws IOException { - if (handshakeComplete) return; - doHandshake(); - handshakeComplete = true; - } - - public URL getURL() { - return connection.getURL(); - } - - public int getContentLength() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getContentLength(); - } - - public String getContentType() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getContentType(); - } - - public String getContentEncoding() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getContentEncoding(); - } - - public long getExpiration() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getExpiration(); - } - - public long getDate() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getDate(); - } - - public long getLastModified() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getLastModified(); - } - - public String getHeaderField(String header) { - try { - handshake(); - } catch (IOException ex) { } - return connection.getHeaderField(header); - } - - private Map getHeaderFields0() { - if (headerFields != null) return headerFields; - Map map = new HashMap(); - String key = connection.getHeaderFieldKey(0); - String value = connection.getHeaderField(0); - for (int i = 1; key != null || value != null; i++) { - List values = (List) map.get(key); - if (values == null) { - values = new ArrayList(); - map.put(key, values); - } - values.add(value); - key = connection.getHeaderFieldKey(i); - value = connection.getHeaderField(i); - } - Iterator entries = map.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); - entry.setValue(Collections.unmodifiableList((List) - entry.getValue())); - } - return (headerFields = Collections.unmodifiableMap(map)); - } - - public Map getHeaderFields() { - if (headerFields != null) return headerFields; - try { - handshake(); - } catch (IOException ex) { } - return getHeaderFields0(); - } - - public int getHeaderFieldInt(String header, int def) { - try { - handshake(); - } catch (IOException ex) { } - return connection.getHeaderFieldInt(header, def); - } - - public long getHeaderFieldDate(String header, long def) { - try { - handshake(); - } catch (IOException ex) { } - return connection.getHeaderFieldDate(header, def); - } - - public String getHeaderFieldKey(int index) { - try { - handshake(); - } catch (IOException ex) { } - return connection.getHeaderFieldKey(index); - } - - public String getHeaderField(int index) { - try { - handshake(); - } catch (IOException ex) { } - return connection.getHeaderField(index); - } - - public Object getContent() throws IOException { - try { - handshake(); - } catch (IOException ex) { } - return connection.getContent(); - } - - public Object getContent(Class[] classes) throws IOException { - try { - handshake(); - } catch (IOException ex) { } - return connection.getContent(classes); - } - - public Permission getPermission() throws IOException { - return connection.getPermission(); - } - - public InputStream getInputStream() throws IOException { - try { - handshake(); - } catch (IOException ex) { } - return connection.getInputStream(); - } - - public OutputStream getOutputStream() throws IOException { - try { - connect(); - } catch (IOException ex) { } - OutputStream output = connection.getOutputStream(); - cachedOutput = new ByteArrayOutputStream(); - return new CacheStream(output, cachedOutput); - } - - public String toString() { - return connection.toString(); - } - - public void setDoInput(boolean doInput) { - connection.setDoInput(doInput); - this.doInput = doInput; - } - - public boolean getDoInput() { - return connection.getDoInput(); - } - - public void setDoOutput(boolean doOutput) { - connection.setDoOutput(doOutput); - this.doOutput = doOutput; - } - - public boolean getDoOutput() { - return connection.getDoOutput(); - } - - public void setAllowUserInteraction(boolean allowUserInteraction) { - connection.setAllowUserInteraction(allowUserInteraction); - this.allowUserInteraction = allowUserInteraction; - } - - public boolean getAllowUserInteraction() { - return connection.getAllowUserInteraction(); - } - - public void setUseCaches(boolean useCaches) { - connection.setUseCaches(useCaches); - this.useCaches = useCaches; - } - - public boolean getUseCaches() { - return connection.getUseCaches(); - } - - public void setIfModifiedSince(long ifModifiedSince) { - connection.setIfModifiedSince(ifModifiedSince); - this.ifModifiedSince = ifModifiedSince; - } - - public long getIfModifiedSince() { - return connection.getIfModifiedSince(); - } - - public boolean getDefaultUseCaches() { - return connection.getDefaultUseCaches(); - } - - public void setDefaultUseCaches(boolean defaultUseCaches) { - connection.setDefaultUseCaches(defaultUseCaches); - } - - public void setRequestProperty(String key, String value) { - if (key == null) throw new NullPointerException(); - List values = new ArrayList(); - values.add(value); - boolean found = false; - Iterator entries = requestProperties.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); - if (key.equalsIgnoreCase((String) entry.getKey())) { - entry.setValue(values); - found = true; - break; - } - } - if (!found) requestProperties.put(key, values); - connection.setRequestProperty(key, value); - } - - public void addRequestProperty(String key, String value) { - if (key == null) throw new NullPointerException(); - List values = null; - Iterator entries = requestProperties.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); - if (key.equalsIgnoreCase((String) entry.getKey())) { - values = (List) entry.getValue(); - values.add(value); - break; - } - } - if (values == null) { - values = new ArrayList(); - values.add(value); - requestProperties.put(key, values); - } - // 1.3-compatible. - StringBuffer buffer = new StringBuffer(); - Iterator propertyValues = values.iterator(); - while (propertyValues.hasNext()) { - buffer.append(propertyValues.next()); - if (propertyValues.hasNext()) { - buffer.append(", "); - } - } - connection.setRequestProperty(key, buffer.toString()); - } - - public String getRequestProperty(String key) { - return connection.getRequestProperty(key); - } - - public Map getRequestProperties() { - Map map = new HashMap(); - Iterator entries = requestProperties.entrySet().iterator(); - while (entries.hasNext()) { - Map.Entry entry = (Map.Entry) entries.next(); - map.put(entry.getKey(), - Collections.unmodifiableList((List) entry.getValue())); - } - return Collections.unmodifiableMap(map); - } - - public void setInstanceFollowRedirects(boolean instanceFollowRedirects) { - connection.setInstanceFollowRedirects(instanceFollowRedirects); - } - - public boolean getInstanceFollowRedirects() { - return connection.getInstanceFollowRedirects(); - } - - public void setRequestMethod(String requestMethod) - throws ProtocolException { - connection.setRequestMethod(requestMethod); - this.method = requestMethod; - } - - public String getRequestMethod() { - return connection.getRequestMethod(); - } - - public int getResponseCode() throws IOException { - try { - handshake(); - } catch (IOException ex) { } - return connection.getResponseCode(); - } - - public String getResponseMessage() throws IOException { - try { - handshake(); - } catch (IOException ex) { } - return connection.getResponseMessage(); - } - - public void disconnect() { - connection.disconnect(); - handshakeComplete = false; - connected = false; - } - - public boolean usingProxy() { - return connection.usingProxy(); - } - - public InputStream getErrorStream() { - try { - handshake(); - } catch (IOException ex) { } - return connection.getErrorStream(); - } - - private int parseResponseCode() throws IOException { - try { - String response = connection.getHeaderField(0); - int index = response.indexOf(' '); - while (response.charAt(index) == ' ') index++; - return Integer.parseInt(response.substring(index, index + 3)); - } catch (Exception ex) { - throw new IOException(ex.getMessage()); - } - } - - private void doHandshake() throws IOException { - connect(); - try { - int response = parseResponseCode(); - if (response != HTTP_UNAUTHORIZED && response != HTTP_PROXY_AUTH) { - return; - } - Type1Message type1 = (Type1Message) attemptNegotiation(response); - if (type1 == null) return; // no NTLM - int attempt = 0; - while (attempt < MAX_REDIRECTS) { - connection.setRequestProperty(authProperty, authMethod + ' ' + - Base64.encode(type1.toByteArray())); - connection.connect(); // send type 1 - response = parseResponseCode(); - if (response != HTTP_UNAUTHORIZED && - response != HTTP_PROXY_AUTH) { - return; - } - Type3Message type3 = (Type3Message) - attemptNegotiation(response); - if (type3 == null) return; - connection.setRequestProperty(authProperty, authMethod + ' ' + - Base64.encode(type3.toByteArray())); - connection.connect(); // send type 3 - if (cachedOutput != null && doOutput) { - OutputStream output = connection.getOutputStream(); - cachedOutput.writeTo(output); - output.flush(); - } - response = parseResponseCode(); - if (response != HTTP_UNAUTHORIZED && - response != HTTP_PROXY_AUTH) { - return; - } - attempt++; - if (allowUserInteraction && attempt < MAX_REDIRECTS) { - reconnect(); - } else { - break; - } - } - throw new IOException("Unable to negotiate NTLM authentication."); - } finally { - cachedOutput = null; - } - } - - private NtlmMessage attemptNegotiation(int response) throws IOException { - authProperty = null; - authMethod = null; - InputStream errorStream = connection.getErrorStream(); - if (errorStream != null && errorStream.available() != 0) { - int count; - byte[] buf = new byte[1024]; - while ((count = errorStream.read(buf, 0, 1024)) != -1); - } - String authHeader; - if (response == HTTP_UNAUTHORIZED) { - authHeader = "WWW-Authenticate"; - authProperty = "Authorization"; - } else { - authHeader = "Proxy-Authenticate"; - authProperty = "Proxy-Authorization"; - } - String authorization = null; - List methods = (List) getHeaderFields0().get(authHeader); - if (methods == null) return null; - Iterator iterator = methods.iterator(); - while (iterator.hasNext()) { - String currentAuthMethod = (String) iterator.next(); - if (currentAuthMethod.startsWith("NTLM")) { - if (currentAuthMethod.length() == 4) { - authMethod = "NTLM"; - break; - } - if (currentAuthMethod.indexOf(' ') != 4) continue; - authMethod = "NTLM"; - authorization = currentAuthMethod.substring(5).trim(); - break; - } else if (currentAuthMethod.startsWith("Negotiate")) { - if (currentAuthMethod.length() == 9) { - authMethod = "Negotiate"; - break; - } - if (currentAuthMethod.indexOf(' ') != 9) continue; - authMethod = "Negotiate"; - authorization = currentAuthMethod.substring(10).trim(); - break; - } - } - if (authMethod == null) return null; - NtlmMessage message = (authorization != null) ? - new Type2Message(Base64.decode(authorization)) : null; - reconnect(); - if (message == null) { - message = new Type1Message(); - if (LM_COMPATIBILITY > 2) { - message.setFlag(NtlmFlags.NTLMSSP_REQUEST_TARGET, true); - } - } else { - String domain = DEFAULT_DOMAIN; - String user = Type3Message.getDefaultUser(); - String password = Type3Message.getDefaultPassword(); - String userInfo = url.getUserInfo(); - if (userInfo != null) { - userInfo = URLDecoder.decode(userInfo); - int index = userInfo.indexOf(':'); - user = (index != -1) ? userInfo.substring(0, index) : userInfo; - if (index != -1) password = userInfo.substring(index + 1); - index = user.indexOf('\\'); - if (index == -1) index = user.indexOf('/'); - domain = (index != -1) ? user.substring(0, index) : domain; - user = (index != -1) ? user.substring(index + 1) : user; - } - if (user == null) { - if (!allowUserInteraction) return null; - try { - URL url = getURL(); - String protocol = url.getProtocol(); - int port = url.getPort(); - if (port == -1) { - port = "https".equalsIgnoreCase(protocol) ? 443 : 80; - } - PasswordAuthentication auth = - Authenticator.requestPasswordAuthentication(null, - port, protocol, "", authMethod); - if (auth == null) return null; - user = auth.getUserName(); - password = new String(auth.getPassword()); - } catch (Exception ex) { } - } - Type2Message type2 = (Type2Message) message; - message = new Type3Message(type2, password, domain, user, - Type3Message.getDefaultWorkstation(), 0); - } - return message; - } - - private void reconnect() throws IOException { - connection = (HttpURLConnection) connection.getURL().openConnection(); - connection.setRequestMethod(method); - headerFields = null; - Iterator properties = requestProperties.entrySet().iterator(); - while (properties.hasNext()) { - Map.Entry property = (Map.Entry) properties.next(); - String key = (String) property.getKey(); - StringBuffer value = new StringBuffer(); - Iterator values = ((List) property.getValue()).iterator(); - while (values.hasNext()) { - value.append(values.next()); - if (values.hasNext()) value.append(", "); - } - connection.setRequestProperty(key, value.toString()); - } - connection.setAllowUserInteraction(allowUserInteraction); - connection.setDoInput(doInput); - connection.setDoOutput(doOutput); - connection.setIfModifiedSince(ifModifiedSince); - connection.setUseCaches(useCaches); - } - - private static class CacheStream extends OutputStream { - - private final OutputStream stream; - - private final OutputStream collector; - - public CacheStream(OutputStream stream, OutputStream collector) { - this.stream = stream; - this.collector = collector; - } - - public void close() throws IOException { - stream.close(); - collector.close(); - } - - public void flush() throws IOException { - stream.flush(); - collector.flush(); - } - - public void write(byte[] b) throws IOException { - stream.write(b); - collector.write(b); - } - - public void write(byte[] b, int off, int len) throws IOException { - stream.write(b, off, len); - collector.write(b, off, len); - } - - public void write(int b) throws IOException { - stream.write(b); - collector.write(b); - } - - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmServlet.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmServlet.java deleted file mode 100644 index 08a7f0bbc7..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmServlet.java +++ /dev/null @@ -1,160 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.netbios.NbtAddress; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.smb.SmbAuthException; -import jcifs.smb.SmbSession; -import jcifs.util.Base64; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; -import java.util.Enumeration; - -/** - * This servlet may be used with pre-2.3 servlet containers - * to protect content with NTLM HTTP Authentication. Servlets that - * extend this abstract base class may be authenticatied against an SMB - * server or domain controller depending on how the - * jcifs.smb.client.domain or jcifs.http.domainController - * properties are be specified. With later containers the - * NtlmHttpFilter should be used/b>. For custom NTLM HTTP Authentication schemes the NtlmSsp may be used. - * - * Read jCIFS NTLM HTTP Authentication and the Network Explorer Servlet related information. - */ - -public abstract class NtlmServlet extends HttpServlet { - - private String defaultDomain; - - private String domainController; - - private boolean loadBalance; - - private boolean enableBasic; - - private boolean insecureBasic; - - private String realm; - - public void init(ServletConfig config) throws ServletException { - super.init(config); - - /* Set jcifs properties we know we want; soTimeout and cachePolicy to 10min. - */ - Config.setProperty( "jcifs.smb.client.soTimeout", "300000" ); - Config.setProperty( "jcifs.netbios.cachePolicy", "600" ); - - Enumeration e = config.getInitParameterNames(); - String name; - while (e.hasMoreElements()) { - name = (String) e.nextElement(); - if (name.startsWith("jcifs.")) { - Config.setProperty(name, config.getInitParameter(name)); - } - } - defaultDomain = Config.getProperty("jcifs.smb.client.domain"); - domainController = Config.getProperty("jcifs.http.domainController"); - if( domainController == null ) { - domainController = defaultDomain; - loadBalance = Config.getBoolean( "jcifs.http.loadBalance", true ); - } - enableBasic = Boolean.valueOf( - Config.getProperty("jcifs.http.enableBasic")).booleanValue(); - insecureBasic = Boolean.valueOf( - Config.getProperty("jcifs.http.insecureBasic")).booleanValue(); - realm = Config.getProperty("jcifs.http.basicRealm"); - if (realm == null) realm = "jCIFS"; - } - - protected void service(HttpServletRequest request, - HttpServletResponse response) throws ServletException, IOException { - UniAddress dc; - boolean offerBasic = enableBasic && - (insecureBasic || request.isSecure()); - String msg = request.getHeader("Authorization"); - if (msg != null && (msg.startsWith("NTLM ") || - (offerBasic && msg.startsWith("Basic ")))) { - if( loadBalance ) { - dc = new UniAddress( NbtAddress.getByName( domainController, 0x1C, null )); - } else { - dc = UniAddress.getByName( domainController, true ); - } - NtlmPasswordAuthentication ntlm; - if (msg.startsWith("NTLM ")) { - byte[] challenge = SmbSession.getChallenge(dc); - ntlm = NtlmSsp.authenticate(request, response, challenge); - if (ntlm == null) return; - } else { - String auth = new String(Base64.decode(msg.substring(6)), - "US-ASCII"); - int index = auth.indexOf(':'); - String user = (index != -1) ? auth.substring(0, index) : auth; - String password = (index != -1) ? auth.substring(index + 1) : - ""; - index = user.indexOf('\\'); - if (index == -1) index = user.indexOf('/'); - String domain = (index != -1) ? user.substring(0, index) : - defaultDomain; - user = (index != -1) ? user.substring(index + 1) : user; - ntlm = new NtlmPasswordAuthentication(domain, user, password); - } - try { - SmbSession.logon(dc, ntlm); - } catch (SmbAuthException sae) { - response.setHeader("WWW-Authenticate", "NTLM"); - if (offerBasic) { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + - realm + "\""); - } - response.setHeader("Connection", "close"); - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - response.flushBuffer(); - return; - } - HttpSession ssn = request.getSession(); - ssn.setAttribute("NtlmHttpAuth", ntlm); - ssn.setAttribute( "ntlmdomain", ntlm.getDomain() ); - ssn.setAttribute( "ntlmuser", ntlm.getUsername() ); - } else { - HttpSession ssn = request.getSession(false); - if (ssn == null || ssn.getAttribute("NtlmHttpAuth") == null) { - response.setHeader("WWW-Authenticate", "NTLM"); - if (offerBasic) { - response.addHeader("WWW-Authenticate", "Basic realm=\"" + - realm + "\""); - } - response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - response.flushBuffer(); - return; - } - } - super.service(request, response); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmSsp.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmSsp.java deleted file mode 100644 index 67029d65be..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/http/NtlmSsp.java +++ /dev/null @@ -1,107 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
- * "Eric Glass" - * "Jason Pugsley" - * "skeetz" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.http; - -import jcifs.ntlmssp.NtlmFlags; -import jcifs.ntlmssp.Type1Message; -import jcifs.ntlmssp.Type2Message; -import jcifs.ntlmssp.Type3Message; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.util.Base64; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * This class is used internally by NtlmHttpFilter, - * NtlmServlet, and NetworkExplorer to negiotiate password - * hashes via NTLM SSP with MSIE. It might also be used directly by servlet - * containers to incorporate similar functionality. - * - * How NTLMSSP is used in conjunction with HTTP and MSIE clients is - * described in an NTLM - * Authentication Scheme for HTTP.
Also, read jCIFS NTLM HTTP Authentication and - * the Network Explorer Servlet related information. - */ - -public class NtlmSsp implements NtlmFlags { - - /** - * Calls the static {@link #authenticate(HttpServletRequest, - * HttpServletResponse, byte[])} method to perform NTLM authentication - * for the specified servlet request. - * - * @param req The request being serviced. - * @param resp The response. - * @param challenge The domain controller challenge. - * @throws IOException If an IO error occurs. - * @throws ServletException If an error occurs. - */ - public NtlmPasswordAuthentication doAuthentication( - HttpServletRequest req, HttpServletResponse resp, byte[] challenge) - throws IOException, ServletException { - return authenticate(req, resp, challenge); - } - - /** - * Performs NTLM authentication for the servlet request. - * - * @param req The request being serviced. - * @param resp The response. - * @param challenge The domain controller challenge. - * @throws IOException If an IO error occurs. - * @throws ServletException If an error occurs. - */ - public static NtlmPasswordAuthentication authenticate( - HttpServletRequest req, HttpServletResponse resp, byte[] challenge) - throws IOException, ServletException { - String msg = req.getHeader("Authorization"); - if (msg != null && msg.startsWith("NTLM ")) { - byte[] src = Base64.decode(msg.substring(5)); - if (src[8] == 1) { - Type1Message type1 = new Type1Message(src); - Type2Message type2 = new Type2Message(type1, challenge, null); - msg = Base64.encode(type2.toByteArray()); - resp.setHeader( "WWW-Authenticate", "NTLM " + msg ); - } else if (src[8] == 3) { - Type3Message type3 = new Type3Message(src); - byte[] lmResponse = type3.getLMResponse(); - if (lmResponse == null) lmResponse = new byte[0]; - byte[] ntResponse = type3.getNTResponse(); - if (ntResponse == null) ntResponse = new byte[0]; - return new NtlmPasswordAuthentication(type3.getDomain(), - type3.getUser(), challenge, lmResponse, ntResponse); - } - } else { - resp.setHeader("WWW-Authenticate", "NTLM"); - } - resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - resp.setContentLength(0); - resp.flushBuffer(); - return null; - } - -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/https/Handler.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/https/Handler.java deleted file mode 100644 index 03cd7c103f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/https/Handler.java +++ /dev/null @@ -1,44 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.https; - -/** - * A URLStreamHandlerused to provide NTLM authentication - * capabilities to the default HTTPS handler. This acts as a wrapper, - * handling authentication and passing control to the underlying - * stream handler. - */ -public class Handler extends jcifs.http.Handler { - - /** - * The default HTTPS port (443). - */ - public static final int DEFAULT_HTTPS_PORT = 443; - - /** - * Returns the default HTTPS port. - * - * @return Anintcontaining the default HTTPS port. - */ - protected int getDefaultPort() { - return DEFAULT_HTTPS_PORT; - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Lmhosts.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Lmhosts.java deleted file mode 100644 index 51375b51f5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Lmhosts.java +++ /dev/null @@ -1,157 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.Config; -import jcifs.smb.SmbFileInputStream; -import jcifs.util.LogStream; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.net.UnknownHostException; -import java.util.Hashtable; - -public class Lmhosts { - - private static final String FILENAME = Config.getProperty( "jcifs.netbios.lmhosts" ); - private static final Hashtable TAB = new Hashtable(); - private static long lastModified = 1L; - private static int alt; - private static LogStream log = LogStream.getInstance(); - - /** - * This is really just for {@link jcifs.UniAddress}. It does - * not throw an {@link UnknownHostException} because this - * is queried frequently and exceptions would be rather costly to - * throw on a regular basis here. - */ - - public synchronized static NbtAddress getByName( String host ) { - return getByName( new Name( host, 0x20, null )); - } - - synchronized static NbtAddress getByName( Name name ) { - NbtAddress result = null; - - try { - if( FILENAME != null ) { - File f = new File( FILENAME ); - long lm; - - if(( lm = f.lastModified() ) > lastModified ) { - lastModified = lm; - TAB.clear(); - alt = 0; - populate( new FileReader( f )); - } - result = (NbtAddress)TAB.get( name ); - } - } catch( FileNotFoundException fnfe ) { - if( log.level > 1 ) { - log.println( "lmhosts file: " + FILENAME ); - fnfe.printStackTrace( log ); - } - } catch( IOException ioe ) { - if( log.level > 0 ) - ioe.printStackTrace( log ); - } - return result; - } - - static void populate( Reader r ) throws IOException { - String line; - BufferedReader br = new BufferedReader( r ); - - while(( line = br.readLine() ) != null ) { - line = line.toUpperCase().trim(); - if( line.length() == 0 ) { - continue; - } else if( line.charAt( 0 ) == '#' ) { - if( line.startsWith( "#INCLUDE " )) { - line = line.substring( line.indexOf( '\\' )); - String url = "smb:" + line.replace( '\\', '/' ); - - if( alt > 0 ) { - try { - populate( new InputStreamReader( new SmbFileInputStream( url ))); - } catch( IOException ioe ) { - log.println( "lmhosts URL: " + url ); - ioe.printStackTrace( log ); - continue; - } - - /* An include was loaded successfully. We can skip - * all other includes up to the #END_ALTERNATE tag. - */ - - alt--; - while(( line = br.readLine() ) != null ) { - line = line.toUpperCase().trim(); - if( line.startsWith( "#END_ALTERNATE" )) { - break; - } - } - } else { - populate( new InputStreamReader( new SmbFileInputStream( url ))); - } - } else if( line.startsWith( "#BEGIN_ALTERNATE" )) { - alt++; - } else if( line.startsWith( "#END_ALTERNATE" ) && alt > 0 ) { - alt--; - throw new IOException( "no lmhosts alternate includes loaded" ); - } - } else if( Character.isDigit( line.charAt( 0 ))) { - char[] data = line.toCharArray(); - int ip, i, j; - Name name; - NbtAddress addr; - char c; - - c = '.'; - ip = i = 0; - for( ; i < data.length && c == '.'; i++ ) { - int b = 0x00; - - for( ; i < data.length && ( c = data[i] ) >= 48 && c <= 57; i++ ) { - b = b * 10 + c - '0'; - } - ip = ( ip << 8 ) + b; - } - while( i < data.length && Character.isWhitespace( data[i] )) { - i++; - } - j = i; - while( j < data.length && Character.isWhitespace( data[j] ) == false ) { - j++; - } - - name = new Name( line.substring( i, j ), 0x20, null ); - addr = new NbtAddress( name, ip, false, NbtAddress.B_NODE, - false, false, true, true, - NbtAddress.UNKNOWN_MAC_ADDRESS ); - TAB.put( name, addr ); - } - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Name.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Name.java deleted file mode 100644 index ac1bd7cd69..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/Name.java +++ /dev/null @@ -1,200 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * "Christopher R. Hertel" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.Config; -import jcifs.util.Hexdump; - -import java.io.UnsupportedEncodingException; - -public class Name { - - private static final int TYPE_OFFSET = 31; - private static final int SCOPE_OFFSET = 33; - private static final String DEFAULT_SCOPE = Config.getProperty( "jcifs.netbios.scope" ); - - static final String OEM_ENCODING = - Config.getProperty( "jcifs.encoding", - System.getProperty( "file.encoding" )); - - public String name, scope; - public int hexCode; - int srcHashCode; /* srcHashCode must be set by name resolution - * routines before entry into addressCache - */ - - Name() { - } - public Name( String name, int hexCode, String scope ) { - if( name.length() > 15 ) { - name = name.substring( 0, 15 ); - } - this.name = name.toUpperCase(); - this.hexCode = hexCode; - this.scope = scope != null && scope.length() > 0 ? scope : DEFAULT_SCOPE; - this.srcHashCode = 0; - } - - int writeWireFormat( byte[] dst, int dstIndex ) { - // write 0x20 in first byte - dst[dstIndex] = 0x20; - - // write name - try { - byte tmp[] = name.getBytes( Name.OEM_ENCODING ); - int i; - for( i = 0; i < tmp.length; i++ ) { - dst[dstIndex + ( 2 * i + 1 )] = (byte)((( tmp[i] & 0xF0 ) >> 4 ) + 0x41 ); - dst[dstIndex + ( 2 * i + 2 )] = (byte)(( tmp[i] & 0x0F ) + 0x41 ); - } - for( ; i < 15; i++ ) { - dst[dstIndex + ( 2 * i + 1 )] = (byte)0x43; - dst[dstIndex + ( 2 * i + 2 )] = (byte)0x41; - } - dst[dstIndex + TYPE_OFFSET] = (byte)((( hexCode & 0xF0 ) >> 4 ) + 0x41 ); - dst[dstIndex + TYPE_OFFSET + 1] = (byte)(( hexCode & 0x0F ) + 0x41 ); - } catch( UnsupportedEncodingException uee ) { - } - return SCOPE_OFFSET + writeScopeWireFormat( dst, dstIndex + SCOPE_OFFSET ); - } - - int readWireFormat( byte[] src, int srcIndex ) { - - byte tmp[] = new byte[SCOPE_OFFSET]; - int length = 15; - for( int i = 0; i < 15; i++ ) { - tmp[i] = (byte)((( src[srcIndex + ( 2 * i + 1 )] & 0xFF ) - 0x41 ) << 4 ); - tmp[i] |= (byte)((( src[srcIndex + ( 2 * i + 2 )] & 0xFF ) - 0x41 ) & 0x0F ); - if( tmp[i] != (byte)' ' ) { - length = i + 1; - } - } - try { - name = new String( tmp, 0, length, Name.OEM_ENCODING ); - } catch( UnsupportedEncodingException uee ) { - } - hexCode = (( src[srcIndex + TYPE_OFFSET] & 0xFF ) - 0x41 ) << 4; - hexCode |= (( src[srcIndex + TYPE_OFFSET + 1] & 0xFF ) - 0x41 ) & 0x0F; - return SCOPE_OFFSET + readScopeWireFormat( src, srcIndex + SCOPE_OFFSET ); - } - int writeScopeWireFormat( byte[] dst, int dstIndex ) { - if( scope == null ) { - dst[dstIndex] = (byte)0x00; - return 1; - } - - // copy new scope in - dst[dstIndex++] = (byte)'.'; - try { - System.arraycopy( scope.getBytes( Name.OEM_ENCODING ), 0, dst, dstIndex, scope.length() ); - } catch( UnsupportedEncodingException uee ) { - } - dstIndex += scope.length(); - - dst[dstIndex++] = (byte)0x00; - - // now go over scope backwards converting '.' to label length - - int i = dstIndex - 2; - int e = i - scope.length(); - int c = 0; - - do { - if( dst[i] == '.' ) { - dst[i] = (byte)c; - c = 0; - } else { - c++; - } - } while( i-- > e ); - return scope.length() + 2; - } - int readScopeWireFormat( byte[] src, int srcIndex ) { - int start = srcIndex; - int n; - StringBuffer sb; - - if(( n = src[srcIndex++] & 0xFF ) == 0 ) { - scope = null; - return 1; - } - - try { - sb = new StringBuffer( new String( src, srcIndex, n, Name.OEM_ENCODING )); - srcIndex += n; - while(( n = src[srcIndex++] & 0xFF ) != 0 ) { - sb.append( '.' ).append( new String( src, srcIndex, n, Name.OEM_ENCODING )); - srcIndex += n; - } - scope = sb.toString(); - } catch( UnsupportedEncodingException uee ) { - } - - return srcIndex - start; - } - - public int hashCode() { - int result; - - result = name.hashCode(); - result += 65599 * hexCode; - result += 65599 * srcHashCode; /* hashCode is different depending - * on where it came from - */ - if( scope != null && scope.length() != 0 ) { - result += scope.hashCode(); - } - return result; - } - public boolean equals( Object obj ) { - Name n; - - if( !( obj instanceof Name )) { - return false; - } - n = (Name)obj; - if( scope == null && n.scope == null ) { - return name.equals( n.name ) && hexCode == n.hexCode; - } - return name.equals( n.name ) && hexCode == n.hexCode && scope.equals( n.scope ); - } - public String toString() { - StringBuffer sb = new StringBuffer(); - String n = name; - - // fix MSBROWSE name - if( n == null ) { - n = "null"; - } else if( n.charAt( 0 ) == 0x01 ) { - char c[] = n.toCharArray(); - c[0] = '.'; - c[1] = '.'; - c[14] = '.'; - n = new String( c ); - } - - sb.append( n ).append( "<" ).append( Hexdump.toHexString( hexCode, 2 )).append( ">" ); - if( scope != null ) { - sb.append( "." ).append( scope ); - } - return sb.toString(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryRequest.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryRequest.java deleted file mode 100644 index 24906d754d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -class NameQueryRequest extends NameServicePacket { - - NameQueryRequest( Name name ) { - questionName = name; - questionType = NB; - } - - int writeBodyWireFormat( byte[] dst, int dstIndex ) { - return writeQuestionSectionWireFormat( dst, dstIndex ); - } - int readBodyWireFormat( byte[] src, int srcIndex ) { - return readQuestionSectionWireFormat( src, srcIndex ); - } - int writeRDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readRDataWireFormat( byte[] src, int srcIndex ) { - return 0; - } - public String toString() { - return new String( "NameQueryRequest[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryResponse.java deleted file mode 100644 index 693e0e9eaa..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameQueryResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -class NameQueryResponse extends NameServicePacket { - - NameQueryResponse() { - recordName = new Name(); - } - - int writeBodyWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readBodyWireFormat( byte[] src, int srcIndex ) { - return readResourceRecordWireFormat( src, srcIndex ); - } - int writeRDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readRDataWireFormat( byte[] src, int srcIndex ) { - if( resultCode != 0 || opCode != QUERY ) { - return 0; - } - boolean groupName = (( src[srcIndex] & 0x80 ) == 0x80 ) ? true : false; - int nodeType = ( src[srcIndex] & 0x60 ) >> 5; - srcIndex += 2; - int address = readInt4( src, srcIndex ); - if( address != 0 ) { - addrEntry[addrIndex] = new NbtAddress( recordName, address, groupName, nodeType ); - } else { - addrEntry[addrIndex] = null; - } - - return 6; - } - public String toString() { - return new String( "NameQueryResponse[" + - super.toString() + - ",addrEntry=" + addrEntry + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServiceClient.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServiceClient.java deleted file mode 100644 index c95ca91cc1..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServiceClient.java +++ /dev/null @@ -1,448 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.Config; -import jcifs.util.Hexdump; -import jcifs.util.LogStream; - -import java.io.IOException; -import java.net.DatagramPacket; -import java.net.DatagramSocket; -import java.net.InetAddress; -import java.net.SocketTimeoutException; -import java.net.UnknownHostException; -import java.util.HashMap; -import java.util.StringTokenizer; - -class NameServiceClient implements Runnable { - - static final int DEFAULT_SO_TIMEOUT = 5000; - static final int DEFAULT_RCV_BUF_SIZE = 576; - static final int DEFAULT_SND_BUF_SIZE = 576; - static final int NAME_SERVICE_UDP_PORT = 137; - static final int DEFAULT_RETRY_COUNT = 2; - static final int DEFAULT_RETRY_TIMEOUT = 3000; - - static final int RESOLVER_LMHOSTS = 1; - static final int RESOLVER_BCAST = 2; - static final int RESOLVER_WINS = 3; - - private static final int SND_BUF_SIZE = Config.getInt( "jcifs.netbios.snd_buf_size", DEFAULT_SND_BUF_SIZE ); - private static final int RCV_BUF_SIZE = Config.getInt( "jcifs.netbios.rcv_buf_size", DEFAULT_RCV_BUF_SIZE ); - private static final int SO_TIMEOUT = Config.getInt( "jcifs.netbios.soTimeout", DEFAULT_SO_TIMEOUT ); - private static final int RETRY_COUNT = Config.getInt( "jcifs.netbios.retryCount", DEFAULT_RETRY_COUNT ); - private static final int RETRY_TIMEOUT = Config.getInt( "jcifs.netbios.retryTimeout", DEFAULT_RETRY_TIMEOUT); - private static final int LPORT = Config.getInt( "jcifs.netbios.lport", 0 ); - private static final InetAddress LADDR = Config.getInetAddress( "jcifs.netbios.laddr", null ); - private static final String RO = Config.getProperty( "jcifs.resolveOrder" ); - - private static LogStream log = LogStream.getInstance(); - - private final Object LOCK = new Object(); - - private int lport, closeTimeout; - private byte[] snd_buf, rcv_buf; - private DatagramSocket socket; - private DatagramPacket in, out; - private HashMap responseTable = new HashMap(); - private Thread thread; - private int nextNameTrnId = 0; - private int[] resolveOrder; - - InetAddress laddr, baddr; - - NameServiceClient() { - this( LPORT, LADDR ); - } - NameServiceClient( int lport, InetAddress laddr ) { - this.lport = lport; - this.laddr = laddr; - - try { - baddr = Config.getInetAddress( "jcifs.netbios.baddr", - InetAddress.getByName( "255.255.255.255" )); - } catch( UnknownHostException uhe ) { - } - - snd_buf = new byte[SND_BUF_SIZE]; - rcv_buf = new byte[RCV_BUF_SIZE]; - out = new DatagramPacket( snd_buf, SND_BUF_SIZE, baddr, NAME_SERVICE_UDP_PORT ); - in = new DatagramPacket( rcv_buf, RCV_BUF_SIZE ); - - if( RO == null || RO.length() == 0 ) { - - /* No resolveOrder has been specified, use the - * default which is LMHOSTS,DNS,WINS,BCAST - * LMHOSTS,BCAST,DNS if jcifs.netbios.wins has not - * been specified. - */ - - if( NbtAddress.getWINSAddress() == null ) { - resolveOrder = new int[2]; - resolveOrder[0] = RESOLVER_LMHOSTS; - resolveOrder[1] = RESOLVER_BCAST; - } else { - resolveOrder = new int[3]; - resolveOrder[0] = RESOLVER_LMHOSTS; - resolveOrder[1] = RESOLVER_WINS; - resolveOrder[2] = RESOLVER_BCAST; - } - } else { - int[] tmp = new int[3]; - StringTokenizer st = new StringTokenizer( RO, "," ); - int i = 0; - while( st.hasMoreTokens() ) { - String s = st.nextToken().trim(); - if( s.equalsIgnoreCase( "LMHOSTS" )) { - tmp[i++] = RESOLVER_LMHOSTS; - } else if( s.equalsIgnoreCase( "WINS" )) { - if( NbtAddress.getWINSAddress() == null ) { - if( log.level > 1 ) { - log.println( "NetBIOS resolveOrder specifies WINS however the " + - "jcifs.netbios.wins property has not been set" ); - } - continue; - } - tmp[i++] = RESOLVER_WINS; - } else if( s.equalsIgnoreCase( "BCAST" )) { - tmp[i++] = RESOLVER_BCAST; - } else if( s.equalsIgnoreCase( "DNS" )) { - ; // skip - } else if( log.level > 1 ) { - log.println( "unknown resolver method: " + s ); - } - } - resolveOrder = new int[i]; - System.arraycopy( tmp, 0, resolveOrder, 0, i ); - } - } - - int getNextNameTrnId() { - if(( ++nextNameTrnId & 0xFFFF ) == 0 ) { - nextNameTrnId = 1; - } - return nextNameTrnId; - } - void ensureOpen( int timeout ) throws IOException { - closeTimeout = 0; - if( SO_TIMEOUT != 0 ) { - closeTimeout = Math.max( SO_TIMEOUT, timeout ); - } - // If socket is still good, the new closeTimeout will - // be ignored; see tryClose comment. - if( socket == null ) { - socket = new DatagramSocket( lport, laddr ); - thread = new Thread( this, "JCIFS-NameServiceClient" ); - thread.setDaemon( true ); - thread.start(); - } - } - void tryClose() { - synchronized( LOCK ) { - - /* Yes, there is the potential to drop packets - * because we might close the socket during a - * request. However the chances are slim and the - * retry code should ensure the overall request - * is serviced. The alternative complicates things - * more than I think is worth it. - */ - - if( socket != null ) { - socket.close(); - socket = null; - } - thread = null; - responseTable.clear(); - } - } - public void run() { - int nameTrnId; - NameServicePacket response; - - try { - while( thread == Thread.currentThread() ) { - in.setLength( RCV_BUF_SIZE ); - - socket.setSoTimeout( closeTimeout ); - socket.receive( in ); - - if( log.level > 3 ) - log.println( "NetBIOS: new data read from socket" ); - - nameTrnId = NameServicePacket.readNameTrnId( rcv_buf, 0 ); - response = (NameServicePacket)responseTable.get( new Integer( nameTrnId )); - if( response == null || response.received ) { - continue; - } - synchronized( response ) { - response.readWireFormat( rcv_buf, 0 ); - response.received = true; - - if( log.level > 3 ) { - log.println( response ); - Hexdump.hexdump( log, rcv_buf, 0, in.getLength() ); - } - - response.notify(); - } - } - } catch(SocketTimeoutException ste) { - } catch( Exception ex ) { - if( log.level > 2 ) - ex.printStackTrace( log ); - } finally { - tryClose(); - } - } - void send( NameServicePacket request, NameServicePacket response, - int timeout ) throws IOException { - Integer nid = null; - int max = NbtAddress.NBNS.length; - - if (max == 0) - max = 1; /* No WINs, try only bcast addr */ - - synchronized( response ) { - while (max-- > 0) { - try { - synchronized( LOCK ) { - request.nameTrnId = getNextNameTrnId(); - nid = new Integer( request.nameTrnId ); - - out.setAddress( request.addr ); - out.setLength( request.writeWireFormat( snd_buf, 0 )); - response.received = false; - - responseTable.put( nid, response ); - ensureOpen( timeout + 1000 ); - socket.send( out ); - - if( log.level > 3 ) { - log.println( request ); - Hexdump.hexdump( log, snd_buf, 0, out.getLength() ); - } - } - - long start = System.currentTimeMillis(); - while (timeout > 0) { - response.wait( timeout ); - - /* JetDirect printer can respond to regular broadcast query - * with node status so we need to check to make sure that - * the record type matches the question type and if not, - * loop around and try again. - */ - if (response.received && request.questionType == response.recordType) - return; - - response.received = false; - timeout -= System.currentTimeMillis() - start; - } - - } catch( InterruptedException ie ) { - throw new IOException(ie.getMessage()); - } finally { - responseTable.remove( nid ); - } - - synchronized (LOCK) { - if (NbtAddress.isWINS( request.addr ) == false) - break; - /* Message was sent to WINS but - * failed to receive response. - * Try a different WINS server. - */ - if (request.addr == NbtAddress.getWINSAddress()) - NbtAddress.switchWINS(); - request.addr = NbtAddress.getWINSAddress(); - } - } - } - } - - NbtAddress[] getAllByName( Name name, InetAddress addr ) - throws UnknownHostException { - int n; - NameQueryRequest request = new NameQueryRequest( name ); - NameQueryResponse response = new NameQueryResponse(); - - request.addr = addr != null ? addr : NbtAddress.getWINSAddress(); - request.isBroadcast = request.addr == null; - - if( request.isBroadcast ) { - request.addr = baddr; - n = RETRY_COUNT; - } else { - request.isBroadcast = false; - n = 1; - } - - do { - try { - send( request, response, RETRY_TIMEOUT ); - } catch( IOException ioe ) { - if( log.level > 1 ) - ioe.printStackTrace( log ); - throw new UnknownHostException( name.name ); - } - - if( response.received && response.resultCode == 0 ) { - return response.addrEntry; - } - } while( --n > 0 && request.isBroadcast ); - - throw new UnknownHostException( name.name ); - } - NbtAddress getByName( Name name, InetAddress addr ) - throws UnknownHostException { - int n; - NameQueryRequest request = new NameQueryRequest( name ); - NameQueryResponse response = new NameQueryResponse(); - - if( addr != null ) { /* UniAddress calls always use this - * because it specifies addr - */ - request.addr = addr; /* if addr ends with 255 flag it bcast */ - request.isBroadcast = (addr.getAddress()[3] == (byte)0xFF); - - n = RETRY_COUNT; - do { - try { - send( request, response, RETRY_TIMEOUT ); - } catch( IOException ioe ) { - if( log.level > 1 ) - ioe.printStackTrace( log ); - throw new UnknownHostException( name.name ); - } - - if( response.received && response.resultCode == 0 ) { - int last = response.addrEntry.length - 1; - response.addrEntry[last].hostName.srcHashCode = addr.hashCode(); - return response.addrEntry[last]; - } - } while( --n > 0 && request.isBroadcast ); - - throw new UnknownHostException( name.name ); - } - - /* If a target address to query was not specified explicitly - * with the addr parameter we fall into this resolveOrder routine. - */ - - for( int i = 0; i < resolveOrder.length; i++ ) { - try { - switch( resolveOrder[i] ) { - case RESOLVER_LMHOSTS: - NbtAddress ans = Lmhosts.getByName( name ); - if( ans != null ) { - ans.hostName.srcHashCode = 0; // just has to be different - // from other methods - return ans; - } - break; - case RESOLVER_WINS: - case RESOLVER_BCAST: - if( resolveOrder[i] == RESOLVER_WINS && - name.name != NbtAddress.MASTER_BROWSER_NAME && - name.hexCode != 0x1d ) { - request.addr = NbtAddress.getWINSAddress(); - request.isBroadcast = false; - } else { - request.addr = baddr; - request.isBroadcast = true; - } - - n = RETRY_COUNT; - while( n-- > 0 ) { - try { - send( request, response, RETRY_TIMEOUT ); - } catch( IOException ioe ) { - if( log.level > 1 ) - ioe.printStackTrace( log ); - throw new UnknownHostException( name.name ); - } - if( response.received && response.resultCode == 0 ) { - -/* Before we return, in anticipation of this address being cached we must - * augment the addresses name's hashCode to distinguish those resolved by - * Lmhosts, WINS, or BCAST. Otherwise a failed query from say WINS would - * get pulled out of the cache for a BCAST on the same name. - */ - response.addrEntry[0].hostName.srcHashCode = - request.addr.hashCode(); - return response.addrEntry[0]; - } else if( resolveOrder[i] == RESOLVER_WINS ) { - /* If WINS reports negative, no point in retry - */ - break; - } - } - break; - } - } catch( IOException ioe ) { - } - } - throw new UnknownHostException( name.name ); - } - NbtAddress[] getNodeStatus( NbtAddress addr ) throws UnknownHostException { - int n, srcHashCode; - NodeStatusRequest request; - NodeStatusResponse response; - - response = new NodeStatusResponse( addr ); - request = new NodeStatusRequest( - new Name( NbtAddress.ANY_HOSTS_NAME, 0x00, null)); - request.addr = addr.getInetAddress(); - - n = RETRY_COUNT; - while( n-- > 0 ) { - try { - send( request, response, RETRY_TIMEOUT ); - } catch( IOException ioe ) { - if( log.level > 1 ) - ioe.printStackTrace( log ); - throw new UnknownHostException( addr.toString() ); - } - if( response.received && response.resultCode == 0 ) { - - /* For name queries resolved by different sources (e.g. WINS, - * BCAST, Node Status) we need to augment the hashcode generated - * for the addresses hostname or failed lookups for one type will - * be cached and cause other types to fail even though they may - * not be the authority for the name. For example, if a WINS lookup - * for FOO fails and caches unknownAddress for FOO, a subsequent - * lookup for FOO using BCAST should not fail because of that - * name cached from WINS. - * - * So, here we apply the source addresses hashCode to each name to - * make them specific to who resolved the name. - */ - - srcHashCode = request.addr.hashCode(); - for( int i = 0; i < response.addressArray.length; i++ ) { - response.addressArray[i].hostName.srcHashCode = srcHashCode; - } - return response.addressArray; - } - } - throw new UnknownHostException( addr.hostName.name ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServicePacket.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServicePacket.java deleted file mode 100644 index 6c24777572..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NameServicePacket.java +++ /dev/null @@ -1,345 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.util.Hexdump; - -import java.net.InetAddress; - -abstract class NameServicePacket { - - // opcode - static final int QUERY = 0; - static final int WACK = 7; - - // rcode - static final int FMT_ERR = 0x1; - static final int SRV_ERR = 0x2; - static final int IMP_ERR = 0x4; - static final int RFS_ERR = 0x5; - static final int ACT_ERR = 0x6; - static final int CFT_ERR = 0x7; - - // type/class - static final int NB_IN = 0x00200001; - static final int NBSTAT_IN = 0x00210001; - static final int NB = 0x0020; - static final int NBSTAT = 0x0021; - static final int IN = 0x0001; - static final int A = 0x0001; - static final int NS = 0x0002; - static final int NULL = 0x000a; - - static final int HEADER_LENGTH = 12; - - // header field offsets - static final int OPCODE_OFFSET = 2; - static final int QUESTION_OFFSET = 4; - static final int ANSWER_OFFSET = 6; - static final int AUTHORITY_OFFSET = 8; - static final int ADDITIONAL_OFFSET = 10; - - static void writeInt2( int val, byte[] dst, int dstIndex ) { - dst[dstIndex++] = (byte)(( val >> 8 ) & 0xFF ); - dst[dstIndex] = (byte)( val & 0xFF ); - } - static void writeInt4( int val, byte[] dst, int dstIndex ) { - dst[dstIndex++] = (byte)(( val >> 24 ) & 0xFF ); - dst[dstIndex++] = (byte)(( val >> 16 ) & 0xFF ); - dst[dstIndex++] = (byte)(( val >> 8 ) & 0xFF ); - dst[dstIndex] = (byte)( val & 0xFF ); - } - static int readInt2( byte[] src, int srcIndex ) { - return (( src[srcIndex] & 0xFF ) << 8 ) + - ( src[srcIndex + 1] & 0xFF ); - } - static int readInt4( byte[] src, int srcIndex ) { - return (( src[srcIndex] & 0xFF ) << 24 ) + - (( src[srcIndex + 1] & 0xFF ) << 16 ) + - (( src[srcIndex + 2] & 0xFF ) << 8 ) + - ( src[srcIndex + 3] & 0xFF ); - } - - static int readNameTrnId( byte[] src, int srcIndex ) { - return readInt2( src, srcIndex ); - } - - int addrIndex; - NbtAddress[] addrEntry; - - int nameTrnId; - - int opCode, - resultCode, - questionCount, - answerCount, - authorityCount, - additionalCount; - boolean received, - isResponse, - isAuthAnswer, - isTruncated, - isRecurDesired, - isRecurAvailable, - isBroadcast; - - Name questionName; - Name recordName; - - int questionType, - questionClass, - recordType, - recordClass, - ttl, - rDataLength; - - InetAddress addr; - - NameServicePacket() { - isRecurDesired = true; - isBroadcast = true; - questionCount = 1; - questionClass = IN; - } - - int writeWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - dstIndex += writeHeaderWireFormat( dst, dstIndex ); - dstIndex += writeBodyWireFormat( dst, dstIndex ); - return dstIndex - start; - } - int readWireFormat( byte[] src, int srcIndex ) { - int start = srcIndex; - srcIndex += readHeaderWireFormat( src, srcIndex ); - srcIndex += readBodyWireFormat( src, srcIndex ); - return srcIndex - start; - } - - int writeHeaderWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - writeInt2( nameTrnId, dst, dstIndex ); - dst[dstIndex + OPCODE_OFFSET] = (byte)(( isResponse ? 0x80 : 0x00 ) + - (( opCode << 3 ) & 0x78 ) + - ( isAuthAnswer ? 0x04 : 0x00 ) + - ( isTruncated ? 0x02 : 0x00 ) + - ( isRecurDesired ? 0x01 : 0x00 )); - dst[dstIndex + OPCODE_OFFSET + 1] = (byte)(( isRecurAvailable ? 0x80 : 0x00 ) + - ( isBroadcast ? 0x10 : 0x00 ) + - ( resultCode & 0x0F )); - writeInt2( questionCount, dst, start + QUESTION_OFFSET ); - writeInt2( answerCount, dst, start + ANSWER_OFFSET ); - writeInt2( authorityCount, dst, start + AUTHORITY_OFFSET ); - writeInt2( additionalCount, dst, start + ADDITIONAL_OFFSET ); - return HEADER_LENGTH; - } - int readHeaderWireFormat( byte[] src, int srcIndex ) { - nameTrnId = readInt2( src, srcIndex ); - isResponse = (( src[srcIndex + OPCODE_OFFSET] & 0x80 ) == 0 ) ? false : true; - opCode = ( src[srcIndex + OPCODE_OFFSET] & 0x78 ) >> 3; - isAuthAnswer = (( src[srcIndex + OPCODE_OFFSET] & 0x04 ) == 0 ) ? false : true; - isTruncated = (( src[srcIndex + OPCODE_OFFSET] & 0x02 ) == 0 ) ? false : true; - isRecurDesired = (( src[srcIndex + OPCODE_OFFSET] & 0x01 ) == 0 ) ? false : true; - isRecurAvailable = - (( src[srcIndex + OPCODE_OFFSET + 1] & 0x80 ) == 0 ) ? false : true; - isBroadcast = (( src[srcIndex + OPCODE_OFFSET + 1] & 0x10 ) == 0 ) ? false : true; - resultCode = src[srcIndex + OPCODE_OFFSET + 1] & 0x0F; - questionCount = readInt2( src, srcIndex + QUESTION_OFFSET ); - answerCount = readInt2( src, srcIndex + ANSWER_OFFSET ); - authorityCount = readInt2( src, srcIndex + AUTHORITY_OFFSET ); - additionalCount = readInt2( src, srcIndex + ADDITIONAL_OFFSET ); - return HEADER_LENGTH; - } - int writeQuestionSectionWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - dstIndex += questionName.writeWireFormat( dst, dstIndex ); - writeInt2( questionType, dst, dstIndex ); - dstIndex += 2; - writeInt2( questionClass, dst, dstIndex ); - dstIndex += 2; - return dstIndex - start; - } - int readQuestionSectionWireFormat( byte[] src, int srcIndex ) { - int start = srcIndex; - srcIndex += questionName.readWireFormat( src, srcIndex ); - questionType = readInt2( src, srcIndex ); - srcIndex += 2; - questionClass = readInt2( src, srcIndex ); - srcIndex += 2; - return srcIndex - start; - } - int writeResourceRecordWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - if( recordName == questionName ) { - dst[dstIndex++] = (byte)0xC0; // label string pointer to - dst[dstIndex++] = (byte)0x0C; // questionName (offset 12) - } else { - dstIndex += recordName.writeWireFormat( dst, dstIndex ); - } - writeInt2( recordType, dst, dstIndex ); - dstIndex += 2; - writeInt2( recordClass, dst, dstIndex ); - dstIndex += 2; - writeInt4( ttl, dst, dstIndex ); - dstIndex += 4; - rDataLength = writeRDataWireFormat( dst, dstIndex + 2 ); - writeInt2( rDataLength, dst, dstIndex ); - dstIndex += 2 + rDataLength; - return dstIndex - start; - } - int readResourceRecordWireFormat( byte[] src, int srcIndex ) { - int start = srcIndex; - int end; - - if(( src[srcIndex] & 0xC0 ) == 0xC0 ) { - recordName = questionName; // label string pointer to questionName - srcIndex += 2; - } else { - srcIndex += recordName.readWireFormat( src, srcIndex ); - } - recordType = readInt2( src, srcIndex ); - srcIndex += 2; - recordClass = readInt2( src, srcIndex ); - srcIndex += 2; - ttl = readInt4( src, srcIndex ); - srcIndex += 4; - rDataLength = readInt2( src, srcIndex ); - srcIndex += 2; - - addrEntry = new NbtAddress[rDataLength / 6]; - end = srcIndex + rDataLength; -/* Apparently readRDataWireFormat can return 0 if resultCode != 0 in -which case this will look indefinitely. Putting this else clause around -the loop might fix that. But I would need to see a capture to confirm. -if (resultCode != 0) { - srcIndex += rDataLength; -} else { -*/ - for( addrIndex = 0; srcIndex < end; addrIndex++ ) { - srcIndex += readRDataWireFormat( src, srcIndex ); - } - - return srcIndex - start; - } - - abstract int writeBodyWireFormat( byte[] dst, int dstIndex ); - abstract int readBodyWireFormat( byte[] src, int srcIndex ); - abstract int writeRDataWireFormat( byte[] dst, int dstIndex ); - abstract int readRDataWireFormat( byte[] src, int srcIndex ); - - public String toString() { - String opCodeString, - resultCodeString, - questionTypeString, - questionClassString, - recordTypeString, - recordClassString; - - switch( opCode ) { - case QUERY: - opCodeString = "QUERY"; - break; - case WACK: - opCodeString = "WACK"; - break; - default: - opCodeString = Integer.toString( opCode ); - break; - } - switch( resultCode ) { - case FMT_ERR: - resultCodeString = "FMT_ERR"; - break; - case SRV_ERR: - resultCodeString = "SRV_ERR"; - break; - case IMP_ERR: - resultCodeString = "IMP_ERR"; - break; - case RFS_ERR: - resultCodeString = "RFS_ERR"; - break; - case ACT_ERR: - resultCodeString = "ACT_ERR"; - break; - case CFT_ERR: - resultCodeString = "CFT_ERR"; - break; - default: - resultCodeString = "0x" + Hexdump.toHexString( resultCode, 1 ); - break; - } - switch( questionType ) { - case NB: - questionTypeString = "NB"; - break; - case NBSTAT: - questionTypeString = "NBSTAT"; - break; - default: - questionTypeString = "0x" + Hexdump.toHexString( questionType, 4 ); - break; - } - switch( recordType ) { - case A: - recordTypeString = "A"; - break; - case NS: - recordTypeString = "NS"; - break; - case NULL: - recordTypeString = "NULL"; - break; - case NB: - recordTypeString = "NB"; - break; - case NBSTAT: - recordTypeString = "NBSTAT"; - break; - default: - recordTypeString = "0x" + Hexdump.toHexString( recordType, 4 ); - break; - } - - return new String( - "nameTrnId=" + nameTrnId + - ",isResponse=" + isResponse + - ",opCode=" + opCodeString + - ",isAuthAnswer=" + isAuthAnswer + - ",isTruncated=" + isTruncated + - ",isRecurAvailable=" + isRecurAvailable + - ",isRecurDesired=" + isRecurDesired + - ",isBroadcast=" + isBroadcast + - ",resultCode=" + resultCode + - ",questionCount=" + questionCount + - ",answerCount=" + answerCount + - ",authorityCount=" + authorityCount + - ",additionalCount=" + additionalCount + - ",questionName=" + questionName + - ",questionType=" + questionTypeString + - ",questionClass=" + ( questionClass == IN ? "IN" : - "0x" + Hexdump.toHexString( questionClass, 4 )) + - ",recordName=" + recordName + - ",recordType=" + recordTypeString + - ",recordClass=" + ( recordClass == IN ? "IN" : - "0x" + Hexdump.toHexString( recordClass, 4 )) + - ",ttl=" + ttl + - ",rDataLength=" + rDataLength ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtAddress.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtAddress.java deleted file mode 100644 index 03a60f1bb3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtAddress.java +++ /dev/null @@ -1,877 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.Config; -import jcifs.util.Hexdump; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.HashMap; - -/** - * This class represents a NetBIOS over TCP/IP address. Under normal - * conditions, users of jCIFS need not be concerned with this class as - * name resolution and session services are handled internally by the smb package. - * - * Applications can use the methods
getLocalHost, - *getByName, and - *getAllByAddressto create a new NbtAddress instance. This - * class is symmetric with {@link InetAddress}. - * - *About NetBIOS: The NetBIOS name - * service is a dynamic distributed service that allows hosts to resolve - * names by broadcasting a query, directing queries to a server such as - * Samba or WINS. NetBIOS is currently the primary networking layer for - * providing name service, datagram service, and session service to the - * Microsoft Windows platform. A NetBIOS name can be 15 characters long - * and hosts usually registers several names on the network. From a - * Windows command prompt you can see - * what names a host registers with the nbtstat command. - *
- *- * C:\>nbtstat -a 192.168.1.15 - * - * NetBIOS Remote Machine Name Table - * - * Name Type Status - * --------------------------------------------- - * JMORRIS2 <00> UNIQUE Registered - * BILLING-NY <00> GROUP Registered - * JMORRIS2 <03> UNIQUE Registered - * JMORRIS2 <20> UNIQUE Registered - * BILLING-NY <1E> GROUP Registered - * JMORRIS <03> UNIQUE Registered - * - * MAC Address = 00-B0-34-21-FA-3B - *The hostname of this machine is
JMORRIS2. It is - * a member of the group(a.k.a workgroup and domain)BILLING-NY. To - * obtain an {@link InetAddress} for a host one might do: - * - *- * InetAddress addr = NbtAddress.getByName( "jmorris2" ).getInetAddress(); - *- *From a UNIX platform with Samba installed you can perform similar - * diagnostics using the
nmblookuputility. - * - * @author Michael B. Allen - * @see InetAddress - * @since jcifs-0.1 - */ - -public final class NbtAddress { - -/* - * This is a special name that means all hosts. If you wish to find all hosts - * on a network querying a workgroup group name is the preferred method. - */ - - static final String ANY_HOSTS_NAME = "*\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"; - -/** - * This is a special name for querying the master browser that serves the - * list of hosts found in "Network Neighborhood". - */ - - public static final String MASTER_BROWSER_NAME = "\u0001\u0002__MSBROWSE__\u0002"; - -/** - * A special generic name specified when connecting to a host for which - * a name is not known. Not all servers respond to this name. - */ - - public static final String SMBSERVER_NAME = "*SMBSERVER "; - -/** - * A B node only broadcasts name queries. This is the default if a - * nameserver such as WINS or Samba is not specified. - */ - - public static final int B_NODE = 0; - -/** - * A Point-to-Point node, or P node, unicasts queries to a nameserver - * only. Natrually thejcifs.netbios.nameserverproperty must - * be set. - */ - - public static final int P_NODE = 1; - -/** - * Try Broadcast queries first, then try to resolve the name using the - * nameserver. - */ - - public static final int M_NODE = 2; - -/** - * A Hybrid node tries to resolve a name using the nameserver first. If - * that fails use the broadcast address. This is the default if a nameserver - * is provided. This is the behavior of Microsoft Windows machines. - */ - - public static final int H_NODE = 3; - - static final InetAddress[] NBNS = Config.getInetAddressArray( "jcifs.netbios.wins", ",", new InetAddress[0] ); - - /* Construct the shared static client object that will - * conduct all encoding and decoding of NetBIOS name service - * messages as well as socket IO in a synchronized fashon. - */ - - private static final NameServiceClient CLIENT = new NameServiceClient(); - - private static final int DEFAULT_CACHE_POLICY = 30; - private static final int CACHE_POLICY = Config.getInt( "jcifs.netbios.cachePolicy", DEFAULT_CACHE_POLICY ); - private static final int FOREVER = -1; - private static int nbnsIndex = 0; - - private static final HashMap ADDRESS_CACHE = new HashMap(); - private static final HashMap LOOKUP_TABLE = new HashMap(); - - static final Name UNKNOWN_NAME = new Name( "0.0.0.0", 0x00, null ); - static final NbtAddress UNKNOWN_ADDRESS = new NbtAddress( UNKNOWN_NAME, 0, false, B_NODE ); - static final byte[] UNKNOWN_MAC_ADDRESS = new byte[] { - (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00 - }; - - static final class CacheEntry { - Name hostName; - NbtAddress address; - long expiration; - - CacheEntry( Name hostName, NbtAddress address, long expiration ) { - this.hostName = hostName; - this.address = address; - this.expiration = expiration; - } - } - - static NbtAddress localhost; - - static { - InetAddress localInetAddress; - String localHostname; - Name localName; - - /* Create an address to represent failed lookups and cache forever. - */ - - ADDRESS_CACHE.put( UNKNOWN_NAME, new CacheEntry( UNKNOWN_NAME, UNKNOWN_ADDRESS, FOREVER )); - - /* Determine the InetAddress of the local interface - * if one was not specified. - */ - localInetAddress = CLIENT.laddr; - if( localInetAddress == null ) { - try { - localInetAddress = InetAddress.getLocalHost(); - } catch( UnknownHostException uhe ) { - /* Java cannot determine the localhost. This is basically a config - * issue on the host. There's not much we can do about it. Just - * to suppress NPEs that would result we can create a possibly bogus - * address. Pretty sure the below cannot actually thrown a UHE tho. - */ - try { - localInetAddress = InetAddress.getByName("127.0.0.1"); - } catch( UnknownHostException ignored ) { - } - } - } - - /* If a local hostname was not provided a name like - * JCIFS34_172_A6 will be dynamically generated for the - * client. This is primarily (exclusively?) used as a - * CallingName during session establishment. - */ - localHostname = Config.getProperty( "jcifs.netbios.hostname", null ); - if( localHostname == null || localHostname.length() == 0 ) { - byte[] addr = localInetAddress.getAddress(); - localHostname = "JCIFS" + - ( addr[2] & 0xFF ) + "_" + - ( addr[3] & 0xFF ) + "_" + - Hexdump.toHexString( (int)( Math.random() * (double)0xFF ), 2 ); - } - - /* Create an NbtAddress for the local interface with - * the name deduced above possibly with scope applied and - * cache it forever. - */ - localName = new Name( localHostname, 0x00, - Config.getProperty( "jcifs.netbios.scope", null )); - localhost = new NbtAddress( localName, - localInetAddress.hashCode(), - false, - B_NODE, - false, false, true, false, - UNKNOWN_MAC_ADDRESS ); - cacheAddress( localName, localhost, FOREVER ); - } - - static void cacheAddress( Name hostName, NbtAddress addr ) { - if( CACHE_POLICY == 0 ) { - return; - } - long expiration = -1; - if( CACHE_POLICY != FOREVER ) { - expiration = System.currentTimeMillis() + CACHE_POLICY * 1000; - } - cacheAddress( hostName, addr, expiration ); - } - static void cacheAddress( Name hostName, NbtAddress addr, long expiration ) { - if( CACHE_POLICY == 0 ) { - return; - } - synchronized( ADDRESS_CACHE ) { - CacheEntry entry = (CacheEntry)ADDRESS_CACHE.get( hostName ); - if( entry == null ) { - entry = new CacheEntry( hostName, addr, expiration ); - ADDRESS_CACHE.put( hostName, entry ); - } else { - entry.address = addr; - entry.expiration = expiration; - } - } - } - static void cacheAddressArray( NbtAddress[] addrs ) { - if( CACHE_POLICY == 0 ) { - return; - } - long expiration = -1; - if( CACHE_POLICY != FOREVER ) { - expiration = System.currentTimeMillis() + CACHE_POLICY * 1000; - } - synchronized( ADDRESS_CACHE ) { - for( int i = 0; i < addrs.length; i++ ) { - CacheEntry entry = (CacheEntry)ADDRESS_CACHE.get( addrs[i].hostName ); - if( entry == null ) { - entry = new CacheEntry( addrs[i].hostName, addrs[i], expiration ); - ADDRESS_CACHE.put( addrs[i].hostName, entry ); - } else { - entry.address = addrs[i]; - entry.expiration = expiration; - } - } - } - } - static NbtAddress getCachedAddress( Name hostName ) { - if( CACHE_POLICY == 0 ) { - return null; - } - synchronized( ADDRESS_CACHE ) { - CacheEntry entry = (CacheEntry)ADDRESS_CACHE.get( hostName ); - if( entry != null && entry.expiration < System.currentTimeMillis() && - entry.expiration >= 0 ) { - entry = null; - } - return entry != null ? entry.address : null; - } - } - - static NbtAddress doNameQuery( Name name, InetAddress svr ) - throws UnknownHostException { - NbtAddress addr; - - if( name.hexCode == 0x1d && svr == null ) { - svr = CLIENT.baddr; // bit of a hack but saves a lookup - } - name.srcHashCode = svr != null ? svr.hashCode() : 0; - addr = getCachedAddress( name ); - - if( addr == null ) { - /* This is almost exactly like InetAddress.java. See the - * comments there for a description of how the LOOKUP_TABLE prevents - * redundant queries from going out on the wire. - */ - if(( addr = (NbtAddress)checkLookupTable( name )) == null ) { - try { - addr = CLIENT.getByName( name, svr ); - } catch( UnknownHostException uhe ) { - addr = UNKNOWN_ADDRESS; - } finally { - cacheAddress( name, addr ); - updateLookupTable( name ); - } - } - } - if( addr == UNKNOWN_ADDRESS ) { - throw new UnknownHostException( name.toString() ); - } - return addr; - } - - private static Object checkLookupTable( Name name ) { - Object obj; - - synchronized( LOOKUP_TABLE ) { - if( LOOKUP_TABLE.containsKey( name ) == false ) { - LOOKUP_TABLE.put( name, name ); - return null; - } - while( LOOKUP_TABLE.containsKey( name )) { - try { - LOOKUP_TABLE.wait(); - } catch( InterruptedException e ) { - } - } - } - obj = getCachedAddress( name ); - if( obj == null ) { - synchronized( LOOKUP_TABLE ) { - LOOKUP_TABLE.put( name, name ); - } - } - - return obj; - } - private static void updateLookupTable( Name name ) { - synchronized( LOOKUP_TABLE ) { - LOOKUP_TABLE.remove( name ); - LOOKUP_TABLE.notifyAll(); - } - } - -/** - * Retrieves the local host address. - * - * @throws UnknownHostException This is not likely as the IP returned - * byInetAddressshould be available - */ - - public static NbtAddress getLocalHost() throws UnknownHostException { - return localhost; - } - public static Name getLocalName() { - return localhost.hostName; - } - -/** - * Determines the address of a host given it's host name. The name can be a NetBIOS name like - * "freto" or an IP address like "192.168.1.15". It cannot be a DNS name; - * the analygous {@link jcifs.UniAddress} or {@link InetAddress} - *getByNamemethods can be used for that. - * - * @param host hostname to resolve - * @throws UnknownHostException if there is an error resolving the name - */ - - public static NbtAddress getByName( String host ) - throws UnknownHostException { - return getByName( host, 0x00, null ); - } - -/** - * Determines the address of a host given it's host name. NetBIOS - * names also have atype. Types(aka Hex Codes) - * are used to distiquish the various services on a host. Here is - * a fairly complete list of NetBIOS hex codes. Scope is not used but is - * still functional in other NetBIOS products and so for completeness it has been - * implemented. Ascopeofnullor""- * signifies no scope. - * - * @param host the name to resolve - * @param type the hex code of the name - * @param scope the scope of the name - * @throws UnknownHostException if there is an error resolving the name - */ - - public static NbtAddress getByName( String host, - int type, - String scope ) - throws UnknownHostException { - - return getByName( host, type, scope, null ); - } - -/* - * The additionalsvrparameter specifies the address to - * query. This might be the address of a specific host, a name server, - * or a broadcast address. - */ - - public static NbtAddress getByName( String host, - int type, - String scope, - InetAddress svr ) - throws UnknownHostException { - - if( host == null || host.length() == 0 ) { - return getLocalHost(); - } - if( !Character.isDigit( host.charAt(0) )) { - return (NbtAddress)doNameQuery( new Name( host, type, scope ), svr ); - } else { - int IP = 0x00; - int hitDots = 0; - char[] data = host.toCharArray(); - - for( int i = 0; i < data.length; i++ ) { - char c = data[i]; - if( c < 48 || c > 57 ) { - return (NbtAddress)doNameQuery( new Name( host, type, scope ), svr ); - } - int b = 0x00; - while( c != '.' ) { - if( c < 48 || c > 57 ) { - return (NbtAddress)doNameQuery( new Name( host, type, scope ), svr ); - } - b = b * 10 + c - '0'; - - if( ++i >= data.length ) - break; - - c = data[i]; - } - if( b > 0xFF ) { - return (NbtAddress)doNameQuery( new Name( host, type, scope ), svr ); - } - IP = ( IP << 8 ) + b; - hitDots++; - } - if( hitDots != 4 || host.endsWith( "." )) { - return (NbtAddress)doNameQuery( new Name( host, type, scope ), svr ); - } - return new NbtAddress( UNKNOWN_NAME, IP, false, B_NODE ); - } - } - - public static NbtAddress[] getAllByName( String host, - int type, - String scope, - InetAddress svr ) - throws UnknownHostException { - return CLIENT.getAllByName( new Name( host, type, scope ), svr ); - } - -/** - * Retrieve all addresses of a host by it's address. NetBIOS hosts can - * have many names for a given IP address. The name and IP address make the - * NetBIOS address. This provides a way to retrieve the other names for a - * host with the same IP address. - * - * @param host hostname to lookup all addresses for - * @throws UnknownHostException if there is an error resolving the name - */ - - - public static NbtAddress[] getAllByAddress( String host ) - throws UnknownHostException { - return getAllByAddress( getByName( host, 0x00, null )); - } - - -/** - * Retrieve all addresses of a host by it's address. NetBIOS hosts can - * have many names for a given IP address. The name and IP address make - * the NetBIOS address. This provides a way to retrieve the other names - * for a host with the same IP address. See {@link #getByName} - * for a description oftype- * andscope. - * - * @param host hostname to lookup all addresses for - * @param type the hexcode of the name - * @param scope the scope of the name - * @throws UnknownHostException if there is an error resolving the name - */ - - - public static NbtAddress[] getAllByAddress( String host, - int type, - String scope ) - throws UnknownHostException { - return getAllByAddress( getByName( host, type, scope )); - } - - -/** - * Retrieve all addresses of a host by it's address. NetBIOS hosts can - * have many names for a given IP address. The name and IP address make the - * NetBIOS address. This provides a way to retrieve the other names for a - * host with the same IP address. - * - * @param addr the address to query - * @throws UnknownHostException if address cannot be resolved - */ - - public static NbtAddress[] getAllByAddress( NbtAddress addr ) - throws UnknownHostException { - try { - NbtAddress[] addrs = CLIENT.getNodeStatus( addr ); - cacheAddressArray( addrs ); - return addrs; - } catch( UnknownHostException uhe ) { - throw new UnknownHostException( "no name with type 0x" + - Hexdump.toHexString( addr.hostName.hexCode, 2 ) + - ((( addr.hostName.scope == null ) || - ( addr.hostName.scope.length() == 0 )) ? - " with no scope" : " with scope " + addr.hostName.scope ) + - " for host " + addr.getHostAddress() ); - } - } - - public static InetAddress getWINSAddress() { - return NBNS.length == 0 ? null : NBNS[nbnsIndex]; - } - public static boolean isWINS( InetAddress svr ) { - for( int i = 0; svr != null && i < NBNS.length; i++ ) { - if( svr.hashCode() == NBNS[i].hashCode() ) { - return true; - } - } - return false; - } - static InetAddress switchWINS() { - nbnsIndex = (nbnsIndex + 1) < NBNS.length ? nbnsIndex + 1 : 0; - return NBNS.length == 0 ? null : NBNS[nbnsIndex]; - } - - Name hostName; - int address, nodeType; - boolean groupName, - isBeingDeleted, - isInConflict, - isActive, - isPermanent, - isDataFromNodeStatus; - byte[] macAddress; - String calledName; - - NbtAddress( Name hostName, int address, boolean groupName, int nodeType ) { - this.hostName = hostName; - this.address = address; - this.groupName = groupName; - this.nodeType = nodeType; - } - - NbtAddress( Name hostName, - int address, - boolean groupName, - int nodeType, - boolean isBeingDeleted, - boolean isInConflict, - boolean isActive, - boolean isPermanent, - byte[] macAddress ) { - -/* The NodeStatusResponse.readNodeNameArray method may also set this - * information. These two places where node status data is populated should - * be consistent. Be carefull! - */ - this.hostName = hostName; - this.address = address; - this.groupName = groupName; - this.nodeType = nodeType; - this.isBeingDeleted = isBeingDeleted; - this.isInConflict = isInConflict; - this.isActive = isActive; - this.isPermanent = isPermanent; - this.macAddress = macAddress; - isDataFromNodeStatus = true; - } - -/* Guess next called name to try for session establishment. These - * methods are used by the smb package. - */ - - public String firstCalledName() { - - calledName = hostName.name; - - if( Character.isDigit( calledName.charAt( 0 ))) { - int i, len, dots; - char[] data; - - i = dots = 0; /* quick IP address validation */ - len = calledName.length(); - data = calledName.toCharArray(); - while( i < len && Character.isDigit( data[i++] )) { - if( i == len && dots == 3 ) { - // probably an IP address - calledName = SMBSERVER_NAME; - break; - } - if( i < len && data[i] == '.' ) { - dots++; - i++; - } - } - } else { - switch (hostName.hexCode) { - case 0x1B: - case 0x1C: - case 0x1D: - calledName = SMBSERVER_NAME; - } - } - - return calledName; - } - public String nextCalledName() { - - if( calledName == hostName.name ) { - calledName = SMBSERVER_NAME; - } else if( calledName == SMBSERVER_NAME ) { - NbtAddress[] addrs; - - try { - addrs = CLIENT.getNodeStatus( this ); - if( hostName.hexCode == 0x1D ) { - for( int i = 0; i < addrs.length; i++ ) { - if( addrs[i].hostName.hexCode == 0x20 ) { - return addrs[i].hostName.name; - } - } - return null; - } else if( isDataFromNodeStatus ) { - /* 'this' has been updated and should now - * have a real NetBIOS name - */ - calledName = null; - return hostName.name; - } - } catch( UnknownHostException uhe ) { - calledName = null; - } - } else { - calledName = null; - } - - return calledName; - } - -/* - * There are three degrees of state that any NbtAddress can have. - * - * 1) IP Address - If a dot-quad IP string is used with getByName (or used - * to create an NbtAddress internal to this netbios package), no query is - * sent on the wire and the only state this object has is it's IP address - * (but that's enough to connect to a host using *SMBSERVER for CallingName). - * - * 2) IP Address, NetBIOS name, nodeType, groupName - If however a - * legal NetBIOS name string is used a name query request will retreive - * the IP, node type, and whether or not this NbtAddress represents a - * group name. This degree of state can be obtained with a Name Query - * Request or Node Status Request. - * - * 3) All - The NbtAddress will be populated with all state such as mac - * address, isPermanent, isBeingDeleted, ...etc. This information can only - * be retrieved with the Node Status request. - * - * The degree of state that an NbtAddress has is dependant on how it was - * created and what is required of it. The second degree of state is the - * most common. This is the state information that would be retrieved from - * WINS for example. Natrually it is not practical for every NbtAddress - * to be populated will all state requiring a Node Status on every host - * encountered. The below methods allow state to be populated when requested - * in a lazy fashon. - */ - - void checkData() throws UnknownHostException { - if( hostName == UNKNOWN_NAME ) { - getAllByAddress( this ); - } - } - void checkNodeStatusData() throws UnknownHostException { - if( isDataFromNodeStatus == false ) { - getAllByAddress( this ); - } - } - -/** - * Determines if the address is a group address. This is also - * known as a workgroup name or group name. - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public boolean isGroupAddress() throws UnknownHostException { - checkData(); - return groupName; - } - -/** - * Checks the node type of this address. - * @return {@link NbtAddress#B_NODE}, - * {@link NbtAddress#P_NODE}, {@link NbtAddress#M_NODE}, - * {@link NbtAddress#H_NODE} - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public int getNodeType() throws UnknownHostException { - checkData(); - return nodeType; - } - -/** - * Determines if this address in the process of being deleted. - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public boolean isBeingDeleted() throws UnknownHostException { - checkNodeStatusData(); - return isBeingDeleted; - } - -/** - * Determines if this address in conflict with another address. - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public boolean isInConflict() throws UnknownHostException { - checkNodeStatusData(); - return isInConflict; - } - -/** - * Determines if this address is active. - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public boolean isActive() throws UnknownHostException { - checkNodeStatusData(); - return isActive; - } - -/** - * Determines if this address is set to be permanent. - * - * @throws UnknownHostException if the host cannot be resolved to find out. - */ - - public boolean isPermanent() throws UnknownHostException { - checkNodeStatusData(); - return isPermanent; - } - -/** - * Retrieves the MAC address of the remote network interface. Samba returns all zeros. - * - * @return the MAC address as an array of six bytes - * @throws UnknownHostException if the host cannot be resolved to - * determine the MAC address. - */ - - public byte[] getMacAddress() throws UnknownHostException { - checkNodeStatusData(); - return macAddress; - } - -/** - * The hostname of this address. If the hostname is null the local machines - * IP address is returned. - * - * @return the text representation of the hostname associated with this address - */ - - public String getHostName() { - /* 2010 - We no longer try a Node Status to get the - * hostname because apparently some servers do not respond - * anymore. I think everyone post Windows 98 will accept - * an IP address as the tconHostName which is the principal - * use of this method. - */ - if (hostName == UNKNOWN_NAME) { - return getHostAddress(); - } - return hostName.name; - } - - -/** - * Returns the raw IP address of this NbtAddress. The result is in network - * byte order: the highest order byte of the address is in getAddress()[0]. - * - * @return a four byte array - */ - - public byte[] getAddress() { - byte[] addr = new byte[4]; - - addr[0] = (byte)(( address >>> 24 ) & 0xFF ); - addr[1] = (byte)(( address >>> 16 ) & 0xFF ); - addr[2] = (byte)(( address >>> 8 ) & 0xFF ); - addr[3] = (byte)( address & 0xFF ); - return addr; - } - -/** - * To convert this address to anInetAddress. - * - * @return the {@link InetAddress} representation of this address. - */ - - public InetAddress getInetAddress() throws UnknownHostException { - return InetAddress.getByName( getHostAddress() ); - } - -/** - * Returns this IP adress as a {@link String} in the form "%d.%d.%d.%d". - */ - - public String getHostAddress() { - return (( address >>> 24 ) & 0xFF ) + "." + - (( address >>> 16 ) & 0xFF ) + "." + - (( address >>> 8 ) & 0xFF ) + "." + - (( address >>> 0 ) & 0xFF ); - } - -/** - * Returned the hex code associated with this name(e.g. 0x20 is for the file service) - */ - - public int getNameType() { - return hostName.hexCode; - } - -/** - * Returns a hashcode for this IP address. The hashcode comes from the IP address - * and is not generated from the string representation. So because NetBIOS nodes - * can have many names, all names associated with an IP will have the same - * hashcode. - */ - - public int hashCode() { - return address; - } - -/** - * Determines if this address is equal two another. Only the IP Addresses - * are compared. Similar to the {@link #hashCode} method, the comparison - * is based on the integer IP address and not the string representation. - */ - - public boolean equals( Object obj ) { - return ( obj != null ) && ( obj instanceof NbtAddress ) && - ( ((NbtAddress)obj).address == address ); - } - -/** - * Returns the {@link String} representaion of this address. - */ - - public String toString() { - return hostName.toString() + "/" + getHostAddress(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtException.java deleted file mode 100644 index b4f7f75776..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtException.java +++ /dev/null @@ -1,103 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.IOException; - -public class NbtException extends IOException { - - // error classes - public static final int SUCCESS = 0; - public static final int ERR_NAM_SRVC = 0x01; - public static final int ERR_SSN_SRVC = 0x02; - - // name service error codes - public static final int FMT_ERR = 0x1; - public static final int SRV_ERR = 0x2; - public static final int IMP_ERR = 0x4; - public static final int RFS_ERR = 0x5; - public static final int ACT_ERR = 0x6; - public static final int CFT_ERR = 0x7; - - // session service error codes - public static final int CONNECTION_REFUSED = -1; - public static final int NOT_LISTENING_CALLED = 0x80; - public static final int NOT_LISTENING_CALLING = 0x81; - public static final int CALLED_NOT_PRESENT = 0x82; - public static final int NO_RESOURCES = 0x83; - public static final int UNSPECIFIED = 0x8F; - - public int errorClass; - public int errorCode; - - public static String getErrorString( int errorClass, int errorCode ) { - String result = ""; - switch( errorClass ) { - case SUCCESS: - result += "SUCCESS"; - break; - case ERR_NAM_SRVC: - result += "ERR_NAM_SRVC/"; - switch( errorCode ) { - case FMT_ERR: - result += "FMT_ERR: Format Error"; - default: - result += "Unknown error code: " + errorCode; - } - break; - case ERR_SSN_SRVC: - result += "ERR_SSN_SRVC/"; - switch( errorCode ) { - case CONNECTION_REFUSED: - result += "Connection refused"; - break; - case NOT_LISTENING_CALLED: - result += "Not listening on called name"; - break; - case NOT_LISTENING_CALLING: - result += "Not listening for calling name"; - break; - case CALLED_NOT_PRESENT: - result += "Called name not present"; - break; - case NO_RESOURCES: - result += "Called name present, but insufficient resources"; - break; - case UNSPECIFIED: - result += "Unspecified error"; - break; - default: - result += "Unknown error code: " + errorCode; - } - break; - default: - result += "unknown error class: " + errorClass; - } - return result; - } - - public NbtException( int errorClass, int errorCode ) { - super( getErrorString( errorClass, errorCode )); - this.errorClass = errorClass; - this.errorCode = errorCode; - } - public String toString() { - return new String( "errorClass=" + errorClass + ",errorCode=" + errorCode + ",errorString=" + getErrorString( errorClass, errorCode )); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtSocket.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtSocket.java deleted file mode 100644 index d09b6e662a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NbtSocket.java +++ /dev/null @@ -1,135 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import jcifs.Config; -import jcifs.util.LogStream; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetAddress; -import java.net.Socket; - -/** -Do not use this class. Writing to the OutputStream of this type of socket -requires leaving a 4 byte prefix for the NBT header. IOW you must call -write( buf, 4, len ). Calling write( buf, 0, len ) will generate an error. - */ - -public class NbtSocket extends Socket { - - private static final int SSN_SRVC_PORT = 139; - private static final int BUFFER_SIZE = 512; - private static final int DEFAULT_SO_TIMEOUT = 5000; - - private static LogStream log = LogStream.getInstance(); - - private NbtAddress address; - private Name calledName; - private int soTimeout; - - public NbtSocket() { - super(); - } - public NbtSocket( NbtAddress address, int port ) throws IOException { - this( address, port, null, 0 ); - } - public NbtSocket( NbtAddress address, int port, - InetAddress localAddr, int localPort ) throws IOException { - this( address, null, port, localAddr, localPort ); - } - public NbtSocket( NbtAddress address, String calledName, int port, - InetAddress localAddr, int localPort ) throws IOException { - super( address.getInetAddress(), ( port == 0 ? SSN_SRVC_PORT : port ), - localAddr, localPort ); - this.address = address; - if( calledName == null ) { - this.calledName = address.hostName; - } else { - this.calledName = new Name( calledName, 0x20, null ); - } - soTimeout = Config.getInt( "jcifs.netbios.soTimeout", DEFAULT_SO_TIMEOUT ); - connect(); - } - - public NbtAddress getNbtAddress() { - return address; - } - public InputStream getInputStream() throws IOException { - return new SocketInputStream( super.getInputStream() ); - } - public OutputStream getOutputStream() throws IOException { - return new SocketOutputStream( super.getOutputStream() ); - } - public int getPort() { - return super.getPort(); - } - public InetAddress getLocalAddress() { - return super.getLocalAddress(); - } - public int getLocalPort() { - return super.getLocalPort(); - } - public String toString() { - return "NbtSocket[addr=" + address + - ",port=" + super.getPort() + - ",localport=" + super.getLocalPort() + "]"; - } - private void connect() throws IOException { - byte[] buffer = new byte[BUFFER_SIZE]; - int type; - InputStream in; - - try { - in = super.getInputStream(); - OutputStream out = super.getOutputStream(); - - SessionServicePacket ssp0 = new SessionRequestPacket( calledName, NbtAddress.localhost.hostName ); - out.write( buffer, 0, ssp0.writeWireFormat( buffer, 0 )); - - setSoTimeout( soTimeout ); - type = ssp0.readPacketType( in, buffer, 0 ); - } catch( IOException ioe ) { - close(); - throw ioe; - } - - switch( type ) { - case SessionServicePacket.POSITIVE_SESSION_RESPONSE: - if( log.level > 2 ) - log.println( "session established ok with " + address ); - return; - case SessionServicePacket.NEGATIVE_SESSION_RESPONSE: - int errorCode = (int)( in.read() & 0xFF ); - close(); - throw new NbtException( NbtException.ERR_SSN_SRVC, errorCode ); - case -1: - throw new NbtException( NbtException.ERR_SSN_SRVC, NbtException.CONNECTION_REFUSED ); - default: - close(); - throw new NbtException( NbtException.ERR_SSN_SRVC, 0 ); - } - } - public void close() throws IOException { - if( log.level > 3 ) - log.println( "close: " + this ); - super.close(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusRequest.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusRequest.java deleted file mode 100644 index 283c9c6e02..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusRequest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -class NodeStatusRequest extends NameServicePacket { - - NodeStatusRequest( Name name ) { - questionName = name; - questionType = NBSTAT; - isRecurDesired = false; - isBroadcast = false; - } - - int writeBodyWireFormat( byte[] dst, int dstIndex ) { - int tmp = questionName.hexCode; - questionName.hexCode = 0x00; // type has to be 0x00 for node status - int result = writeQuestionSectionWireFormat( dst, dstIndex ); - questionName.hexCode = tmp; - return result; - } - int readBodyWireFormat( byte[] src, int srcIndex ) { - return 0; - } - int writeRDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readRDataWireFormat( byte[] src, int srcIndex ) { - return 0; - } - public String toString() { - return new String( "NodeStatusRequest[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusResponse.java deleted file mode 100644 index 86879888b0..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/NodeStatusResponse.java +++ /dev/null @@ -1,144 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.UnsupportedEncodingException; - -class NodeStatusResponse extends NameServicePacket { - - private NbtAddress queryAddress; - - private int numberOfNames; - private byte[] macAddress; - private byte[] stats; - - NbtAddress[] addressArray; - - /* It is a little awkward but prudent to pass the quering address - * so that it may be included in the list of results. IOW we do - * not want to create a new NbtAddress object for this particular - * address from which the query is constructed, we want to populate - * the data of the existing address that should be one of several - * returned by the node status. - */ - - NodeStatusResponse( NbtAddress queryAddress ) { - this.queryAddress = queryAddress; - recordName = new Name(); - macAddress = new byte[6]; - } - - int writeBodyWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readBodyWireFormat( byte[] src, int srcIndex ) { - return readResourceRecordWireFormat( src, srcIndex ); - } - int writeRDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readRDataWireFormat( byte[] src, int srcIndex ) { - int start = srcIndex; - numberOfNames = src[srcIndex] & 0xFF; - int namesLength = numberOfNames * 18; - int statsLength = rDataLength - namesLength - 1; - numberOfNames = src[srcIndex++] & 0xFF; - // gotta read the mac first so we can populate addressArray with it - System.arraycopy( src, srcIndex + namesLength, macAddress, 0, 6 ); - srcIndex += readNodeNameArray( src, srcIndex ); - stats = new byte[statsLength]; - System.arraycopy( src, srcIndex, stats, 0, statsLength ); - srcIndex += statsLength; - return srcIndex - start; - } - private int readNodeNameArray( byte[] src, int srcIndex ) { - int start = srcIndex; - - addressArray = new NbtAddress[numberOfNames]; - - String n; - int hexCode; - String scope = queryAddress.hostName.scope; - boolean groupName; - int ownerNodeType; - boolean isBeingDeleted; - boolean isInConflict; - boolean isActive; - boolean isPermanent; - int j; - boolean addrFound = false; - - try { - for( int i = 0; i < numberOfNames; srcIndex += 18, i++ ) { - for( j = srcIndex + 14; src[j] == 0x20; j-- ) - ; - n = new String( src, srcIndex, j - srcIndex + 1, Name.OEM_ENCODING ); - hexCode = src[srcIndex + 15] & 0xFF; - groupName = (( src[srcIndex + 16] & 0x80 ) == 0x80 ) ? true : false; - ownerNodeType = ( src[srcIndex + 16] & 0x60 ) >> 5; - isBeingDeleted = (( src[srcIndex + 16] & 0x10 ) == 0x10 ) ? true : false; - isInConflict = (( src[srcIndex + 16] & 0x08 ) == 0x08 ) ? true : false; - isActive = (( src[srcIndex + 16] & 0x04 ) == 0x04 ) ? true : false; - isPermanent = (( src[srcIndex + 16] & 0x02 ) == 0x02 ) ? true : false; - - /* The NbtAddress object used to query this node will be in the list - * returned by the Node Status. A new NbtAddress object should not be - * created for it because the original is potentially being actively - * referenced by other objects. We must populate the existing object's - * data explicitly (and carefully). - */ - if( !addrFound && queryAddress.hostName.hexCode == hexCode && - ( queryAddress.hostName == NbtAddress.UNKNOWN_NAME || - queryAddress.hostName.name.equals( n ))) { - - if( queryAddress.hostName == NbtAddress.UNKNOWN_NAME ) { - queryAddress.hostName = new Name( n, hexCode, scope ); - } - queryAddress.groupName = groupName; - queryAddress.nodeType = ownerNodeType; - queryAddress.isBeingDeleted = isBeingDeleted; - queryAddress.isInConflict = isInConflict; - queryAddress.isActive = isActive; - queryAddress.isPermanent = isPermanent; - queryAddress.macAddress = macAddress; - queryAddress.isDataFromNodeStatus = true; - addrFound = true; - addressArray[i] = queryAddress; - } else { - addressArray[i] = new NbtAddress( new Name( n, hexCode, scope ), - queryAddress.address, - groupName, - ownerNodeType, - isBeingDeleted, - isInConflict, - isActive, - isPermanent, - macAddress ); - } - } - } catch( UnsupportedEncodingException uee ) { - } - return srcIndex - start; - } - public String toString() { - return new String( "NodeStatusResponse[" + - super.toString() + "]" ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRequestPacket.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRequestPacket.java deleted file mode 100644 index 28325df23b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRequestPacket.java +++ /dev/null @@ -1,55 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.IOException; -import java.io.InputStream; - -public class SessionRequestPacket extends SessionServicePacket { - - private Name calledName, callingName; - - SessionRequestPacket() { - calledName = new Name(); - callingName = new Name(); - } - public SessionRequestPacket( Name calledName, Name callingName ) { - type = SESSION_REQUEST; - this.calledName = calledName; - this.callingName = callingName; - } - int writeTrailerWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - dstIndex += calledName.writeWireFormat( dst, dstIndex ); - dstIndex += callingName.writeWireFormat( dst, dstIndex ); - return dstIndex - start; - } - int readTrailerWireFormat( InputStream in, - byte[] buffer, - int bufferIndex ) - throws IOException { - int start = bufferIndex; - if( in.read( buffer, bufferIndex, length ) != length ) { - throw new IOException( "invalid session request wire format" ); - } - bufferIndex += calledName.readWireFormat( buffer, bufferIndex ); - bufferIndex += callingName.readWireFormat( buffer, bufferIndex ); - return bufferIndex - start; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRetargetResponsePacket.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRetargetResponsePacket.java deleted file mode 100644 index dafd1d4991..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionRetargetResponsePacket.java +++ /dev/null @@ -1,50 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.IOException; -import java.io.InputStream; - -class SessionRetargetResponsePacket extends SessionServicePacket { - - private NbtAddress retargetAddress; - private int retargetPort; - - SessionRetargetResponsePacket() { - type = SESSION_RETARGET_RESPONSE; - length = 6; - } - - int writeTrailerWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readTrailerWireFormat( InputStream in, - byte[] buffer, - int bufferIndex ) - throws IOException { - if( in.read( buffer, bufferIndex, length ) != length ) { - throw new IOException( "unexpected EOF reading netbios retarget session response" ); - } - int addr = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - retargetAddress = new NbtAddress( null, addr, false, NbtAddress.B_NODE ); - retargetPort = readInt2( buffer, bufferIndex ); - return length; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionServicePacket.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionServicePacket.java deleted file mode 100644 index 66174eff96..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SessionServicePacket.java +++ /dev/null @@ -1,128 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.IOException; -import java.io.InputStream; - -public abstract class SessionServicePacket { - - // session service packet types - static final int SESSION_MESSAGE = 0x00; - static final int SESSION_REQUEST = 0x81; - public static final int POSITIVE_SESSION_RESPONSE = 0x82; - public static final int NEGATIVE_SESSION_RESPONSE = 0x83; - static final int SESSION_RETARGET_RESPONSE = 0x84; - static final int SESSION_KEEP_ALIVE = 0x85; - - static final int MAX_MESSAGE_SIZE = 0x0001FFFF; - static final int HEADER_LENGTH = 4; - - static void writeInt2( int val, byte[] dst, int dstIndex ) { - dst[dstIndex++] = (byte)(( val >> 8 ) & 0xFF ); - dst[dstIndex] = (byte)( val & 0xFF ); - } - static void writeInt4( int val, byte[] dst, int dstIndex ) { - dst[dstIndex++] = (byte)(( val >> 24 ) & 0xFF ); - dst[dstIndex++] = (byte)(( val >> 16 ) & 0xFF ); - dst[dstIndex++] = (byte)(( val >> 8 ) & 0xFF ); - dst[dstIndex] = (byte)( val & 0xFF ); - } - static int readInt2( byte[] src, int srcIndex ) { - return (( src[srcIndex] & 0xFF ) << 8 ) + - ( src[srcIndex + 1] & 0xFF ); - } - static int readInt4( byte[] src, int srcIndex ) { - return (( src[srcIndex] & 0xFF ) << 24 ) + - (( src[srcIndex + 1] & 0xFF ) << 16 ) + - (( src[srcIndex + 2] & 0xFF ) << 8 ) + - ( src[srcIndex + 3] & 0xFF ); - } - static int readLength( byte[] src, int srcIndex ) { - srcIndex++; - return (( src[srcIndex++] & 0x01 ) << 16 ) + - (( src[srcIndex++] & 0xFF ) << 8 ) + - ( src[srcIndex++] & 0xFF ); - } - static int readn( InputStream in, - byte[] b, - int off, - int len ) throws IOException { - int i = 0, n; - - while (i < len) { - n = in.read( b, off + i, len - i ); - if (n <= 0) { - break; - } - i += n; - } - - return i; - } - static int readPacketType( InputStream in, - byte[] buffer, - int bufferIndex ) - throws IOException { - int n; - if(( n = readn( in, buffer, bufferIndex, HEADER_LENGTH )) != HEADER_LENGTH ) { - if( n == -1 ) { - return -1; - } - throw new IOException( "unexpected EOF reading netbios session header" ); - } - int t = buffer[bufferIndex] & 0xFF; - return t; - } - - int type, length; - - public int writeWireFormat( byte[] dst, int dstIndex ) { - length = writeTrailerWireFormat( dst, dstIndex + HEADER_LENGTH ); - writeHeaderWireFormat( dst, dstIndex ); - return HEADER_LENGTH + length; - } - int readWireFormat( InputStream in, byte[] buffer, int bufferIndex ) throws IOException { - readHeaderWireFormat( in, buffer, bufferIndex ); - return HEADER_LENGTH + readTrailerWireFormat( in, buffer, bufferIndex ); - } - int writeHeaderWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = (byte)type; - if( length > 0x0000FFFF ) { - dst[dstIndex] = (byte)0x01; - } - dstIndex++; - writeInt2( length, dst, dstIndex ); - return HEADER_LENGTH; - } - int readHeaderWireFormat( InputStream in, - byte[] buffer, - int bufferIndex ) - throws IOException { - type = buffer[bufferIndex++] & 0xFF; - length = (( buffer[bufferIndex] & 0x01 ) << 16 ) + readInt2( buffer, bufferIndex + 1 ); - return HEADER_LENGTH; - } - - abstract int writeTrailerWireFormat( byte[] dst, int dstIndex ); - abstract int readTrailerWireFormat( InputStream in, - byte[] buffer, - int bufferIndex ) - throws IOException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketInputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketInputStream.java deleted file mode 100644 index acc73f869b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketInputStream.java +++ /dev/null @@ -1,112 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.IOException; -import java.io.InputStream; - -class SocketInputStream extends InputStream { - - private static final int TMP_BUFFER_SIZE = 256; - - private InputStream in; - private SessionServicePacket ssp; - private int tot, bip, n; - private byte[] header, tmp; - - SocketInputStream( InputStream in ) { - this.in = in; - header = new byte[4]; - tmp = new byte[TMP_BUFFER_SIZE]; - } - - public synchronized int read() throws IOException { - if( read( tmp, 0, 1 ) < 0 ) { - return -1; - } - return tmp[0] & 0xFF; - } - public synchronized int read( byte[] b ) throws IOException { - return read( b, 0, b.length ); - } - - /* This method will not return until len bytes have been read - * or the stream has been closed. - */ - - public synchronized int read( byte[] b, int off, int len ) throws IOException { - if( len == 0 ) { - return 0; - } - tot = 0; - - while( true ) { - while( bip > 0 ) { - n = in.read( b, off, Math.min( len, bip )); - if( n == -1 ) { - return tot > 0 ? tot : -1; - } - tot += n; - off += n; - len -= n; - bip -= n; - if( len == 0 ) { - return tot; - } - } - - switch( SessionServicePacket.readPacketType( in, header, 0 )) { - case SessionServicePacket.SESSION_KEEP_ALIVE: - break; - case SessionServicePacket.SESSION_MESSAGE: - bip = SessionServicePacket.readLength( header, 0 ); - break; - case -1: - if( tot > 0 ) { - return tot; - } - return -1; - } - } - } - public synchronized long skip( long numbytes ) throws IOException { - if( numbytes <= 0 ) { - return 0; - } - long n = numbytes; - while( n > 0 ) { - int r = read( tmp, 0, (int)Math.min( (long)TMP_BUFFER_SIZE, n )); - if (r < 0) { - break; - } - n -= r; - } - return numbytes - n; - } - public int available() throws IOException { - if( bip > 0 ) { - return bip; - } - return in.available(); - } - public void close() throws IOException { - in.close(); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketOutputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketOutputStream.java deleted file mode 100644 index 66dcd0e2ee..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/netbios/SocketOutputStream.java +++ /dev/null @@ -1,47 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.netbios; - -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -class SocketOutputStream extends FilterOutputStream { - - SocketOutputStream( OutputStream out ) { - super( out ); - } - - public synchronized void write( byte[] b, int off, int len ) throws IOException { - if( len > 0xFFFF ) { - throw new IOException( "write too large: " + len ); - } else if( off < 4 ) { - throw new IOException( "NetBIOS socket output buffer requires 4 bytes available before off" ); - } - - off -= 4; - - b[off + 0] = (byte)SessionServicePacket.SESSION_MESSAGE; - b[off + 1] = (byte)0x00; - b[off + 2] = (byte)(( len >> 8 ) & 0xFF ); - b[off + 3] = (byte)( len & 0xFF ); - - out.write( b, off, 4 + len ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmFlags.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmFlags.java deleted file mode 100644 index 9cd8d50e52..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmFlags.java +++ /dev/null @@ -1,155 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.ntlmssp; - -/** - * Flags used during negotiation of NTLMSSP authentication. - */ -public interface NtlmFlags { - - /** - * Indicates whether Unicode strings are supported or used. - */ - public static final int NTLMSSP_NEGOTIATE_UNICODE = 0x00000001; - - /** - * Indicates whether OEM strings are supported or used. - */ - public static final int NTLMSSP_NEGOTIATE_OEM = 0x00000002; - - /** - * Indicates whether the authentication target is requested from - * the server. - */ - public static final int NTLMSSP_REQUEST_TARGET = 0x00000004; - - /** - * Specifies that communication across the authenticated channel - * should carry a digital signature (message integrity). - */ - public static final int NTLMSSP_NEGOTIATE_SIGN = 0x00000010; - - /** - * Specifies that communication across the authenticated channel - * should be encrypted (message confidentiality). - */ - public static final int NTLMSSP_NEGOTIATE_SEAL = 0x00000020; - - /** - * Indicates datagram authentication. - */ - public static final int NTLMSSP_NEGOTIATE_DATAGRAM_STYLE = 0x00000040; - - /** - * Indicates that the LAN Manager session key should be used for - * signing and sealing authenticated communication. - */ - public static final int NTLMSSP_NEGOTIATE_LM_KEY = 0x00000080; - - public static final int NTLMSSP_NEGOTIATE_NETWARE = 0x00000100; - - /** - * Indicates support for NTLM authentication. - */ - public static final int NTLMSSP_NEGOTIATE_NTLM = 0x00000200; - - /** - * Indicates whether the OEM-formatted domain name in which the - * client workstation has membership is supplied in the Type-1 message. - * This is used in the negotation of local authentication. - */ - public static final int NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED = - 0x00001000; - - /** - * Indicates whether the OEM-formatted workstation name is supplied - * in the Type-1 message. This is used in the negotiation of local - * authentication. - */ - public static final int NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED = - 0x00002000; - - /** - * Sent by the server to indicate that the server and client are - * on the same machine. This implies that the server will include - * a local security context handle in the Type 2 message, for - * use in local authentication. - */ - public static final int NTLMSSP_NEGOTIATE_LOCAL_CALL = 0x00004000; - - /** - * Indicates that authenticated communication between the client - * and server should carry a "dummy" digital signature. - */ - public static final int NTLMSSP_NEGOTIATE_ALWAYS_SIGN = 0x00008000; - - /** - * Sent by the server in the Type 2 message to indicate that the - * target authentication realm is a domain. - */ - public static final int NTLMSSP_TARGET_TYPE_DOMAIN = 0x00010000; - - /** - * Sent by the server in the Type 2 message to indicate that the - * target authentication realm is a server. - */ - public static final int NTLMSSP_TARGET_TYPE_SERVER = 0x00020000; - - /** - * Sent by the server in the Type 2 message to indicate that the - * target authentication realm is a share (presumably for share-level - * authentication). - */ - public static final int NTLMSSP_TARGET_TYPE_SHARE = 0x00040000; - - /** - * Indicates that the NTLM2 signing and sealing scheme should be used - * for protecting authenticated communications. This refers to a - * particular session security scheme, and is not related to the use - * of NTLMv2 authentication. - */ - public static final int NTLMSSP_NEGOTIATE_NTLM2 = 0x00080000; - - public static final int NTLMSSP_REQUEST_INIT_RESPONSE = 0x00100000; - - public static final int NTLMSSP_REQUEST_ACCEPT_RESPONSE = 0x00200000; - - public static final int NTLMSSP_REQUEST_NON_NT_SESSION_KEY = 0x00400000; - - /** - * Sent by the server in the Type 2 message to indicate that it is - * including a Target Information block in the message. The Target - * Information block is used in the calculation of the NTLMv2 response. - */ - public static final int NTLMSSP_NEGOTIATE_TARGET_INFO = 0x00800000; - - /** - * Indicates that 128-bit encryption is supported. - */ - public static final int NTLMSSP_NEGOTIATE_128 = 0x20000000; - - public static final int NTLMSSP_NEGOTIATE_KEY_EXCH = 0x40000000; - - /** - * Indicates that 56-bit encryption is supported. - */ - public static final int NTLMSSP_NEGOTIATE_56 = 0x80000000; - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmMessage.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmMessage.java deleted file mode 100644 index 68faa9b5f1..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/NtlmMessage.java +++ /dev/null @@ -1,136 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.ntlmssp; - -import jcifs.Config; - -/** - * Abstract superclass for all NTLMSSP messages. - */ -public abstract class NtlmMessage implements NtlmFlags { - - /** - * The NTLMSSP "preamble". - */ - protected static final byte[] NTLMSSP_SIGNATURE = new byte[] { - (byte) 'N', (byte) 'T', (byte) 'L', (byte) 'M', - (byte) 'S', (byte) 'S', (byte) 'P', (byte) 0 - }; - - private static final String OEM_ENCODING = Config.DEFAULT_OEM_ENCODING; - protected static final String UNI_ENCODING = "UTF-16LE"; - - private int flags; - - /** - * Returns the flags currently in use for this message. - * - * @return An intcontaining the flags in use for this - * message. - */ - public int getFlags() { - return flags; - } - - /** - * Sets the flags for this message. - * - * @param flags The flags for this message. - */ - public void setFlags(int flags) { - this.flags = flags; - } - - /** - * Returns the status of the specified flag. - * - * @param flag The flag to test (i.e.,NTLMSSP_NEGOTIATE_OEM). - * @return Abooleanindicating whether the flag is set. - */ - public boolean getFlag(int flag) { - return (getFlags() & flag) != 0; - } - - /** - * Sets or clears the specified flag. - * - * @param flag The flag to set/clear (i.e., - *NTLMSSP_NEGOTIATE_OEM). - * @param value Indicates whether to set (true) or - * clear (false) the specified flag. - */ - public void setFlag(int flag, boolean value) { - setFlags(value ? (getFlags() | flag) : - (getFlags() & (0xffffffff ^ flag))); - } - - static int readULong(byte[] src, int index) { - return (src[index] & 0xff) | - ((src[index + 1] & 0xff) << 8) | - ((src[index + 2] & 0xff) << 16) | - ((src[index + 3] & 0xff) << 24); - } - - static int readUShort(byte[] src, int index) { - return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8); - } - - static byte[] readSecurityBuffer(byte[] src, int index) { - int length = readUShort(src, index); - int offset = readULong(src, index + 4); - byte[] buffer = new byte[length]; - System.arraycopy(src, offset, buffer, 0, length); - return buffer; - } - - static void writeULong(byte[] dest, int offset, int ulong) { - dest[offset] = (byte) (ulong & 0xff); - dest[offset + 1] = (byte) (ulong >> 8 & 0xff); - dest[offset + 2] = (byte) (ulong >> 16 & 0xff); - dest[offset + 3] = (byte) (ulong >> 24 & 0xff); - } - - static void writeUShort(byte[] dest, int offset, int ushort) { - dest[offset] = (byte) (ushort & 0xff); - dest[offset + 1] = (byte) (ushort >> 8 & 0xff); - } - - static void writeSecurityBuffer(byte[] dest, int offset, int bodyOffset, - byte[] src) { - int length = (src != null) ? src.length : 0; - if (length == 0) return; - writeUShort(dest, offset, length); - writeUShort(dest, offset + 2, length); - writeULong(dest, offset + 4, bodyOffset); - System.arraycopy(src, 0, dest, bodyOffset, length); - } - - static String getOEMEncoding() { - return OEM_ENCODING; - } - - /** - * Returns the raw byte representation of this message. - * - * @return Abyte[]containing the raw message material. - */ - public abstract byte[] toByteArray(); - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type1Message.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type1Message.java deleted file mode 100644 index 8a8725818a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type1Message.java +++ /dev/null @@ -1,228 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.ntlmssp; - -import jcifs.Config; -import jcifs.netbios.NbtAddress; - -import java.io.IOException; -import java.net.UnknownHostException; - -/** - * Represents an NTLMSSP Type-1 message. - */ -public class Type1Message extends NtlmMessage { - - private static final int DEFAULT_FLAGS; - - private static final String DEFAULT_DOMAIN; - - private static final String DEFAULT_WORKSTATION; - - private String suppliedDomain; - - private String suppliedWorkstation; - - static { - DEFAULT_FLAGS = NTLMSSP_NEGOTIATE_NTLM | - (Config.getBoolean("jcifs.smb.client.useUnicode", true) ? - NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM); - DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", null); - String defaultWorkstation = null; - try { - defaultWorkstation = NbtAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ex) { } - DEFAULT_WORKSTATION = defaultWorkstation; - } - - /** - * Creates a Type-1 message using default values from the current - * environment. - */ - public Type1Message() { - this(getDefaultFlags(), getDefaultDomain(), getDefaultWorkstation()); - } - - /** - * Creates a Type-1 message with the specified parameters. - * - * @param flags The flags to apply to this message. - * @param suppliedDomain The supplied authentication domain. - * @param suppliedWorkstation The supplied workstation name. - */ - public Type1Message(int flags, String suppliedDomain, - String suppliedWorkstation) { - setFlags(getDefaultFlags() | flags); - setSuppliedDomain(suppliedDomain); - if (suppliedWorkstation == null) - suppliedWorkstation = getDefaultWorkstation(); - setSuppliedWorkstation(suppliedWorkstation); - } - - /** - * Creates a Type-1 message using the given raw Type-1 material. - * - * @param material The raw Type-1 material used to construct this message. - * @throws IOException If an error occurs while parsing the material. - */ - public Type1Message(byte[] material) throws IOException { - parse(material); - } - - /** - * Returns the supplied authentication domain. - * - * @return A Stringcontaining the supplied domain. - */ - public String getSuppliedDomain() { - return suppliedDomain; - } - - /** - * Sets the supplied authentication domain for this message. - * - * @param suppliedDomain The supplied domain for this message. - */ - public void setSuppliedDomain(String suppliedDomain) { - this.suppliedDomain = suppliedDomain; - } - - /** - * Returns the supplied workstation name. - * - * @return AStringcontaining the supplied workstation name. - */ - public String getSuppliedWorkstation() { - return suppliedWorkstation; - } - - /** - * Sets the supplied workstation name for this message. - * - * @param suppliedWorkstation The supplied workstation for this message. - */ - public void setSuppliedWorkstation(String suppliedWorkstation) { - this.suppliedWorkstation = suppliedWorkstation; - } - - public byte[] toByteArray() { - try { - String suppliedDomain = getSuppliedDomain(); - String suppliedWorkstation = getSuppliedWorkstation(); - int flags = getFlags(); - boolean hostInfo = false; - byte[] domain = new byte[0]; - if (suppliedDomain != null && suppliedDomain.length() != 0) { - hostInfo = true; - flags |= NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED; - domain = suppliedDomain.toUpperCase().getBytes( - getOEMEncoding()); - } else { - flags &= (NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED ^ 0xffffffff); - } - byte[] workstation = new byte[0]; - if (suppliedWorkstation != null && - suppliedWorkstation.length() != 0) { - hostInfo = true; - flags |= NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED; - workstation = - suppliedWorkstation.toUpperCase().getBytes( - getOEMEncoding()); - } else { - flags &= (NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED ^ - 0xffffffff); - } - byte[] type1 = new byte[hostInfo ? - (32 + domain.length + workstation.length) : 16]; - System.arraycopy(NTLMSSP_SIGNATURE, 0, type1, 0, 8); - writeULong(type1, 8, 1); - writeULong(type1, 12, flags); - if (hostInfo) { - writeSecurityBuffer(type1, 16, 32, domain); - writeSecurityBuffer(type1, 24, 32 + domain.length, workstation); - } - return type1; - } catch (IOException ex) { - throw new IllegalStateException(ex.getMessage()); - } - } - - public String toString() { - String suppliedDomain = getSuppliedDomain(); - String suppliedWorkstation = getSuppliedWorkstation(); - return "Type1Message[suppliedDomain=" + (suppliedDomain == null ? "null" : suppliedDomain) + - ",suppliedWorkstation=" + (suppliedWorkstation == null ? "null" : suppliedWorkstation) + - ",flags=0x" + jcifs.util.Hexdump.toHexString(getFlags(), 8) + "]"; - } - - /** - * Returns the default flags for a generic Type-1 message in the - * current environment. - * - * @return Anintcontaining the default flags. - */ - public static int getDefaultFlags() { - return DEFAULT_FLAGS; - } - - /** - * Returns the default domain from the current environment. - * - * @return AStringcontaining the default domain. - */ - public static String getDefaultDomain() { - return DEFAULT_DOMAIN; - } - - /** - * Returns the default workstation from the current environment. - * - * @return AStringcontaining the default workstation. - */ - public static String getDefaultWorkstation() { - return DEFAULT_WORKSTATION; - } - - private void parse(byte[] material) throws IOException { - for (int i = 0; i < 8; i++) { - if (material[i] != NTLMSSP_SIGNATURE[i]) { - throw new IOException("Not an NTLMSSP message."); - } - } - if (readULong(material, 8) != 1) { - throw new IOException("Not a Type 1 message."); - } - int flags = readULong(material, 12); - String suppliedDomain = null; - if ((flags & NTLMSSP_NEGOTIATE_OEM_DOMAIN_SUPPLIED) != 0) { - byte[] domain = readSecurityBuffer(material, 16); - suppliedDomain = new String(domain, getOEMEncoding()); - } - String suppliedWorkstation = null; - if ((flags & NTLMSSP_NEGOTIATE_OEM_WORKSTATION_SUPPLIED) != 0) { - byte[] workstation = readSecurityBuffer(material, 24); - suppliedWorkstation = new String(workstation, getOEMEncoding()); - } - setFlags(flags); - setSuppliedDomain(suppliedDomain); - setSuppliedWorkstation(suppliedWorkstation); - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type2Message.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type2Message.java deleted file mode 100644 index ed42e7f41b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type2Message.java +++ /dev/null @@ -1,367 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.ntlmssp; - -import jcifs.Config; -import jcifs.netbios.NbtAddress; - -import java.io.IOException; -import java.net.UnknownHostException; - -/** - * Represents an NTLMSSP Type-2 message. - */ -public class Type2Message extends NtlmMessage { - - private static final int DEFAULT_FLAGS; - - private static final String DEFAULT_DOMAIN; - - private static final byte[] DEFAULT_TARGET_INFORMATION; - - private byte[] challenge; - - private String target; - - private byte[] context; - - private byte[] targetInformation; - - static { - DEFAULT_FLAGS = NTLMSSP_NEGOTIATE_NTLM | - (Config.getBoolean("jcifs.smb.client.useUnicode", true) ? - NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM); - DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", null); - byte[] domain = new byte[0]; - if (DEFAULT_DOMAIN != null) { - try { - domain = DEFAULT_DOMAIN.getBytes(UNI_ENCODING); - } catch (IOException ex) { } - } - int domainLength = domain.length; - byte[] server = new byte[0]; - try { - String host = NbtAddress.getLocalHost().getHostName(); - if (host != null) { - try { - server = host.getBytes(UNI_ENCODING); - } catch (IOException ex) { } - } - } catch (UnknownHostException ex) { } - int serverLength = server.length; - byte[] targetInfo = new byte[(domainLength > 0 ? domainLength + 4 : 0) + - (serverLength > 0 ? serverLength + 4 : 0) + 4]; - int offset = 0; - if (domainLength > 0) { - writeUShort(targetInfo, offset, 2); - offset += 2; - writeUShort(targetInfo, offset, domainLength); - offset += 2; - System.arraycopy(domain, 0, targetInfo, offset, domainLength); - offset += domainLength; - } - if (serverLength > 0) { - writeUShort(targetInfo, offset, 1); - offset += 2; - writeUShort(targetInfo, offset, serverLength); - offset += 2; - System.arraycopy(server, 0, targetInfo, offset, serverLength); - } - DEFAULT_TARGET_INFORMATION = targetInfo; - } - - /** - * Creates a Type-2 message using default values from the current - * environment. - */ - public Type2Message() { - this(getDefaultFlags(), null, null); - } - - /** - * Creates a Type-2 message in response to the given Type-1 message - * using default values from the current environment. - * - * @param type1 The Type-1 message which this represents a response to. - */ - public Type2Message(Type1Message type1) { - this(type1, null, null); - } - - /** - * Creates a Type-2 message in response to the given Type-1 message. - * - * @param type1 The Type-1 message which this represents a response to. - * @param challenge The challenge from the domain controller/server. - * @param target The authentication target. - */ - public Type2Message(Type1Message type1, byte[] challenge, String target) { - this(getDefaultFlags(type1), challenge, (type1 != null && - target == null && type1.getFlag(NTLMSSP_REQUEST_TARGET)) ? - getDefaultDomain() : target); - } - - /** - * Creates a Type-2 message with the specified parameters. - * - * @param flags The flags to apply to this message. - * @param challenge The challenge from the domain controller/server. - * @param target The authentication target. - */ - public Type2Message(int flags, byte[] challenge, String target) { - setFlags(flags); - setChallenge(challenge); - setTarget(target); - if (target != null) setTargetInformation(getDefaultTargetInformation()); - } - - /** - * Creates a Type-2 message using the given raw Type-2 material. - * - * @param material The raw Type-2 material used to construct this message. - * @throws IOException If an error occurs while parsing the material. - */ - public Type2Message(byte[] material) throws IOException { - parse(material); - } - - /** - * Returns the challenge for this message. - * - * @return A byte[]containing the challenge. - */ - public byte[] getChallenge() { - return challenge; - } - - /** - * Sets the challenge for this message. - * - * @param challenge The challenge from the domain controller/server. - */ - public void setChallenge(byte[] challenge) { - this.challenge = challenge; - } - - /** - * Returns the authentication target. - * - * @return AStringcontaining the authentication target. - */ - public String getTarget() { - return target; - } - - /** - * Sets the authentication target. - * - * @param target The authentication target. - */ - public void setTarget(String target) { - this.target = target; - } - - /** - * Returns the target information block. - * - * @return Abyte[]containing the target information block. - * The target information block is used by the client to create an - * NTLMv2 response. - */ - public byte[] getTargetInformation() { - return targetInformation; - } - - /** - * Sets the target information block. - * The target information block is used by the client to create - * an NTLMv2 response. - * - * @param targetInformation The target information block. - */ - public void setTargetInformation(byte[] targetInformation) { - this.targetInformation = targetInformation; - } - - /** - * Returns the local security context. - * - * @return Abyte[]containing the local security - * context. This is used by the client to negotiate local - * authentication. - */ - public byte[] getContext() { - return context; - } - - /** - * Sets the local security context. This is used by the client - * to negotiate local authentication. - * - * @param context The local security context. - */ - public void setContext(byte[] context) { - this.context = context; - } - - public byte[] toByteArray() { - try { - String targetName = getTarget(); - byte[] challenge = getChallenge(); - byte[] context = getContext(); - byte[] targetInformation = getTargetInformation(); - int flags = getFlags(); - byte[] target = new byte[0]; - if ((flags & NTLMSSP_REQUEST_TARGET) != 0) { - if (targetName != null && targetName.length() != 0) { - target = (flags & NTLMSSP_NEGOTIATE_UNICODE) != 0 ? - targetName.getBytes(UNI_ENCODING) : - targetName.toUpperCase().getBytes(getOEMEncoding()); - } else { - flags &= (0xffffffff ^ NTLMSSP_REQUEST_TARGET); - } - } - if (targetInformation != null) { - flags |= NTLMSSP_NEGOTIATE_TARGET_INFO; - // empty context is needed for padding when t.i. is supplied. - if (context == null) context = new byte[8]; - } - int data = 32; - if (context != null) data += 8; - if (targetInformation != null) data += 8; - byte[] type2 = new byte[data + target.length + - (targetInformation != null ? targetInformation.length : 0)]; - System.arraycopy(NTLMSSP_SIGNATURE, 0, type2, 0, 8); - writeULong(type2, 8, 2); - writeSecurityBuffer(type2, 12, data, target); - writeULong(type2, 20, flags); - System.arraycopy(challenge != null ? challenge : new byte[8], 0, - type2, 24, 8); - if (context != null) System.arraycopy(context, 0, type2, 32, 8); - if (targetInformation != null) { - writeSecurityBuffer(type2, 40, data + target.length, - targetInformation); - } - return type2; - } catch (IOException ex) { - throw new IllegalStateException(ex.getMessage()); - } - } - - public String toString() { - String target = getTarget(); - byte[] challenge = getChallenge(); - byte[] context = getContext(); - byte[] targetInformation = getTargetInformation(); - - return "Type2Message[target=" + target + - ",challenge=" + (challenge == null ? "null" : "<" + challenge.length + " bytes>") + - ",context=" + (context == null ? "null" : "<" + context.length + " bytes>") + - ",targetInformation=" + (targetInformation == null ? "null" : "<" + targetInformation.length + " bytes>") + - ",flags=0x" + jcifs.util.Hexdump.toHexString(getFlags(), 8) + "]"; - } - - /** - * Returns the default flags for a generic Type-2 message in the - * current environment. - * - * @return Anintcontaining the default flags. - */ - public static int getDefaultFlags() { - return DEFAULT_FLAGS; - } - - /** - * Returns the default flags for a Type-2 message created in response - * to the given Type-1 message in the current environment. - * - * @return Anintcontaining the default flags. - */ - public static int getDefaultFlags(Type1Message type1) { - if (type1 == null) return DEFAULT_FLAGS; - int flags = NTLMSSP_NEGOTIATE_NTLM; - int type1Flags = type1.getFlags(); - flags |= ((type1Flags & NTLMSSP_NEGOTIATE_UNICODE) != 0) ? - NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM; - if ((type1Flags & NTLMSSP_REQUEST_TARGET) != 0) { - String domain = getDefaultDomain(); - if (domain != null) { - flags |= NTLMSSP_REQUEST_TARGET | NTLMSSP_TARGET_TYPE_DOMAIN; - } - } - return flags; - } - - /** - * Returns the default domain from the current environment. - * - * @return AStringcontaining the domain. - */ - public static String getDefaultDomain() { - return DEFAULT_DOMAIN; - } - - public static byte[] getDefaultTargetInformation() { - return DEFAULT_TARGET_INFORMATION; - } - - private void parse(byte[] material) throws IOException { - for (int i = 0; i < 8; i++) { - if (material[i] != NTLMSSP_SIGNATURE[i]) { - throw new IOException("Not an NTLMSSP message."); - } - } - if (readULong(material, 8) != 2) { - throw new IOException("Not a Type 2 message."); - } - int flags = readULong(material, 20); - setFlags(flags); - String target = null; - byte[] bytes = readSecurityBuffer(material, 12); - if (bytes.length != 0) { - target = new String(bytes, - ((flags & NTLMSSP_NEGOTIATE_UNICODE) != 0) ? - UNI_ENCODING : getOEMEncoding()); - } - setTarget(target); - for (int i = 24; i < 32; i++) { - if (material[i] != 0) { - byte[] challenge = new byte[8]; - System.arraycopy(material, 24, challenge, 0, 8); - setChallenge(challenge); - break; - } - } - int offset = readULong(material, 16); // offset of targetname start - if (offset == 32 || material.length == 32) return; - for (int i = 32; i < 40; i++) { - if (material[i] != 0) { - byte[] context = new byte[8]; - System.arraycopy(material, 32, context, 0, 8); - setContext(context); - break; - } - } - if (offset == 40 || material.length == 40) return; - bytes = readSecurityBuffer(material, 40); - if (bytes.length != 0) setTargetInformation(bytes); - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type3Message.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type3Message.java deleted file mode 100644 index 6d3038b8a4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/ntlmssp/Type3Message.java +++ /dev/null @@ -1,648 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.ntlmssp; - -import jcifs.Config; -import jcifs.netbios.NbtAddress; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.util.HMACT64; -import jcifs.util.MD4; -import jcifs.util.RC4; - -import java.io.IOException; -import java.net.UnknownHostException; -import java.security.SecureRandom; - -/** - * Represents an NTLMSSP Type-3 message. - */ -public class Type3Message extends NtlmMessage { - - static final long MILLISECONDS_BETWEEN_1970_AND_1601 = 11644473600000L; - - private static final int DEFAULT_FLAGS; - - private static final String DEFAULT_DOMAIN; - - private static final String DEFAULT_USER; - - private static final String DEFAULT_PASSWORD; - - private static final String DEFAULT_WORKSTATION; - - private static final int LM_COMPATIBILITY; - - private static final SecureRandom RANDOM = new SecureRandom(); - - private byte[] lmResponse; - - private byte[] ntResponse; - - private String domain; - - private String user; - - private String workstation; - - private byte[] masterKey = null; - private byte[] sessionKey = null; - - static { - DEFAULT_FLAGS = NTLMSSP_NEGOTIATE_NTLM | - (Config.getBoolean("jcifs.smb.client.useUnicode", true) ? - NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM); - DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", null); - DEFAULT_USER = Config.getProperty("jcifs.smb.client.username", null); - DEFAULT_PASSWORD = Config.getProperty("jcifs.smb.client.password", - null); - String defaultWorkstation = null; - try { - defaultWorkstation = NbtAddress.getLocalHost().getHostName(); - } catch (UnknownHostException ex) { } - DEFAULT_WORKSTATION = defaultWorkstation; - LM_COMPATIBILITY = Config.getInt("jcifs.smb.lmCompatibility", 3); - } - - /** - * Creates a Type-3 message using default values from the current - * environment. - */ - public Type3Message() { - setFlags(getDefaultFlags()); - setDomain(getDefaultDomain()); - setUser(getDefaultUser()); - setWorkstation(getDefaultWorkstation()); - } - - /** - * Creates a Type-3 message in response to the given Type-2 message - * using default values from the current environment. - * - * @param type2 The Type-2 message which this represents a response to. - */ - public Type3Message(Type2Message type2) { - setFlags(getDefaultFlags(type2)); - setWorkstation(getDefaultWorkstation()); - String domain = getDefaultDomain(); - setDomain(domain); - String user = getDefaultUser(); - setUser(user); - String password = getDefaultPassword(); - switch (LM_COMPATIBILITY) { - case 0: - case 1: - setLMResponse(getLMResponse(type2, password)); - setNTResponse(getNTResponse(type2, password)); - break; - case 2: - byte[] nt = getNTResponse(type2, password); - setLMResponse(nt); - setNTResponse(nt); - break; - case 3: - case 4: - case 5: - byte[] clientChallenge = new byte[8]; - RANDOM.nextBytes(clientChallenge); - setLMResponse(getLMv2Response(type2, domain, user, password, - clientChallenge)); - /* - setNTResponse(getNTLMv2Response(type2, domain, user, password, - clientChallenge)); - */ - break; - default: - setLMResponse(getLMResponse(type2, password)); - setNTResponse(getNTResponse(type2, password)); - } - } - - /** - * Creates a Type-3 message in response to the given Type-2 message. - * - * @param type2 The Type-2 message which this represents a response to. - * @param password The password to use when constructing the response. - * @param domain The domain in which the user has an account. - * @param user The username for the authenticating user. - * @param workstation The workstation from which authentication is - * taking place. - */ - public Type3Message(Type2Message type2, String password, String domain, - String user, String workstation, int flags) { - setFlags(flags | getDefaultFlags(type2)); - if (workstation == null) - workstation = getDefaultWorkstation(); - setWorkstation(workstation); - setDomain(domain); - setUser(user); - - switch (LM_COMPATIBILITY) { - case 0: - case 1: - if ((getFlags() & NTLMSSP_NEGOTIATE_NTLM2) == 0) { - setLMResponse(getLMResponse(type2, password)); - setNTResponse(getNTResponse(type2, password)); - } else { - // NTLM2 Session Response - - byte[] clientChallenge = new byte[24]; - RANDOM.nextBytes(clientChallenge); - java.util.Arrays.fill(clientChallenge, 8, 24, (byte)0x00); - -// NTLMv1 w/ NTLM2 session sec and key exch all been verified with a debug build of smbclient - - byte[] responseKeyNT = NtlmPasswordAuthentication.nTOWFv1(password); - byte[] ntlm2Response = NtlmPasswordAuthentication.getNTLM2Response(responseKeyNT, - type2.getChallenge(), - clientChallenge); - - setLMResponse(clientChallenge); - setNTResponse(ntlm2Response); - - if ((getFlags() & NTLMSSP_NEGOTIATE_SIGN) == NTLMSSP_NEGOTIATE_SIGN) { - byte[] sessionNonce = new byte[16]; - System.arraycopy(type2.getChallenge(), 0, sessionNonce, 0, 8); - System.arraycopy(clientChallenge, 0, sessionNonce, 8, 8); - - MD4 md4 = new MD4(); - md4.update(responseKeyNT); - byte[] userSessionKey = md4.digest(); - - HMACT64 hmac = new HMACT64(userSessionKey); - hmac.update(sessionNonce); - byte[] ntlm2SessionKey = hmac.digest(); - - if ((getFlags() & NTLMSSP_NEGOTIATE_KEY_EXCH) != 0) { - masterKey = new byte[16]; - RANDOM.nextBytes(masterKey); - - byte[] exchangedKey = new byte[16]; - RC4 rc4 = new RC4(ntlm2SessionKey); - rc4.update(masterKey, 0, 16, exchangedKey, 0); -/* RC4 was not added to Java until 1.5u7 so let's use our own for a little while longer ... - try { - Cipher rc4 = Cipher.getInstance("RC4"); - rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(ntlm2SessionKey, "RC4")); - rc4.update(masterKey, 0, 16, exchangedKey, 0); - } catch (GeneralSecurityException gse) { - throw new RuntimeException("", gse); - } -*/ - - setSessionKey(exchangedKey); - } else { - masterKey = ntlm2SessionKey; - setSessionKey(masterKey); - } - } - } - break; - case 2: - byte[] nt = getNTResponse(type2, password); - setLMResponse(nt); - setNTResponse(nt); - break; - case 3: - case 4: - case 5: - byte[] responseKeyNT = NtlmPasswordAuthentication.nTOWFv2(domain, user, password); - - byte[] clientChallenge = new byte[8]; - RANDOM.nextBytes(clientChallenge); - setLMResponse(getLMv2Response(type2, domain, user, password, clientChallenge)); - - byte[] clientChallenge2 = new byte[8]; - RANDOM.nextBytes(clientChallenge2); - setNTResponse(getNTLMv2Response(type2, responseKeyNT, clientChallenge2)); - - if ((getFlags() & NTLMSSP_NEGOTIATE_SIGN) == NTLMSSP_NEGOTIATE_SIGN) { - HMACT64 hmac = new HMACT64(responseKeyNT); - hmac.update(ntResponse, 0, 16); // only first 16 bytes of ntResponse - byte[] userSessionKey = hmac.digest(); - - if ((getFlags() & NTLMSSP_NEGOTIATE_KEY_EXCH) != 0) { - masterKey = new byte[16]; - RANDOM.nextBytes(masterKey); - - byte[] exchangedKey = new byte[16]; - RC4 rc4 = new RC4(userSessionKey); - rc4.update(masterKey, 0, 16, exchangedKey, 0); -/* RC4 was not added to Java until 1.5u7 so let's use our own for a little while longer ... - try { - Cipher rc4 = Cipher.getInstance("RC4"); - rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(userSessionKey, "RC4")); - rc4.update(masterKey, 0, 16, exchangedKey, 0); - } catch (GeneralSecurityException gse) { - throw new RuntimeException("", gse); - } -*/ - - setSessionKey(exchangedKey); - } else { - masterKey = userSessionKey; - setSessionKey(masterKey); - } - } - - break; - default: - setLMResponse(getLMResponse(type2, password)); - setNTResponse(getNTResponse(type2, password)); - } - } - - /** - * Creates a Type-3 message with the specified parameters. - * - * @param flags The flags to apply to this message. - * @param lmResponse The LanManager/LMv2 response. - * @param ntResponse The NT/NTLMv2 response. - * @param domain The domain in which the user has an account. - * @param user The username for the authenticating user. - * @param workstation The workstation from which authentication is - * taking place. - */ - public Type3Message(int flags, byte[] lmResponse, byte[] ntResponse, - String domain, String user, String workstation) { - setFlags(flags); - setLMResponse(lmResponse); - setNTResponse(ntResponse); - setDomain(domain); - setUser(user); - setWorkstation(workstation); - } - - /** - * Creates a Type-3 message using the given raw Type-3 material. - * - * @param material The raw Type-3 material used to construct this message. - * @throws IOException If an error occurs while parsing the material. - */ - public Type3Message(byte[] material) throws IOException { - parse(material); - } - - /** - * Returns the LanManager/LMv2 response. - * - * @return A byte[]containing the LanManager response. - */ - public byte[] getLMResponse() { - return lmResponse; - } - - /** - * Sets the LanManager/LMv2 response for this message. - * - * @param lmResponse The LanManager response. - */ - public void setLMResponse(byte[] lmResponse) { - this.lmResponse = lmResponse; - } - - /** - * Returns the NT/NTLMv2 response. - * - * @return Abyte[]containing the NT/NTLMv2 response. - */ - public byte[] getNTResponse() { - return ntResponse; - } - - /** - * Sets the NT/NTLMv2 response for this message. - * - * @param ntResponse The NT/NTLMv2 response. - */ - public void setNTResponse(byte[] ntResponse) { - this.ntResponse = ntResponse; - } - - /** - * Returns the domain in which the user has an account. - * - * @return AStringcontaining the domain for the user. - */ - public String getDomain() { - return domain; - } - - /** - * Sets the domain for this message. - * - * @param domain The domain. - */ - public void setDomain(String domain) { - this.domain = domain; - } - - /** - * Returns the username for the authenticating user. - * - * @return AStringcontaining the user for this message. - */ - public String getUser() { - return user; - } - - /** - * Sets the user for this message. - * - * @param user The user. - */ - public void setUser(String user) { - this.user = user; - } - - /** - * Returns the workstation from which authentication is being performed. - * - * @return AStringcontaining the workstation. - */ - public String getWorkstation() { - return workstation; - } - - /** - * Sets the workstation for this message. - * - * @param workstation The workstation. - */ - public void setWorkstation(String workstation) { - this.workstation = workstation; - } - - /** - * The real session key if the regular session key is actually - * the encrypted version used for key exchange. - * - * @return Abyte[]containing the session key. - */ - public byte[] getMasterKey() { - return masterKey; - } - - /** - * Returns the session key. - * - * @return Abyte[]containing the session key. - */ - public byte[] getSessionKey() { - return sessionKey; - } - - /** - * Sets the session key. - * - * @param sessionKey The session key. - */ - public void setSessionKey(byte[] sessionKey) { - this.sessionKey = sessionKey; - } - - public byte[] toByteArray() { - try { - int flags = getFlags(); - boolean unicode = (flags & NTLMSSP_NEGOTIATE_UNICODE) != 0; - String oem = unicode ? null : getOEMEncoding(); - String domainName = getDomain(); - byte[] domain = null; - if (domainName != null && domainName.length() != 0) { - domain = unicode ? - domainName.getBytes(UNI_ENCODING) : - domainName.getBytes(oem); - } - int domainLength = (domain != null) ? domain.length : 0; - String userName = getUser(); - byte[] user = null; - if (userName != null && userName.length() != 0) { - user = unicode ? userName.getBytes(UNI_ENCODING) : - userName.toUpperCase().getBytes(oem); - } - int userLength = (user != null) ? user.length : 0; - String workstationName = getWorkstation(); - byte[] workstation = null; - if (workstationName != null && workstationName.length() != 0) { - workstation = unicode ? - workstationName.getBytes(UNI_ENCODING) : - workstationName.toUpperCase().getBytes(oem); - } - int workstationLength = (workstation != null) ? - workstation.length : 0; - byte[] lmResponse = getLMResponse(); - int lmLength = (lmResponse != null) ? lmResponse.length : 0; - byte[] ntResponse = getNTResponse(); - int ntLength = (ntResponse != null) ? ntResponse.length : 0; - byte[] sessionKey = getSessionKey(); - int keyLength = (sessionKey != null) ? sessionKey.length : 0; - byte[] type3 = new byte[64 + domainLength + userLength + - workstationLength + lmLength + ntLength + keyLength]; - System.arraycopy(NTLMSSP_SIGNATURE, 0, type3, 0, 8); - writeULong(type3, 8, 3); - int offset = 64; - writeSecurityBuffer(type3, 12, offset, lmResponse); - offset += lmLength; - writeSecurityBuffer(type3, 20, offset, ntResponse); - offset += ntLength; - writeSecurityBuffer(type3, 28, offset, domain); - offset += domainLength; - writeSecurityBuffer(type3, 36, offset, user); - offset += userLength; - writeSecurityBuffer(type3, 44, offset, workstation); - offset += workstationLength; - writeSecurityBuffer(type3, 52, offset, sessionKey); - writeULong(type3, 60, flags); - return type3; - } catch (IOException ex) { - throw new IllegalStateException(ex.getMessage()); - } - } - - public String toString() { - String user = getUser(); - String domain = getDomain(); - String workstation = getWorkstation(); - byte[] lmResponse = getLMResponse(); - byte[] ntResponse = getNTResponse(); - byte[] sessionKey = getSessionKey(); - - return "Type3Message[domain=" + domain + - ",user=" + user + - ",workstation=" + workstation + - ",lmResponse=" + (lmResponse == null ? "null" : "<" + lmResponse.length + " bytes>") + - ",ntResponse=" + (ntResponse == null ? "null" : "<" + ntResponse.length + " bytes>") + - ",sessionKey=" + (sessionKey == null ? "null" : "<" + sessionKey.length + " bytes>") + - ",flags=0x" + jcifs.util.Hexdump.toHexString(getFlags(), 8) + "]"; - } - - /** - * Returns the default flags for a generic Type-3 message in the - * current environment. - * - * @return Anintcontaining the default flags. - */ - public static int getDefaultFlags() { - return DEFAULT_FLAGS; - } - - /** - * Returns the default flags for a Type-3 message created in response - * to the given Type-2 message in the current environment. - * - * @return Anintcontaining the default flags. - */ - public static int getDefaultFlags(Type2Message type2) { - if (type2 == null) return DEFAULT_FLAGS; - int flags = NTLMSSP_NEGOTIATE_NTLM; - flags |= ((type2.getFlags() & NTLMSSP_NEGOTIATE_UNICODE) != 0) ? - NTLMSSP_NEGOTIATE_UNICODE : NTLMSSP_NEGOTIATE_OEM; - return flags; - } - - /** - * Constructs the LanManager response to the given Type-2 message using - * the supplied password. - * - * @param type2 The Type-2 message. - * @param password The password. - * @return Abyte[]containing the LanManager response. - */ - public static byte[] getLMResponse(Type2Message type2, String password) { - if (type2 == null || password == null) return null; - return NtlmPasswordAuthentication.getPreNTLMResponse(password, - type2.getChallenge()); - } - - public static byte[] getLMv2Response(Type2Message type2, - String domain, String user, String password, - byte[] clientChallenge) { - if (type2 == null || domain == null || user == null || - password == null || clientChallenge == null) { - return null; - } - return NtlmPasswordAuthentication.getLMv2Response(domain, user, - password, type2.getChallenge(), clientChallenge); - } - public static byte[] getNTLMv2Response(Type2Message type2, - byte[] responseKeyNT, - byte[] clientChallenge) { - if (type2 == null || responseKeyNT == null || clientChallenge == null) { - return null; - } - long nanos1601 = (System.currentTimeMillis() + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L; - return NtlmPasswordAuthentication.getNTLMv2Response(responseKeyNT, - type2.getChallenge(), - clientChallenge, - nanos1601, - type2.getTargetInformation()); - } - - /** - * Constructs the NT response to the given Type-2 message using - * the supplied password. - * - * @param type2 The Type-2 message. - * @param password The password. - * @return Abyte[]containing the NT response. - */ - public static byte[] getNTResponse(Type2Message type2, String password) { - if (type2 == null || password == null) return null; - return NtlmPasswordAuthentication.getNTLMResponse(password, - type2.getChallenge()); - } - - /** - * Returns the default domain from the current environment. - * - * @return The default domain. - */ - public static String getDefaultDomain() { - return DEFAULT_DOMAIN; - } - - /** - * Returns the default user from the current environment. - * - * @return The default user. - */ - public static String getDefaultUser() { - return DEFAULT_USER; - } - - /** - * Returns the default password from the current environment. - * - * @return The default password. - */ - public static String getDefaultPassword() { - return DEFAULT_PASSWORD; - } - - /** - * Returns the default workstation from the current environment. - * - * @return The default workstation. - */ - public static String getDefaultWorkstation() { - return DEFAULT_WORKSTATION; - } - - private void parse(byte[] material) throws IOException { - for (int i = 0; i < 8; i++) { - if (material[i] != NTLMSSP_SIGNATURE[i]) { - throw new IOException("Not an NTLMSSP message."); - } - } - if (readULong(material, 8) != 3) { - throw new IOException("Not a Type 3 message."); - } - byte[] lmResponse = readSecurityBuffer(material, 12); - int lmResponseOffset = readULong(material, 16); - byte[] ntResponse = readSecurityBuffer(material, 20); - int ntResponseOffset = readULong(material, 24); - byte[] domain = readSecurityBuffer(material, 28); - int domainOffset = readULong(material, 32); - byte[] user = readSecurityBuffer(material, 36); - int userOffset = readULong(material, 40); - byte[] workstation = readSecurityBuffer(material, 44); - int workstationOffset = readULong(material, 48); - int flags; - String charset; - byte[] _sessionKey = null; - if (lmResponseOffset == 52 || ntResponseOffset == 52 || - domainOffset == 52 || userOffset == 52 || - workstationOffset == 52) { - flags = NTLMSSP_NEGOTIATE_NTLM | NTLMSSP_NEGOTIATE_OEM; - charset = getOEMEncoding(); - } else { - _sessionKey = readSecurityBuffer(material, 52); - flags = readULong(material, 60); - charset = ((flags & NTLMSSP_NEGOTIATE_UNICODE) != 0) ? - UNI_ENCODING : getOEMEncoding(); - } - setSessionKey(_sessionKey); - setFlags(flags); - setLMResponse(lmResponse); - setNTResponse(ntResponse); - setDomain(new String(domain, charset)); - setUser(new String(user, charset)); - setWorkstation(new String(workstation, charset)); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ACE.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ACE.java deleted file mode 100644 index 3b305c4df8..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ACE.java +++ /dev/null @@ -1,180 +0,0 @@ -package jcifs.smb; - -import jcifs.util.Hexdump; - -/** - * An Access Control Entry (ACE) is an element in a security descriptor - * such as those associated with files and directories. The Windows OS - * determines which users have the necessary permissions to access objects - * based on these entries. - *- * To fully understand the information exposed by this class a description - * of the access check algorithm used by Windows is required. The following - * is a basic description of the algorithm. For a more complete description - * we recommend reading the section on Access Control in Keith Brown's - * "The .NET Developer's Guide to Windows Security" (which is also - * available online). - *
- * Direct ACEs are evaluated first in order. The SID of the user performing - * the operation and the desired access bits are compared to the SID - * and access mask of each ACE. If the SID matches, the allow/deny flags - * and access mask are considered. If the ACE is a "deny" - * ACE and any of the desired access bits match bits in the access - * mask of the ACE, the whole access check fails. If the ACE is an "allow" - * ACE and all of the bits in the desired access bits match bits in - * the access mask of the ACE, the access check is successful. Otherwise, - * more ACEs are evaluated until all desired access bits (combined) - * are "allowed". If all of the desired access bits are not "allowed" - * the then same process is repeated for inherited ACEs. - *
- * For example, if user WNET\alice tries to open a file - * with desired access bits 0x00000003 (FILE_READ_DATA | - * FILE_WRITE_DATA) and the target file has the following security - * descriptor ACEs: - *
- * Allow WNET\alice 0x001200A9 Direct - * Allow Administrators 0x001F01FF Inherited - * Allow SYSTEM 0x001F01FF Inherited - *- * the access check would fail because the direct ACE has an access mask - * of 0x001200A9 which doesn't have the - * FILE_WRITE_DATA bit on (bit 0x00000002). Actually, this isn't quite correct. If - * WNET\alice is in the local Administrators group the access check - * will succeed because the inherited ACE allows local Administrators - * both FILE_READ_DATA and FILE_WRITE_DATA access. - */ - -public class ACE { - - public static final int FILE_READ_DATA = 0x00000001; // 1 - public static final int FILE_WRITE_DATA = 0x00000002; // 2 - public static final int FILE_APPEND_DATA = 0x00000004; // 3 - public static final int FILE_READ_EA = 0x00000008; // 4 - public static final int FILE_WRITE_EA = 0x00000010; // 5 - public static final int FILE_EXECUTE = 0x00000020; // 6 - public static final int FILE_DELETE = 0x00000040; // 7 - public static final int FILE_READ_ATTRIBUTES = 0x00000080; // 8 - public static final int FILE_WRITE_ATTRIBUTES = 0x00000100; // 9 - public static final int DELETE = 0x00010000; // 16 - public static final int READ_CONTROL = 0x00020000; // 17 - public static final int WRITE_DAC = 0x00040000; // 18 - public static final int WRITE_OWNER = 0x00080000; // 19 - public static final int SYNCHRONIZE = 0x00100000; // 20 - public static final int GENERIC_ALL = 0x10000000; // 28 - public static final int GENERIC_EXECUTE = 0x20000000; // 29 - public static final int GENERIC_WRITE = 0x40000000; // 30 - public static final int GENERIC_READ = 0x80000000; // 31 - - public static final int FLAGS_OBJECT_INHERIT = 0x01; - public static final int FLAGS_CONTAINER_INHERIT = 0x02; - public static final int FLAGS_NO_PROPAGATE = 0x04; - public static final int FLAGS_INHERIT_ONLY = 0x08; - public static final int FLAGS_INHERITED = 0x10; - - boolean allow; - int flags; - int access; - SID sid; - - /** - * Returns true if this ACE is an allow ACE and false if it is a deny ACE. - */ - public boolean isAllow() { - return allow; - } - /** - * Returns true if this ACE is an inherited ACE and false if it is a direct ACE. - *- * Note: For reasons not fully understood, FLAGS_INHERITED may - * not be set within all security descriptors even though the ACE was in - * face inherited. If an inherited ACE is added to a parent the Windows - * ACL editor will rebuild all children ACEs and set this flag accordingly. - */ - public boolean isInherited() { - return (flags & FLAGS_INHERITED) != 0; - } - /** - * Returns the flags for this ACE. The isInherited() - * method checks the FLAGS_INHERITED bit in these flags. - */ - public int getFlags() { - return flags; - } - /** - * Returns the 'Apply To' text for inheritance of ACEs on - * directories such as 'This folder, subfolder and files'. For - * files the text is always 'This object only'. - */ - public String getApplyToText() { - switch (flags & (FLAGS_OBJECT_INHERIT | FLAGS_CONTAINER_INHERIT | FLAGS_INHERIT_ONLY)) { - case 0x00: - return "This folder only"; - case 0x03: - return "This folder, subfolders and files"; - case 0x0B: - return "Subfolders and files only"; - case 0x02: - return "This folder and subfolders"; - case 0x0A: - return "Subfolders only"; - case 0x01: - return "This folder and files"; - case 0x09: - return "Files only"; - } - return "Invalid"; - } - /** - * Returns the access mask accociated with this ACE. Use the - * constants for FILE_READ_DATA, FILE_WRITE_DATA, - * READ_CONTROL, GENERIC_ALL, etc with bitwise - * operators to determine which bits of the mask are on or off. - */ - public int getAccessMask() { - return access; - } - - /** - * Return the SID associated with this ACE. - */ - public SID getSID() { - return sid; - } - - int decode( byte[] buf, int bi ) { - allow = buf[bi++] == (byte)0x00; - flags = buf[bi++] & 0xFF; - int size = ServerMessageBlock.readInt2(buf, bi); - bi += 2; - access = ServerMessageBlock.readInt4(buf, bi); - bi += 4; - sid = new SID(buf, bi); - return size; - } - - void appendCol(StringBuffer sb, String str, int width) { - sb.append(str); - int count = width - str.length(); - for (int i = 0; i < count; i++) { - sb.append(' '); - } - } - /** - * Return a string represeting this ACE. - *
- * Note: This function should probably be changed to return SDDL - * fragments but currently it does not. - */ - public String toString() { - int count, i; - String str; - - StringBuffer sb = new StringBuffer(); - sb.append( isAllow() ? "Allow " : "Deny " ); - appendCol(sb, sid.toDisplayString(), 25); - sb.append( " 0x" ).append( Hexdump.toHexString( access, 8 )).append(' '); - sb.append(isInherited() ? "Inherited " : "Direct "); - appendCol(sb, getApplyToText(), 34); - return sb.toString(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AllocInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AllocInfo.java deleted file mode 100644 index 299bb60e7f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AllocInfo.java +++ /dev/null @@ -1,24 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -interface AllocInfo { - long getCapacity(); - long getFree(); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AndXServerMessageBlock.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AndXServerMessageBlock.java deleted file mode 100644 index 3c9eb430b3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/AndXServerMessageBlock.java +++ /dev/null @@ -1,301 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -abstract class AndXServerMessageBlock extends ServerMessageBlock { - - private static final int ANDX_COMMAND_OFFSET = 1; - private static final int ANDX_RESERVED_OFFSET = 2; - private static final int ANDX_OFFSET_OFFSET = 3; - - private byte andxCommand = (byte)0xFF; - private int andxOffset = 0; - - ServerMessageBlock andx = null; - - AndXServerMessageBlock() { - } - AndXServerMessageBlock( ServerMessageBlock andx ) { - if (andx != null) { - this.andx = andx; - andxCommand = andx.command; - } - } - - int getBatchLimit( byte command ) { - /* the default limit is 0 batched messages before this - * one, meaning this message cannot be batched. - */ - return 0; - } - - /* - * We overload this method from ServerMessageBlock because - * we want writeAndXWireFormat to write the parameterWords - * and bytes. This is so we can write batched smbs because - * all but the first smb of the chaain do not have a header - * and therefore we do not want to writeHeaderWireFormat. We - * just recursivly call writeAndXWireFormat. - */ - - int encode( byte[] dst, int dstIndex ) { - int start = headerStart = dstIndex; - - dstIndex += writeHeaderWireFormat( dst, dstIndex ); - dstIndex += writeAndXWireFormat( dst, dstIndex ); - length = dstIndex - start; - - if( digest != null ) { - digest.sign( dst, headerStart, length, this, response ); - } - - return length; - } - - /* - * We overload this because we want readAndXWireFormat to - * read the parameter words and bytes. This is so when - * commands are batched together we can recursivly call - * readAndXWireFormat without reading the non-existent header. - */ - - int decode( byte[] buffer, int bufferIndex ) { - int start = headerStart = bufferIndex; - - bufferIndex += readHeaderWireFormat( buffer, bufferIndex ); - bufferIndex += readAndXWireFormat( buffer, bufferIndex ); - - length = bufferIndex - start; - return length; - } - int writeAndXWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - wordCount = writeParameterWordsWireFormat( dst, - start + ANDX_OFFSET_OFFSET + 2 ); - wordCount += 4; // for command, reserved, and offset - dstIndex += wordCount + 1; - wordCount /= 2; - dst[start] = (byte)( wordCount & 0xFF ); - - byteCount = writeBytesWireFormat( dst, dstIndex + 2 ); - dst[dstIndex++] = (byte)( byteCount & 0xFF ); - dst[dstIndex++] = (byte)(( byteCount >> 8 ) & 0xFF ); - dstIndex += byteCount; - - /* Normally, without intervention everything would batch - * with everything else. If the below clause evaluates true - * the andx command will not be written and therefore the - * response will not read a batched command and therefore - * the 'received' member of the response object will not - * be set to true indicating the send and sendTransaction - * methods that the next part should be sent. This is a - * very indirect and simple batching control mechanism. - */ - - if( andx == null || USE_BATCHING == false || - batchLevel >= getBatchLimit( andx.command )) { - andxCommand = (byte)0xFF; - andx = null; - - dst[start + ANDX_COMMAND_OFFSET] = (byte)0xFF; - dst[start + ANDX_RESERVED_OFFSET] = (byte)0x00; -// dst[start + ANDX_OFFSET_OFFSET] = (byte)0x00; -// dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0x00; - dst[start + ANDX_OFFSET_OFFSET] = (byte)0xde; - dst[start + ANDX_OFFSET_OFFSET + 1] = (byte)0xde; - - // andx not used; return - return dstIndex - start; - } - - /* The message provided to batch has a batchLimit that is - * higher than the current batchLevel so we will now encode - * that chained message. Before doing so we must increment - * the batchLevel of the andx message in case it itself is an - * andx message and needs to perform the same check as above. - */ - - andx.batchLevel = batchLevel + 1; - - - dst[start + ANDX_COMMAND_OFFSET] = andxCommand; - dst[start + ANDX_RESERVED_OFFSET] = (byte)0x00; - andxOffset = dstIndex - headerStart; - writeInt2( andxOffset, dst, start + ANDX_OFFSET_OFFSET ); - - andx.useUnicode = useUnicode; - if( andx instanceof AndXServerMessageBlock ) { - - /* - * A word about communicating header info to andx smbs - * - * This is where we recursively invoke the provided andx smb - * object to write it's parameter words and bytes to our outgoing - * array. Incedentally when these andx smbs are created they are not - * necessarily populated with header data because they're not writing - * the header, only their body. But for whatever reason one might wish - * to populate fields if the writeXxx operation needs this header data - * for whatever reason. I copy over the uid here so it appears correct - * in logging output. Logging of andx segments of messages inadvertantly - * print header information because of the way toString always makes a - * super.toString() call(see toString() at the end of all smbs classes). - */ - - andx.uid = uid; - dstIndex += ((AndXServerMessageBlock)andx).writeAndXWireFormat( dst, dstIndex ); - } else { - // the andx smb is not of type andx so lets just write it here and - // were done. - int andxStart = dstIndex; - andx.wordCount = andx.writeParameterWordsWireFormat( dst, dstIndex ); - dstIndex += andx.wordCount + 1; - andx.wordCount /= 2; - dst[andxStart] = (byte)( andx.wordCount & 0xFF ); - - andx.byteCount = andx.writeBytesWireFormat( dst, dstIndex + 2 ); - dst[dstIndex++] = (byte)( andx.byteCount & 0xFF ); - dst[dstIndex++] = (byte)(( andx.byteCount >> 8 ) & 0xFF ); - dstIndex += andx.byteCount; - } - - return dstIndex - start; - } - int readAndXWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - wordCount = buffer[bufferIndex++]; - - if( wordCount != 0 ) { - /* - * these fields are common to all andx commands - * so let's populate them here - */ - - andxCommand = buffer[bufferIndex]; - andxOffset = readInt2( buffer, bufferIndex + 2 ); - - if( andxOffset == 0 ) { /* Snap server workaround */ - andxCommand = (byte)0xFF; - } - - /* - * no point in calling readParameterWordsWireFormat if there are no more - * parameter words. besides, win98 doesn't return "OptionalSupport" field - */ - - if( wordCount > 2 ) { - readParameterWordsWireFormat( buffer, bufferIndex + 4 ); - - /* The SMB_COM_NT_CREATE_ANDX response wordCount is wrong. There's an - * extra 16 bytes for some "Offline Files (CSC or Client Side Caching)" - * junk. We need to bump up the wordCount here so that this method returns - * the correct number of bytes for signing purposes. Otherwise we get a - * signing verification failure. - */ - if (command == SMB_COM_NT_CREATE_ANDX && ((SmbComNTCreateAndXResponse)this).isExtended) - wordCount += 8; - } - - bufferIndex = start + 1 + (wordCount * 2); - } - - byteCount = readInt2( buffer, bufferIndex ); bufferIndex += 2; - - if (byteCount != 0) { - int n; - n = readBytesWireFormat( buffer, bufferIndex ); - bufferIndex += byteCount; - } - - /* - * if there is an andx and it itself is an andx then just recur by - * calling this method for it. otherwise just read it's parameter words - * and bytes as usual. Note how we can't just call andx.readWireFormat - * because there's no header. - */ - - if( errorCode != 0 || andxCommand == (byte)0xFF ) { - andxCommand = (byte)0xFF; - andx = null; - } else if( andx == null ) { - andxCommand = (byte)0xFF; - throw new RuntimeException( "no andx command supplied with response" ); - } else { - - /* - * Set bufferIndex according to andxOffset - */ - - bufferIndex = headerStart + andxOffset; - - andx.headerStart = headerStart; - andx.command = andxCommand; - andx.errorCode = errorCode; - andx.flags = flags; - andx.flags2 = flags2; - andx.tid = tid; - andx.pid = pid; - andx.uid = uid; - andx.mid = mid; - andx.useUnicode = useUnicode; - - if( andx instanceof AndXServerMessageBlock ) { - bufferIndex += ((AndXServerMessageBlock)andx).readAndXWireFormat( - buffer, bufferIndex ); - } else { - - /* - * Just a plain smb. Read it as normal. - */ - - buffer[bufferIndex++] = (byte)( andx.wordCount & 0xFF ); - - if( andx.wordCount != 0 ) { - /* - * no point in calling readParameterWordsWireFormat if there are no more - * parameter words. besides, win98 doesn't return "OptionalSupport" field - */ - - if( andx.wordCount > 2 ) { - bufferIndex += andx.readParameterWordsWireFormat( buffer, bufferIndex ); - } - } - - andx.byteCount = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - if( andx.byteCount != 0 ) { - andx.readBytesWireFormat( buffer, bufferIndex ); - bufferIndex += andx.byteCount; - } - } - andx.received = true; - } - - return bufferIndex - start; - } - public String toString() { - return new String( super.toString() + - ",andxCommand=0x" + Hexdump.toHexString( andxCommand, 2 ) + - ",andxOffset=" + andxOffset ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.jav b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.jav deleted file mode 100644 index 1dea6bfaf9..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.jav +++ /dev/null @@ -1,83 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; - -public class BufferCache { - - private static final int MAX_BUFFERS = Config.getInt( "jcifs.smb.maxBuffers", 16 ); - - static Object[] cache = new Object[MAX_BUFFERS]; - private static int freeBuffers = 0; - - private static byte[] getBuffer0() { - byte[] buf; - - if (freeBuffers > 0) { - for (int i = 0; i < MAX_BUFFERS; i++) { - if( cache[i] != null ) { - buf = (byte[])cache[i]; - cache[i] = null; - freeBuffers--; - return buf; - } - } - } - - buf = new byte[SmbComTransaction.TRANSACTION_BUF_SIZE]; - - return buf; - } - - static void getBuffers( SmbComTransaction req, - SmbComTransactionResponse rsp ) throws InterruptedException { - synchronized( cache ) { - if (freeBuffers < 2) { - /* The first time this is called we always wait because freeBuffers - * will be 0. But after a few calls to releaseBuffer, threads will - * no longer wait. - */ - cache.wait(100); - } - req.txn_buf = getBuffer0(); - rsp.txn_buf = getBuffer0(); - } - } - static public byte[] getBuffer() throws InterruptedException { - synchronized( cache ) { - if (freeBuffers < 1) { - cache.wait(100); - } - return getBuffer0(); - } - } - static public void releaseBuffer( byte[] buf ) { - synchronized( cache ) { - for (int i = 0; i < MAX_BUFFERS; i++) { - if (cache[i] == null) { - cache[i] = buf; - freeBuffers++; - cache.notify(); - return; - } - } - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.java deleted file mode 100644 index dce2525910..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/BufferCache.java +++ /dev/null @@ -1,69 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; - -public class BufferCache { - - private static final int MAX_BUFFERS = Config.getInt( "jcifs.smb.maxBuffers", 16 ); - - static Object[] cache = new Object[MAX_BUFFERS]; - private static int freeBuffers = 0; - - static public byte[] getBuffer() { - synchronized( cache ) { - byte[] buf; - - if (freeBuffers > 0) { - for (int i = 0; i < MAX_BUFFERS; i++) { - if( cache[i] != null ) { - buf = (byte[])cache[i]; - cache[i] = null; - freeBuffers--; - return buf; - } - } - } - - buf = new byte[SmbComTransaction.TRANSACTION_BUF_SIZE]; - - return buf; - } - } - static void getBuffers( SmbComTransaction req, SmbComTransactionResponse rsp ) { - synchronized( cache ) { - req.txn_buf = getBuffer(); - rsp.txn_buf = getBuffer(); - } - } - static public void releaseBuffer( byte[] buf ) { - synchronized( cache ) { - if (freeBuffers < MAX_BUFFERS) { - for (int i = 0; i < MAX_BUFFERS; i++) { - if (cache[i] == null) { - cache[i] = buf; - freeBuffers++; - return; - } - } - } - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Dfs.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Dfs.java deleted file mode 100644 index 48efb25812..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Dfs.java +++ /dev/null @@ -1,328 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2008 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.util.LogStream; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; - -public class Dfs { - - static class CacheEntry { - long expiration; - HashMap map; - - CacheEntry(long ttl) { - if (ttl == 0) - ttl = Dfs.TTL; - expiration = System.currentTimeMillis() + ttl * 1000L; - map = new HashMap(); - } - } - - static LogStream log = LogStream.getInstance(); - static final boolean strictView = Config.getBoolean("jcifs.smb.client.dfs.strictView", false); - static final long TTL = Config.getLong("jcifs.smb.client.dfs.ttl", 300); - static final boolean DISABLED = Config.getBoolean("jcifs.smb.client.dfs.disabled", false); - - protected static CacheEntry FALSE_ENTRY = new CacheEntry(0L); - - protected CacheEntry _domains = null; /* aka trusted domains cache */ - protected CacheEntry referrals = null; - - public HashMap getTrustedDomains(NtlmPasswordAuthentication auth) throws SmbAuthException { - if (DISABLED || auth.domain == "?") - return null; - - if (_domains != null && System.currentTimeMillis() > _domains.expiration) { - _domains = null; - } - if (_domains != null) - return _domains.map; - try { - UniAddress addr = UniAddress.getByName(auth.domain, true); - SmbTransport trans = SmbTransport.getSmbTransport(addr, 0); - CacheEntry entry = new CacheEntry(Dfs.TTL * 10L); - - DfsReferral dr = trans.getDfsReferrals(auth, "", 0); - if (dr != null) { - DfsReferral start = dr; - do { - String domain = dr.server.toLowerCase(); - entry.map.put(domain, new HashMap()); - dr = dr.next; - } while (dr != start); - - _domains = entry; - return _domains.map; - } - } catch (IOException ioe) { - if (log.level >= 3) - ioe.printStackTrace(log); - if (strictView && ioe instanceof SmbAuthException) { - throw (SmbAuthException)ioe; - } - } - return null; - } - public boolean isTrustedDomain(String domain, - NtlmPasswordAuthentication auth) throws SmbAuthException - { - HashMap domains = getTrustedDomains(auth); - if (domains == null) - return false; - domain = domain.toLowerCase(); - return domains.get(domain) != null; - } - public SmbTransport getDc(String domain, - NtlmPasswordAuthentication auth) throws SmbAuthException { - if (DISABLED) - return null; - - try { - UniAddress addr = UniAddress.getByName(domain, true); - SmbTransport trans = SmbTransport.getSmbTransport(addr, 0); - DfsReferral dr = trans.getDfsReferrals(auth, "\\" + domain, 1); - if (dr != null) { - DfsReferral start = dr; - IOException e = null; - - do { - try { - addr = UniAddress.getByName(dr.server); - return SmbTransport.getSmbTransport(addr, 0); - } catch (IOException ioe) { - e = ioe; - } - - dr = dr.next; - } while (dr != start); - - throw e; - } - } catch (IOException ioe) { - if (log.level >= 3) - ioe.printStackTrace(log); - if (strictView && ioe instanceof SmbAuthException) { - throw (SmbAuthException)ioe; - } - } - return null; - } - public DfsReferral getReferral(SmbTransport trans, - String domain, - String root, - String path, - NtlmPasswordAuthentication auth) throws SmbAuthException { - if (DISABLED) - return null; - - try { - String p = "\\" + domain + "\\" + root; - if (path != null) - p += path; - DfsReferral dr = trans.getDfsReferrals(auth, p, 0); - if (dr != null) - return dr; - } catch (IOException ioe) { - if (log.level >= 4) - ioe.printStackTrace(log); - if (strictView && ioe instanceof SmbAuthException) { - throw (SmbAuthException)ioe; - } - } - return null; - } - public synchronized DfsReferral resolve(String domain, - String root, - String path, - NtlmPasswordAuthentication auth) throws SmbAuthException { - DfsReferral dr = null; - long now = System.currentTimeMillis(); - - if (DISABLED || root.equals("IPC$")) { - return null; - } - /* domains that can contain DFS points to maps of roots for each - */ - HashMap domains = getTrustedDomains(auth); - if (domains != null) { - domain = domain.toLowerCase(); - /* domain-based DFS root shares to links for each - */ - HashMap roots = (HashMap)domains.get(domain); - if (roots != null) { - SmbTransport trans = null; - - root = root.toLowerCase(); - - /* The link entries contain maps of referrals by path representing DFS links. - * Note that paths are relative to the root like "\" and not "\example.com\root". - */ - CacheEntry links = (CacheEntry)roots.get(root); - if (links != null && now > links.expiration) { - roots.remove(root); - links = null; - } - - if (links == null) { - if ((trans = getDc(domain, auth)) == null) - return null; - - dr = getReferral(trans, domain, root, path, auth); - if (dr != null) { - int len = 1 + domain.length() + 1 + root.length(); - - links = new CacheEntry(0L); - - DfsReferral tmp = dr; - do { - if (path == null) { - /* Store references to the map and key so that - * SmbFile.resolveDfs can re-insert the dr list with - * the dr that was successful so that subsequent - * attempts to resolve DFS use the last successful - * referral first. - */ - tmp.map = links.map; - tmp.key = "\\"; - } - tmp.pathConsumed -= len; - tmp = tmp.next; - } while (tmp != dr); - - if (dr.key != null) - links.map.put(dr.key, dr); - - roots.put(root, links); - } else if (path == null) { - roots.put(root, Dfs.FALSE_ENTRY); - } - } else if (links == Dfs.FALSE_ENTRY) { - links = null; - } - - if (links != null) { - String link = "\\"; - - /* Lookup the domain based DFS root target referral. Note the - * path is just "\" and not "\example.com\root". - */ - dr = (DfsReferral)links.map.get(link); - if (dr != null && now > dr.expiration) { - links.map.remove(link); - dr = null; - } - - if (dr == null) { - if (trans == null) - if ((trans = getDc(domain, auth)) == null) - return null; - dr = getReferral(trans, domain, root, path, auth); - if (dr != null) { - dr.pathConsumed -= 1 + domain.length() + 1 + root.length(); - dr.link = link; - links.map.put(link, dr); - } - } - } - } - } - - if (dr == null && path != null) { - /* We did not match a domain based root. Now try to match the - * longest path in the list of stand-alone referrals. - */ - if (referrals != null && now > referrals.expiration) { - referrals = null; - } - if (referrals == null) { - referrals = new CacheEntry(0); - } - String key = "\\" + domain + "\\" + root; - if (path.equals("\\") == false) - key += path; - key = key.toLowerCase(); - - Iterator iter = referrals.map.keySet().iterator(); - while (iter.hasNext()) { - String _key = (String)iter.next(); - int _klen = _key.length(); - boolean match = false; - - if (_klen == key.length()) { - match = _key.equals(key); - } else if (_klen < key.length()) { - match = _key.regionMatches(0, key, 0, _klen) && key.charAt(_klen) == '\\'; - } - - if (match) - dr = (DfsReferral)referrals.map.get(_key); - } - } - - return dr; - } - synchronized void insert(String path, DfsReferral dr) { - int s1, s2; - String server, share, key; - - if (DISABLED) - return; - - s1 = path.indexOf('\\', 1); - s2 = path.indexOf('\\', s1 + 1); - server = path.substring(1, s1); - share = path.substring(s1 + 1, s2); - - key = path.substring(0, dr.pathConsumed).toLowerCase(); - - /* Samba has a tendency to return referral paths and pathConsumed values - * in such a way that there can be a slash at the end of the path. This - * causes problems matching keys in resolve() where an extra slash causes - * a mismatch. This strips trailing slashes from all keys to eliminate - * this problem. - */ - int ki = key.length(); - while (ki > 1 && key.charAt(ki - 1) == '\\') { - ki--; - } - if (ki < key.length()) { - key = key.substring(0, ki); - } - - /* Subtract the server and share from the pathConsumed so that - * it refects the part of the relative path consumed and not - * the entire path. - */ - dr.pathConsumed -= 1 + server.length() + 1 + share.length(); - - if (referrals != null && (System.currentTimeMillis() + 10000) > referrals.expiration) { - referrals = null; - } - if (referrals == null) { - referrals = new CacheEntry(0); - } - referrals.map.put(key, dr); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DfsReferral.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DfsReferral.java deleted file mode 100644 index d6d06928ef..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DfsReferral.java +++ /dev/null @@ -1,59 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.util.Map; - -public class DfsReferral extends SmbException { - - public int pathConsumed; - public long ttl; - public String server; // Server - public String share; // Share - public String link; - public String path; // Path relative to tree from which this referral was thrown - public boolean resolveHashes; - public long expiration; - - DfsReferral next; - Map map; - String key = null; - - public DfsReferral() - { - this.next = this; - } - - void append(DfsReferral dr) - { - dr.next = next; - next = dr; - } - - public String toString() { - return "DfsReferral[pathConsumed=" + pathConsumed + - ",server=" + server + - ",share=" + share + - ",link=" + link + - ",path=" + path + - ",ttl=" + ttl + - ",expiration=" + expiration + - ",resolveHashes=" + resolveHashes + "]"; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosError.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosError.java deleted file mode 100644 index 666fb5c658..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosError.java +++ /dev/null @@ -1,112 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2004 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public interface DosError { - - static final int[][] DOS_ERROR_CODES = { - { 0x00000000, 0x00000000 }, - { 0x00010001, 0xc0000002 }, - { 0x00010002, 0xc0000002 }, - { 0x00020001, 0xc000000f }, - { 0x00020002, 0xc000006a }, - { 0x00030001, 0xc000003a }, - { 0x00030002, 0xc00000cb }, - { 0x00040002, 0xc00000ca }, - { 0x00050001, 0xc0000022 }, - { 0x00050002, 0xc000000d }, - { 0x00060001, 0xc0000008 }, - { 0x00060002, 0xc00000cc }, - { 0x00080001, 0xc000009a }, - { 0x00130003, 0xc00000a2 }, - { 0x00150003, 0xc0000013 }, - { 0x001f0001, 0xc0000001 }, - { 0x001f0003, 0xc0000001 }, - { 0x00200001, 0xc0000043 }, - { 0x00200003, 0xc0000043 }, - { 0x00210003, 0xc0000054 }, - { 0x00270003, 0xc000007f }, - { 0x00340001, 0xC00000bd }, - { 0x00430001, 0xc00000cc }, - { 0x00470001, 0xC00000d0 }, - { 0x00500001, 0xc0000035 }, - { 0x00570001, 0xc0000003 }, - { 0x005a0002, 0xc00000ce }, - { 0x005b0002, 0xc000000d }, - { 0x006d0001, 0xC000014b }, - { 0x007b0001, 0xc0000033 }, - { 0x00910001, 0xC0000101 }, - { 0x00b70001, 0xc0000035 }, - { 0x00e70001, 0xc00000ab }, - { 0x00e80001, 0xc00000b1 }, - { 0x00e90001, 0xc00000b0 }, - { 0x00ea0001, 0xc0000016 }, - { 0x08bf0002, 0xC0000193 }, - { 0x08c00002, 0xC0000070 }, - { 0x08c10002, 0xC000006f }, - { 0x08c20002, 0xC0000071 }, - }; - - /* These aren't really used by jCIFS -- the map above is used - * to immediately map to NTSTATUS codes. - */ - static final String[] DOS_ERROR_MESSAGES = { - "The operation completed successfully.", - "Incorrect function.", - "Incorrect function.", - "The system cannot find the file specified.", - "Bad password.", - "The system cannot find the path specified.", - "reserved", - "The client does not have the necessary access rights to perform the requested function.", - "Access is denied.", - "The TID specified was invalid.", - "The handle is invalid.", - "The network name cannot be found.", - "Not enough storage is available to process this command.", - "The media is write protected.", - "The device is not ready.", - "A device attached to the system is not functioning.", - "A device attached to the system is not functioning.", - "The process cannot access the file because it is being used by another process.", - "The process cannot access the file because it is being used by another process.", - "The process cannot access the file because another process has locked a portion of the file.", - "The disk is full.", - "A duplicate name exists on the network.", - "The network name cannot be found.", - "ERRnomoreconn.", - "The file exists.", - "The parameter is incorrect.", - "Too many Uids active on this session.", - "The Uid is not known as a valid user identifier on this session.", - "The pipe has been ended.", - "The filename, directory name, or volume label syntax is incorrect.", - "The directory is not empty.", - "Cannot create a file when that file already exists.", - "All pipe instances are busy.", - "The pipe is being closed.", - "No process is on the other end of the pipe.", - "More data is available.", - "This user account has expired.", - "The user is not allowed to log on from this workstation.", - "The user is not allowed to log on at this time.", - "The password of this user has expired.", - }; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosFileFilter.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosFileFilter.java deleted file mode 100644 index 394794a0cf..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/DosFileFilter.java +++ /dev/null @@ -1,46 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public class DosFileFilter implements SmbFileFilter { - - protected String wildcard; - protected int attributes; - -/* This filter can be considerably more efficient than other file filters - * as the specifed wildcard and attributes are passed to the server for - * filtering there (although attributes are largely ignored by servers - * they are filtered locally by the default accept method). - */ - public DosFileFilter( String wildcard, int attributes ) { - this.wildcard = wildcard; - this.attributes = attributes; - } - -/* This returns true if the file's attributes contain any of the attributes - * specified for this filter. The wildcard has no influence on this - * method as the server should have performed that filtering already. The - * attributes are asserted here only because server file systems may not - * support filtering by all attributes (e.g. even though ATTR_DIRECTORY was - * specified the server may still return objects that are not directories). - */ - public boolean accept( SmbFile file ) throws SmbException { - return (file.getAttributes() & attributes) != 0; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/FileEntry.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/FileEntry.java deleted file mode 100644 index 489e6a7da0..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/FileEntry.java +++ /dev/null @@ -1,11 +0,0 @@ -package jcifs.smb; - -public interface FileEntry { - - String getName(); - int getType(); - int getAttributes(); - long createTime(); - long lastModified(); - long length(); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Handler.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Handler.java deleted file mode 100644 index 35dda2f1fa..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Handler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; - -public class Handler extends URLStreamHandler { - - static final URLStreamHandler SMB_HANDLER = new Handler(); - - protected int getDefaultPort() { - return SmbConstants.DEFAULT_PORT; - } - public URLConnection openConnection( URL u ) throws IOException { - return new SmbFile( u ); - } - protected void parseURL( URL u, String spec, int start, int limit ) { - String host = u.getHost(); - String path, ref; - int port; - - if( spec.equals( "smb://" )) { - spec = "smb:////"; - limit += 2; - } else if( spec.startsWith( "smb://" ) == false && - host != null && host.length() == 0 ) { - spec = "//" + spec; - limit += 2; - } - super.parseURL( u, spec, start, limit ); - path = u.getPath(); - ref = u.getRef(); - if (ref != null) { - path += '#' + ref; - } - port = u.getPort(); - if( port == -1 ) { - port = getDefaultPort(); - } - setURL( u, "smb", u.getHost(), port, - u.getAuthority(), u.getUserInfo(), - path, u.getQuery(), null ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Info.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Info.java deleted file mode 100644 index ef0dd91dd4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Info.java +++ /dev/null @@ -1,26 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -interface Info { - int getAttributes(); - long getCreateTime(); - long getLastWriteTime(); - long getSize(); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2.java deleted file mode 100644 index dab09b4140..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2.java +++ /dev/null @@ -1,106 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * Gary Rambo - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.UnsupportedEncodingException; - -class NetServerEnum2 extends SmbComTransaction { - - static final int SV_TYPE_ALL = 0xFFFFFFFF; - static final int SV_TYPE_DOMAIN_ENUM = 0x80000000; - - static final String[] DESCR = { - "WrLehDO\u0000B16BBDz\u0000", - "WrLehDz\u0000B16BBDz\u0000", - }; - - String domain, lastName = null; - int serverTypes; - - NetServerEnum2( String domain, int serverTypes ) { - this.domain = domain; - this.serverTypes = serverTypes; - command = SMB_COM_TRANSACTION; - subCommand = NET_SERVER_ENUM2; // not really true be used by upper logic - name = "\\PIPE\\LANMAN"; - - maxParameterCount = 8; - maxDataCount = 16384; - maxSetupCount = (byte)0x00; - setupCount = 0; - timeout = 5000; - } - - void reset( int key, String lastName ) { - super.reset(); - this.lastName = lastName; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - byte[] descr; - int which = subCommand == NET_SERVER_ENUM2 ? 0 : 1; - - try { - descr = DESCR[which].getBytes( "ASCII" ); - } catch( UnsupportedEncodingException uee ) { - return 0; - } - - writeInt2( subCommand & 0xFF, dst, dstIndex ); - dstIndex += 2; - System.arraycopy( descr, 0, dst, dstIndex, descr.length ); - dstIndex += descr.length; - writeInt2( 0x0001, dst, dstIndex ); - dstIndex += 2; - writeInt2( maxDataCount, dst, dstIndex ); - dstIndex += 2; - writeInt4( serverTypes, dst, dstIndex ); - dstIndex += 4; - dstIndex += writeString( domain.toUpperCase(), dst, dstIndex, false ); - if( which == 1 ) { - dstIndex += writeString( lastName.toUpperCase(), dst, dstIndex, false ); - } - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "NetServerEnum2[" + super.toString() + - ",name=" + name + - ",serverTypes=" + (serverTypes == SV_TYPE_ALL ? - "SV_TYPE_ALL" : "SV_TYPE_DOMAIN_ENUM" ) + - "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2Response.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2Response.java deleted file mode 100644 index 1d8390de1d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetServerEnum2Response.java +++ /dev/null @@ -1,130 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * Gary Rambo - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class NetServerEnum2Response extends SmbComTransactionResponse { - - class ServerInfo1 implements FileEntry { - String name; - int versionMajor; - int versionMinor; - int type; - String commentOrMasterBrowser; - - public String getName() { - return name; - } - public int getType() { - return (type & 0x80000000) != 0 ? SmbFile.TYPE_WORKGROUP : SmbFile.TYPE_SERVER; - } - public int getAttributes() { - return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY; - } - public long createTime() { - return 0L; - } - public long lastModified() { - return 0L; - } - public long length() { - return 0L; - } - - public String toString() { - return new String( "ServerInfo1[" + - "name=" + name + - ",versionMajor=" + versionMajor + - ",versionMinor=" + versionMinor + - ",type=0x" + Hexdump.toHexString( type, 8 ) + - ",commentOrMasterBrowser=" + commentOrMasterBrowser + "]" ); - } - } - - private int converter, totalAvailableEntries; - - String lastName; - - NetServerEnum2Response() { - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - status = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - converter = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - numEntries = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - totalAvailableEntries = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - return bufferIndex - start; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - ServerInfo1 e = null; - - results = new ServerInfo1[numEntries]; - for( int i = 0; i < numEntries; i++ ) { - results[i] = e = new ServerInfo1(); - e.name = readString( buffer, bufferIndex, 16, false ); - bufferIndex += 16; - e.versionMajor = (int)( buffer[bufferIndex++] & 0xFF ); - e.versionMinor = (int)( buffer[bufferIndex++] & 0xFF ); - e.type = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - int off = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - off = ( off & 0xFFFF ) - converter; - off = start + off; - e.commentOrMasterBrowser = readString( buffer, off, 48, false ); - - if( log.level >= 4 ) - log.println( e ); - } - lastName = numEntries == 0 ? null : e.name; - - return bufferIndex - start; - } - public String toString() { - return new String( "NetServerEnum2Response[" + - super.toString() + - ",status=" + status + - ",converter=" + converter + - ",entriesReturned=" + numEntries + - ",totalAvailableEntries=" + totalAvailableEntries + - ",lastName=" + lastName + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnum.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnum.java deleted file mode 100644 index 16b423fedc..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnum.java +++ /dev/null @@ -1,78 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.UnsupportedEncodingException; - -class NetShareEnum extends SmbComTransaction { - - private static final String DESCR = "WrLeh\u0000B13BWz\u0000"; - - NetShareEnum() { - command = SMB_COM_TRANSACTION; - subCommand = NET_SHARE_ENUM; // not really true be used by upper logic - name = new String( "\\PIPE\\LANMAN" ); - maxParameterCount = 8; - -// maxDataCount = 4096; why was this set? - maxSetupCount = (byte)0x00; - setupCount = 0; - timeout = 5000; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - byte[] descr; - - try { - descr = DESCR.getBytes( "ASCII" ); - } catch( UnsupportedEncodingException uee ) { - return 0; - } - - writeInt2( NET_SHARE_ENUM, dst, dstIndex ); - dstIndex += 2; - System.arraycopy( descr, 0, dst, dstIndex, descr.length ); - dstIndex += descr.length; - writeInt2( 0x0001, dst, dstIndex ); - dstIndex += 2; - writeInt2( maxDataCount, dst, dstIndex ); - dstIndex += 2; - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "NetShareEnum[" + super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnumResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnumResponse.java deleted file mode 100644 index c51491ea32..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NetShareEnumResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class NetShareEnumResponse extends SmbComTransactionResponse { - - private int converter, totalAvailableEntries; - - NetShareEnumResponse() { - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - status = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - converter = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - numEntries = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - totalAvailableEntries = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - return bufferIndex - start; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - SmbShareInfo e; - - useUnicode = false; - - results = new SmbShareInfo[numEntries]; - for( int i = 0; i < numEntries; i++ ) { - results[i] = e = new SmbShareInfo(); - e.netName = readString( buffer, bufferIndex, 13, false ); - bufferIndex += 14; - e.type = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - int off = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - off = ( off & 0xFFFF ) - converter; - off = start + off; - e.remark = readString( buffer, off, 128, false ); - - if (log.level >= 4) - log.println( e ); - } - - return bufferIndex - start; - } - public String toString() { - return new String( "NetShareEnumResponse[" + - super.toString() + - ",status=" + status + - ",converter=" + converter + - ",entriesReturned=" + numEntries + - ",totalAvailableEntries=" + totalAvailableEntries + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtStatus.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtStatus.java deleted file mode 100644 index 7eeabf1fa8..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtStatus.java +++ /dev/null @@ -1,220 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2004 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public interface NtStatus { - - /* Don't bother to edit this. Everthing within the interface - * block is automatically generated from the ntstatus package. - */ - - public static final int NT_STATUS_OK = 0x00000000; - public static final int NT_STATUS_UNSUCCESSFUL = 0xC0000001; - public static final int NT_STATUS_NOT_IMPLEMENTED = 0xC0000002; - public static final int NT_STATUS_INVALID_INFO_CLASS = 0xC0000003; - public static final int NT_STATUS_ACCESS_VIOLATION = 0xC0000005; - public static final int NT_STATUS_INVALID_HANDLE = 0xC0000008; - public static final int NT_STATUS_INVALID_PARAMETER = 0xC000000d; - public static final int NT_STATUS_NO_SUCH_DEVICE = 0xC000000e; - public static final int NT_STATUS_NO_SUCH_FILE = 0xC000000f; - public static final int NT_STATUS_MORE_PROCESSING_REQUIRED = 0xC0000016; - public static final int NT_STATUS_ACCESS_DENIED = 0xC0000022; - public static final int NT_STATUS_BUFFER_TOO_SMALL = 0xC0000023; - public static final int NT_STATUS_OBJECT_NAME_INVALID = 0xC0000033; - public static final int NT_STATUS_OBJECT_NAME_NOT_FOUND = 0xC0000034; - public static final int NT_STATUS_OBJECT_NAME_COLLISION = 0xC0000035; - public static final int NT_STATUS_PORT_DISCONNECTED = 0xC0000037; - public static final int NT_STATUS_OBJECT_PATH_INVALID = 0xC0000039; - public static final int NT_STATUS_OBJECT_PATH_NOT_FOUND = 0xC000003a; - public static final int NT_STATUS_OBJECT_PATH_SYNTAX_BAD = 0xC000003b; - public static final int NT_STATUS_SHARING_VIOLATION = 0xC0000043; - public static final int NT_STATUS_DELETE_PENDING = 0xC0000056; - public static final int NT_STATUS_NO_LOGON_SERVERS = 0xC000005e; - public static final int NT_STATUS_USER_EXISTS = 0xC0000063; - public static final int NT_STATUS_NO_SUCH_USER = 0xC0000064; - public static final int NT_STATUS_WRONG_PASSWORD = 0xC000006a; - public static final int NT_STATUS_LOGON_FAILURE = 0xC000006d; - public static final int NT_STATUS_ACCOUNT_RESTRICTION = 0xC000006e; - public static final int NT_STATUS_INVALID_LOGON_HOURS = 0xC000006f; - public static final int NT_STATUS_INVALID_WORKSTATION = 0xC0000070; - public static final int NT_STATUS_PASSWORD_EXPIRED = 0xC0000071; - public static final int NT_STATUS_ACCOUNT_DISABLED = 0xC0000072; - public static final int NT_STATUS_NONE_MAPPED = 0xC0000073; - public static final int NT_STATUS_INVALID_SID = 0xC0000078; - public static final int NT_STATUS_INSTANCE_NOT_AVAILABLE = 0xC00000ab; - public static final int NT_STATUS_PIPE_NOT_AVAILABLE = 0xC00000ac; - public static final int NT_STATUS_INVALID_PIPE_STATE = 0xC00000ad; - public static final int NT_STATUS_PIPE_BUSY = 0xC00000ae; - public static final int NT_STATUS_PIPE_DISCONNECTED = 0xC00000b0; - public static final int NT_STATUS_PIPE_CLOSING = 0xC00000b1; - public static final int NT_STATUS_PIPE_LISTENING = 0xC00000b3; - public static final int NT_STATUS_FILE_IS_A_DIRECTORY = 0xC00000ba; - public static final int NT_STATUS_DUPLICATE_NAME = 0xC00000bd; - public static final int NT_STATUS_NETWORK_NAME_DELETED = 0xC00000c9; - public static final int NT_STATUS_NETWORK_ACCESS_DENIED = 0xC00000ca; - public static final int NT_STATUS_BAD_NETWORK_NAME = 0xC00000cc; - public static final int NT_STATUS_REQUEST_NOT_ACCEPTED = 0xC00000d0; - public static final int NT_STATUS_CANT_ACCESS_DOMAIN_INFO = 0xC00000da; - public static final int NT_STATUS_NO_SUCH_DOMAIN = 0xC00000df; - public static final int NT_STATUS_NOT_A_DIRECTORY = 0xC0000103; - public static final int NT_STATUS_CANNOT_DELETE = 0xC0000121; - public static final int NT_STATUS_INVALID_COMPUTER_NAME = 0xC0000122; - public static final int NT_STATUS_PIPE_BROKEN = 0xC000014b; - public static final int NT_STATUS_NO_SUCH_ALIAS = 0xC0000151; - public static final int NT_STATUS_LOGON_TYPE_NOT_GRANTED = 0xC000015b; - public static final int NT_STATUS_NO_TRUST_SAM_ACCOUNT = 0xC000018b; - public static final int NT_STATUS_TRUSTED_DOMAIN_FAILURE = 0xC000018c; - public static final int NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT = 0xC0000199; - public static final int NT_STATUS_PASSWORD_MUST_CHANGE = 0xC0000224; - public static final int NT_STATUS_NOT_FOUND = 0xC0000225; - public static final int NT_STATUS_ACCOUNT_LOCKED_OUT = 0xC0000234; - public static final int NT_STATUS_PATH_NOT_COVERED = 0xC0000257; - public static final int NT_STATUS_IO_REPARSE_TAG_NOT_HANDLED = 0xC0000279; - - static final int[] NT_STATUS_CODES = { - NT_STATUS_OK, - NT_STATUS_UNSUCCESSFUL, - NT_STATUS_NOT_IMPLEMENTED, - NT_STATUS_INVALID_INFO_CLASS, - NT_STATUS_ACCESS_VIOLATION, - NT_STATUS_INVALID_HANDLE, - NT_STATUS_INVALID_PARAMETER, - NT_STATUS_NO_SUCH_DEVICE, - NT_STATUS_NO_SUCH_FILE, - NT_STATUS_MORE_PROCESSING_REQUIRED, - NT_STATUS_ACCESS_DENIED, - NT_STATUS_BUFFER_TOO_SMALL, - NT_STATUS_OBJECT_NAME_INVALID, - NT_STATUS_OBJECT_NAME_NOT_FOUND, - NT_STATUS_OBJECT_NAME_COLLISION, - NT_STATUS_PORT_DISCONNECTED, - NT_STATUS_OBJECT_PATH_INVALID, - NT_STATUS_OBJECT_PATH_NOT_FOUND, - NT_STATUS_OBJECT_PATH_SYNTAX_BAD, - NT_STATUS_SHARING_VIOLATION, - NT_STATUS_DELETE_PENDING, - NT_STATUS_NO_LOGON_SERVERS, - NT_STATUS_USER_EXISTS, - NT_STATUS_NO_SUCH_USER, - NT_STATUS_WRONG_PASSWORD, - NT_STATUS_LOGON_FAILURE, - NT_STATUS_ACCOUNT_RESTRICTION, - NT_STATUS_INVALID_LOGON_HOURS, - NT_STATUS_INVALID_WORKSTATION, - NT_STATUS_PASSWORD_EXPIRED, - NT_STATUS_ACCOUNT_DISABLED, - NT_STATUS_NONE_MAPPED, - NT_STATUS_INVALID_SID, - NT_STATUS_INSTANCE_NOT_AVAILABLE, - NT_STATUS_PIPE_NOT_AVAILABLE, - NT_STATUS_INVALID_PIPE_STATE, - NT_STATUS_PIPE_BUSY, - NT_STATUS_PIPE_DISCONNECTED, - NT_STATUS_PIPE_CLOSING, - NT_STATUS_PIPE_LISTENING, - NT_STATUS_FILE_IS_A_DIRECTORY, - NT_STATUS_DUPLICATE_NAME, - NT_STATUS_NETWORK_NAME_DELETED, - NT_STATUS_NETWORK_ACCESS_DENIED, - NT_STATUS_BAD_NETWORK_NAME, - NT_STATUS_REQUEST_NOT_ACCEPTED, - NT_STATUS_CANT_ACCESS_DOMAIN_INFO, - NT_STATUS_NO_SUCH_DOMAIN, - NT_STATUS_NOT_A_DIRECTORY, - NT_STATUS_CANNOT_DELETE, - NT_STATUS_INVALID_COMPUTER_NAME, - NT_STATUS_PIPE_BROKEN, - NT_STATUS_NO_SUCH_ALIAS, - NT_STATUS_LOGON_TYPE_NOT_GRANTED, - NT_STATUS_NO_TRUST_SAM_ACCOUNT, - NT_STATUS_TRUSTED_DOMAIN_FAILURE, - NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT, - NT_STATUS_PASSWORD_MUST_CHANGE, - NT_STATUS_NOT_FOUND, - NT_STATUS_ACCOUNT_LOCKED_OUT, - NT_STATUS_PATH_NOT_COVERED, - NT_STATUS_IO_REPARSE_TAG_NOT_HANDLED, - }; - - static final String[] NT_STATUS_MESSAGES = { - "The operation completed successfully.", - "A device attached to the system is not functioning.", - "Incorrect function.", - "The parameter is incorrect.", - "Invalid access to memory location.", - "The handle is invalid.", - "The parameter is incorrect.", - "The system cannot find the file specified.", - "The system cannot find the file specified.", - "More data is available.", - "Access is denied.", - "The data area passed to a system call is too small.", - "The filename, directory name, or volume label syntax is incorrect.", - "The system cannot find the file specified.", - "Cannot create a file when that file already exists.", - "The handle is invalid.", - "The specified path is invalid.", - "The system cannot find the path specified.", - "The specified path is invalid.", - "The process cannot access the file because it is being used by another process.", - "Access is denied.", - "There are currently no logon servers available to service the logon request.", - "The specified user already exists.", - "The specified user does not exist.", - "The specified network password is not correct.", - "Logon failure: unknown user name or bad password.", - "Logon failure: user account restriction.", - "Logon failure: account logon time restriction violation.", - "Logon failure: user not allowed to log on to this computer.", - "Logon failure: the specified account password has expired.", - "Logon failure: account currently disabled.", - "No mapping between account names and security IDs was done.", - "The security ID structure is invalid.", - "All pipe instances are busy.", - "All pipe instances are busy.", - "The pipe state is invalid.", - "All pipe instances are busy.", - "No process is on the other end of the pipe.", - "The pipe is being closed.", - "Waiting for a process to open the other end of the pipe.", - "Access is denied.", - "A duplicate name exists on the network.", - "The specified network name is no longer available.", - "Network access is denied.", - "The network name cannot be found.", - "No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.", - "Indicates a Windows NT Server could not be contacted or that objects within the domain are protected such that necessary information could not be retrieved.", - "The specified domain did not exist.", - "The directory name is invalid.", - "Access is denied.", - "The format of the specified computer name is invalid.", - "The pipe has been ended.", - "The specified local group does not exist.", - "Logon failure: the user has not been granted the requested logon type at this computer.", - "The SAM database on the Windows NT Server does not have a computer account for this workstation trust relationship.", - "The trust relationship between the primary domain and the trusted domain failed.", - "The account used is a Computer Account. Use your global user account or local user account to access this server.", - "The user must change his password before he logs on the first time.", - "NT_STATUS_NOT_FOUND", - "The referenced account is currently locked out and may not be logged on to.", - "The remote system is not reachable by the transport.", - "NT_STATUS_IO_REPARSE_TAG_NOT_HANDLED", - }; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDesc.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDesc.java deleted file mode 100644 index bf80cac7a5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDesc.java +++ /dev/null @@ -1,72 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class NtTransQuerySecurityDesc extends SmbComNtTransaction { - - int fid; - int securityInformation; - - NtTransQuerySecurityDesc( int fid, int securityInformation ) { - this.fid = fid; - this.securityInformation = securityInformation; - command = SMB_COM_NT_TRANSACT; - function = NT_TRANSACT_QUERY_SECURITY_DESC; - setupCount = 0; - totalDataCount = 0; - maxParameterCount = 4; - maxDataCount = 32768; - maxSetupCount = (byte)0x00; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - dst[dstIndex++] = (byte)0x00; // Reserved - dst[dstIndex++] = (byte)0x00; // Reserved - writeInt4( securityInformation, dst, dstIndex ); - dstIndex += 4; - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "NtTransQuerySecurityDesc[" + super.toString() + - ",fid=0x" + Hexdump.toHexString( fid, 4 ) + - ",securityInformation=0x" + Hexdump.toHexString( securityInformation, 8 ) + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDescResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDescResponse.java deleted file mode 100644 index 31e2ec4245..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtTransQuerySecurityDescResponse.java +++ /dev/null @@ -1,66 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; - -class NtTransQuerySecurityDescResponse extends SmbComNtTransactionResponse { - - SecurityDescriptor securityDescriptor; - - NtTransQuerySecurityDescResponse() { - super(); - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - length = readInt4( buffer, bufferIndex ); - return 4; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - if (errorCode != 0) - return 4; - - try { - securityDescriptor = new SecurityDescriptor(); - bufferIndex += securityDescriptor.decode(buffer, bufferIndex, len); - } catch (IOException ioe) { - throw new RuntimeException(ioe.getMessage()); - } - - return bufferIndex - start; - } - public String toString() { - return new String( "NtTransQuerySecurityResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmAuthenticator.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmAuthenticator.java deleted file mode 100644 index 58e6323135..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmAuthenticator.java +++ /dev/null @@ -1,77 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -/** -This class can be extended by applications that wish to trap authentication related exceptions and automatically retry the exceptional operation with different credentials. Read jCIFS Exceptions and NtlmAuthenticator for complete details. - */ - -public abstract class NtlmAuthenticator { - - private static NtlmAuthenticator auth; - - private String url; - private SmbAuthException sae; - - private void reset() { - url = null; - sae = null; - } - -/** -Set the default NtlmAuthenticator. Once the default authenticator is set it cannot be changed. Calling this metho again will have no effect. - */ - - public synchronized static void setDefault( NtlmAuthenticator a ) { - if( auth != null ) { - return; - } - auth = a; - } - - protected final String getRequestingURL() { - return url; - } - protected final SmbAuthException getRequestingException() { - return sae; - } - -/** -Used internally by jCIFS when an SmbAuthException is trapped to retrieve new user credentials. - */ - - public static NtlmPasswordAuthentication - requestNtlmPasswordAuthentication( String url, SmbAuthException sae ) { - if( auth == null ) { - return null; - } - synchronized( auth ) { - auth.url = url; - auth.sae = sae; - return auth.getNtlmPasswordAuthentication(); - } - } -/** -An application extending this class must provide an implementation for this method that returns new user credentials try try when accessing SMB resources described by the getRequestingURL and getRequestingException methods. -If this method returns null the SmbAuthException that triggered the authenticator check will simply be rethrown. The default implementation returns null. -*/ - protected NtlmPasswordAuthentication getNtlmPasswordAuthentication() { - return null; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmChallenge.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmChallenge.java deleted file mode 100644 index b803441fe1..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmChallenge.java +++ /dev/null @@ -1,41 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2004 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.UniAddress; -import jcifs.util.Hexdump; - -import java.io.Serializable; - -public final class NtlmChallenge implements Serializable { - - public byte[] challenge; - public UniAddress dc; - - NtlmChallenge( byte[] challenge, UniAddress dc ) { - this.challenge = challenge; - this.dc = dc; - } - - public String toString() { - return "NtlmChallenge[challenge=0x" + - Hexdump.toHexString( challenge, 0, challenge.length * 2 ) + - ",dc=" + dc.toString() + "]"; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmContext.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmContext.java deleted file mode 100644 index 3f8b8045c0..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmContext.java +++ /dev/null @@ -1,178 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2008 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.ntlmssp.NtlmFlags; -import jcifs.ntlmssp.Type1Message; -import jcifs.ntlmssp.Type2Message; -import jcifs.ntlmssp.Type3Message; -import jcifs.util.Encdec; -import jcifs.util.Hexdump; -import jcifs.util.LogStream; - -/** -For initiating NTLM authentication (including NTLMv2). If you want to add NTLMv2 authentication support to something this is what you want to use. See the code for details. Note that JCIFS does not implement the acceptor side of NTLM authentication. - */ - -public class NtlmContext { - - - NtlmPasswordAuthentication auth; - int ntlmsspFlags; - String workstation; - boolean isEstablished = false; - byte[] serverChallenge = null; - byte[] signingKey = null; - String netbiosName = null; - int state = 1; - LogStream log; - - public NtlmContext(NtlmPasswordAuthentication auth, boolean doSigning) { - this.auth = auth; - this.ntlmsspFlags = ntlmsspFlags | - NtlmFlags.NTLMSSP_REQUEST_TARGET | - NtlmFlags.NTLMSSP_NEGOTIATE_NTLM2 | - NtlmFlags.NTLMSSP_NEGOTIATE_128; - if (doSigning) { - this.ntlmsspFlags |= NtlmFlags.NTLMSSP_NEGOTIATE_SIGN | - NtlmFlags.NTLMSSP_NEGOTIATE_ALWAYS_SIGN | - NtlmFlags.NTLMSSP_NEGOTIATE_KEY_EXCH; - } - this.workstation = Type1Message.getDefaultWorkstation(); - log = LogStream.getInstance(); - } - - public String toString() { - String ret = "NtlmContext[auth=" + auth + - ",ntlmsspFlags=0x" + Hexdump.toHexString(ntlmsspFlags, 8) + - ",workstation=" + workstation + - ",isEstablished=" + isEstablished + - ",state=" + state + - ",serverChallenge="; - if (serverChallenge == null) { - ret += "null"; - } else { - ret += Hexdump.toHexString(serverChallenge, 0, serverChallenge.length * 2); - } - ret += ",signingKey="; - if (signingKey == null) { - ret += "null"; - } else { - ret += Hexdump.toHexString(signingKey, 0, signingKey.length * 2); - } - ret += "]"; - return ret; - } - - public boolean isEstablished() { - return isEstablished; - } - public byte[] getServerChallenge() - { - return serverChallenge; - } - public byte[] getSigningKey() - { - return signingKey; - } - public String getNetbiosName() - { - return netbiosName; - } - - private String getNtlmsspListItem(byte[] type2token, int id0) - { - int ri = 58; - - for ( ;; ) { - int id = Encdec.dec_uint16le(type2token, ri); - int len = Encdec.dec_uint16le(type2token, ri + 2); - ri += 4; - if (id == 0 || (ri + len) > type2token.length) { - break; - } else if (id == id0) { - try { - return new String(type2token, ri, len, SmbConstants.UNI_ENCODING); - } catch (java.io.UnsupportedEncodingException uee) { - break; - } - } - ri += len; - } - - return null; - } - public byte[] initSecContext(byte[] token, int offset, int len) throws SmbException { - switch (state) { - case 1: - Type1Message msg1 = new Type1Message(ntlmsspFlags, auth.getDomain(), workstation); - token = msg1.toByteArray(); - - if (log.level >= 4) { - log.println(msg1); - if (log.level >= 6) - Hexdump.hexdump(log, token, 0, token.length); - } - - state++; - break; - case 2: - try { - Type2Message msg2 = new Type2Message(token); - - if (log.level >= 4) { - log.println(msg2); - if (log.level >= 6) - Hexdump.hexdump(log, token, 0, token.length); - } - - serverChallenge = msg2.getChallenge(); - ntlmsspFlags &= msg2.getFlags(); - -// netbiosName = getNtlmsspListItem(token, 0x0001); - - Type3Message msg3 = new Type3Message(msg2, - auth.getPassword(), - auth.getDomain(), - auth.getUsername(), - workstation, - ntlmsspFlags); - token = msg3.toByteArray(); - - if (log.level >= 4) { - log.println(msg3); - if (log.level >= 6) - Hexdump.hexdump(log, token, 0, token.length); - } - - if ((ntlmsspFlags & NtlmFlags.NTLMSSP_NEGOTIATE_SIGN) != 0) - signingKey = msg3.getMasterKey(); - - isEstablished = true; - state++; - break; - } catch (Exception e) { - throw new SmbException(e.getMessage(), e); - } - default: - throw new SmbException("Invalid state"); - } - return token; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmPasswordAuthentication.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmPasswordAuthentication.java deleted file mode 100644 index eea7fa8c29..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/NtlmPasswordAuthentication.java +++ /dev/null @@ -1,639 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.util.DES; -import jcifs.util.Encdec; -import jcifs.util.HMACT64; -import jcifs.util.LogStream; -import jcifs.util.MD4; - -import java.io.Serializable; -import java.io.UnsupportedEncodingException; -import java.security.GeneralSecurityException; -import java.security.MessageDigest; -import java.security.Principal; -import java.util.Arrays; -import java.util.Random; - -/** - * This class stores and encrypts NTLM user credentials. The default - * credentials are retrieved from the jcifs.smb.client.domain, - * jcifs.smb.client.username, and jcifs.smb.client.password - * properties. - * - * Read jCIFS Exceptions and - * NtlmAuthenticator for related information. - */ - -public final class NtlmPasswordAuthentication implements Principal, Serializable { - - private static final int LM_COMPATIBILITY = - Config.getInt("jcifs.smb.lmCompatibility", 3); - - private static final Random RANDOM = new Random(); - - private static LogStream log = LogStream.getInstance(); - - // KGS!@#$% - private static final byte[] S8 = { - (byte)0x4b, (byte)0x47, (byte)0x53, (byte)0x21, - (byte)0x40, (byte)0x23, (byte)0x24, (byte)0x25 - }; - /* Accepts key multiple of 7 - * Returns enc multiple of 8 - * Multiple is the same like: 21 byte key gives 24 byte result - */ - private static void E( byte[] key, byte[] data, byte[] e ) { - byte[] key7 = new byte[7]; - byte[] e8 = new byte[8]; - - for( int i = 0; i < key.length / 7; i++ ) { - System.arraycopy( key, i * 7, key7, 0, 7 ); - DES des = new DES( key7 ); - des.encrypt( data, e8 ); - System.arraycopy( e8, 0, e, i * 8, 8 ); - } - } - - static String DEFAULT_DOMAIN; - static String DEFAULT_USERNAME; - static String DEFAULT_PASSWORD; - static final String BLANK = ""; - - public static final NtlmPasswordAuthentication ANONYMOUS = new NtlmPasswordAuthentication("", "", ""); - - static void initDefaults() { - if (DEFAULT_DOMAIN != null) return; - DEFAULT_DOMAIN = Config.getProperty("jcifs.smb.client.domain", "?"); - DEFAULT_USERNAME = Config.getProperty("jcifs.smb.client.username", "GUEST"); - DEFAULT_PASSWORD = Config.getProperty("jcifs.smb.client.password", BLANK); - } - -/** - * Generate the ANSI DES hash for the password associated with these credentials. - */ - static public byte[] getPreNTLMResponse( String password, byte[] challenge ) { - byte[] p14 = new byte[14]; - byte[] p21 = new byte[21]; - byte[] p24 = new byte[24]; - byte[] passwordBytes; - try { - passwordBytes = password.toUpperCase().getBytes( ServerMessageBlock.OEM_ENCODING ); - } catch( UnsupportedEncodingException uee ) { - throw new RuntimeException("Try setting jcifs.encoding=US-ASCII", uee); - } - int passwordLength = passwordBytes.length; - - // Only encrypt the first 14 bytes of the password for Pre 0.12 NT LM - if( passwordLength > 14) { - passwordLength = 14; - } - System.arraycopy( passwordBytes, 0, p14, 0, passwordLength ); - E( p14, S8, p21); - E( p21, challenge, p24); - return p24; - } -/** - * Generate the Unicode MD4 hash for the password associated with these credentials. - */ - static public byte[] getNTLMResponse( String password, byte[] challenge ) { - byte[] uni = null; - byte[] p21 = new byte[21]; - byte[] p24 = new byte[24]; - - try { - uni = password.getBytes( SmbConstants.UNI_ENCODING ); - } catch( UnsupportedEncodingException uee ) { - if( log.level > 0 ) - uee.printStackTrace( log ); - } - MD4 md4 = new MD4(); - md4.update( uni ); - try { - md4.digest(p21, 0, 16); - } catch (Exception ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - } - E( p21, challenge, p24 ); - return p24; - } - - /** - * Creates the LMv2 response for the supplied information. - * - * @param domain The domain in which the username exists. - * @param user The username. - * @param password The user's password. - * @param challenge The server challenge. - * @param clientChallenge The client challenge (nonce). - */ - public static byte[] getLMv2Response(String domain, String user, - String password, byte[] challenge, byte[] clientChallenge) { - try { - byte[] hash = new byte[16]; - byte[] response = new byte[24]; -// The next 2-1/2 lines of this should be placed with nTOWFv1 in place of password - MD4 md4 = new MD4(); - md4.update(password.getBytes(SmbConstants.UNI_ENCODING)); - HMACT64 hmac = new HMACT64(md4.digest()); - hmac.update(user.toUpperCase().getBytes(SmbConstants.UNI_ENCODING)); - hmac.update(domain.toUpperCase().getBytes(SmbConstants.UNI_ENCODING)); - hmac = new HMACT64(hmac.digest()); - hmac.update(challenge); - hmac.update(clientChallenge); - hmac.digest(response, 0, 16); - System.arraycopy(clientChallenge, 0, response, 16, 8); - return response; - } catch (Exception ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - return null; - } - } - public static byte[] getNTLM2Response(byte[] nTOWFv1, - byte[] serverChallenge, - byte[] clientChallenge) - { - byte[] sessionHash = new byte[8]; - - try { - MessageDigest md5; - md5 = MessageDigest.getInstance("MD5"); - md5.update(serverChallenge); - md5.update(clientChallenge, 0, 8); - System.arraycopy(md5.digest(), 0, sessionHash, 0, 8); - } catch (GeneralSecurityException gse) { - if (log.level > 0) - gse.printStackTrace(log); - throw new RuntimeException("MD5", gse); - } - - byte[] key = new byte[21]; - System.arraycopy(nTOWFv1, 0, key, 0, 16); - byte[] ntResponse = new byte[24]; - E(key, sessionHash, ntResponse); - - return ntResponse; - } - public static byte[] nTOWFv1(String password) - { - if (password == null) - throw new RuntimeException("Password parameter is required"); - try { - MD4 md4 = new MD4(); - md4.update(password.getBytes(SmbConstants.UNI_ENCODING)); - return md4.digest(); - } catch (UnsupportedEncodingException uee) { - throw new RuntimeException(uee.getMessage()); - } - } - public static byte[] nTOWFv2(String domain, String username, String password) - { - try { - MD4 md4 = new MD4(); - md4.update(password.getBytes(SmbConstants.UNI_ENCODING)); - HMACT64 hmac = new HMACT64(md4.digest()); - hmac.update(username.toUpperCase().getBytes(SmbConstants.UNI_ENCODING)); - hmac.update(domain.getBytes(SmbConstants.UNI_ENCODING)); - return hmac.digest(); - } catch (UnsupportedEncodingException uee) { - throw new RuntimeException(uee.getMessage()); - } - } - static byte[] computeResponse(byte[] responseKey, - byte[] serverChallenge, - byte[] clientData, - int offset, - int length) - { - HMACT64 hmac = new HMACT64(responseKey); - hmac.update(serverChallenge); - hmac.update(clientData, offset, length); - byte[] mac = hmac.digest(); - byte[] ret = new byte[mac.length + clientData.length]; - System.arraycopy(mac, 0, ret, 0, mac.length); - System.arraycopy(clientData, 0, ret, mac.length, clientData.length); - return ret; - } - public static byte[] getLMv2Response( - byte[] responseKeyLM, - byte[] serverChallenge, - byte[] clientChallenge) - { - return NtlmPasswordAuthentication.computeResponse(responseKeyLM, - serverChallenge, - clientChallenge, - 0, - clientChallenge.length); - } - public static byte[] getNTLMv2Response( - byte[] responseKeyNT, - byte[] serverChallenge, - byte[] clientChallenge, - long nanos1601, - byte[] targetInfo) - { - int targetInfoLength = targetInfo != null ? targetInfo.length : 0; - byte[] temp = new byte[28 + targetInfoLength + 4]; - - Encdec.enc_uint32le(0x00000101, temp, 0); // Header - Encdec.enc_uint32le(0x00000000, temp, 4); // Reserved - Encdec.enc_uint64le(nanos1601, temp, 8); - System.arraycopy(clientChallenge, 0, temp, 16, 8); - Encdec.enc_uint32le(0x00000000, temp, 24); // Unknown - if (targetInfo != null) - System.arraycopy(targetInfo, 0, temp, 28, targetInfoLength); - Encdec.enc_uint32le(0x00000000, temp, 28 + targetInfoLength); // mystery bytes! - - return NtlmPasswordAuthentication.computeResponse(responseKeyNT, - serverChallenge, - temp, - 0, - temp.length); - } - - static final NtlmPasswordAuthentication NULL = - new NtlmPasswordAuthentication( "", "", "" ); - static final NtlmPasswordAuthentication GUEST = - new NtlmPasswordAuthentication( "?", "GUEST", "" ); - static final NtlmPasswordAuthentication DEFAULT = - new NtlmPasswordAuthentication( null ); - - String domain; - String username; - String password; - byte[] ansiHash; - byte[] unicodeHash; - boolean hashesExternal = false; - byte[] clientChallenge = null; - byte[] challenge = null; - -/** - * Create an NtlmPasswordAuthentication object from the userinfo - * component of an SMB URL like "domain;user:pass". This constructor - * is used internally be jCIFS when parsing SMB URLs. - */ - - public NtlmPasswordAuthentication( String userInfo ) { - domain = username = password = null; - - if( userInfo != null ) { - try { - userInfo = unescape( userInfo ); - } catch( UnsupportedEncodingException uee ) { - } - int i, u, end; - char c; - - end = userInfo.length(); - for( i = 0, u = 0; i < end; i++ ) { - c = userInfo.charAt( i ); - if( c == ';' ) { - domain = userInfo.substring( 0, i ); - u = i + 1; - } else if( c == ':' ) { - password = userInfo.substring( i + 1 ); - break; - } - } - username = userInfo.substring( u, i ); - } - - initDefaults(); - - if( domain == null ) this.domain = DEFAULT_DOMAIN; - if( username == null ) this.username = DEFAULT_USERNAME; - if( password == null ) this.password = DEFAULT_PASSWORD; - } -/** - * Create an NtlmPasswordAuthentication object from a - * domain, username, and password. Parameters that are null - * will be substituted with jcifs.smb.client.domain, - * jcifs.smb.client.username, jcifs.smb.client.password - * property values. - */ - public NtlmPasswordAuthentication( String domain, String username, String password ) { - int ci; - - if (username != null) { - ci = username.indexOf('@'); - if (ci > 0) { - domain = username.substring(ci + 1); - username = username.substring(0, ci); - } else { - ci = username.indexOf('\\'); - if (ci > 0) { - domain = username.substring(0, ci); - username = username.substring(ci + 1); - } - } - } - - this.domain = domain; - this.username = username; - this.password = password; - - initDefaults(); - - if( domain == null ) this.domain = DEFAULT_DOMAIN; - if( username == null ) this.username = DEFAULT_USERNAME; - if( password == null ) this.password = DEFAULT_PASSWORD; - } -/** - * Create an NtlmPasswordAuthentication object with raw password - * hashes. This is used exclusively by the jcifs.http.NtlmSsp - * class which is in turn used by NTLM HTTP authentication functionality. - */ - public NtlmPasswordAuthentication( String domain, String username, - byte[] challenge, byte[] ansiHash, byte[] unicodeHash ) { - if( domain == null || username == null || - ansiHash == null || unicodeHash == null ) { - throw new IllegalArgumentException( "External credentials cannot be null" ); - } - this.domain = domain; - this.username = username; - this.password = null; - this.challenge = challenge; - this.ansiHash = ansiHash; - this.unicodeHash = unicodeHash; - hashesExternal = true; - } - -/** - * Returns the domain. - */ - public String getDomain() { - return domain; - } - -/** - * Returns the username. - */ - public String getUsername() { - return username; - } -/** - * Returns the password in plain text or null if the raw password - * hashes were used to construct this NtlmPasswordAuthentication - * object which will be the case when NTLM HTTP Authentication is - * used. There is no way to retrieve a users password in plain text unless - * it is supplied by the user at runtime. - */ - public String getPassword() { - return password; - } -/** - * Return the domain and username in the format: - * domain\\username. This is equivalent to toString(). - */ - public String getName() { - boolean d = domain.length() > 0 && domain.equals( "?" ) == false; - return d ? domain + "\\" + username : username; - } - -/** - * Computes the 24 byte ANSI password hash given the 8 byte server challenge. - */ - public byte[] getAnsiHash( byte[] challenge ) { - if( hashesExternal ) { - return ansiHash; - } - switch (LM_COMPATIBILITY) { - case 0: - case 1: - return getPreNTLMResponse( password, challenge ); - case 2: - return getNTLMResponse( password, challenge ); - case 3: - case 4: - case 5: - if( clientChallenge == null ) { - clientChallenge = new byte[8]; - RANDOM.nextBytes( clientChallenge ); - } - return getLMv2Response(domain, username, password, challenge, - clientChallenge); - default: - return getPreNTLMResponse( password, challenge ); - } - } -/** - * Computes the 24 byte Unicode password hash given the 8 byte server challenge. - */ - public byte[] getUnicodeHash( byte[] challenge ) { - if( hashesExternal ) { - return unicodeHash; - } - switch (LM_COMPATIBILITY) { - case 0: - case 1: - case 2: - return getNTLMResponse( password, challenge ); - case 3: - case 4: - case 5: - /* - if( clientChallenge == null ) { - clientChallenge = new byte[8]; - RANDOM.nextBytes( clientChallenge ); - } - return getNTLMv2Response(domain, username, password, null, - challenge, clientChallenge); - */ - return new byte[0]; - default: - return getNTLMResponse( password, challenge ); - } - } - - public byte[] getSigningKey(byte[] challenge) throws SmbException - { - switch (LM_COMPATIBILITY) { - case 0: - case 1: - case 2: - byte[] signingKey = new byte[40]; - getUserSessionKey(challenge, signingKey, 0); - System.arraycopy(getUnicodeHash(challenge), 0, signingKey, 16, 24); - return signingKey; - case 3: - case 4: - case 5: - /* This code is only called if extended security is not on. This will - * all be cleaned up an normalized in JCIFS 2.x. - */ - throw new SmbException("NTLMv2 requires extended security (jcifs.smb.client.useExtendedSecurity must be true if jcifs.smb.lmCompatibility >= 3)"); - } - return null; - } - - /** - * Returns the effective user session key. - * - * @param challenge The server challenge. - * @return A
byte[]containing the effective user session key, - * used in SMB MAC signing and NTLMSSP signing and sealing. - */ - public byte[] getUserSessionKey(byte[] challenge) { - if (hashesExternal) return null; - byte[] key = new byte[16]; - try { - getUserSessionKey(challenge, key, 0); - } catch (Exception ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - } - return key; - } - - /** - * Calculates the effective user session key. - * - * @param challenge The server challenge. - * @param dest The destination array in which the user session key will be - * placed. - * @param offset The offset in the destination array at which the - * session key will start. - */ - void getUserSessionKey(byte[] challenge, byte[] dest, int offset) throws SmbException { - if (hashesExternal) return; - try { - MD4 md4 = new MD4(); - md4.update(password.getBytes(SmbConstants.UNI_ENCODING)); - switch (LM_COMPATIBILITY) { - case 0: - case 1: - case 2: - md4.update(md4.digest()); - md4.digest(dest, offset, 16); - break; - case 3: - case 4: - case 5: - if( clientChallenge == null ) { - clientChallenge = new byte[8]; - RANDOM.nextBytes( clientChallenge ); - } - - HMACT64 hmac = new HMACT64(md4.digest()); - hmac.update(username.toUpperCase().getBytes( - SmbConstants.UNI_ENCODING)); - hmac.update(domain.toUpperCase().getBytes( - SmbConstants.UNI_ENCODING)); - byte[] ntlmv2Hash = hmac.digest(); - hmac = new HMACT64(ntlmv2Hash); - hmac.update(challenge); - hmac.update(clientChallenge); - HMACT64 userKey = new HMACT64(ntlmv2Hash); - userKey.update(hmac.digest()); - userKey.digest(dest, offset, 16); - break; - default: - md4.update(md4.digest()); - md4.digest(dest, offset, 16); - break; - } - } catch (Exception e) { - throw new SmbException("", e); - } - } - -/** - * Compares two NtlmPasswordAuthentication objects for - * equality. Two NtlmPasswordAuthentication objects are equal if - * their caseless domain and username fields are equal and either both hashes are external and they are equal or both internally supplied passwords are equal. If one NtlmPasswordAuthentication object has external hashes (meaning negotiated via NTLM HTTP Authentication) and the other does not they will not be equal. This is technically not correct however the server 8 byte challage would be required to compute and compare the password hashes but that it not available with this method. - */ - public boolean equals( Object obj ) { - if( obj instanceof NtlmPasswordAuthentication ) { - NtlmPasswordAuthentication ntlm = (NtlmPasswordAuthentication)obj; - if( ntlm.domain.toUpperCase().equals( domain.toUpperCase() ) && - ntlm.username.toUpperCase().equals( username.toUpperCase() )) { - if( hashesExternal && ntlm.hashesExternal ) { - return Arrays.equals( ansiHash, ntlm.ansiHash ) && - Arrays.equals( unicodeHash, ntlm.unicodeHash ); - /* This still isn't quite right. If one npa object does not have external - * hashes and the other does then they will not be considered equal even - * though they may be. - */ - } else if( !hashesExternal && password.equals( ntlm.password )) { - return true; - } - } - } - return false; - } - - -/** - * Return the upcased username hash code. - */ - public int hashCode() { - return getName().toUpperCase().hashCode(); - } -/** - * Return the domain and username in the format: - * domain\\username. This is equivalent to getName(). - */ - public String toString() { - return getName(); - } - - static String unescape( String str ) throws NumberFormatException, UnsupportedEncodingException { - char ch; - int i, j, state, len; - char[] out; - byte[] b = new byte[1]; - - if( str == null ) { - return null; - } - - len = str.length(); - out = new char[len]; - state = 0; - for( i = j = 0; i < len; i++ ) { - switch( state ) { - case 0: - ch = str.charAt( i ); - if( ch == '%' ) { - state = 1; - } else { - out[j++] = ch; - } - break; - case 1: - /* Get ASCII hex value and convert to platform dependant - * encoding like EBCDIC perhaps - */ - b[0] = (byte)(Integer.parseInt( str.substring( i, i + 2 ), 16 ) & 0xFF); - out[j++] = (new String( b, 0, 1, "ASCII" )).charAt( 0 ); - i++; - state = 0; - } - } - - return new String( out, 0, j ); - } - -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SID.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SID.java deleted file mode 100644 index 8e2e5c0dd3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SID.java +++ /dev/null @@ -1,730 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2006 "Michael B. Allen"- * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.UnicodeString; -import jcifs.dcerpc.msrpc.*; -import jcifs.dcerpc.rpc; -import jcifs.util.Hexdump; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; - -/** - * A Windows SID is a numeric identifier used to represent Windows - * accounts. SIDs are commonly represented using a textual format such as - * S-1-5-21-1496946806-2192648263-3843101252-1029 but they may - * also be resolved to yield the name of the associated Windows account - * such as Administrators or MYDOM\alice. - * - * Consider the following output of examples/SidLookup.java: - *
- * toString: S-1-5-21-4133388617-793952518-2001621813-512 - * toDisplayString: WNET\Domain Admins - * getType: 2 - * getTypeText: Domain group - * getDomainName: WNET - * getAccountName: Domain Admins - *- */ - -public class SID extends rpc.sid_t { - - public static final int SID_TYPE_USE_NONE = lsarpc.SID_NAME_USE_NONE; - public static final int SID_TYPE_USER = lsarpc.SID_NAME_USER; - public static final int SID_TYPE_DOM_GRP = lsarpc.SID_NAME_DOM_GRP; - public static final int SID_TYPE_DOMAIN = lsarpc.SID_NAME_DOMAIN; - public static final int SID_TYPE_ALIAS = lsarpc.SID_NAME_ALIAS; - public static final int SID_TYPE_WKN_GRP = lsarpc.SID_NAME_WKN_GRP; - public static final int SID_TYPE_DELETED = lsarpc.SID_NAME_DELETED; - public static final int SID_TYPE_INVALID = lsarpc.SID_NAME_INVALID; - public static final int SID_TYPE_UNKNOWN = lsarpc.SID_NAME_UNKNOWN; - - static final String[] SID_TYPE_NAMES = { - "0", - "User", - "Domain group", - "Domain", - "Local group", - "Builtin group", - "Deleted", - "Invalid", - "Unknown" - }; - - public static final int SID_FLAG_RESOLVE_SIDS = 0x0001; - - public static SID EVERYONE = null; - public static SID CREATOR_OWNER = null; - public static SID SYSTEM = null; - - static { - try { - EVERYONE = new SID("S-1-1-0"); - CREATOR_OWNER = new SID("S-1-3-0"); - SYSTEM = new SID("S-1-5-18"); - } catch (SmbException se) { - } - } - - static Map sid_cache = new HashMap(); - - static void resolveSids(DcerpcHandle handle, - LsaPolicyHandle policyHandle, - SID[] sids) throws IOException { - MsrpcLookupSids rpc = new MsrpcLookupSids(policyHandle, sids); - handle.sendrecv(rpc); - switch (rpc.retval) { - case 0: - case NtStatus.NT_STATUS_NONE_MAPPED: - case 0x00000107: // NT_STATUS_SOME_NOT_MAPPED - break; - default: - throw new SmbException(rpc.retval, false); - } - - for (int si = 0; si < sids.length; si++) { - sids[si].type = rpc.names.names[si].sid_type; - sids[si].domainName = null; - - switch (sids[si].type) { - case SID_TYPE_USER: - case SID_TYPE_DOM_GRP: - case SID_TYPE_DOMAIN: - case SID_TYPE_ALIAS: - case SID_TYPE_WKN_GRP: - int sid_index = rpc.names.names[si].sid_index; - rpc.unicode_string ustr = rpc.domains.domains[sid_index].name; - sids[si].domainName = (new UnicodeString(ustr, false)).toString(); - break; - } - - sids[si].acctName = (new UnicodeString(rpc.names.names[si].name, false)).toString(); - sids[si].origin_server = null; - sids[si].origin_auth = null; - } - } - static void resolveSids0(String authorityServerName, - NtlmPasswordAuthentication auth, - SID[] sids) throws IOException { - DcerpcHandle handle = null; - LsaPolicyHandle policyHandle = null; - -synchronized (sid_cache) { - try { - handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + - "[\\PIPE\\lsarpc]", auth); - String server = authorityServerName; - int dot = server.indexOf('.'); - if (dot > 0 && Character.isDigit(server.charAt(0)) == false) - server = server.substring(0, dot); - policyHandle = new LsaPolicyHandle(handle, "\\\\" + server, 0x00000800); - SID.resolveSids(handle, policyHandle, sids); - } finally { - if (handle != null) { - if (policyHandle != null) { - policyHandle.close(); - } - handle.close(); - } - } -} - } - - static public void resolveSids(String authorityServerName, - NtlmPasswordAuthentication auth, - SID[] sids, - int offset, - int length) throws IOException { - ArrayList list = new ArrayList(sids.length); - int si; - -synchronized (sid_cache) { - for (si = 0; si < length; si++) { - SID sid = (SID)sid_cache.get(sids[offset + si]); - if (sid != null) { - sids[offset + si].type = sid.type; - sids[offset + si].domainName = sid.domainName; - sids[offset + si].acctName = sid.acctName; - } else { - list.add(sids[offset + si]); - } - } - - if (list.size() > 0) { - sids = (SID[])list.toArray(new SID[0]); - SID.resolveSids0(authorityServerName, auth, sids); - for (si = 0; si < sids.length; si++) { - sid_cache.put(sids[si], sids[si]); - } - } -} - } - /** - * Resolve an array of SIDs using a cache and at most one MSRPC request. - *- * This method will attempt - * to resolve SIDs using a cache and cache the results of any SIDs that - * required resolving with the authority. SID cache entries are currently not - * expired because under normal circumstances SID information never changes. - * - * @param authorityServerName The hostname of the server that should be queried. For maximum efficiency this should be the hostname of a domain controller however a member server will work as well and a domain controller may not return names for SIDs corresponding to local accounts for which the domain controller is not an authority. - * @param auth The credentials that should be used to communicate with the named server. As usual, null indicates that default credentials should be used. - * @param sids The SIDs that should be resolved. After this function is called, the names associated with the SIDs may be queried with the toDisplayString, getDomainName, and getAccountName methods. - */ - static public void resolveSids(String authorityServerName, - NtlmPasswordAuthentication auth, - SID[] sids) throws IOException { - ArrayList list = new ArrayList(sids.length); - int si; - -synchronized (sid_cache) { - for (si = 0; si < sids.length; si++) { - SID sid = (SID)sid_cache.get(sids[si]); - if (sid != null) { - sids[si].type = sid.type; - sids[si].domainName = sid.domainName; - sids[si].acctName = sid.acctName; - } else { - list.add(sids[si]); - } - } - - if (list.size() > 0) { - sids = (SID[])list.toArray(new SID[0]); - SID.resolveSids0(authorityServerName, auth, sids); - for (si = 0; si < sids.length; si++) { - sid_cache.put(sids[si], sids[si]); - } - } -} - } - public static SID getServerSid(String server, - NtlmPasswordAuthentication auth) throws IOException { - DcerpcHandle handle = null; - LsaPolicyHandle policyHandle = null; - lsarpc.LsarDomainInfo info = new lsarpc.LsarDomainInfo(); - MsrpcQueryInformationPolicy rpc; - -synchronized (sid_cache) { - try { - handle = DcerpcHandle.getHandle("ncacn_np:" + server + - "[\\PIPE\\lsarpc]", auth); - // NetApp doesn't like the 'generic' access mask values - policyHandle = new LsaPolicyHandle(handle, null, 0x00000001); - rpc = new MsrpcQueryInformationPolicy(policyHandle, - (short)lsarpc.POLICY_INFO_ACCOUNT_DOMAIN, - info); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - - return new SID(info.sid, - SID.SID_TYPE_DOMAIN, - (new UnicodeString(info.name, false)).toString(), - null, - false); - } finally { - if (handle != null) { - if (policyHandle != null) { - policyHandle.close(); - } - handle.close(); - } - } -} - } - public static byte[] toByteArray(rpc.sid_t sid) { - byte[] dst = new byte[1 + 1 + 6 + sid.sub_authority_count * 4]; - int di = 0; - dst[di++] = sid.revision; - dst[di++] = sid.sub_authority_count; - System.arraycopy(sid.identifier_authority, 0, dst, di, 6); - di += 6; - for (int ii = 0; ii < sid.sub_authority_count; ii++) { - jcifs.util.Encdec.enc_uint32le(sid.sub_authority[ii], dst, di); - di += 4; - } - return dst; - } - - int type; - String domainName = null; - String acctName = null; - String origin_server = null; - NtlmPasswordAuthentication origin_auth = null; - - /* - * Construct a SID from it's binary representation. - */ - public SID(byte[] src, int si) { - revision = src[si++]; - sub_authority_count = src[si++]; - identifier_authority = new byte[6]; - System.arraycopy(src, si, identifier_authority, 0, 6); - si += 6; - if (sub_authority_count > 100) - throw new RuntimeException( "Invalid SID sub_authority_count" ); - sub_authority = new int[sub_authority_count]; - for (int i = 0; i < sub_authority_count; i++) { - sub_authority[i] = ServerMessageBlock.readInt4( src, si ); - si += 4; - } - } - /** - * Construct a SID from it's textual representation such as - * S-1-5-21-1496946806-2192648263-3843101252-1029. - */ - public SID(String textual) throws SmbException { - StringTokenizer st = new StringTokenizer(textual, "-"); - if (st.countTokens() < 3 || !st.nextToken().equals("S")) - // need S-N-M - throw new SmbException("Bad textual SID format: " + textual); - - this.revision = Byte.parseByte(st.nextToken()); - String tmp = st.nextToken(); - long id = 0; - if (tmp.startsWith("0x")) - id = Long.parseLong(tmp.substring(2), 16); - else - id = Long.parseLong(tmp); - - this.identifier_authority = new byte[6]; - for (int i = 5; id > 0; i--) { - this.identifier_authority[i] = (byte) (id % 256); - id >>= 8; - } - - this.sub_authority_count = (byte) st.countTokens(); - if (this.sub_authority_count > 0) { - this.sub_authority = new int[this.sub_authority_count]; - for (int i = 0; i < this.sub_authority_count; i++) - this.sub_authority[i] = (int)(Long.parseLong(st.nextToken()) & 0xFFFFFFFFL); - } - } - - /** - * Construct a SID from a domain SID and an RID - * (relative identifier). For example, a domain SID - * S-1-5-21-1496946806-2192648263-3843101252 and RID 1029 would - * yield the SID S-1-5-21-1496946806-2192648263-3843101252-1029. - */ - public SID(SID domsid, int rid) { - this.revision = domsid.revision; - this.identifier_authority = domsid.identifier_authority; - this.sub_authority_count = (byte)(domsid.sub_authority_count + 1); - this.sub_authority = new int[this.sub_authority_count]; - int i; - for (i = 0; i < domsid.sub_authority_count; i++) { - this.sub_authority[i] = domsid.sub_authority[i]; - } - this.sub_authority[i] = rid; - } - public SID(rpc.sid_t sid, - int type, - String domainName, - String acctName, - boolean decrementAuthority) { - this.revision = sid.revision; - this.sub_authority_count = sid.sub_authority_count; - this.identifier_authority = sid.identifier_authority; - this.sub_authority = sid.sub_authority; - this.type = type; - this.domainName = domainName; - this.acctName = acctName; - - if (decrementAuthority) { - this.sub_authority_count--; - this.sub_authority = new int[sub_authority_count]; - for (int i = 0; i < this.sub_authority_count; i++) { - this.sub_authority[i] = sid.sub_authority[i]; - } - } - } - - public SID getDomainSid() { - return new SID(this, - SID_TYPE_DOMAIN, - this.domainName, - null, - getType() != SID_TYPE_DOMAIN); - } - public int getRid() { - if (getType() == SID_TYPE_DOMAIN) - throw new IllegalArgumentException("This SID is a domain sid"); - return sub_authority[sub_authority_count - 1]; - } - - /** - * Returns the type of this SID indicating the state or type of account. - *
- * SID types are described in the following table. - * - *
- *
- * - */ - public int getType() { - if (origin_server != null) - resolveWeak(); - return type; - } - - /** - * Return text represeting the SID type suitable for display to - * users. Text includes 'User', 'Domain group', 'Local group', etc. - */ - public String getTypeText() { - if (origin_server != null) - resolveWeak(); - return SID_TYPE_NAMES[type]; - } - - /** - * Return the domain name of this SID unless it could not be - * resolved in which case the numeric representation is returned. - */ - public String getDomainName() { - if (origin_server != null) - resolveWeak(); - if (type == SID_TYPE_UNKNOWN) { - String full = toString(); - return full.substring(0, full.length() - getAccountName().length() - 1); - } - return domainName; - } - - /** - * Return the sAMAccountName of this SID unless it could not - * be resolved in which case the numeric RID is returned. If this - * SID is a domain SID, this method will return an empty String. - */ - public String getAccountName() { - if (origin_server != null) - resolveWeak(); - if (type == SID_TYPE_UNKNOWN) - return "" + sub_authority[sub_authority_count - 1]; - if (type == SID_TYPE_DOMAIN) - return ""; - return acctName; - } - - public int hashCode() { - int hcode = identifier_authority[5]; - for (int i = 0; i < sub_authority_count; i++) { - hcode += 65599 * sub_authority[i]; - } - return hcode; - } - public boolean equals(Object obj) { - if (obj instanceof SID) { - SID sid = (SID)obj; - if (sid == this) - return true; - if (sid.sub_authority_count == sub_authority_count) { - int i = sub_authority_count; - while (i-- > 0) { - if (sid.sub_authority[i] != sub_authority[i]) { - return false; - } - } - for (i = 0; i < 6; i++) { - if (sid.identifier_authority[i] != identifier_authority[i]) { - return false; - } - } - - return sid.revision == revision; - } - } - return false; - } - - /** - * Return the numeric representation of this sid such as - * S-1-5-21-1496946806-2192648263-3843101252-1029. - */ - public String toString() { - String ret = "S-" + (revision & 0xFF) + "-"; - - if (identifier_authority[0] != (byte)0 || identifier_authority[1] != (byte)0) { - ret += "0x"; - ret += Hexdump.toHexString(identifier_authority, 0, 6); - } else { - long shift = 0; - long id = 0; - for (int i = 5; i > 1; i--) { - id += (identifier_authority[i] & 0xFFL) << shift; - shift += 8; - } - ret += id; - } - - for (int i = 0; i < sub_authority_count ; i++) - ret += "-" + (sub_authority[i] & 0xFFFFFFFFL); - - return ret; - } - - /** - * Return a String representing this SID ideal for display to - * users. This method should return the same text that the ACL - * editor in Windows would display. - *- * Type Name - * SID_TYPE_USE_NONE 0 - * SID_TYPE_USER User - * SID_TYPE_DOM_GRP Domain group - * SID_TYPE_DOMAIN Domain - * SID_TYPE_ALIAS Local group - * SID_TYPE_WKN_GRP Builtin group - * SID_TYPE_DELETED Deleted - * SID_TYPE_INVALID Invalid - * SID_TYPE_UNKNOWN Unknown - * Specifically, if the SID has - * been resolved and it is not a domain SID or builtin account, - * the full DOMAIN\name form of the account will be - * returned (e.g. MYDOM\alice or MYDOM\Domain Users). - * If the SID has been resolved but it is is a domain SID, - * only the domain name will be returned (e.g. MYDOM). - * If the SID has been resolved but it is a builtin account, - * only the name component will be returned (e.g. SYSTEM). - * If the sid cannot be resolved the numeric representation from - * toString() is returned. - */ - public String toDisplayString() { - if (origin_server != null) - resolveWeak(); - if (domainName != null) { - String str; - - if (type == SID_TYPE_DOMAIN) { - str = domainName; - } else if (type == SID_TYPE_WKN_GRP || - domainName.equals("BUILTIN")) { - if (type == SID_TYPE_UNKNOWN) { - str = toString(); - } else { - str = acctName; - } - } else { - str = domainName + "\\" + acctName; - } - - return str; - } - return toString(); - } - - /** - * Manually resolve this SID. Normally SIDs are automatically - * resolved. However, if a SID is constructed explicitly using a SID - * constructor, JCIFS will have no knowledge of the server that created the - * SID and therefore cannot possibly resolve it automatically. In this case, - * this method will be necessary. - * - * @param authorityServerName The FQDN of the server that is an authority for the SID. - * @param auth Credentials suitable for accessing the SID's information. - */ - public void resolve(String authorityServerName, - NtlmPasswordAuthentication auth) throws IOException { - SID[] sids = new SID[1]; - sids[0] = this; - SID.resolveSids(authorityServerName, auth, sids); - } - - void resolveWeak() { - if (origin_server != null) { - try { - resolve(origin_server, origin_auth); - } catch(IOException ioe) { - } finally { - origin_server = null; - origin_auth = null; - } - } - } - - static SID[] getGroupMemberSids0(DcerpcHandle handle, - SamrDomainHandle domainHandle, - SID domsid, - int rid, - int flags) throws IOException { - SamrAliasHandle aliasHandle = null; - lsarpc.LsarSidArray sidarray = new lsarpc.LsarSidArray(); - MsrpcGetMembersInAlias rpc = null; - - try { - aliasHandle = new SamrAliasHandle(handle, domainHandle, 0x0002000c, rid); - rpc = new MsrpcGetMembersInAlias(aliasHandle, sidarray); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - SID[] sids = new SID[rpc.sids.num_sids]; - - String origin_server = handle.getServer(); - NtlmPasswordAuthentication origin_auth = - (NtlmPasswordAuthentication)handle.getPrincipal(); - - for (int i = 0; i < sids.length; i++) { - sids[i] = new SID(rpc.sids.sids[i].sid, - 0, - null, - null, - false); - sids[i].origin_server = origin_server; - sids[i].origin_auth = origin_auth; - } - if (sids.length > 0 && (flags & SID_FLAG_RESOLVE_SIDS) != 0) { - SID.resolveSids(origin_server, origin_auth, sids); - } - return sids; - } finally { - if (aliasHandle != null) { - aliasHandle.close(); - } - } - } - - public SID[] getGroupMemberSids(String authorityServerName, - NtlmPasswordAuthentication auth, - int flags) throws IOException { - if (type != SID_TYPE_DOM_GRP && type != SID_TYPE_ALIAS) - return new SID[0]; - - DcerpcHandle handle = null; - SamrPolicyHandle policyHandle = null; - SamrDomainHandle domainHandle = null; - SID domsid = getDomainSid(); - -synchronized (sid_cache) { - try { - handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + - "[\\PIPE\\samr]", auth); - policyHandle = new SamrPolicyHandle(handle, authorityServerName, 0x00000030); - domainHandle = new SamrDomainHandle(handle, policyHandle, 0x00000200, domsid); - return SID.getGroupMemberSids0(handle, - domainHandle, - domsid, - getRid(), - flags); - } finally { - if (handle != null) { - if (policyHandle != null) { - if (domainHandle != null) { - domainHandle.close(); - } - policyHandle.close(); - } - handle.close(); - } - } -} - } - - /** - * This specialized method returns a Map of users and local groups for the - * target server where keys are SIDs representing an account and each value - * is an ArrayList of SIDs represents the local groups that the account is - * a member of. - *
- * This method is designed to assist with computing access control for a - * given user when the target object's ACL has local groups. Local groups - * are not listed in a user's group membership (e.g. as represented by the - * tokenGroups constructed attribute retrived via LDAP). - * - * Domain groups nested inside a local group are currently not expanded. In - * this case the key (SID) type will be SID_TYPE_DOM_GRP rather than - * SID_TYPE_USER. - * - * @param authorityServerName The server from which the local groups will be queried. - * @param auth The credentials required to query groups and group members. - * @param flags Flags that control the behavior of the operation. When all - * name associated with SIDs will be required, the SID_FLAG_RESOLVE_SIDS - * flag should be used which causes all group member SIDs to be resolved - * together in a single more efficient operation. - */ - static Map getLocalGroupsMap(String authorityServerName, - NtlmPasswordAuthentication auth, - int flags) throws IOException { - SID domsid = SID.getServerSid(authorityServerName, auth); - DcerpcHandle handle = null; - SamrPolicyHandle policyHandle = null; - SamrDomainHandle domainHandle = null; - samr.SamrSamArray sam = new samr.SamrSamArray(); - MsrpcEnumerateAliasesInDomain rpc; - -synchronized (sid_cache) { - try { - handle = DcerpcHandle.getHandle("ncacn_np:" + authorityServerName + - "[\\PIPE\\samr]", auth); - policyHandle = new SamrPolicyHandle(handle, authorityServerName, 0x02000000); - domainHandle = new SamrDomainHandle(handle, policyHandle, 0x02000000, domsid); - rpc = new MsrpcEnumerateAliasesInDomain(domainHandle, 0xFFFF, sam); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, false); - - Map map = new HashMap(); - - for (int ei = 0; ei < rpc.sam.count; ei++) { - samr.SamrSamEntry entry = rpc.sam.entries[ei]; - - SID[] mems = SID.getGroupMemberSids0(handle, - domainHandle, - domsid, - entry.idx, - flags); - SID groupSid = new SID(domsid, entry.idx); - groupSid.type = SID_TYPE_ALIAS; - groupSid.domainName = domsid.getDomainName(); - groupSid.acctName = (new UnicodeString(entry.name, false)).toString(); - - for (int mi = 0; mi < mems.length; mi++) { - ArrayList groups = (ArrayList)map.get(mems[mi]); - if (groups == null) { - groups = new ArrayList(); - map.put(mems[mi], groups); - } - if (!groups.contains(groupSid)) - groups.add(groupSid); - } - } - - return map; - } finally { - if (handle != null) { - if (policyHandle != null) { - if (domainHandle != null) { - domainHandle.close(); - } - policyHandle.close(); - } - handle.close(); - } - } -} - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SecurityDescriptor.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SecurityDescriptor.java deleted file mode 100644 index 90e1261ab2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SecurityDescriptor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; - -public class SecurityDescriptor { - - public int type; - public ACE[] aces; - - public SecurityDescriptor() { - } - public SecurityDescriptor(byte[] buffer, int bufferIndex, int len) throws IOException { - this.decode(buffer, bufferIndex, len); - } - public int decode(byte[] buffer, int bufferIndex, int len) throws IOException { - int start = bufferIndex; - - bufferIndex++; // revision - bufferIndex++; - type = ServerMessageBlock.readInt2(buffer, bufferIndex); - bufferIndex += 2; - ServerMessageBlock.readInt4(buffer, bufferIndex); // offset to owner sid - bufferIndex += 4; - ServerMessageBlock.readInt4(buffer, bufferIndex); // offset to group sid - bufferIndex += 4; - ServerMessageBlock.readInt4(buffer, bufferIndex); // offset to sacl - bufferIndex += 4; - int daclOffset = ServerMessageBlock.readInt4(buffer, bufferIndex); - - bufferIndex = start + daclOffset; - - bufferIndex++; // revision - bufferIndex++; - int size = ServerMessageBlock.readInt2(buffer, bufferIndex); - bufferIndex += 2; - int numAces = ServerMessageBlock.readInt4(buffer, bufferIndex); - bufferIndex += 4; - - if (numAces > 4096) - throw new IOException( "Invalid SecurityDescriptor" ); - - if (daclOffset != 0) { - aces = new ACE[numAces]; - for (int i = 0; i < numAces; i++) { - aces[i] = new ACE(); - bufferIndex += aces[i].decode(buffer, bufferIndex); - } - } else { - aces = null; - } - - return bufferIndex - start; - } - public String toString() { - String ret = "SecurityDescriptor:\n"; - if (aces != null) { - for (int ai = 0; ai < aces.length; ai++) { - ret += aces[ai].toString() + "\n"; - } - } else { - ret += "NULL"; - } - return ret; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ServerMessageBlock.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ServerMessageBlock.java deleted file mode 100644 index a7b6cdafae..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/ServerMessageBlock.java +++ /dev/null @@ -1,533 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; -import jcifs.util.LogStream; -import jcifs.util.transport.Request; -import jcifs.util.transport.Response; - -import java.io.UnsupportedEncodingException; -import java.util.Date; - -abstract class ServerMessageBlock extends Response implements Request, SmbConstants { - - static LogStream log = LogStream.getInstance(); - - static final byte[] header = { - (byte)0xFF, (byte)'S', (byte)'M', (byte)'B', - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, - (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 - }; - - static void writeInt2( long val, byte[] dst, int dstIndex ) { - dst[dstIndex] = (byte)(val); - dst[++dstIndex] = (byte)(val >> 8); - } - static void writeInt4( long val, byte[] dst, int dstIndex ) { - dst[dstIndex] = (byte)(val); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >> 8); - } - static int readInt2( byte[] src, int srcIndex ) { - return ( src[srcIndex] & 0xFF ) + - (( src[srcIndex + 1] & 0xFF ) << 8 ); - } - static int readInt4( byte[] src, int srcIndex ) { - return ( src[srcIndex] & 0xFF ) + - (( src[srcIndex + 1] & 0xFF ) << 8 ) + - (( src[srcIndex + 2] & 0xFF ) << 16 ) + - (( src[srcIndex + 3] & 0xFF ) << 24 ); - } - static long readInt8( byte[] src, int srcIndex ) { - return (readInt4( src, srcIndex ) & 0xFFFFFFFFL) + - ((long)(readInt4( src, srcIndex + 4 )) << 32); - } - static void writeInt8( long val, byte[] dst, int dstIndex ) { - dst[dstIndex] = (byte)(val); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >>= 8); - dst[++dstIndex] = (byte)(val >> 8); - } - static long readTime( byte[] src, int srcIndex ) { - int low = readInt4( src, srcIndex ); - int hi = readInt4( src, srcIndex + 4 ); - long t = ((long)hi << 32L ) | (low & 0xFFFFFFFFL); - t = ( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601 ); - return t; - } - static void writeTime( long t, byte[] dst, int dstIndex ) { - if( t != 0L ) { - t = (t + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L; - } - writeInt8( t, dst, dstIndex ); - } - static long readUTime( byte[] buffer, int bufferIndex ) { - return readInt4( buffer, bufferIndex ) * 1000L; - } - static void writeUTime( long t, byte[] dst, int dstIndex ) { - if( t == 0L || t == 0xFFFFFFFFFFFFFFFFL ) { - writeInt4( 0xFFFFFFFF, dst, dstIndex ); - return; - } - synchronized( TZ ) { - if( TZ.inDaylightTime( new Date() )) { - // in DST - if( TZ.inDaylightTime( new Date( t ))) { - // t also in DST so no correction - } else { - // t not in DST so subtract 1 hour - t -= 3600000; - } - } else { - // not in DST - if( TZ.inDaylightTime( new Date( t ))) { - // t is in DST so add 1 hour - t += 3600000; - } else { - // t isn't in DST either - } - } - } - writeInt4( (int)(t / 1000L), dst, dstIndex ); - } - - /* - * These are all the smbs supported by this library. This includes requests - * and well as their responses for each type however the actuall implementations - * of the readXxxWireFormat and writeXxxWireFormat methods may not be in - * place. For example at the time of this writing the readXxxWireFormat - * for requests and the writeXxxWireFormat for responses are not implemented - * and simply return 0. These would need to be completed for a server - * implementation. - */ - - static final byte SMB_COM_CREATE_DIRECTORY = (byte)0x00; - static final byte SMB_COM_DELETE_DIRECTORY = (byte)0x01; - static final byte SMB_COM_CLOSE = (byte)0x04; - static final byte SMB_COM_DELETE = (byte)0x06; - static final byte SMB_COM_RENAME = (byte)0x07; - static final byte SMB_COM_QUERY_INFORMATION = (byte)0x08; - static final byte SMB_COM_WRITE = (byte)0x0B; - static final byte SMB_COM_CHECK_DIRECTORY = (byte)0x10; - static final byte SMB_COM_TRANSACTION = (byte)0x25; - static final byte SMB_COM_TRANSACTION_SECONDARY = (byte)0x26; - static final byte SMB_COM_MOVE = (byte)0x2A; - static final byte SMB_COM_ECHO = (byte)0x2B; - static final byte SMB_COM_OPEN_ANDX = (byte)0x2D; - static final byte SMB_COM_READ_ANDX = (byte)0x2E; - static final byte SMB_COM_WRITE_ANDX = (byte)0x2F; - static final byte SMB_COM_TRANSACTION2 = (byte)0x32; - static final byte SMB_COM_FIND_CLOSE2 = (byte)0x34; - static final byte SMB_COM_TREE_DISCONNECT = (byte)0x71; - static final byte SMB_COM_NEGOTIATE = (byte)0x72; - static final byte SMB_COM_SESSION_SETUP_ANDX = (byte)0x73; - static final byte SMB_COM_LOGOFF_ANDX = (byte)0x74; - static final byte SMB_COM_TREE_CONNECT_ANDX = (byte)0x75; - static final byte SMB_COM_NT_TRANSACT = (byte)0xA0; - static final byte SMB_COM_NT_TRANSACT_SECONDARY = (byte)0xA1; - static final byte SMB_COM_NT_CREATE_ANDX = (byte)0xA2; - - /* - * Some fields specify the offset from the beginning of the header. This - * field should be used for calculating that. This would likely be zero - * but an implemantation that encorporates the transport header(for - * efficiency) might use a different initial bufferIndex. For example, - * to eliminate copying data when writing NbtSession data one might - * manage that 4 byte header specifically and therefore the initial - * bufferIndex, and thus headerStart, would be 4).(NOTE: If one where - * looking for a way to improve perfomance this is precisly what you - * would want to do as the jcifs.netbios.SocketXxxputStream classes - * arraycopy all data read or written into a new buffer shifted over 4!) - */ - - byte command, flags; - int headerStart, - length, - batchLevel, - errorCode, - flags2, - tid, pid, uid, mid, - wordCount, byteCount; - boolean useUnicode, received, extendedSecurity; - long responseTimeout = 1; - int signSeq; - boolean verifyFailed; - NtlmPasswordAuthentication auth = null; - String path; - SigningDigest digest = null; - ServerMessageBlock response; - - ServerMessageBlock() { - flags = (byte)( FLAGS_PATH_NAMES_CASELESS | FLAGS_PATH_NAMES_CANONICALIZED ); - pid = PID; - batchLevel = 0; - } - - void reset() { - flags = (byte)( FLAGS_PATH_NAMES_CASELESS | FLAGS_PATH_NAMES_CANONICALIZED ); - flags2 = 0; - errorCode = 0; - received = false; - digest = null; - } - int writeString( String str, byte[] dst, int dstIndex ) { - return writeString( str, dst, dstIndex, useUnicode ); - } - int writeString( String str, byte[] dst, int dstIndex, boolean useUnicode ) { - int start = dstIndex; - - try { - if( useUnicode ) { - // Unicode requires word alignment - if((( dstIndex - headerStart ) % 2 ) != 0 ) { - dst[dstIndex++] = (byte)'\0'; - } - System.arraycopy( str.getBytes( UNI_ENCODING ), 0, - dst, dstIndex, str.length() * 2 ); - dstIndex += str.length() * 2; - dst[dstIndex++] = (byte)'\0'; - dst[dstIndex++] = (byte)'\0'; - } else { - byte[] b = str.getBytes( OEM_ENCODING ); - System.arraycopy( b, 0, dst, dstIndex, b.length ); - dstIndex += b.length; - dst[dstIndex++] = (byte)'\0'; - } - } catch( UnsupportedEncodingException uee ) { - if( log.level > 1 ) - uee.printStackTrace( log ); - } - - return dstIndex - start; - } - String readString( byte[] src, int srcIndex ) { - return readString( src, srcIndex, 256, useUnicode ); - } - String readString( byte[] src, int srcIndex, int maxLen, boolean useUnicode ) { - int len = 0; - String str = null; - try { - if( useUnicode ) { - // Unicode requires word alignment - if((( srcIndex - headerStart ) % 2 ) != 0 ) { - srcIndex++; - } - while( src[srcIndex + len] != (byte)0x00 || - src[srcIndex + len + 1] != (byte)0x00 ) { - len += 2; - if( len > maxLen ) { -if( log.level > 0 ) -Hexdump.hexdump( System.err, src, srcIndex, maxLen < 128 ? maxLen + 8 : 128 ); - throw new RuntimeException( "zero termination not found" ); - } - } - str = new String( src, srcIndex, len, UNI_ENCODING ); - } else { - while( src[srcIndex + len] != (byte)0x00 ) { - len++; - if( len > maxLen ) { -if( log.level > 0 ) -Hexdump.hexdump( System.err, src, srcIndex, maxLen < 128 ? maxLen + 8 : 128 ); - throw new RuntimeException( "zero termination not found" ); - } - } - str = new String( src, srcIndex, len, OEM_ENCODING ); - } - } catch( UnsupportedEncodingException uee ) { - if( log.level > 1 ) - uee.printStackTrace( log ); - } - return str; - } - String readString(byte[] src, int srcIndex, int srcEnd, int maxLen, boolean useUnicode) { - int len = 0; - String str = null; - try { - if (useUnicode) { - // Unicode requires word alignment - if (((srcIndex - headerStart) % 2) != 0) { - srcIndex++; - } - for (len = 0; (srcIndex + len + 1) < srcEnd; len += 2) { - if (src[srcIndex + len] == (byte)0x00 && src[srcIndex + len + 1] == (byte)0x00) { - break; - } - if (len > maxLen) { - if (log.level > 0) - Hexdump.hexdump(System.err, src, srcIndex, maxLen < 128 ? maxLen + 8 : 128); - throw new RuntimeException("zero termination not found"); - } - } - str = new String(src, srcIndex, len, UNI_ENCODING); - } else { - for (len = 0; srcIndex < srcEnd; len++) { - if (src[srcIndex + len] == (byte)0x00) { - break; - } - if (len > maxLen) { - if (log.level > 0) - Hexdump.hexdump(System.err, src, srcIndex, maxLen < 128 ? maxLen + 8 : 128); - throw new RuntimeException("zero termination not found"); - } - } - str = new String(src, srcIndex, len, OEM_ENCODING); - } - } catch( UnsupportedEncodingException uee ) { - if( log.level > 1 ) - uee.printStackTrace( log ); - } - return str; - } - int stringWireLength( String str, int offset ) { - int len = str.length() + 1; - if( useUnicode ) { - len = str.length() * 2 + 2; - len = ( offset % 2 ) != 0 ? len + 1 : len; - } - return len; - } - int readStringLength( byte[] src, int srcIndex, int max ) { - int len = 0; - while( src[srcIndex + len] != (byte)0x00 ) { - if( len++ > max ) { - throw new RuntimeException( "zero termination not found: " + this ); - } - } - return len; - } - int encode( byte[] dst, int dstIndex ) { - int start = headerStart = dstIndex; - - dstIndex += writeHeaderWireFormat( dst, dstIndex ); - wordCount = writeParameterWordsWireFormat( dst, dstIndex + 1 ); - dst[dstIndex++] = (byte)(( wordCount / 2 ) & 0xFF ); - dstIndex += wordCount; - wordCount /= 2; - byteCount = writeBytesWireFormat( dst, dstIndex + 2 ); - dst[dstIndex++] = (byte)( byteCount & 0xFF ); - dst[dstIndex++] = (byte)(( byteCount >> 8 ) & 0xFF ); - dstIndex += byteCount; - - length = dstIndex - start; - - if( digest != null ) { - digest.sign( dst, headerStart, length, this, response ); - } - - return length; - } - int decode( byte[] buffer, int bufferIndex ) { - int start = headerStart = bufferIndex; - - bufferIndex += readHeaderWireFormat( buffer, bufferIndex ); - - wordCount = buffer[bufferIndex++]; - if( wordCount != 0 ) { - int n; - if(( n = readParameterWordsWireFormat( buffer, bufferIndex )) != wordCount * 2 ) { - if( log.level >= 5 ) { - log.println( "wordCount * 2=" + ( wordCount * 2 ) + - " but readParameterWordsWireFormat returned " + n ); - } - } - bufferIndex += wordCount * 2; - } - - byteCount = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - if( byteCount != 0 ) { - int n; - if(( n = readBytesWireFormat( buffer, bufferIndex )) != byteCount ) { - if( log.level >= 5 ) { - log.println( "byteCount=" + byteCount + - " but readBytesWireFormat returned " + n ); - } - } - // Don't think we can rely on n being correct here. Must use byteCount. - // Last paragraph of section 3.13.3 eludes to this. - - bufferIndex += byteCount; - } - - length = bufferIndex - start; - return length; - } - int writeHeaderWireFormat( byte[] dst, int dstIndex ) { - System.arraycopy( header, 0, dst, dstIndex, header.length ); - dst[dstIndex + CMD_OFFSET] = command; - dst[dstIndex + FLAGS_OFFSET] = flags; - writeInt2( flags2, dst, dstIndex + FLAGS_OFFSET + 1 ); - dstIndex += TID_OFFSET; - writeInt2( tid, dst, dstIndex ); - writeInt2( pid, dst, dstIndex + 2 ); - writeInt2( uid, dst, dstIndex + 4 ); - writeInt2( mid, dst, dstIndex + 6 ); - return HEADER_LENGTH; - } - int readHeaderWireFormat( byte[] buffer, int bufferIndex ) { - command = buffer[bufferIndex + CMD_OFFSET]; - errorCode = readInt4( buffer, bufferIndex + ERROR_CODE_OFFSET ); - flags = buffer[bufferIndex + FLAGS_OFFSET]; - flags2 = readInt2( buffer, bufferIndex + FLAGS_OFFSET + 1 ); - tid = readInt2( buffer, bufferIndex + TID_OFFSET ); - pid = readInt2( buffer, bufferIndex + TID_OFFSET + 2 ); - uid = readInt2( buffer, bufferIndex + TID_OFFSET + 4 ); - mid = readInt2( buffer, bufferIndex + TID_OFFSET + 6 ); - return HEADER_LENGTH; - } - boolean isResponse() { - return ( flags & FLAGS_RESPONSE ) == FLAGS_RESPONSE; - } - - /* - * For this packet deconstruction technique to work for - * other networking protocols the InputStream may need - * to be passed to the readXxxWireFormat methods. This is - * actually purer. However, in the case of smb we know the - * wordCount and byteCount. And since every subclass of - * ServerMessageBlock would have to perform the same read - * operation on the input stream, we might as will pull that - * common functionality into the superclass and read wordCount - * and byteCount worth of data. - * - * We will still use the readXxxWireFormat return values to - * indicate how many bytes(note: readParameterWordsWireFormat - * returns bytes read and not the number of words(but the - * wordCount member DOES store the number of words)) we - * actually read. Incedentally this is important to the - * AndXServerMessageBlock class that needs to potentially - * read in another smb's parameter words and bytes based on - * information in it's andxCommand, andxOffset, ...etc. - */ - - abstract int writeParameterWordsWireFormat( byte[] dst, int dstIndex ); - abstract int writeBytesWireFormat( byte[] dst, int dstIndex ); - abstract int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ); - abstract int readBytesWireFormat( byte[] buffer, int bufferIndex ); - - public int hashCode() { - return mid; - } - public boolean equals( Object obj ) { - return obj instanceof ServerMessageBlock && ((ServerMessageBlock)obj).mid == mid; - } - public String toString() { - String c; - switch( command ) { - case SMB_COM_NEGOTIATE: - c = "SMB_COM_NEGOTIATE"; - break; - case SMB_COM_SESSION_SETUP_ANDX: - c = "SMB_COM_SESSION_SETUP_ANDX"; - break; - case SMB_COM_TREE_CONNECT_ANDX: - c = "SMB_COM_TREE_CONNECT_ANDX"; - break; - case SMB_COM_QUERY_INFORMATION: - c = "SMB_COM_QUERY_INFORMATION"; - break; - case SMB_COM_CHECK_DIRECTORY: - c = "SMB_COM_CHECK_DIRECTORY"; - break; - case SMB_COM_TRANSACTION: - c = "SMB_COM_TRANSACTION"; - break; - case SMB_COM_TRANSACTION2: - c = "SMB_COM_TRANSACTION2"; - break; - case SMB_COM_TRANSACTION_SECONDARY: - c = "SMB_COM_TRANSACTION_SECONDARY"; - break; - case SMB_COM_FIND_CLOSE2: - c = "SMB_COM_FIND_CLOSE2"; - break; - case SMB_COM_TREE_DISCONNECT: - c = "SMB_COM_TREE_DISCONNECT"; - break; - case SMB_COM_LOGOFF_ANDX: - c = "SMB_COM_LOGOFF_ANDX"; - break; - case SMB_COM_ECHO: - c = "SMB_COM_ECHO"; - break; - case SMB_COM_MOVE: - c = "SMB_COM_MOVE"; - break; - case SMB_COM_RENAME: - c = "SMB_COM_RENAME"; - break; - case SMB_COM_DELETE: - c = "SMB_COM_DELETE"; - break; - case SMB_COM_DELETE_DIRECTORY: - c = "SMB_COM_DELETE_DIRECTORY"; - break; - case SMB_COM_NT_CREATE_ANDX: - c = "SMB_COM_NT_CREATE_ANDX"; - break; - case SMB_COM_OPEN_ANDX: - c = "SMB_COM_OPEN_ANDX"; - break; - case SMB_COM_READ_ANDX: - c = "SMB_COM_READ_ANDX"; - break; - case SMB_COM_CLOSE: - c = "SMB_COM_CLOSE"; - break; - case SMB_COM_WRITE_ANDX: - c = "SMB_COM_WRITE_ANDX"; - break; - case SMB_COM_CREATE_DIRECTORY: - c = "SMB_COM_CREATE_DIRECTORY"; - break; - case SMB_COM_NT_TRANSACT: - c = "SMB_COM_NT_TRANSACT"; - break; - case SMB_COM_NT_TRANSACT_SECONDARY: - c = "SMB_COM_NT_TRANSACT_SECONDARY"; - break; - default: - c = "UNKNOWN"; - } - String str = errorCode == 0 ? "0" : SmbException.getMessageByCode( errorCode ); - return new String( - "command=" + c + - ",received=" + received + - ",errorCode=" + str + - ",flags=0x" + Hexdump.toHexString( flags & 0xFF, 4 ) + - ",flags2=0x" + Hexdump.toHexString( flags2, 4 ) + - ",signSeq=" + signSeq + - ",tid=" + tid + - ",pid=" + pid + - ",uid=" + uid + - ",mid=" + mid + - ",wordCount=" + wordCount + - ",byteCount=" + byteCount ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SigningDigest.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SigningDigest.java deleted file mode 100644 index 7b9d57c5f6..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SigningDigest.java +++ /dev/null @@ -1,195 +0,0 @@ -package jcifs.smb; - -import jcifs.util.Hexdump; -import jcifs.util.LogStream; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -/** - * To filter 0 len updates and for debugging - */ - -public class SigningDigest implements SmbConstants { - - static LogStream log = LogStream.getInstance(); - - private MessageDigest digest; - private byte[] macSigningKey; - private boolean bypass = false; - private int updates; - private int signSequence; - - public SigningDigest(byte[] macSigningKey, boolean bypass) throws SmbException { - try { - digest = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - throw new SmbException( "MD5", ex ); - } - - this.macSigningKey = macSigningKey; - this.bypass = bypass; - this.updates = 0; - this.signSequence = 0; - - if( log.level >= 5 ) { - log.println("macSigningKey:"); - Hexdump.hexdump( log, macSigningKey, 0, macSigningKey.length ); - } - } - - public SigningDigest( SmbTransport transport, - NtlmPasswordAuthentication auth ) throws SmbException { - try { - digest = MessageDigest.getInstance("MD5"); - } catch (NoSuchAlgorithmException ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - throw new SmbException( "MD5", ex ); - } - - try { - switch (LM_COMPATIBILITY) { - case 0: - case 1: - case 2: - macSigningKey = new byte[40]; - auth.getUserSessionKey(transport.server.encryptionKey, macSigningKey, 0); - System.arraycopy(auth.getUnicodeHash(transport.server.encryptionKey), - 0, macSigningKey, 16, 24); - break; - case 3: - case 4: - case 5: - macSigningKey = new byte[16]; - auth.getUserSessionKey(transport.server.encryptionKey, macSigningKey, 0); - break; - default: - macSigningKey = new byte[40]; - auth.getUserSessionKey(transport.server.encryptionKey, macSigningKey, 0); - System.arraycopy(auth.getUnicodeHash(transport.server.encryptionKey), - 0, macSigningKey, 16, 24); - break; - } - } catch( Exception ex ) { - throw new SmbException( "", ex ); - } - if( log.level >= 5 ) { - log.println( "LM_COMPATIBILITY=" + LM_COMPATIBILITY ); - Hexdump.hexdump( log, macSigningKey, 0, macSigningKey.length ); - } - } - - public void update( byte[] input, int offset, int len ) { - if( log.level >= 5 ) { - log.println( "update: " + updates + " " + offset + ":" + len ); - Hexdump.hexdump( log, input, offset, Math.min( len, 256 )); - log.flush(); - } - if( len == 0 ) { - return; /* CRITICAL */ - } - digest.update( input, offset, len ); - updates++; - } - public byte[] digest() { - byte[] b; - - b = digest.digest(); - - if( log.level >= 5 ) { - log.println( "digest: " ); - Hexdump.hexdump( log, b, 0, b.length ); - log.flush(); - } - updates = 0; - - return b; - } - - /** - * Performs MAC signing of the SMB. This is done as follows. - * The signature field of the SMB is overwritted with the sequence number; - * The MD5 digest of the MAC signing key + the entire SMB is taken; - * The first 8 bytes of this are placed in the signature field. - * - * @param data The data. - * @param offset The starting offset at which the SMB header begins. - * @param length The length of the SMB data starting at offset. - */ - void sign(byte[] data, int offset, int length, - ServerMessageBlock request, ServerMessageBlock response) { - request.signSeq = signSequence; - if( response != null ) { - response.signSeq = signSequence + 1; - response.verifyFailed = false; - } - - try { - update(macSigningKey, 0, macSigningKey.length); - int index = offset + ServerMessageBlock.SIGNATURE_OFFSET; - for (int i = 0; i < 8; i++) data[index + i] = 0; - ServerMessageBlock.writeInt4(signSequence, data, index); - update(data, offset, length); - System.arraycopy(digest(), 0, data, index, 8); - if (bypass) { - bypass = false; - System.arraycopy("BSRSPYL ".getBytes(), 0, data, index, 8); - } - } catch (Exception ex) { - if( log.level > 0 ) - ex.printStackTrace( log ); - } finally { - signSequence += 2; - } - } - - /** - * Performs MAC signature verification. This calculates the signature - * of the SMB and compares it to the signature field on the SMB itself. - * - * @param data The data. - * @param offset The starting offset at which the SMB header begins. - * @param length The length of the SMB data starting at offset. - */ - boolean verify(byte[] data, int offset, ServerMessageBlock response) { - update(macSigningKey, 0, macSigningKey.length); - int index = offset; - update(data, index, ServerMessageBlock.SIGNATURE_OFFSET); - index += ServerMessageBlock.SIGNATURE_OFFSET; - byte[] sequence = new byte[8]; - ServerMessageBlock.writeInt4(response.signSeq, sequence, 0); - update(sequence, 0, sequence.length); - index += 8; - if( response.command == ServerMessageBlock.SMB_COM_READ_ANDX ) { - /* SmbComReadAndXResponse reads directly from the stream into separate byte[] b. - */ - SmbComReadAndXResponse raxr = (SmbComReadAndXResponse)response; - int length = response.length - raxr.dataLength; - update(data, index, length - ServerMessageBlock.SIGNATURE_OFFSET - 8); - update(raxr.b, raxr.off, raxr.dataLength); - } else { - update(data, index, response.length - ServerMessageBlock.SIGNATURE_OFFSET - 8); - } - byte[] signature = digest(); - for (int i = 0; i < 8; i++) { - if (signature[i] != data[offset + ServerMessageBlock.SIGNATURE_OFFSET + i]) { - if( log.level >= 2 ) { - log.println( "signature verification failure" ); - Hexdump.hexdump( log, signature, 0, 8 ); - Hexdump.hexdump( log, data, - offset + ServerMessageBlock.SIGNATURE_OFFSET, 8 ); - } - return response.verifyFailed = true; - } - } - - return response.verifyFailed = false; - } - public String toString() { - return "LM_COMPATIBILITY=" + LM_COMPATIBILITY + " MacSigningKey=" + Hexdump.toHexString(macSigningKey, 0, macSigningKey.length); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbAuthException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbAuthException.java deleted file mode 100644 index 2e93162be5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbAuthException.java +++ /dev/null @@ -1,33 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -/** - * The SmbAuthExceptionencapsulates the variety of - * authentication related error codes returned by an SMB server. - *- * See jCIFS Exceptions and NtlmAuthenticator for more information about
SmbAuthException. - */ - -public class SmbAuthException extends SmbException { - - SmbAuthException( int errcode ) { - super( errcode, null ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComBlankResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComBlankResponse.java deleted file mode 100644 index 36b622eb1f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComBlankResponse.java +++ /dev/null @@ -1,42 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComBlankResponse extends ServerMessageBlock { - - SmbComBlankResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComBlankResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCheckDirectory.jav b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCheckDirectory.jav deleted file mode 100644 index 3b4031af21..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCheckDirectory.jav +++ /dev/null @@ -1,52 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComCheckDirectory extends ServerMessageBlock { - - String directoryPath; - - SmbComCheckDirectory( String directoryPath ) { - command = SMB_COM_CHECK_DIRECTORY; - this.directoryPath = directoryPath; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( directoryPath, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComCheckDirectory[" + - super.toString() + - ",directoryPath=" + directoryPath + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComClose.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComClose.java deleted file mode 100644 index 2a2025f84c..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComClose.java +++ /dev/null @@ -1,53 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComClose extends ServerMessageBlock { - - private int fid; - private long lastWriteTime; - - SmbComClose( int fid, long lastWriteTime ) { - this.fid = fid; - this.lastWriteTime = lastWriteTime; - command = SMB_COM_CLOSE; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - writeUTime( lastWriteTime, dst, dstIndex ); - return 6; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComClose[" + - super.toString() + - ",fid=" + fid + - ",lastWriteTime=" + lastWriteTime + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCreateDirectory.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCreateDirectory.java deleted file mode 100644 index f716fede29..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComCreateDirectory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComCreateDirectory extends ServerMessageBlock { - - SmbComCreateDirectory( String directoryName ) { - this.path = directoryName; - command = SMB_COM_CREATE_DIRECTORY; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComCreateDirectory[" + - super.toString() + - ",directoryName=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDelete.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDelete.java deleted file mode 100644 index c79981fead..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDelete.java +++ /dev/null @@ -1,57 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class SmbComDelete extends ServerMessageBlock { - - private int searchAttributes; - - SmbComDelete( String fileName ) { - this.path = fileName; - command = SMB_COM_DELETE; - searchAttributes = ATTR_HIDDEN | ATTR_HIDDEN | ATTR_SYSTEM; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - writeInt2( searchAttributes, dst, dstIndex ); - return 2; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComDelete[" + - super.toString() + - ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 4 ) + - ",fileName=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDeleteDirectory.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDeleteDirectory.java deleted file mode 100644 index 95cd426d6a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComDeleteDirectory.java +++ /dev/null @@ -1,50 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComDeleteDirectory extends ServerMessageBlock { - - SmbComDeleteDirectory( String directoryName ) { - this.path = directoryName; - command = SMB_COM_DELETE_DIRECTORY; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComDeleteDirectory[" + - super.toString() + - ",directoryName=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEcho.jav b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEcho.jav deleted file mode 100644 index abb5528a5b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEcho.jav +++ /dev/null @@ -1,49 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComEcho extends ServerMessageBlock { - - int echoCount; - - SmbComEcho( int echoCount ) { - command = SMB_COM_ECHO; - this.echoCount = echoCount; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - writeInt2( echoCount, dst, dstIndex ); - return 2; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex] = (byte)'M'; - return 1; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComEcho[" + - super.toString() + - ",echoCount=" + echoCount + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEchoResponse.jav b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEchoResponse.jav deleted file mode 100644 index 87530c4291..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComEchoResponse.jav +++ /dev/null @@ -1,45 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComEchoResponse extends ServerMessageBlock { - - int sequenceNumber; - - SmbComEchoResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - sequenceNumber = readInt2( buffer, bufferIndex ); - return 2; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 1; - } - public String toString() { - return new String( "SmbComEchoResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComFindClose2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComFindClose2.java deleted file mode 100644 index c2969621ed..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComFindClose2.java +++ /dev/null @@ -1,48 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComFindClose2 extends ServerMessageBlock { - - private int sid; - - SmbComFindClose2( int sid ) { - this.sid = sid; - command = SMB_COM_FIND_CLOSE2; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - writeInt2( sid, dst, dstIndex ); - return 2; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComFindClose2[" + - super.toString() + - ",sid=" + sid + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComLogoffAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComLogoffAndX.java deleted file mode 100644 index 3b7d63cd50..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComLogoffAndX.java +++ /dev/null @@ -1,44 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComLogoffAndX extends AndXServerMessageBlock { - - SmbComLogoffAndX( ServerMessageBlock andx ) { - super( andx ); - command = SMB_COM_LOGOFF_ANDX; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComLogoffAndX[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndX.java deleted file mode 100644 index 7bb0eb507b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndX.java +++ /dev/null @@ -1,195 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class SmbComNTCreateAndX extends AndXServerMessageBlock { - - // share access specified in SmbFile - - // create disposition - - /* Creates a new file or supersedes the existing one - */ - - static final int FILE_SUPERSEDE = 0x0; - - /* Open the file or fail if it does not exist - * aka OPEN_EXISTING - */ - - static final int FILE_OPEN = 0x1; - - /* Create the file or fail if it does not exist - * aka CREATE_NEW - */ - - static final int FILE_CREATE = 0x2; - - /* Open the file or create it if it does not exist - * aka OPEN_ALWAYS - */ - - static final int FILE_OPEN_IF = 0x3; - - /* Open the file and overwrite it's contents or fail if it does not exist - * aka TRUNCATE_EXISTING - */ - - static final int FILE_OVERWRITE = 0x4; - - /* Open the file and overwrite it's contents or create it if it does not exist - * aka CREATE_ALWAYS (according to the wire when calling CreateFile) - */ - - static final int FILE_OVERWRITE_IF = 0x5; - - - // create options - static final int FILE_WRITE_THROUGH = 0x00000002; - static final int FILE_SEQUENTIAL_ONLY = 0x00000004; - static final int FILE_SYNCHRONOUS_IO_ALERT = 0x00000010; - static final int FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020; - - // security flags - static final int SECURITY_CONTEXT_TRACKING = 0x01; - static final int SECURITY_EFFECTIVE_ONLY = 0x02; - - private int rootDirectoryFid, - extFileAttributes, - shareAccess, - createDisposition, - createOptions, - impersonationLevel; - private long allocationSize; - private byte securityFlags; - private int namelen_index; - -int flags0, desiredAccess; - - SmbComNTCreateAndX( String name, int flags, - int access, - int shareAccess, - int extFileAttributes, - int createOptions, - ServerMessageBlock andx ) { - super( andx ); - this.path = name; - command = SMB_COM_NT_CREATE_ANDX; - - desiredAccess = access; - desiredAccess |= FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES; - - // extFileAttributes - this.extFileAttributes = extFileAttributes; - - // shareAccess - this.shareAccess = shareAccess; - - // createDisposition - if(( flags & SmbFile.O_TRUNC ) == SmbFile.O_TRUNC ) { - // truncate the file - if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { - // create it if necessary - createDisposition = FILE_OVERWRITE_IF; - } else { - createDisposition = FILE_OVERWRITE; - } - } else { - // don't truncate the file - if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { - // create it if necessary - if ((flags & SmbFile.O_EXCL ) == SmbFile.O_EXCL ) { - // fail if already exists - createDisposition = FILE_CREATE; - } else { - createDisposition = FILE_OPEN_IF; - } - } else { - createDisposition = FILE_OPEN; - } - } - - if ((createOptions & 0x0001) == 0) { - this.createOptions = createOptions | 0x0040; - } else { - this.createOptions = createOptions; - } - impersonationLevel = 0x02; // As seen on NT :~) - securityFlags = (byte)0x03; // SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x00; - // name length without counting null termination - namelen_index = dstIndex; - dstIndex += 2; - writeInt4( flags0, dst, dstIndex ); - dstIndex += 4; - writeInt4( rootDirectoryFid, dst, dstIndex ); - dstIndex += 4; - writeInt4( desiredAccess, dst, dstIndex ); - dstIndex += 4; - writeInt8( allocationSize, dst, dstIndex ); - dstIndex += 8; - writeInt4( extFileAttributes, dst, dstIndex ); - dstIndex += 4; - writeInt4( shareAccess, dst, dstIndex ); - dstIndex += 4; - writeInt4( createDisposition, dst, dstIndex ); - dstIndex += 4; - writeInt4( createOptions, dst, dstIndex ); - dstIndex += 4; - writeInt4( impersonationLevel, dst, dstIndex ); - dstIndex += 4; - dst[dstIndex++] = securityFlags; - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int n; - n = writeString( path, dst, dstIndex ); - writeInt2( ( useUnicode ? path.length() * 2 : n ), dst, namelen_index ); - return n; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComNTCreateAndX[" + - super.toString() + - ",flags=0x" + Hexdump.toHexString( flags0, 2 ) + - ",rootDirectoryFid=" + rootDirectoryFid + - ",desiredAccess=0x" + Hexdump.toHexString( desiredAccess, 4 ) + - ",allocationSize=" + allocationSize + - ",extFileAttributes=0x" + Hexdump.toHexString( extFileAttributes, 4 ) + - ",shareAccess=0x" + Hexdump.toHexString( shareAccess, 4 ) + - ",createDisposition=0x" + Hexdump.toHexString( createDisposition, 4 ) + - ",createOptions=0x" + Hexdump.toHexString( createOptions, 8 ) + - ",impersonationLevel=0x" + Hexdump.toHexString( impersonationLevel, 4 ) + - ",securityFlags=0x" + Hexdump.toHexString( securityFlags, 2 ) + - ",name=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndXResponse.java deleted file mode 100644 index 4b8a0fb473..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNTCreateAndXResponse.java +++ /dev/null @@ -1,105 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -import java.util.Date; - -class SmbComNTCreateAndXResponse extends AndXServerMessageBlock { - - static final int EXCLUSIVE_OPLOCK_GRANTED = 1; - static final int BATCH_OPLOCK_GRANTED = 2; - static final int LEVEL_II_OPLOCK_GRANTED = 3; - - byte oplockLevel; - int fid, - createAction, - extFileAttributes, - fileType, - deviceState; - long creationTime, - lastAccessTime, - lastWriteTime, - changeTime, - allocationSize, - endOfFile; - boolean directory; -boolean isExtended; - - SmbComNTCreateAndXResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - oplockLevel = buffer[bufferIndex++]; - fid = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - createAction = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - creationTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - lastAccessTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - lastWriteTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - changeTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - extFileAttributes = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - allocationSize = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - endOfFile = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - fileType = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - deviceState = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - directory = ( buffer[bufferIndex++] & 0xFF ) > 0; - - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComNTCreateAndXResponse[" + - super.toString() + - ",oplockLevel=" + oplockLevel + - ",fid=" + fid + - ",createAction=0x" + Hexdump.toHexString( createAction, 4 ) + - ",creationTime=" + new Date( creationTime ) + - ",lastAccessTime=" + new Date( lastAccessTime ) + - ",lastWriteTime=" + new Date( lastWriteTime ) + - ",changeTime=" + new Date( changeTime ) + - ",extFileAttributes=0x" + Hexdump.toHexString( extFileAttributes, 4 ) + - ",allocationSize=" + allocationSize + - ",endOfFile=" + endOfFile + - ",fileType=" + fileType + - ",deviceState=" + deviceState + - ",directory=" + directory + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiate.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiate.java deleted file mode 100644 index 9f6af4df76..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiate.java +++ /dev/null @@ -1,58 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.UnsupportedEncodingException; - -class SmbComNegotiate extends ServerMessageBlock { - - private static final String DIALECTS = "\u0002NT LM 0.12\u0000"; - - SmbComNegotiate() { - command = SMB_COM_NEGOTIATE; - flags2 = DEFAULT_FLAGS2; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - byte[] dialects; - try { - dialects = DIALECTS.getBytes( "ASCII" ); - } catch( UnsupportedEncodingException uee ) { - return 0; - } - System.arraycopy( dialects, 0, dst, dstIndex, dialects.length ); - return dialects.length; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComNegotiate[" + - super.toString() + - ",wordCount=" + wordCount + - ",dialects=NT LM 0.12]" ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiateResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiateResponse.java deleted file mode 100644 index cd974a0d72..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNegotiateResponse.java +++ /dev/null @@ -1,137 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -import java.io.UnsupportedEncodingException; -import java.util.Date; - -class SmbComNegotiateResponse extends ServerMessageBlock { - - int dialectIndex; - SmbTransport.ServerData server; - - SmbComNegotiateResponse( SmbTransport.ServerData server ) { - this.server = server; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, - int bufferIndex ) { - int start = bufferIndex; - - dialectIndex = readInt2( buffer, bufferIndex ); bufferIndex += 2; - if( dialectIndex > 10 ) { - return bufferIndex - start; - } - server.securityMode = buffer[bufferIndex++] & 0xFF; - server.security = server.securityMode & 0x01; - server.encryptedPasswords = ( server.securityMode & 0x02 ) == 0x02; - server.signaturesEnabled = ( server.securityMode & 0x04 ) == 0x04; - server.signaturesRequired = ( server.securityMode & 0x08 ) == 0x08; - server.maxMpxCount = readInt2( buffer, bufferIndex ); bufferIndex += 2; - server.maxNumberVcs = readInt2( buffer, bufferIndex ); bufferIndex += 2; - server.maxBufferSize = readInt4( buffer, bufferIndex ); bufferIndex += 4; - server.maxRawSize = readInt4( buffer, bufferIndex ); bufferIndex += 4; - server.sessionKey = readInt4( buffer, bufferIndex ); bufferIndex += 4; - server.capabilities = readInt4( buffer, bufferIndex ); bufferIndex += 4; - server.serverTime = readTime( buffer, bufferIndex ); bufferIndex += 8; - server.serverTimeZone = readInt2( buffer, bufferIndex ); bufferIndex += 2; - server.encryptionKeyLength = buffer[bufferIndex++] & 0xFF; - - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, - int bufferIndex ) { - int start = bufferIndex; - - if ((server.capabilities & CAP_EXTENDED_SECURITY) == 0) { - server.encryptionKey = new byte[server.encryptionKeyLength]; - System.arraycopy( buffer, bufferIndex, - server.encryptionKey, 0, server.encryptionKeyLength ); - bufferIndex += server.encryptionKeyLength; - if( byteCount > server.encryptionKeyLength ) { - int len = 0; -// TODO: we can use new string routine here - try { - if(( flags2 & FLAGS2_UNICODE ) == FLAGS2_UNICODE ) { - while( buffer[bufferIndex + len] != (byte)0x00 || - buffer[bufferIndex + len + 1] != (byte)0x00 ) { - len += 2; - if( len > 256 ) { - throw new RuntimeException( "zero termination not found" ); - } - } - server.oemDomainName = new String( buffer, bufferIndex, - len, UNI_ENCODING ); - } else { - while( buffer[bufferIndex + len] != (byte)0x00 ) { - len++; - if( len > 256 ) { - throw new RuntimeException( "zero termination not found" ); - } - } - server.oemDomainName = new String( buffer, bufferIndex, - len, ServerMessageBlock.OEM_ENCODING ); - } - } catch( UnsupportedEncodingException uee ) { - if( log.level > 1 ) - uee.printStackTrace( log ); - } - bufferIndex += len; - } else { - server.oemDomainName = new String(); - } - } else { - server.guid = new byte[16]; - System.arraycopy(buffer, bufferIndex, server.guid, 0, 16); - server.oemDomainName = new String(); - // ignore SPNEGO token for now ... - } - - return bufferIndex - start; - } - public String toString() { - return new String( "SmbComNegotiateResponse[" + - super.toString() + - ",wordCount=" + wordCount + - ",dialectIndex=" + dialectIndex + - ",securityMode=0x" + Hexdump.toHexString( server.securityMode, 1 ) + - ",security=" + ( server.security == SECURITY_SHARE ? "share" : "user" ) + - ",encryptedPasswords=" + server.encryptedPasswords + - ",maxMpxCount=" + server.maxMpxCount + - ",maxNumberVcs=" + server.maxNumberVcs + - ",maxBufferSize=" + server.maxBufferSize + - ",maxRawSize=" + server.maxRawSize + - ",sessionKey=0x" + Hexdump.toHexString( server.sessionKey, 8 ) + - ",capabilities=0x" + Hexdump.toHexString( server.capabilities, 8 ) + - ",serverTime=" + new Date( server.serverTime ) + - ",serverTimeZone=" + server.serverTimeZone + - ",encryptionKeyLength=" + server.encryptionKeyLength + - ",byteCount=" + byteCount + - ",oemDomainName=" + server.oemDomainName + "]" ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransaction.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransaction.java deleted file mode 100644 index 69d2814b34..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransaction.java +++ /dev/null @@ -1,82 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -abstract class SmbComNtTransaction extends SmbComTransaction { - - // relative to headerStart - private static final int NTT_PRIMARY_SETUP_OFFSET = 69; - private static final int NTT_SECONDARY_PARAMETER_OFFSET = 51; - - static final int NT_TRANSACT_QUERY_SECURITY_DESC = 6; - - int function; - - SmbComNtTransaction() { - super(); - primarySetupOffset = NTT_PRIMARY_SETUP_OFFSET; - secondaryParameterOffset = NTT_SECONDARY_PARAMETER_OFFSET; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - if (command != SMB_COM_NT_TRANSACT_SECONDARY) { - dst[dstIndex++] = maxSetupCount; - } else { - dst[dstIndex++] = (byte)0x00; // Reserved - } - dst[dstIndex++] = (byte)0x00; // Reserved - dst[dstIndex++] = (byte)0x00; // Reserved - writeInt4( totalParameterCount, dst, dstIndex ); - dstIndex += 4; - writeInt4( totalDataCount, dst, dstIndex ); - dstIndex += 4; - if (command != SMB_COM_NT_TRANSACT_SECONDARY) { - writeInt4( maxParameterCount, dst, dstIndex ); - dstIndex += 4; - writeInt4( maxDataCount, dst, dstIndex ); - dstIndex += 4; - } - writeInt4( parameterCount, dst, dstIndex ); - dstIndex += 4; - writeInt4(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex ); - dstIndex += 4; - if (command == SMB_COM_NT_TRANSACT_SECONDARY) { - writeInt4( parameterDisplacement, dst, dstIndex ); - dstIndex += 4; - } - writeInt4( dataCount, dst, dstIndex ); - dstIndex += 4; - writeInt4(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex ); - dstIndex += 4; - if (command == SMB_COM_NT_TRANSACT_SECONDARY) { - writeInt4( dataDisplacement, dst, dstIndex ); - dstIndex += 4; - dst[dstIndex++] = (byte)0x00; // Reserved1 - } else { - dst[dstIndex++] = (byte)setupCount; - writeInt2( function, dst, dstIndex ); - dstIndex += 2; - dstIndex += writeSetupWireFormat( dst, dstIndex ); - } - - return dstIndex - start; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransactionResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransactionResponse.java deleted file mode 100644 index 15bfa9645b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComNtTransactionResponse.java +++ /dev/null @@ -1,62 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -abstract class SmbComNtTransactionResponse extends SmbComTransactionResponse { - - SmbComNtTransactionResponse() { - super(); - } - - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - buffer[bufferIndex++] = (byte)0x00; // Reserved - buffer[bufferIndex++] = (byte)0x00; // Reserved - buffer[bufferIndex++] = (byte)0x00; // Reserved - - totalParameterCount = readInt4( buffer, bufferIndex ); - if( bufDataStart == 0 ) { - bufDataStart = totalParameterCount; - } - bufferIndex += 4; - totalDataCount = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - parameterCount = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - parameterOffset = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - parameterDisplacement = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - dataCount = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - dataOffset = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - dataDisplacement = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - setupCount = buffer[bufferIndex] & 0xFF; - bufferIndex += 2; - if( setupCount != 0 ) { - if( log.level >= 3 ) - log.println( "setupCount is not zero: " + setupCount ); - } - - return bufferIndex - start; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndX.java deleted file mode 100644 index 9a8e5bf01a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndX.java +++ /dev/null @@ -1,158 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.util.Hexdump; - -import java.util.Date; - -class SmbComOpenAndX extends AndXServerMessageBlock { - - // flags (not the same as flags constructor argument) - private static final int FLAGS_RETURN_ADDITIONAL_INFO = 0x01; - private static final int FLAGS_REQUEST_OPLOCK = 0x02; - private static final int FLAGS_REQUEST_BATCH_OPLOCK = 0x04; - - // Access Mode Encoding for desiredAccess - private static final int SHARING_COMPATIBILITY = 0x00; - private static final int SHARING_DENY_READ_WRITE_EXECUTE = 0x10; - private static final int SHARING_DENY_WRITE = 0x20; - private static final int SHARING_DENY_READ_EXECUTE = 0x30; - private static final int SHARING_DENY_NONE = 0x40; - - private static final int DO_NOT_CACHE = 0x1000; // bit 12 - private static final int WRITE_THROUGH = 0x4000; // bit 14 - - private static final int OPEN_FN_CREATE = 0x10; - private static final int OPEN_FN_FAIL_IF_EXISTS = 0x00; - private static final int OPEN_FN_OPEN = 0x01; - private static final int OPEN_FN_TRUNC = 0x02; - - private static final int BATCH_LIMIT = Config.getInt( "jcifs.smb.client.OpenAndX.ReadAndX", 1 ); - - int flags, - desiredAccess, - searchAttributes, - fileAttributes, - creationTime, - openFunction, - allocationSize; - - // flags is NOT the same as flags member - - SmbComOpenAndX( String fileName, int access, int flags, ServerMessageBlock andx ) { - super( andx ); - this.path = fileName; - command = SMB_COM_OPEN_ANDX; - - desiredAccess = access & 0x3; - if( desiredAccess == 0x3 ) { - desiredAccess = 0x2; /* Mmm, I thought 0x03 was RDWR */ - } - desiredAccess |= SHARING_DENY_NONE; - desiredAccess &= ~0x1; // Win98 doesn't like GENERIC_READ ?! -- get Access Denied. - - // searchAttributes - searchAttributes = ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM; - - // fileAttributes - fileAttributes = 0; - - // openFunction - if(( flags & SmbFile.O_TRUNC ) == SmbFile.O_TRUNC ) { - // truncate the file - if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { - // create it if necessary - openFunction = OPEN_FN_TRUNC | OPEN_FN_CREATE; - } else { - openFunction = OPEN_FN_TRUNC; - } - } else { - // don't truncate the file - if(( flags & SmbFile.O_CREAT ) == SmbFile.O_CREAT ) { - // create it if necessary - if(( flags & SmbFile.O_EXCL ) == SmbFile.O_EXCL ) { - // fail if already exists - openFunction = OPEN_FN_CREATE | OPEN_FN_FAIL_IF_EXISTS; - } else { - openFunction = OPEN_FN_CREATE | OPEN_FN_OPEN; - } - } else { - openFunction = OPEN_FN_OPEN; - } - } - } - - int getBatchLimit( byte command ) { - return command == SMB_COM_READ_ANDX ? BATCH_LIMIT : 0; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( flags, dst, dstIndex ); - dstIndex += 2; - writeInt2( desiredAccess, dst, dstIndex ); - dstIndex += 2; - writeInt2( searchAttributes, dst, dstIndex ); - dstIndex += 2; - writeInt2( fileAttributes, dst, dstIndex ); - dstIndex += 2; - creationTime = 0; - writeInt4( creationTime, dst, dstIndex ); - dstIndex += 4; - writeInt2( openFunction, dst, dstIndex ); - dstIndex += 2; - writeInt4( allocationSize, dst, dstIndex ); - dstIndex += 4; - for( int i = 0; i < 8; i++ ) { - dst[dstIndex++] = 0x00; - } - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - if( useUnicode ) { - dst[dstIndex++] = (byte)'\0'; - } - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComOpenAndX[" + - super.toString() + - ",flags=0x" + Hexdump.toHexString( flags, 2 ) + - ",desiredAccess=0x" + Hexdump.toHexString( desiredAccess, 4 ) + - ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 4 ) + - ",fileAttributes=0x" + Hexdump.toHexString( fileAttributes, 4 ) + - ",creationTime=" + new Date( creationTime ) + - ",openFunction=0x" + Hexdump.toHexString( openFunction, 2 ) + - ",allocationSize=" + allocationSize + - ",fileName=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndXResponse.java deleted file mode 100644 index b8d04fb717..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComOpenAndXResponse.java +++ /dev/null @@ -1,82 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComOpenAndXResponse extends AndXServerMessageBlock { - - int fid, - fileAttributes, - dataSize, - grantedAccess, - fileType, - deviceState, - action, - serverFid; - long lastWriteTime; - - SmbComOpenAndXResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - fid = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - fileAttributes = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - lastWriteTime = readUTime( buffer, bufferIndex ); - bufferIndex += 4; - dataSize = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - grantedAccess = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - fileType = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - deviceState = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - action = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - serverFid = readInt4( buffer, bufferIndex ); - bufferIndex += 6; - - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComOpenAndXResponse[" + - super.toString() + - ",fid=" + fid + - ",fileAttributes=" + fileAttributes + - ",lastWriteTime=" + lastWriteTime + - ",dataSize=" + dataSize + - ",grantedAccess=" + grantedAccess + - ",fileType=" + fileType + - ",deviceState=" + deviceState + - ",action=" + action + - ",serverFid=" + serverFid + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformation.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformation.java deleted file mode 100644 index ca4ea7ea75..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformation.java +++ /dev/null @@ -1,49 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComQueryInformation extends ServerMessageBlock { - - SmbComQueryInformation( String filename ) { - path = filename; - command = SMB_COM_QUERY_INFORMATION; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( path, dst, dstIndex ); - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComQueryInformation[" + - super.toString() + - ",filename=" + path + "]" ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformationResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformationResponse.java deleted file mode 100644 index ef82a22781..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComQueryInformationResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -import java.util.Date; - -class SmbComQueryInformationResponse extends ServerMessageBlock implements Info { - - private int fileAttributes = 0x0000; - private long lastWriteTime = 0L; - private long serverTimeZoneOffset; - private int fileSize = 0; - - SmbComQueryInformationResponse( long serverTimeZoneOffset ) { - this.serverTimeZoneOffset = serverTimeZoneOffset; - command = SMB_COM_QUERY_INFORMATION; - } - - public int getAttributes() { - return fileAttributes; - } - public long getCreateTime() { - return lastWriteTime + serverTimeZoneOffset; - } - public long getLastWriteTime() { - return lastWriteTime + serverTimeZoneOffset; - } - public long getSize() { - return fileSize; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - if( wordCount == 0 ) { - return 0; - } - fileAttributes = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - lastWriteTime = readUTime( buffer, bufferIndex ); - bufferIndex += 4; - fileSize = readInt4( buffer, bufferIndex ); - return 20; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComQueryInformationResponse[" + - super.toString() + - ",fileAttributes=0x" + Hexdump.toHexString( fileAttributes, 4 ) + - ",lastWriteTime=" + new Date( lastWriteTime ) + - ",fileSize=" + fileSize + "]" ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndX.java deleted file mode 100644 index 6e3506b466..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndX.java +++ /dev/null @@ -1,95 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; - -class SmbComReadAndX extends AndXServerMessageBlock { - - private static final int BATCH_LIMIT = Config.getInt( "jcifs.smb.client.ReadAndX.Close", 1 ); - - private long offset; - private int fid, - openTimeout; -int maxCount, minCount, remaining; - - SmbComReadAndX() { - super( null ); - command = SMB_COM_READ_ANDX; - openTimeout = 0xFFFFFFFF; - } - SmbComReadAndX( int fid, long offset, int maxCount, ServerMessageBlock andx ) { - super( andx ); - this.fid = fid; - this.offset = offset; - this.maxCount = minCount = maxCount; - command = SMB_COM_READ_ANDX; - openTimeout = 0xFFFFFFFF; - } - - void setParam( int fid, long offset, int maxCount ) { - this.fid = fid; - this.offset = offset; - this.maxCount = minCount = maxCount; - } - int getBatchLimit( byte command ) { - return command == SMB_COM_CLOSE ? BATCH_LIMIT : 0; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - writeInt4( offset, dst, dstIndex ); - dstIndex += 4; - writeInt2( maxCount, dst, dstIndex ); - dstIndex += 2; - writeInt2( minCount, dst, dstIndex ); - dstIndex += 2; - writeInt4( openTimeout, dst, dstIndex ); - dstIndex += 4; - writeInt2( remaining, dst, dstIndex ); - dstIndex += 2; - writeInt4( offset >> 32, dst, dstIndex ); - dstIndex += 4; - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComReadAndX[" + - super.toString() + - ",fid=" + fid + - ",offset=" + offset + - ",maxCount=" + maxCount + - ",minCount=" + minCount + - ",openTimeout=" + openTimeout + - ",remaining=" + remaining + - ",offset=" + offset + - "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndXResponse.java deleted file mode 100644 index e027319caa..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComReadAndXResponse.java +++ /dev/null @@ -1,67 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComReadAndXResponse extends AndXServerMessageBlock { - - byte[] b; - int off, dataCompactionMode, dataLength, dataOffset; - - SmbComReadAndXResponse() { - } - SmbComReadAndXResponse( byte[] b, int off ) { - this.b = b; - this.off = off; - } - - void setParam( byte[] b, int off ) { - this.b = b; - this.off = off; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - bufferIndex += 2; // reserved - dataCompactionMode = readInt2( buffer, bufferIndex ); - bufferIndex += 4; // 2 reserved - dataLength = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - dataOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 12; // 10 reserved - - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - // handled special in SmbTransport.doRecv() - return 0; - } - public String toString() { - return new String( "SmbComReadAndXResponse[" + - super.toString() + - ",dataCompactionMode=" + dataCompactionMode + - ",dataLength=" + dataLength + - ",dataOffset=" + dataOffset + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComRename.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComRename.java deleted file mode 100644 index 5fa8914f05..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComRename.java +++ /dev/null @@ -1,66 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class SmbComRename extends ServerMessageBlock { - - private int searchAttributes; - private String oldFileName; - private String newFileName; - - SmbComRename( String oldFileName, String newFileName ) { - command = SMB_COM_RENAME; - this.oldFileName = oldFileName; - this.newFileName = newFileName; - searchAttributes = ATTR_HIDDEN | ATTR_SYSTEM | ATTR_DIRECTORY; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - writeInt2( searchAttributes, dst, dstIndex ); - return 2; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x04; - dstIndex += writeString( oldFileName, dst, dstIndex ); - dst[dstIndex++] = (byte)0x04; - if( useUnicode ) { - dst[dstIndex++] = (byte)'\0'; - } - dstIndex += writeString( newFileName, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComRename[" + - super.toString() + - ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 4 ) + - ",oldFileName=" + oldFileName + - ",newFileName=" + newFileName + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndX.java deleted file mode 100644 index c2445da37b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndX.java +++ /dev/null @@ -1,176 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; - -class SmbComSessionSetupAndX extends AndXServerMessageBlock { - - private static final int BATCH_LIMIT = - Config.getInt( "jcifs.smb.client.SessionSetupAndX.TreeConnectAndX", 1 ); - private static final boolean DISABLE_PLAIN_TEXT_PASSWORDS = - Config.getBoolean( "jcifs.smb.client.disablePlainTextPasswords", true ); - - private byte[] lmHash, ntHash, blob = null; - private int sessionKey, capabilities; - private String accountName, primaryDomain; - - SmbSession session; - Object cred; - - SmbComSessionSetupAndX( SmbSession session, ServerMessageBlock andx, Object cred ) throws SmbException { - super( andx ); - command = SMB_COM_SESSION_SETUP_ANDX; - this.session = session; - this.cred = cred; - - sessionKey = session.transport.sessionKey; - capabilities = session.transport.capabilities; - - if (session.transport.server.security == SECURITY_USER) { - if (cred instanceof NtlmPasswordAuthentication) { - NtlmPasswordAuthentication auth = (NtlmPasswordAuthentication)cred; - - if (auth == NtlmPasswordAuthentication.ANONYMOUS) { - lmHash = new byte[0]; - ntHash = new byte[0]; - capabilities &= ~SmbConstants.CAP_EXTENDED_SECURITY; - } else if (session.transport.server.encryptedPasswords) { - lmHash = auth.getAnsiHash( session.transport.server.encryptionKey ); - ntHash = auth.getUnicodeHash( session.transport.server.encryptionKey ); - // prohibit HTTP auth attempts for the null session - if (lmHash.length == 0 && ntHash.length == 0) { - throw new RuntimeException("Null setup prohibited."); - } - } else if( DISABLE_PLAIN_TEXT_PASSWORDS ) { - throw new RuntimeException( "Plain text passwords are disabled" ); - } else if( useUnicode ) { - // plain text - String password = auth.getPassword(); - lmHash = new byte[0]; - ntHash = new byte[(password.length() + 1) * 2]; - writeString( password, ntHash, 0 ); - } else { - // plain text - String password = auth.getPassword(); - lmHash = new byte[(password.length() + 1) * 2]; - ntHash = new byte[0]; - writeString( password, lmHash, 0 ); - } - accountName = auth.username; - if (useUnicode) - accountName = accountName.toUpperCase(); - primaryDomain = auth.domain.toUpperCase(); - } else if (cred instanceof byte[]) { - blob = (byte[])cred; - } else { - throw new SmbException("Unsupported credential type"); - } - } else if (session.transport.server.security == SECURITY_SHARE) { - if (cred instanceof NtlmPasswordAuthentication) { - NtlmPasswordAuthentication auth = (NtlmPasswordAuthentication)cred; - lmHash = new byte[0]; - ntHash = new byte[0]; - accountName = auth.username; - if (useUnicode) - accountName = accountName.toUpperCase(); - primaryDomain = auth.domain.toUpperCase(); - } else { - throw new SmbException("Unsupported credential type"); - } - } else { - throw new SmbException("Unsupported"); - } - } - - int getBatchLimit( byte command ) { - return command == SMB_COM_TREE_CONNECT_ANDX ? BATCH_LIMIT : 0; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( session.transport.snd_buf_size, dst, dstIndex ); - dstIndex += 2; - writeInt2( session.transport.maxMpxCount, dst, dstIndex ); - dstIndex += 2; - writeInt2( session.transport.VC_NUMBER, dst, dstIndex ); - dstIndex += 2; - writeInt4( sessionKey, dst, dstIndex ); - dstIndex += 4; - if (blob != null) { - writeInt2( blob.length, dst, dstIndex ); - dstIndex += 2; - } else { - writeInt2( lmHash.length, dst, dstIndex ); - dstIndex += 2; - writeInt2( ntHash.length, dst, dstIndex ); - dstIndex += 2; - } - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - writeInt4( capabilities, dst, dstIndex ); - dstIndex += 4; - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - if (blob != null) { - System.arraycopy(blob, 0, dst, dstIndex, blob.length ); - dstIndex += blob.length; - } else { - System.arraycopy( lmHash, 0, dst, dstIndex, lmHash.length ); - dstIndex += lmHash.length; - System.arraycopy( ntHash, 0, dst, dstIndex, ntHash.length ); - dstIndex += ntHash.length; - - dstIndex += writeString( accountName, dst, dstIndex ); - dstIndex += writeString( primaryDomain, dst, dstIndex ); - } - dstIndex += writeString( session.transport.NATIVE_OS, dst, dstIndex ); - dstIndex += writeString( session.transport.NATIVE_LANMAN, dst, dstIndex ); - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - String result = new String( "SmbComSessionSetupAndX[" + - super.toString() + - ",snd_buf_size=" + session.transport.snd_buf_size + - ",maxMpxCount=" + session.transport.maxMpxCount + - ",VC_NUMBER=" + session.transport.VC_NUMBER + - ",sessionKey=" + sessionKey + - ",lmHash.length=" + (lmHash == null ? 0 : lmHash.length) + - ",ntHash.length=" + (ntHash == null ? 0 : ntHash.length) + - ",capabilities=" + capabilities + - ",accountName=" + accountName + - ",primaryDomain=" + primaryDomain + - ",NATIVE_OS=" + session.transport.NATIVE_OS + - ",NATIVE_LANMAN=" + session.transport.NATIVE_LANMAN + "]" ); - return result; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndXResponse.java deleted file mode 100644 index a8be11a844..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComSessionSetupAndXResponse.java +++ /dev/null @@ -1,79 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComSessionSetupAndXResponse extends AndXServerMessageBlock { - - private String nativeOs = ""; - private String nativeLanMan = ""; - private String primaryDomain = ""; - - boolean isLoggedInAsGuest; - byte[] blob = null; - - SmbComSessionSetupAndXResponse( ServerMessageBlock andx ) { - super( andx ); - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - isLoggedInAsGuest = ( buffer[bufferIndex] & 0x01 ) == 0x01 ? true : false; - bufferIndex += 2; - if (extendedSecurity) { - int blobLength = readInt2(buffer, bufferIndex); - bufferIndex += 2; - blob = new byte[blobLength]; - } - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - if (extendedSecurity) { - System.arraycopy(buffer, bufferIndex, blob, 0, blob.length); - bufferIndex += blob.length; - } - nativeOs = readString( buffer, bufferIndex ); - bufferIndex += stringWireLength( nativeOs, bufferIndex ); - nativeLanMan = readString( buffer, bufferIndex, start + byteCount, 255, useUnicode ); - bufferIndex += stringWireLength( nativeLanMan, bufferIndex ); - if (!extendedSecurity) { - primaryDomain = readString(buffer, bufferIndex, start + byteCount, 255, useUnicode); - bufferIndex += stringWireLength(primaryDomain, bufferIndex); - } - - return bufferIndex - start; - } - public String toString() { - String result = new String( "SmbComSessionSetupAndXResponse[" + - super.toString() + - ",isLoggedInAsGuest=" + isLoggedInAsGuest + - ",nativeOs=" + nativeOs + - ",nativeLanMan=" + nativeLanMan + - ",primaryDomain=" + primaryDomain + "]" ); - return result; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransaction.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransaction.java deleted file mode 100644 index 05e6d02062..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransaction.java +++ /dev/null @@ -1,282 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.util.Hexdump; - -import java.util.Enumeration; - -abstract class SmbComTransaction extends ServerMessageBlock implements Enumeration { - - private static final int DEFAULT_MAX_DATA_COUNT = - Config.getInt( "jcifs.smb.client.transaction_buf_size", - SmbComTransaction.TRANSACTION_BUF_SIZE ) - 512; - - // relative to headerStart - private static final int PRIMARY_SETUP_OFFSET = 61; - private static final int SECONDARY_PARAMETER_OFFSET = 51; - - private static final int DISCONNECT_TID = 0x01; - private static final int ONE_WAY_TRANSACTION = 0x02; - - private static final int PADDING_SIZE = 2; - - private int flags = 0x00; - private int fid; - private int pad = 0; - private int pad1 = 0; - private boolean hasMore = true; - private boolean isPrimary = true; - private int bufParameterOffset; - private int bufDataOffset; - - static final int TRANSACTION_BUF_SIZE = 0xFFFF; - - static final byte TRANS2_FIND_FIRST2 = (byte)0x01; - static final byte TRANS2_FIND_NEXT2 = (byte)0x02; - static final byte TRANS2_QUERY_FS_INFORMATION = (byte)0x03; - static final byte TRANS2_QUERY_PATH_INFORMATION = (byte)0x05; - static final byte TRANS2_GET_DFS_REFERRAL = (byte)0x10; - static final byte TRANS2_SET_FILE_INFORMATION = (byte)0x08; - - static final int NET_SHARE_ENUM = 0x0000; - static final int NET_SERVER_ENUM2 = 0x0068; - static final int NET_SERVER_ENUM3 = 0x00D7; - - static final byte TRANS_PEEK_NAMED_PIPE = (byte)0x23; - static final byte TRANS_WAIT_NAMED_PIPE = (byte)0x53; - static final byte TRANS_CALL_NAMED_PIPE = (byte)0x54; - static final byte TRANS_TRANSACT_NAMED_PIPE = (byte)0x26; - - protected int primarySetupOffset; - protected int secondaryParameterOffset; - protected int parameterCount; - protected int parameterOffset; - protected int parameterDisplacement; - protected int dataCount; - protected int dataOffset; - protected int dataDisplacement; - - int totalParameterCount; - int totalDataCount; - int maxParameterCount; - int maxDataCount = DEFAULT_MAX_DATA_COUNT; - byte maxSetupCount; - int timeout = 0; - int setupCount = 1; - byte subCommand; - String name = ""; - int maxBufferSize; // set in SmbTransport.sendTransaction() before nextElement called - - byte[] txn_buf; - - SmbComTransaction() { - maxParameterCount = 1024; - primarySetupOffset = PRIMARY_SETUP_OFFSET; - secondaryParameterOffset = SECONDARY_PARAMETER_OFFSET; - } - - void reset() { - super.reset(); - isPrimary = hasMore = true; - } - void reset( int key, String lastName ) { - reset(); - } - public boolean hasMoreElements() { - return hasMore; - } - public Object nextElement() { - if( isPrimary ) { - isPrimary = false; - - parameterOffset = primarySetupOffset + ( setupCount * 2 ) + 2; - if (command != SMB_COM_NT_TRANSACT) { - if( command == SMB_COM_TRANSACTION && isResponse() == false ) { - parameterOffset += stringWireLength( name, parameterOffset ); - } - } else if (command == SMB_COM_NT_TRANSACT) { - parameterOffset += 2; - } - pad = parameterOffset % PADDING_SIZE; - pad = pad == 0 ? 0 : PADDING_SIZE - pad; - parameterOffset += pad; - - totalParameterCount = writeParametersWireFormat( txn_buf, bufParameterOffset ); - bufDataOffset = totalParameterCount; // data comes right after data - - int available = maxBufferSize - parameterOffset; - parameterCount = Math.min( totalParameterCount, available ); - available -= parameterCount; - - dataOffset = parameterOffset + parameterCount; - pad1 = dataOffset % PADDING_SIZE; - pad1 = pad1 == 0 ? 0 : PADDING_SIZE - pad1; - dataOffset += pad1; - - totalDataCount = writeDataWireFormat( txn_buf, bufDataOffset ); - - dataCount = Math.min( totalDataCount, available ); - } else { - if (command != SMB_COM_NT_TRANSACT) { - command = SMB_COM_TRANSACTION_SECONDARY; - } else { - command = SMB_COM_NT_TRANSACT_SECONDARY; - } - // totalParameterCount and totalDataCount are set ok from primary - - parameterOffset = SECONDARY_PARAMETER_OFFSET; - if(( totalParameterCount - parameterDisplacement ) > 0 ) { - pad = parameterOffset % PADDING_SIZE; - pad = pad == 0 ? 0 : PADDING_SIZE - pad; - parameterOffset += pad; - } - - // caclulate parameterDisplacement before calculating new parameterCount - parameterDisplacement += parameterCount; - - int available = maxBufferSize - parameterOffset - pad; - parameterCount = Math.min( totalParameterCount - parameterDisplacement, available); - available -= parameterCount; - - dataOffset = parameterOffset + parameterCount; - pad1 = dataOffset % PADDING_SIZE; - pad1 = pad1 == 0 ? 0 : PADDING_SIZE - pad1; - dataOffset += pad1; - - dataDisplacement += dataCount; - - available -= pad1; - dataCount = Math.min( totalDataCount - dataDisplacement, available ); - } - if(( parameterDisplacement + parameterCount ) >= totalParameterCount && - ( dataDisplacement + dataCount ) >= totalDataCount ) { - hasMore = false; - } - return this; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( totalParameterCount, dst, dstIndex ); - dstIndex += 2; - writeInt2( totalDataCount, dst, dstIndex ); - dstIndex += 2; - if( command != SMB_COM_TRANSACTION_SECONDARY ) { - writeInt2( maxParameterCount, dst, dstIndex ); - dstIndex += 2; - writeInt2( maxDataCount, dst, dstIndex ); - dstIndex += 2; - dst[dstIndex++] = maxSetupCount; - dst[dstIndex++] = (byte)0x00; // Reserved1 - writeInt2( flags, dst, dstIndex ); - dstIndex += 2; - writeInt4( timeout, dst, dstIndex ); - dstIndex += 4; - dst[dstIndex++] = (byte)0x00; // Reserved2 - dst[dstIndex++] = (byte)0x00; - } - writeInt2( parameterCount, dst, dstIndex ); - dstIndex += 2; -// writeInt2(( parameterCount == 0 ? 0 : parameterOffset ), dst, dstIndex ); - writeInt2(parameterOffset, dst, dstIndex ); - dstIndex += 2; - if( command == SMB_COM_TRANSACTION_SECONDARY ) { - writeInt2( parameterDisplacement, dst, dstIndex ); - dstIndex += 2; - } - writeInt2( dataCount, dst, dstIndex ); - dstIndex += 2; - writeInt2(( dataCount == 0 ? 0 : dataOffset ), dst, dstIndex ); - dstIndex += 2; - if( command == SMB_COM_TRANSACTION_SECONDARY ) { - writeInt2( dataDisplacement, dst, dstIndex ); - dstIndex += 2; - } else { - dst[dstIndex++] = (byte)setupCount; - dst[dstIndex++] = (byte)0x00; // Reserved3 - dstIndex += writeSetupWireFormat( dst, dstIndex ); - } - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - int p = pad; - - if( command == SMB_COM_TRANSACTION && isResponse() == false ) { - dstIndex += writeString( name, dst, dstIndex ); - } - - if( parameterCount > 0 ) { - while( p-- > 0 ) { - dst[dstIndex++] = (byte)0x00; // Pad - } - - System.arraycopy( txn_buf, bufParameterOffset, dst, dstIndex, parameterCount ); - dstIndex += parameterCount; - } - - if( dataCount > 0 ) { - p = pad1; - while( p-- > 0 ) { - dst[dstIndex++] = (byte)0x00; // Pad1 - } - System.arraycopy( txn_buf, bufDataOffset, dst, dstIndex, dataCount ); - bufDataOffset += dataCount; - dstIndex += dataCount; - } - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - - abstract int writeSetupWireFormat( byte[] dst, int dstIndex ); - abstract int writeParametersWireFormat( byte[] dst, int dstIndex ); - abstract int writeDataWireFormat( byte[] dst, int dstIndex ); - abstract int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ); - abstract int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ); - abstract int readDataWireFormat( byte[] buffer, int bufferIndex, int len ); - - public String toString() { - return new String( super.toString() + - ",totalParameterCount=" + totalParameterCount + - ",totalDataCount=" + totalDataCount + - ",maxParameterCount=" + maxParameterCount + - ",maxDataCount=" + maxDataCount + - ",maxSetupCount=" + (int)maxSetupCount + - ",flags=0x" + Hexdump.toHexString( flags, 2 ) + - ",timeout=" + timeout + - ",parameterCount=" + parameterCount + - ",parameterOffset=" + parameterOffset + - ",parameterDisplacement=" + parameterDisplacement + - ",dataCount=" + dataCount + - ",dataOffset=" + dataOffset + - ",dataDisplacement=" + dataDisplacement + - ",setupCount=" + setupCount + - ",pad=" + pad + - ",pad1=" + pad1 ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransactionResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransactionResponse.java deleted file mode 100644 index f4e2fc3324..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTransactionResponse.java +++ /dev/null @@ -1,173 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.util.Enumeration; - -abstract class SmbComTransactionResponse extends ServerMessageBlock implements Enumeration { - - // relative to headerStart - private static final int SETUP_OFFSET = 61; - - private static final int DISCONNECT_TID = 0x01; - private static final int ONE_WAY_TRANSACTION = 0x02; - - private int pad; - private int pad1; - private boolean parametersDone, dataDone; - - protected int totalParameterCount; - protected int totalDataCount; - protected int parameterCount; - protected int parameterOffset; - protected int parameterDisplacement; - protected int dataOffset; - protected int dataDisplacement; - protected int setupCount; - protected int bufParameterStart; - protected int bufDataStart; - - int dataCount; - byte subCommand; - boolean hasMore = true; - boolean isPrimary = true; - byte[] txn_buf; - - /* for doNetEnum and doFindFirstNext */ - int status; - int numEntries; - FileEntry[] results; - - SmbComTransactionResponse() { - txn_buf = null; - } - - void reset() { - super.reset(); - bufDataStart = 0; - isPrimary = hasMore = true; - parametersDone = dataDone = false; - } - public boolean hasMoreElements() { - return errorCode == 0 && hasMore; - } - public Object nextElement() { - if( isPrimary ) { - isPrimary = false; - } - return this; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - totalParameterCount = readInt2( buffer, bufferIndex ); - if( bufDataStart == 0 ) { - bufDataStart = totalParameterCount; - } - bufferIndex += 2; - totalDataCount = readInt2( buffer, bufferIndex ); - bufferIndex += 4; // Reserved - parameterCount = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - parameterOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - parameterDisplacement = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - dataCount = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - dataOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - dataDisplacement = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - setupCount = buffer[bufferIndex] & 0xFF; - bufferIndex += 2; - if( setupCount != 0 ) { - if( log.level > 2 ) - log.println( "setupCount is not zero: " + setupCount ); - } - - return bufferIndex - start; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - pad = pad1 = 0; - int n; - - if( parameterCount > 0 ) { - bufferIndex += pad = parameterOffset - ( bufferIndex - headerStart ); - System.arraycopy( buffer, bufferIndex, txn_buf, - bufParameterStart + parameterDisplacement, parameterCount ); - bufferIndex += parameterCount; - } - if( dataCount > 0 ) { - bufferIndex += pad1 = dataOffset - ( bufferIndex - headerStart ); - System.arraycopy( buffer, bufferIndex, txn_buf, - bufDataStart + dataDisplacement, dataCount ); - bufferIndex += dataCount; - } - - /* Check to see if the entire transaction has been - * read. If so call the read methods. - */ - - if( !parametersDone && - ( parameterDisplacement + parameterCount ) == totalParameterCount) { - parametersDone = true; - } - - if( !dataDone && ( dataDisplacement + dataCount ) == totalDataCount) { - dataDone = true; - } - - if( parametersDone && dataDone ) { - hasMore = false; - readParametersWireFormat( txn_buf, bufParameterStart, totalParameterCount ); - readDataWireFormat( txn_buf, bufDataStart, totalDataCount ); - } - - return pad + parameterCount + pad1 + dataCount; - } - - abstract int writeSetupWireFormat( byte[] dst, int dstIndex ); - abstract int writeParametersWireFormat( byte[] dst, int dstIndex ); - abstract int writeDataWireFormat( byte[] dst, int dstIndex ); - abstract int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ); - abstract int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ); - abstract int readDataWireFormat( byte[] buffer, int bufferIndex, int len ); - - public String toString() { - return new String( super.toString() + - ",totalParameterCount=" + totalParameterCount + - ",totalDataCount=" + totalDataCount + - ",parameterCount=" + parameterCount + - ",parameterOffset=" + parameterOffset + - ",parameterDisplacement=" + parameterDisplacement + - ",dataCount=" + dataCount + - ",dataOffset=" + dataOffset + - ",dataDisplacement=" + dataDisplacement + - ",setupCount=" + setupCount + - ",pad=" + pad + - ",pad1=" + pad1 ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndX.java deleted file mode 100644 index 61716fac82..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndX.java +++ /dev/null @@ -1,186 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.util.Hexdump; - -import java.io.UnsupportedEncodingException; - -class SmbComTreeConnectAndX extends AndXServerMessageBlock { - - private static final boolean DISABLE_PLAIN_TEXT_PASSWORDS = - Config.getBoolean( "jcifs.smb.client.disablePlainTextPasswords", true ); - - private SmbSession session; - private boolean disconnectTid = false; - private String service; - private byte[] password; - private int passwordLength; - String path; - - /* batchLimits indecies - * - * 0 = SMB_COM_CHECK_DIRECTORY - * 2 = SMB_COM_CREATE_DIRECTORY - * 3 = SMB_COM_DELETE - * 4 = SMB_COM_DELETE_DIRECTORY - * 5 = SMB_COM_OPEN_ANDX - * 6 = SMB_COM_RENAME - * 7 = SMB_COM_TRANSACTION - * 8 = SMB_COM_QUERY_INFORMATION - */ - - /* All batch limits are single batch only until further notice - */ - - private static byte[] batchLimits = { - 1, 1, 1, 1, 1, 1, 1, 1, 0 - }; - - static { - String s; - - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.CheckDirectory" )) != null ) { - batchLimits[0] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.CreateDirectory" )) != null ) { - batchLimits[2] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.Delete" )) != null ) { - batchLimits[3] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.DeleteDirectory" )) != null ) { - batchLimits[4] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.OpenAndX" )) != null ) { - batchLimits[5] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.Rename" )) != null ) { - batchLimits[6] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.Transaction" )) != null ) { - batchLimits[7] = Byte.parseByte( s ); - } - if(( s = Config.getProperty( "jcifs.smb.client.TreeConnectAndX.QueryInformation" )) != null ) { - batchLimits[8] = Byte.parseByte( s ); - } - } - - SmbComTreeConnectAndX( SmbSession session, String path, - String service, ServerMessageBlock andx ) { - super( andx ); - this.session = session; - this.path = path; - this.service = service; - command = SMB_COM_TREE_CONNECT_ANDX; - } - - int getBatchLimit( byte command ) { - int c = (int)( command & 0xFF ); - // why isn't this just return batchLimits[c]? - switch( c ) { - case SMB_COM_CHECK_DIRECTORY: - return batchLimits[0]; - case SMB_COM_CREATE_DIRECTORY: - return batchLimits[2]; - case SMB_COM_DELETE: - return batchLimits[3]; - case SMB_COM_DELETE_DIRECTORY: - return batchLimits[4]; - case SMB_COM_OPEN_ANDX: - return batchLimits[5]; - case SMB_COM_RENAME: - return batchLimits[6]; - case SMB_COM_TRANSACTION: - return batchLimits[7]; - case SMB_COM_QUERY_INFORMATION: - return batchLimits[8]; - } - return 0; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - - if( session.transport.server.security == SECURITY_SHARE && - ( session.auth.hashesExternal || - session.auth.password.length() > 0 )) { - - if( session.transport.server.encryptedPasswords ) { - // encrypted - password = session.auth.getAnsiHash( session.transport.server.encryptionKey ); - passwordLength = password.length; - } else if( DISABLE_PLAIN_TEXT_PASSWORDS ) { - throw new RuntimeException( "Plain text passwords are disabled" ); - } else { - // plain text - password = new byte[(session.auth.password.length() + 1) * 2]; - passwordLength = writeString( session.auth.password, password, 0 ); - } - } else { - // no password in tree connect - passwordLength = 1; - } - - dst[dstIndex++] = disconnectTid ? (byte)0x01 : (byte)0x00; - dst[dstIndex++] = (byte)0x00; - writeInt2( passwordLength, dst, dstIndex ); - return 4; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - if( session.transport.server.security == SECURITY_SHARE && - ( session.auth.hashesExternal || - session.auth.password.length() > 0 )) { - System.arraycopy( password, 0, dst, dstIndex, passwordLength ); - dstIndex += passwordLength; - } else { - // no password in tree connect - dst[dstIndex++] = (byte)0x00; - } - dstIndex += writeString( path, dst, dstIndex ); - try { - System.arraycopy( service.getBytes( "ASCII" ), 0, dst, dstIndex, service.length() ); - } catch( UnsupportedEncodingException uee ) { - return 0; - } - dstIndex += service.length(); - dst[dstIndex++] = (byte)'\0'; - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - String result = new String( "SmbComTreeConnectAndX[" + - super.toString() + - ",disconnectTid=" + disconnectTid + - ",passwordLength=" + passwordLength + - ",password=" + Hexdump.toHexString( password, passwordLength, 0 ) + - ",path=" + path + - ",service=" + service + "]" ); - return result; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndXResponse.java deleted file mode 100644 index 0ca6f7d910..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeConnectAndXResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.UnsupportedEncodingException; - -class SmbComTreeConnectAndXResponse extends AndXServerMessageBlock { - - private static final int SMB_SUPPORT_SEARCH_BITS = 0x0001; - private static final int SMB_SHARE_IS_IN_DFS = 0x0002; - - boolean supportSearchBits, shareIsInDfs; - String service, nativeFileSystem = ""; - - SmbComTreeConnectAndXResponse( ServerMessageBlock andx ) { - super( andx ); - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - supportSearchBits = ( buffer[bufferIndex] & SMB_SUPPORT_SEARCH_BITS ) == SMB_SUPPORT_SEARCH_BITS; - shareIsInDfs = ( buffer[bufferIndex] & SMB_SHARE_IS_IN_DFS ) == SMB_SHARE_IS_IN_DFS; - return 2; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - int len = readStringLength( buffer, bufferIndex, 32 ); - try { - service = new String( buffer, bufferIndex, len, "ASCII" ); - } catch( UnsupportedEncodingException uee ) { - return 0; - } - bufferIndex += len + 1; - // win98 observed not returning nativeFileSystem -/* Problems here with iSeries returning ASCII even though useUnicode = true - * Fortunately we don't really need nativeFileSystem for anything. - if( byteCount > bufferIndex - start ) { - nativeFileSystem = readString( buffer, bufferIndex ); - bufferIndex += stringWireLength( nativeFileSystem, bufferIndex ); - } -*/ - - return bufferIndex - start; - } - public String toString() { - String result = new String( "SmbComTreeConnectAndXResponse[" + - super.toString() + - ",supportSearchBits=" + supportSearchBits + - ",shareIsInDfs=" + shareIsInDfs + - ",service=" + service + - ",nativeFileSystem=" + nativeFileSystem + "]" ); - return result; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeDisconnect.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeDisconnect.java deleted file mode 100644 index 0c5148bf7a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComTreeDisconnect.java +++ /dev/null @@ -1,43 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComTreeDisconnect extends ServerMessageBlock { - - SmbComTreeDisconnect() { - command = SMB_COM_TREE_DISCONNECT; - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComTreeDisconnect[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWrite.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWrite.java deleted file mode 100644 index f276cb8607..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWrite.java +++ /dev/null @@ -1,95 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComWrite extends ServerMessageBlock { - - private int fid, - count, - offset, - remaining, - off; - private byte[] b; - - SmbComWrite() { - super(); - command = SMB_COM_WRITE; - } - SmbComWrite( int fid, int offset, int remaining, byte[] b, int off, int len ) { - this.fid = fid; - this.count = len; - this.offset = offset; - this.remaining = remaining; - this.b = b; - this.off = off; - command = SMB_COM_WRITE; - } - - void setParam( int fid, long offset, int remaining, - byte[] b, int off, int len ) { - this.fid = fid; - this.offset = (int)(offset & 0xFFFFFFFFL); - this.remaining = remaining; - this.b = b; - this.off = off; - count = len; - digest = null; /* otherwise recycled commands - * like writeandx will choke if session - * closes in between */ - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - writeInt2( count, dst, dstIndex ); - dstIndex += 2; - writeInt4( offset, dst, dstIndex ); - dstIndex += 4; - writeInt2( remaining, dst, dstIndex ); - dstIndex += 2; - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dst[dstIndex++] = (byte)0x01; /* BufferFormat */ - writeInt2( count, dst, dstIndex ); /* DataLength? */ - dstIndex += 2; - System.arraycopy( b, off, dst, dstIndex, count ); - dstIndex += count; - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComWrite[" + - super.toString() + - ",fid=" + fid + - ",count=" + count + - ",offset=" + offset + - ",remaining=" + remaining + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndX.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndX.java deleted file mode 100644 index 07a25338fa..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndX.java +++ /dev/null @@ -1,137 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; - -class SmbComWriteAndX extends AndXServerMessageBlock { - - private static final int READ_ANDX_BATCH_LIMIT = - Config.getInt( "jcifs.smb.client.WriteAndX.ReadAndX", 1 ); - private static final int CLOSE_BATCH_LIMIT = - Config.getInt( "jcifs.smb.client.WriteAndX.Close", 1 ); - - private int fid, - remaining, - dataLength, - dataOffset, - off; - private byte[] b; - private long offset; - -private int pad; - - int writeMode; - - SmbComWriteAndX() { - super( null ); - command = SMB_COM_WRITE_ANDX; - } - SmbComWriteAndX( int fid, long offset, int remaining, - byte[] b, int off, int len, ServerMessageBlock andx ) { - super( andx ); - this.fid = fid; - this.offset = offset; - this.remaining = remaining; - this.b = b; - this.off = off; - dataLength = len; - command = SMB_COM_WRITE_ANDX; - } - - void setParam( int fid, long offset, int remaining, - byte[] b, int off, int len ) { - this.fid = fid; - this.offset = offset; - this.remaining = remaining; - this.b = b; - this.off = off; - dataLength = len; - digest = null; /* otherwise recycled commands - * like writeandx will choke if session - * closes in between */ - } - int getBatchLimit( byte command ) { - if( command == SMB_COM_READ_ANDX ) { - return READ_ANDX_BATCH_LIMIT; - } - if( command == SMB_COM_CLOSE ) { - return CLOSE_BATCH_LIMIT; - } - return 0; - } - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - dataOffset = (dstIndex - headerStart) + 26; // 26 = off from here to pad - -pad = ( dataOffset - headerStart ) % 4; -pad = pad == 0 ? 0 : 4 - pad; -dataOffset += pad; - - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - writeInt4( offset, dst, dstIndex ); - dstIndex += 4; - for( int i = 0; i < 4; i++ ) { - dst[dstIndex++] = (byte)0xFF; - } - writeInt2( writeMode, dst, dstIndex ); - dstIndex += 2; - writeInt2( remaining, dst, dstIndex ); - dstIndex += 2; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - writeInt2( dataLength, dst, dstIndex ); - dstIndex += 2; - writeInt2( dataOffset, dst, dstIndex ); - dstIndex += 2; - writeInt4( offset >> 32, dst, dstIndex ); - dstIndex += 4; - - return dstIndex - start; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - -while( pad-- > 0 ) { - dst[dstIndex++] = (byte)0xEE; -} - System.arraycopy( b, off, dst, dstIndex, dataLength ); - dstIndex += dataLength; - - return dstIndex - start; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComWriteAndX[" + - super.toString() + - ",fid=" + fid + - ",offset=" + offset + - ",writeMode=" + writeMode + - ",remaining=" + remaining + - ",dataLength=" + dataLength + - ",dataOffset=" + dataOffset + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndXResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndXResponse.java deleted file mode 100644 index 692d832448..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteAndXResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComWriteAndXResponse extends AndXServerMessageBlock { - - long count; - - SmbComWriteAndXResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - count = readInt2( buffer, bufferIndex ) & 0xFFFFL; - return 8; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComWriteAndXResponse[" + - super.toString() + - ",count=" + count + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteResponse.java deleted file mode 100644 index 368c4dd3a3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbComWriteResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbComWriteResponse extends ServerMessageBlock { - - long count; - - SmbComWriteResponse() { - } - - int writeParameterWordsWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeBytesWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParameterWordsWireFormat( byte[] buffer, int bufferIndex ) { - count = readInt2( buffer, bufferIndex ) & 0xFFFFL; - return 8; - } - int readBytesWireFormat( byte[] buffer, int bufferIndex ) { - return 0; - } - public String toString() { - return new String( "SmbComWriteResponse[" + - super.toString() + - ",count=" + count + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbConstants.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbConstants.java deleted file mode 100644 index 312b0323bd..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbConstants.java +++ /dev/null @@ -1,165 +0,0 @@ -package jcifs.smb; - -import jcifs.Config; - -import java.net.InetAddress; -import java.util.LinkedList; -import java.util.TimeZone; - -interface SmbConstants { - - static final int DEFAULT_PORT = 445; - - static final int DEFAULT_MAX_MPX_COUNT = 10; - static final int DEFAULT_RESPONSE_TIMEOUT = 30000; - static final int DEFAULT_SO_TIMEOUT = 35000; - static final int DEFAULT_RCV_BUF_SIZE = 60416; - static final int DEFAULT_SND_BUF_SIZE = 16644; - static final int DEFAULT_SSN_LIMIT = 250; - static final int DEFAULT_CONN_TIMEOUT = 35000; - - static final InetAddress LADDR = Config.getLocalHost(); - static final int LPORT = Config.getInt( "jcifs.smb.client.lport", 0 ); - static final int MAX_MPX_COUNT = Config.getInt( "jcifs.smb.client.maxMpxCount", DEFAULT_MAX_MPX_COUNT ); - static final int SND_BUF_SIZE = Config.getInt( "jcifs.smb.client.snd_buf_size", DEFAULT_SND_BUF_SIZE ); - static final int RCV_BUF_SIZE = Config.getInt( "jcifs.smb.client.rcv_buf_size", DEFAULT_RCV_BUF_SIZE ); - static final boolean USE_UNICODE = Config.getBoolean( "jcifs.smb.client.useUnicode", true ); - static final boolean FORCE_UNICODE = Config.getBoolean( "jcifs.smb.client.useUnicode", false ); - static final boolean USE_NTSTATUS = Config.getBoolean( "jcifs.smb.client.useNtStatus", true ); - static final boolean SIGNPREF = Config.getBoolean("jcifs.smb.client.signingPreferred", false ); - static final boolean USE_NTSMBS = Config.getBoolean( "jcifs.smb.client.useNTSmbs", true ); - static final boolean USE_EXTSEC = Config.getBoolean( "jcifs.smb.client.useExtendedSecurity", true ); - - static final String NETBIOS_HOSTNAME = Config.getProperty( "jcifs.netbios.hostname", null ); - static final int LM_COMPATIBILITY = Config.getInt( "jcifs.smb.lmCompatibility", 3); - - static final int FLAGS_NONE = 0x00; - static final int FLAGS_LOCK_AND_READ_WRITE_AND_UNLOCK = 0x01; - static final int FLAGS_RECEIVE_BUFFER_POSTED = 0x02; - static final int FLAGS_PATH_NAMES_CASELESS = 0x08; - static final int FLAGS_PATH_NAMES_CANONICALIZED = 0x10; - static final int FLAGS_OPLOCK_REQUESTED_OR_GRANTED = 0x20; - static final int FLAGS_NOTIFY_OF_MODIFY_ACTION = 0x40; - static final int FLAGS_RESPONSE = 0x80; - - static final int FLAGS2_NONE = 0x0000; - static final int FLAGS2_LONG_FILENAMES = 0x0001; - static final int FLAGS2_EXTENDED_ATTRIBUTES = 0x0002; - static final int FLAGS2_SECURITY_SIGNATURES = 0x0004; - static final int FLAGS2_EXTENDED_SECURITY_NEGOTIATION = 0x0800; - static final int FLAGS2_RESOLVE_PATHS_IN_DFS = 0x1000; - static final int FLAGS2_PERMIT_READ_IF_EXECUTE_PERM = 0x2000; - static final int FLAGS2_STATUS32 = 0x4000; - static final int FLAGS2_UNICODE = 0x8000; - - static final int CAP_NONE = 0x0000; - static final int CAP_RAW_MODE = 0x0001; - static final int CAP_MPX_MODE = 0x0002; - static final int CAP_UNICODE = 0x0004; - static final int CAP_LARGE_FILES = 0x0008; - static final int CAP_NT_SMBS = 0x0010; - static final int CAP_RPC_REMOTE_APIS = 0x0020; - static final int CAP_STATUS32 = 0x0040; - static final int CAP_LEVEL_II_OPLOCKS = 0x0080; - static final int CAP_LOCK_AND_READ = 0x0100; - static final int CAP_NT_FIND = 0x0200; - static final int CAP_DFS = 0x1000; - static final int CAP_EXTENDED_SECURITY = 0x80000000; - - // file attribute encoding - static final int ATTR_READONLY = 0x01; - static final int ATTR_HIDDEN = 0x02; - static final int ATTR_SYSTEM = 0x04; - static final int ATTR_VOLUME = 0x08; - static final int ATTR_DIRECTORY = 0x10; - static final int ATTR_ARCHIVE = 0x20; - - // extended file attribute encoding(others same as above) - static final int ATTR_COMPRESSED = 0x800; - static final int ATTR_NORMAL = 0x080; - static final int ATTR_TEMPORARY = 0x100; - - // access mask encoding - static final int FILE_READ_DATA = 0x00000001; // 1 - static final int FILE_WRITE_DATA = 0x00000002; // 2 - static final int FILE_APPEND_DATA = 0x00000004; // 3 - static final int FILE_READ_EA = 0x00000008; // 4 - static final int FILE_WRITE_EA = 0x00000010; // 5 - static final int FILE_EXECUTE = 0x00000020; // 6 - static final int FILE_DELETE = 0x00000040; // 7 - static final int FILE_READ_ATTRIBUTES = 0x00000080; // 8 - static final int FILE_WRITE_ATTRIBUTES = 0x00000100; // 9 - static final int DELETE = 0x00010000; // 16 - static final int READ_CONTROL = 0x00020000; // 17 - static final int WRITE_DAC = 0x00040000; // 18 - static final int WRITE_OWNER = 0x00080000; // 19 - static final int SYNCHRONIZE = 0x00100000; // 20 - static final int GENERIC_ALL = 0x10000000; // 28 - static final int GENERIC_EXECUTE = 0x20000000; // 29 - static final int GENERIC_WRITE = 0x40000000; // 30 - static final int GENERIC_READ = 0x80000000; // 31 - - - // flags for move and copy - static final int FLAGS_TARGET_MUST_BE_FILE = 0x0001; - static final int FLAGS_TARGET_MUST_BE_DIRECTORY = 0x0002; - static final int FLAGS_COPY_TARGET_MODE_ASCII = 0x0004; - static final int FLAGS_COPY_SOURCE_MODE_ASCII = 0x0008; - static final int FLAGS_VERIFY_ALL_WRITES = 0x0010; - static final int FLAGS_TREE_COPY = 0x0020; - - // open function - static final int OPEN_FUNCTION_FAIL_IF_EXISTS = 0x0000; - static final int OPEN_FUNCTION_OVERWRITE_IF_EXISTS = 0x0020; - - static final int PID = (int)( Math.random() * 65536d ); - - static final int SECURITY_SHARE = 0x00; - static final int SECURITY_USER = 0x01; - - static final int CMD_OFFSET = 4; - static final int ERROR_CODE_OFFSET = 5; - static final int FLAGS_OFFSET = 9; - static final int SIGNATURE_OFFSET = 14; - static final int TID_OFFSET = 24; - static final int HEADER_LENGTH = 32; - - static final long MILLISECONDS_BETWEEN_1970_AND_1601 = 11644473600000L; - static final TimeZone TZ = TimeZone.getDefault(); - - static final boolean USE_BATCHING = Config.getBoolean( "jcifs.smb.client.useBatching", true ); - static final String OEM_ENCODING = Config.getProperty( "jcifs.encoding", Config.DEFAULT_OEM_ENCODING ); - static final String UNI_ENCODING = "UTF-16LE"; - static final int DEFAULT_FLAGS2 = - FLAGS2_LONG_FILENAMES | - FLAGS2_EXTENDED_ATTRIBUTES | - ( USE_EXTSEC ? FLAGS2_EXTENDED_SECURITY_NEGOTIATION : 0 ) | - ( SIGNPREF ? FLAGS2_SECURITY_SIGNATURES : 0 ) | - ( USE_NTSTATUS ? FLAGS2_STATUS32 : 0 ) | - ( USE_UNICODE ? FLAGS2_UNICODE : 0 ); - static final int DEFAULT_CAPABILITIES = - ( USE_NTSMBS ? CAP_NT_SMBS : 0 ) | - ( USE_NTSTATUS ? CAP_STATUS32 : 0 ) | - ( USE_UNICODE ? CAP_UNICODE : 0 ) | - CAP_DFS; - static final int FLAGS2 = Config.getInt( "jcifs.smb.client.flags2", DEFAULT_FLAGS2 ); - static final int CAPABILITIES = Config.getInt( "jcifs.smb.client.capabilities", DEFAULT_CAPABILITIES ); - static final boolean TCP_NODELAY = Config.getBoolean( "jcifs.smb.client.tcpNoDelay", false ); - static final int RESPONSE_TIMEOUT = - Config.getInt( "jcifs.smb.client.responseTimeout", DEFAULT_RESPONSE_TIMEOUT ); - - static final LinkedList CONNECTIONS = new LinkedList(); - - static final int SSN_LIMIT = - Config.getInt( "jcifs.smb.client.ssnLimit", DEFAULT_SSN_LIMIT ); - static final int SO_TIMEOUT = - Config.getInt( "jcifs.smb.client.soTimeout", DEFAULT_SO_TIMEOUT ); - static final int CONN_TIMEOUT = - Config.getInt( "jcifs.smb.client.connTimeout", DEFAULT_CONN_TIMEOUT ); - static final String NATIVE_OS = - Config.getProperty( "jcifs.smb.client.nativeOs", System.getProperty( "os.name" )); - static final String NATIVE_LANMAN = - Config.getProperty( "jcifs.smb.client.nativeLanMan", "jCIFS" ); - static final int VC_NUMBER = 1; - static final SmbTransport NULL_TRANSPORT = new SmbTransport( null, 0, null, 0 ); -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbException.java deleted file mode 100644 index 692927c02d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbException.java +++ /dev/null @@ -1,170 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -/** - * There are hundreds of error codes that may be returned by a CIFS - * server. Rather than represent each with it's own Exception- * class, this class represents all of them. For many of the popular - * error codes, constants and text messages like "The device is not ready" - * are provided. - *- * The jCIFS client maps DOS error codes to NTSTATUS codes. This means that - * the user may recieve a different error from a legacy server than that of - * a newer varient such as Windows NT and above. If you should encounter - * such a case, please report it to jcifs at samba dot org and we will - * change the mapping. - */ - -public class SmbException extends IOException implements NtStatus, DosError, WinError { - - static String getMessageByCode( int errcode ) { - /* Note there's a signedness error here because 0xC0000000 based values are - * negative so it with NT_STATUS_SUCCESS (0) the binary search will not be - * performed properly. The effect is that the code at index 1 is never found - * (NT_STATUS_UNSUCCESSFUL). So here we factor out NT_STATUS_SUCCESS - * as a special case (which it is). - */ - if (errcode == 0) { - return "NT_STATUS_SUCCESS"; - } - if(( errcode & 0xC0000000 ) == 0xC0000000 ) { - int min = 1; /* Don't include NT_STATUS_SUCCESS */ - int max = NT_STATUS_CODES.length - 1; - - while( max >= min ) { - int mid = (min + max) / 2; - - if( errcode > NT_STATUS_CODES[mid] ) { - min = mid + 1; - } else if( errcode < NT_STATUS_CODES[mid] ) { - max = mid - 1; - } else { - return NT_STATUS_MESSAGES[mid]; - } - } - } else { - int min = 0; - int max = DOS_ERROR_CODES.length - 1; - - while( max >= min ) { - int mid = (min + max) / 2; - - if( errcode > DOS_ERROR_CODES[mid][0] ) { - min = mid + 1; - } else if( errcode < DOS_ERROR_CODES[mid][0] ) { - max = mid - 1; - } else { - return DOS_ERROR_MESSAGES[mid]; - } - } - } - - return "0x" + Hexdump.toHexString( errcode, 8 ); - } - static int getStatusByCode( int errcode ) { - if(( errcode & 0xC0000000 ) != 0 ) { - return errcode; - } else { - int min = 0; - int max = DOS_ERROR_CODES.length - 1; - - while( max >= min ) { - int mid = (min + max) / 2; - - if( errcode > DOS_ERROR_CODES[mid][0] ) { - min = mid + 1; - } else if( errcode < DOS_ERROR_CODES[mid][0] ) { - max = mid - 1; - } else { - return DOS_ERROR_CODES[mid][1]; - } - } - } - - return NT_STATUS_UNSUCCESSFUL; - } - static String getMessageByWinerrCode( int errcode ) { - int min = 0; - int max = WINERR_CODES.length - 1; - - while( max >= min ) { - int mid = (min + max) / 2; - - if( errcode > WINERR_CODES[mid] ) { - min = mid + 1; - } else if( errcode < WINERR_CODES[mid] ) { - max = mid - 1; - } else { - return WINERR_MESSAGES[mid]; - } - } - - return errcode + ""; - } - - - private int status; - private Throwable rootCause; - - SmbException() { - } - SmbException( int errcode, Throwable rootCause ) { - super( getMessageByCode( errcode )); - status = getStatusByCode( errcode ); - this.rootCause = rootCause; - } - SmbException( String msg ) { - super( msg ); - status = NT_STATUS_UNSUCCESSFUL; - } - SmbException( String msg, Throwable rootCause ) { - super( msg ); - this.rootCause = rootCause; - status = NT_STATUS_UNSUCCESSFUL; - } - public SmbException( int errcode, boolean winerr ) { - super( winerr ? getMessageByWinerrCode( errcode ) : getMessageByCode( errcode )); - status = winerr ? errcode : getStatusByCode( errcode ); - } - - public int getNtStatus() { - return status; - } - public Throwable getRootCause() { - return rootCause; - } - public String toString() { - if( rootCause != null ) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter( sw ); - rootCause.printStackTrace( pw ); - return super.toString() + "\n" + sw; - } else { - return super.toString(); - } - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFile.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFile.java deleted file mode 100644 index eb50d12fb8..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFile.java +++ /dev/null @@ -1,2983 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"
- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.msrpc.MsrpcDfsRootEnum; -import jcifs.dcerpc.msrpc.MsrpcShareEnum; -import jcifs.dcerpc.msrpc.MsrpcShareGetInfo; -import jcifs.netbios.NbtAddress; -import jcifs.util.LogStream; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.UnknownHostException; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; - -/** - * This class represents a resource on an SMB network. Mainly these - * resources are files and directories however an SmbFile- * may also refer to servers and workgroups. If the resource is a file or - * directory the methods ofSmbFilefollow the behavior of - * the well known {@link java.io.File} class. One fundamental difference - * is the usage of a URL scheme [1] to specify the target file or - * directory. SmbFile URLs have the following syntax: - * - *- * - * This example: - * - *- * smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]file]]][?param=value[param2=value2[...]]] - *- * - * would reference the file- * smb://storage15/public/foo.txt - *foo.txtin the share - *publicon the serverstorage15. In addition - * to referencing files and directories, jCIFS can also address servers, - * and workgroups. - *- * Important: all SMB URLs that represent - * workgroups, servers, shares, or directories require a trailing slash '/'. - * - *
- * When using the java.net.URL class with - * 'smb://' URLs it is necessary to first call the static - * jcifs.Config.registerSmbURLHandler(); method. This is required - * to register the SMB protocol handler. - *
- * The userinfo component of the SMB URL (domain;user:pass) must - * be URL encoded if it contains reserved characters. According to RFC 2396 - * these characters are non US-ASCII characters and most meta characters - * however jCIFS will work correctly with anything but '@' which is used - * to delimit the userinfo component from the server and '%' which is the - * URL escape character itself. - *
- * The server - * component may a traditional NetBIOS name, a DNS name, or IP - * address. These name resolution mechanisms and their resolution order - * can be changed (See Setting Name - * Resolution Properties). The servername and path components are - * not case sensitive but the domain, username, and password components - * are. It is also likely that properties must be specified for jcifs - * to function (See Setting - * JCIFS Properties). Here are some examples of SMB URLs with brief - * descriptions of what they do: - * - *
[1] This URL scheme is based largely on the SMB - * Filesharing URL Scheme IETF draft. - * - *
- *
- * - *- * SMB URL Examples - *- * - * URL Description - * - * smb://users-nyc;miallen:mypass@angus/tmp/- * This URL references a share called tmpon the server - *angusas usermiallenwho's password is - *mypass. - *- * - * - * smb://Administrator:P%40ss@msmith1/c/WINDOWS/Desktop/foo.txt- * A relativly sophisticated example that references a file - * msmith1's desktop as userAdministrator. Notice the '@' is URL encoded with the '%40' hexcode escape. - *- * - * smb://angus/- * This references only a server. The behavior of some methods is different - * in this context(e.g. you cannot deletea server) however - * as you might expect thelistmethod will list the available - * shares on this server. - *- * - * smb://myworkgroup/- * This syntactically is identical to the above example. However if - * myworkgrouphappends to be a workgroup(which is indeed - * suggested by the name) thelistmethod will return - * a list of servers that have registered themselves as members of - *myworkgroup. - *- * - * smb://- * Just as smb://server/lists shares and - *smb://workgroup/lists servers, thesmb://- * URL lists all available workgroups on a netbios LAN. Again, - * in this context many methods are not valid and return default - * values(e.g.isHiddenwill always return false). - *- * - * smb://angus.foo.net/d/jcifs/pipes.doc- * The server name may also be a DNS name as it is in this example. See - * Setting Name Resolution Properties - * for details. - * - * - * smb://192.168.1.15/ADMIN$/- * The server name may also be an IP address. See Setting Name Resolution Properties - * for details. - * - * - * - * smb://domain;username:password@server/share/path/to/file.txt- * A prototypical example that uses all the fields. - * - * - * smb://myworkgroup/angus/ <-- ILLEGAL- * Despite the hierarchial relationship between workgroups, servers, and - * filesystems this example is not valid. - * - * - * - * smb://server/share/path/to/dir <-- ILLEGAL- * URLs that represent workgroups, servers, shares, or directories require a trailing slash '/'. - * - * - * - * smb://MYGROUP/?SERVER=192.168.10.15- * SMB URLs support some query string parameters. In this example - * the SERVERparameter is used to override the - * server name service lookup to contact the server 192.168.10.15 - * (presumably known to be a master - * browser) for the server list in workgroupMYGROUP. - *A second constructor argument may be specified to augment the URL - * for better programmatic control when processing many files under - * a common base. This is slightly different from the corresponding - *
java.io.Fileusage; a '/' at the beginning of the second - * parameter will still use the server component of the first parameter. The - * examples below illustrate the resulting URLs when this second contructor - * argument is used. - * - *- *
- * - *- * - * Examples Of SMB URLs When Augmented With A Second Constructor Parameter - *- * - * - * First Parameter Second Parameter Result - * - * - * smb://host/share/a/b/ - *- * c/d/ - *- * smb://host/share/a/b/c/d/ - *- * - * - * smb://host/share/foo/bar/ - *- * /share2/zig/zag - *- * smb://host/share2/zig/zag - *- * - * - * smb://host/share/foo/bar/ - *- * ../zip/ - *- * smb://host/share/foo/zip/ - *- * - * - * smb://host/share/zig/zag - *- * smb://foo/bar/ - *- * smb://foo/bar/ - *- * - * - * smb://host/share/foo/ - *- * ../.././.././../foo/ - *- * smb://host/foo/ - *- * - * - * smb://host/share/zig/zag - *- * / - *- * smb://host/ - *- * - * - * smb://server/ - *- * ../ - *- * smb://server/ - *- * - * - * smb:// - *- * myworkgroup/ - *- * smb://myworkgroup/ - *- * - * - * smb://myworkgroup/ - *- * angus/ - *- * smb://myworkgroup/angus/ <-- ILLEGAL
(But if you first create an SmbFile with 'smb://workgroup/' and use and use it as the first parameter to a constructor that accepts it with a second String parameter jCIFS will factor out the 'workgroup'.) - *Instances of the
SmbFileclass are immutable; that is, - * once created, the abstract pathname represented by an SmbFile object - * will never change. - * - * @see java.io.File - */ - -public class SmbFile extends URLConnection implements SmbConstants { - - static final int O_RDONLY = 0x01; - static final int O_WRONLY = 0x02; - static final int O_RDWR = 0x03; - static final int O_APPEND = 0x04; - - // Open Function Encoding - // create if the file does not exist - static final int O_CREAT = 0x0010; - // fail if the file exists - static final int O_EXCL = 0x0020; - // truncate if the file exists - static final int O_TRUNC = 0x0040; - - // share access -/** - * When specified as the shareAccess constructor parameter, - * other SMB clients (including other threads making calls into jCIFS) - * will not be permitted to access the target file and will receive "The - * file is being accessed by another process" message. - */ - public static final int FILE_NO_SHARE = 0x00; -/** - * When specified as the shareAccess constructor parameter, - * other SMB clients will be permitted to read from the target file while - * this file is open. This constant may be logically OR'd with other share - * access flags. - */ - public static final int FILE_SHARE_READ = 0x01; -/** - * When specified as the shareAccess constructor parameter, - * other SMB clients will be permitted to write to the target file while - * this file is open. This constant may be logically OR'd with other share - * access flags. - */ - public static final int FILE_SHARE_WRITE = 0x02; -/** - * When specified as the shareAccess constructor parameter, - * other SMB clients will be permitted to delete the target file while - * this file is open. This constant may be logically OR'd with other share - * access flags. - */ - public static final int FILE_SHARE_DELETE = 0x04; - - // file attribute encoding -/** - * A file with this bit on as returned by getAttributes() or set - * with setAttributes() will be read-only - */ - public static final int ATTR_READONLY = 0x01; -/** - * A file with this bit on as returned by getAttributes() or set - * with setAttributes() will be hidden - */ - public static final int ATTR_HIDDEN = 0x02; -/** - * A file with this bit on as returned by getAttributes() or set - * with setAttributes() will be a system file - */ - public static final int ATTR_SYSTEM = 0x04; -/** - * A file with this bit on as returned by getAttributes() is - * a volume - */ - public static final int ATTR_VOLUME = 0x08; -/** - * A file with this bit on as returned by getAttributes() is - * a directory - */ - public static final int ATTR_DIRECTORY = 0x10; -/** - * A file with this bit on as returned by getAttributes() or set - * with setAttributes() is an archived file - */ - public static final int ATTR_ARCHIVE = 0x20; - - // extended file attribute encoding(others same as above) - static final int ATTR_COMPRESSED = 0x800; - static final int ATTR_NORMAL = 0x080; - static final int ATTR_TEMPORARY = 0x100; - - static final int ATTR_GET_MASK = 0x7FFF; /* orig 0x7fff */ - static final int ATTR_SET_MASK = 0x30A7; /* orig 0x0027 */ - - static final int DEFAULT_ATTR_EXPIRATION_PERIOD = 5000; - - static final int HASH_DOT = ".".hashCode(); - static final int HASH_DOT_DOT = "..".hashCode(); - - static LogStream log = LogStream.getInstance(); - static long attrExpirationPeriod; - static boolean ignoreCopyToException; - - static { - - try { - Class.forName( "jcifs.Config" ); - } catch( ClassNotFoundException cnfe ) { - cnfe.printStackTrace(); - } - attrExpirationPeriod = Config.getLong( "jcifs.smb.client.attrExpirationPeriod", DEFAULT_ATTR_EXPIRATION_PERIOD ); - ignoreCopyToException = Config.getBoolean( "jcifs.smb.client.ignoreCopyToException", true ); - dfs = new Dfs(); - } - - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a regular file or directory. - */ - public static final int TYPE_FILESYSTEM = 0x01; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a workgroup. - */ - public static final int TYPE_WORKGROUP = 0x02; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a server. - */ - public static final int TYPE_SERVER = 0x04; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a share. - */ - public static final int TYPE_SHARE = 0x08; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a named pipe. - */ - public static final int TYPE_NAMED_PIPE = 0x10; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a printer. - */ - public static final int TYPE_PRINTER = 0x20; - /** - * Returned by {@link #getType()} if the resource this SmbFile - * represents is a communications device. - */ - public static final int TYPE_COMM = 0x40; - - - private String canon; // Initially null; set by getUncPath; dir must end with '/' - private String share; // Can be null - private long createTime; - private long lastModified; - private int attributes; - private long attrExpiration; - private long size; - private long sizeExpiration; - private boolean isExists; - private int shareAccess = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - private SmbComBlankResponse blank_resp = null; - private DfsReferral dfsReferral = null; // For getDfsPath() and getServerWithDfs() - - protected static Dfs dfs; - - NtlmPasswordAuthentication auth; // Cannot be null - SmbTree tree = null; // Initially null - String unc; // Initially null; set by getUncPath; never ends with '/' - int fid; // Initially 0; set by open() - int type; - boolean opened; - int tree_num; - -/** - * Constructs an SmbFile representing a resource on an SMB network such as - * a file or directory. See the description and examples of smb URLs above. - * - * @param url A URL string - * @throws MalformedURLException - * If theparentandchildparameters - * do not follow the prescribed syntax - */ - - public SmbFile( String url ) throws MalformedURLException { - this( new URL( null, url, Handler.SMB_HANDLER )); - } - -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. The second parameter is a relative path from - * theparent SmbFile. See the description above for examples - * of using the secondnameparameter. - * - * @param context A baseSmbFile- * @param name A path string relative to theparentparemeter - * @throws MalformedURLException - * If theparentandchildparameters - * do not follow the prescribed syntax - * @throws UnknownHostException - * If the server or workgroup of the context file cannot be determined - */ - - public SmbFile( SmbFile context, String name ) - throws MalformedURLException, UnknownHostException { - this( context.isWorkgroup0() ? - new URL( null, "smb://" + name, Handler.SMB_HANDLER ) : - new URL( context.url, name, Handler.SMB_HANDLER ), context.auth ); - } - -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. The second parameter is a relative path from - * theparent. See the description above for examples of - * using the secondchileparameter. - * - * @param context A URL string - * @param name A path string relative to thecontextparemeter - * @throws MalformedURLException - * If thecontextandnameparameters - * do not follow the prescribed syntax - */ - - public SmbFile( String context, String name ) throws MalformedURLException { - this( new URL( new URL( null, context, Handler.SMB_HANDLER ), - name, Handler.SMB_HANDLER )); - } - -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. - * - * @param url A URL string - * @param auth The credentials the client should use for authentication - * @throws MalformedURLException - * If theurlparameter does not follow the prescribed syntax - */ - public SmbFile( String url, NtlmPasswordAuthentication auth ) - throws MalformedURLException { - this( new URL( null, url, Handler.SMB_HANDLER ), auth ); - } -/** - * Constructs an SmbFile representing a file on an SMB network. The - * shareAccess parameter controls what permissions other - * clients have when trying to access the same file while this instance - * is still open. This value is either FILE_NO_SHARE or any - * combination of FILE_SHARE_READ, FILE_SHARE_WRITE, - * and FILE_SHARE_DELETE logically OR'd together. - * - * @param url A URL string - * @param auth The credentials the client should use for authentication - * @param shareAccess Specifies what access other clients have while this file is open. - * @throws MalformedURLException - * If theurlparameter does not follow the prescribed syntax - */ - public SmbFile( String url, NtlmPasswordAuthentication auth, int shareAccess ) - throws MalformedURLException { - this( new URL( null, url, Handler.SMB_HANDLER ), auth ); - if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)) != 0) { - throw new RuntimeException( "Illegal shareAccess parameter" ); - } - this.shareAccess = shareAccess; - } -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. The second parameter is a relative path from - * thecontext. See the description above for examples of - * using the secondnameparameter. - * - * @param context A URL string - * @param name A path string relative to thecontextparemeter - * @param auth The credentials the client should use for authentication - * @throws MalformedURLException - * If thecontextandnameparameters - * do not follow the prescribed syntax - */ - public SmbFile( String context, String name, NtlmPasswordAuthentication auth ) - throws MalformedURLException { - this( new URL( new URL( null, context, Handler.SMB_HANDLER ), name, Handler.SMB_HANDLER ), auth ); - } -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. The second parameter is a relative path from - * thecontext. See the description above for examples of - * using the secondnameparameter. The shareAccess - * parameter controls what permissions other clients have when trying - * to access the same file while this instance is still open. This - * value is either FILE_NO_SHARE or any combination - * of FILE_SHARE_READ, FILE_SHARE_WRITE, and - * FILE_SHARE_DELETE logically OR'd together. - * - * @param context A URL string - * @param name A path string relative to thecontextparemeter - * @param auth The credentials the client should use for authentication - * @param shareAccess Specifies what access other clients have while this file is open. - * @throws MalformedURLException - * If thecontextandnameparameters - * do not follow the prescribed syntax - */ - public SmbFile( String context, String name, NtlmPasswordAuthentication auth, int shareAccess ) - throws MalformedURLException { - this( new URL( new URL( null, context, Handler.SMB_HANDLER ), name, Handler.SMB_HANDLER ), auth ); - if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)) != 0) { - throw new RuntimeException( "Illegal shareAccess parameter" ); - } - this.shareAccess = shareAccess; - } -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory. The second parameter is a relative path from - * thecontext. See the description above for examples of - * using the secondnameparameter. The shareAccess - * parameter controls what permissions other clients have when trying - * to access the same file while this instance is still open. This - * value is either FILE_NO_SHARE or any combination - * of FILE_SHARE_READ, FILE_SHARE_WRITE, and - * FILE_SHARE_DELETE logically OR'd together. - * - * @param context A baseSmbFile- * @param name A path string relative to thecontextfile path - * @param shareAccess Specifies what access other clients have while this file is open. - * @throws MalformedURLException - * If thecontextandnameparameters - * do not follow the prescribed syntax - */ - public SmbFile( SmbFile context, String name, int shareAccess ) - throws MalformedURLException, UnknownHostException { - this( context.isWorkgroup0() ? - new URL( null, "smb://" + name, Handler.SMB_HANDLER ) : - new URL( context.url, name, Handler.SMB_HANDLER ), context.auth ); - if ((shareAccess & ~(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)) != 0) { - throw new RuntimeException( "Illegal shareAccess parameter" ); - } - this.shareAccess = shareAccess; - } -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory from a URL object. - * - * @param url The URL of the target resource - */ - public SmbFile( URL url ) { - this( url, new NtlmPasswordAuthentication( url.getUserInfo() )); - } -/** - * Constructs an SmbFile representing a resource on an SMB network such - * as a file or directory from a URL object and an - * NtlmPasswordAuthentication object. - * - * @param url The URL of the target resource - * @param auth The credentials the client should use for authentication - */ - public SmbFile( URL url, NtlmPasswordAuthentication auth ) { - super( url ); - this.auth = auth == null ? new NtlmPasswordAuthentication( url.getUserInfo() ) : auth; - - getUncPath0(); - } - SmbFile( SmbFile context, String name, int type, - int attributes, long createTime, long lastModified, long size ) - throws MalformedURLException, UnknownHostException { - this( context.isWorkgroup0() ? - new URL( null, "smb://" + name + "/", Handler.SMB_HANDLER ) : - new URL( context.url, name + (( attributes & ATTR_DIRECTORY ) > 0 ? "/" : "" ))); - - /* why was this removed before? DFS? copyTo? Am I going around in circles? */ - auth = context.auth; - - - if( context.share != null ) { - this.tree = context.tree; - this.dfsReferral = context.dfsReferral; - } - int last = name.length() - 1; - if( name.charAt( last ) == '/' ) { - name = name.substring( 0, last ); - } - if( context.share == null ) { - this.unc = "\\"; - } else if( context.unc.equals( "\\" )) { - this.unc = '\\' + name; - } else { - this.unc = context.unc + '\\' + name; - } - /* why? am I going around in circles? - * this.type = type == TYPE_WORKGROUP ? 0 : type; - */ - this.type = type; - this.attributes = attributes; - this.createTime = createTime; - this.lastModified = lastModified; - this.size = size; - isExists = true; - - attrExpiration = sizeExpiration = - System.currentTimeMillis() + attrExpirationPeriod; - } - - private SmbComBlankResponse blank_resp() { - if( blank_resp == null ) { - blank_resp = new SmbComBlankResponse(); - } - return blank_resp; - } - void resolveDfs(ServerMessageBlock request) throws SmbException { - if (request instanceof SmbComClose) - return; - - connect0(); - - DfsReferral dr = dfs.resolve( - tree.session.transport.tconHostName, - tree.share, - unc, - auth); - if (dr != null) { - String service = null; - - if (request != null) { - switch( request.command ) { - case ServerMessageBlock.SMB_COM_TRANSACTION: - case ServerMessageBlock.SMB_COM_TRANSACTION2: - switch( ((SmbComTransaction)request).subCommand & 0xFF ) { - case SmbComTransaction.TRANS2_GET_DFS_REFERRAL: - break; - default: - service = "A:"; - } - break; - default: - service = "A:"; - } - } - - DfsReferral start = dr; - SmbException se = null; - - do { - try { - if (log.level >= 2) - log.println("DFS redirect: " + dr); - - UniAddress addr = UniAddress.getByName(dr.server); - SmbTransport trans = SmbTransport.getSmbTransport(addr, url.getPort()); - /* This is a key point. This is where we set the "tree" of this file which - * is like changing the rug out from underneath our feet. - */ -/* Technically we should also try to authenticate here but that means doing the session setup and tree connect separately. For now a simple connect will at least tell us if the host is alive. That should be sufficient for 99% of the cases. We can revisit this again for 2.0. - */ - trans.connect(); - tree = trans.getSmbSession( auth ).getSmbTree( dr.share, service ); - - if (dr != start && dr.key != null) { - dr.map.put(dr.key, dr); - } - - se = null; - - break; - } catch (IOException ioe) { - if (ioe instanceof SmbException) { - se = (SmbException)ioe; - } else { - se = new SmbException(dr.server, ioe); - } - } - - dr = dr.next; - } while (dr != start); - - if (se != null) - throw se; - - if (log.level >= 3) - log.println( dr ); - - dfsReferral = dr; - if (dr.pathConsumed < 0) { - dr.pathConsumed = 0; - } else if (dr.pathConsumed > unc.length()) { - dr.pathConsumed = unc.length(); - } - String dunc = unc.substring(dr.pathConsumed); - if (dunc.equals("")) - dunc = "\\"; - if (!dr.path.equals("")) - dunc = "\\" + dr.path + dunc; - - unc = dunc; - if (request != null && - request.path != null && - request.path.endsWith("\\") && - dunc.endsWith("\\") == false) { - dunc += "\\"; - } - if (request != null) { - request.path = dunc; - request.flags2 |= ServerMessageBlock.FLAGS2_RESOLVE_PATHS_IN_DFS; - } - } else if (tree.inDomainDfs && - !(request instanceof NtTransQuerySecurityDesc) && - !(request instanceof SmbComClose) && - !(request instanceof SmbComFindClose2)) { - throw new SmbException(NtStatus.NT_STATUS_NOT_FOUND, false); - } else { - if (request != null) - request.flags2 &= ~ServerMessageBlock.FLAGS2_RESOLVE_PATHS_IN_DFS; - } - } - void send( ServerMessageBlock request, - ServerMessageBlock response ) throws SmbException { - for( ;; ) { - resolveDfs(request); - try { - tree.send( request, response ); - break; - } catch( DfsReferral dre ) { - if( dre.resolveHashes ) { - throw dre; - } - request.reset(); - } - } - } - - static String queryLookup( String query, String param ) { - char in[] = query.toCharArray(); - int i, ch, st, eq; - - st = eq = 0; - for( i = 0; i < in.length; i++) { - ch = in[i]; - if( ch == '&' ) { - if( eq > st ) { - String p = new String( in, st, eq - st ); - if( p.equalsIgnoreCase( param )) { - eq++; - return new String( in, eq, i - eq ); - } - } - st = i + 1; - } else if( ch == '=' ) { - eq = i; - } - } - if( eq > st ) { - String p = new String( in, st, eq - st ); - if( p.equalsIgnoreCase( param )) { - eq++; - return new String( in, eq, in.length - eq ); - } - } - - return null; - } - -UniAddress[] addresses; -int addressIndex; - - UniAddress getAddress() throws UnknownHostException { - if (addressIndex == 0) - return getFirstAddress(); - return addresses[addressIndex - 1]; - } - UniAddress getFirstAddress() throws UnknownHostException { - addressIndex = 0; - - String host = url.getHost(); - String path = url.getPath(); - String query = url.getQuery(); - - if( query != null ) { - String server = queryLookup( query, "server" ); - if( server != null && server.length() > 0 ) { - addresses = new UniAddress[1]; - addresses[0] = UniAddress.getByName( server ); - return getNextAddress(); - } - String address = queryLookup(query, "address"); - if (address != null && address.length() > 0) { - byte[] ip = java.net.InetAddress.getByName(address).getAddress(); - addresses = new UniAddress[1]; - addresses[0] = new UniAddress(java.net.InetAddress.getByAddress(host, ip)); - return getNextAddress(); - } - } - - if (host.length() == 0) { - try { - NbtAddress addr = NbtAddress.getByName( - NbtAddress.MASTER_BROWSER_NAME, 0x01, null); - addresses = new UniAddress[1]; - addresses[0] = UniAddress.getByName( addr.getHostAddress() ); - } catch( UnknownHostException uhe ) { - NtlmPasswordAuthentication.initDefaults(); - if( NtlmPasswordAuthentication.DEFAULT_DOMAIN.equals( "?" )) { - throw uhe; - } - addresses = UniAddress.getAllByName( NtlmPasswordAuthentication.DEFAULT_DOMAIN, true ); - } - } else if( path.length() == 0 || path.equals( "/" )) { - addresses = UniAddress.getAllByName( host, true ); - } else { - addresses = UniAddress.getAllByName(host, false); - } - - return getNextAddress(); - } - UniAddress getNextAddress() { - UniAddress addr = null; - if (addressIndex < addresses.length) - addr = addresses[addressIndex++]; - return addr; - } - boolean hasNextAddress() { - return addressIndex < addresses.length; - } - void connect0() throws SmbException { - try { - connect(); - } catch( UnknownHostException uhe ) { - throw new SmbException( "Failed to connect to server", uhe ); - } catch( SmbException se ) { - throw se; - } catch( IOException ioe ) { - throw new SmbException( "Failed to connect to server", ioe ); - } - } - void doConnect() throws IOException { - SmbTransport trans; - UniAddress addr; - - addr = getAddress(); - if (tree != null) { - trans = tree.session.transport; - } else { - trans = SmbTransport.getSmbTransport(addr, url.getPort()); - tree = trans.getSmbSession(auth).getSmbTree(share, null); - } - - String hostName = getServerWithDfs(); - tree.inDomainDfs = dfs.resolve(hostName, tree.share, null, auth) != null; - if (tree.inDomainDfs) { - tree.connectionState = 2; - } - - try { - if( log.level >= 3 ) - log.println( "doConnect: " + addr ); - - tree.treeConnect(null, null); - } catch (SmbAuthException sae) { - NtlmPasswordAuthentication a; - SmbSession ssn; - - if (share == null) { // IPC$ - try "anonymous" credentials - ssn = trans.getSmbSession(NtlmPasswordAuthentication.NULL); - tree = ssn.getSmbTree(null, null); - tree.treeConnect(null, null); - } else if ((a = NtlmAuthenticator.requestNtlmPasswordAuthentication( - url.toString(), sae)) != null) { - auth = a; - ssn = trans.getSmbSession(auth); - tree = ssn.getSmbTree(share, null); - tree.inDomainDfs = dfs.resolve(hostName, tree.share, null, auth) != null; - if (tree.inDomainDfs) { - tree.connectionState = 2; - } - tree.treeConnect(null, null); - } else { - if (log.level >= 1 && hasNextAddress()) - sae.printStackTrace(log); - throw sae; - } - } - } -/** - * It is not necessary to call this method directly. This is the - * URLConnection implementation of connect(). - */ - public void connect() throws IOException { - if (isConnected() && tree.session.transport.tconHostName == null) { - /* Tree thinks it is connected but transport disconnected - * under it, reset tree to reflect the truth. - */ - tree.treeDisconnect(true); - } - - if( isConnected() ) { - return; - } - - getUncPath0(); - getFirstAddress(); - for ( ;; ) { - try { - doConnect(); - return; - } catch(SmbAuthException sae) { - throw sae; // Prevents account lockout on servers with multiple IPs - } catch(SmbException se) { - if (getNextAddress() == null) - throw se; - if (log.level >= 3) - se.printStackTrace(log); - } - } - } - boolean isConnected() { - return tree != null && tree.connectionState == 2; - } - int open0( int flags, int access, int attrs, int options ) throws SmbException { - int f; - - connect0(); - - if( log.level >= 3 ) - log.println( "open0: " + unc ); - - /* - * NT Create AndX / Open AndX Request / Response - */ - - if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) { - SmbComNTCreateAndXResponse response = new SmbComNTCreateAndXResponse(); -SmbComNTCreateAndX request = new SmbComNTCreateAndX( unc, flags, access, shareAccess, attrs, options, null ); -if (this instanceof SmbNamedPipe) { - request.flags0 |= 0x16; - request.desiredAccess |= 0x20000; - response.isExtended = true; -} - send( request, response ); - f = response.fid; - attributes = response.extFileAttributes & ATTR_GET_MASK; - attrExpiration = System.currentTimeMillis() + attrExpirationPeriod; - isExists = true; - } else { - SmbComOpenAndXResponse response = new SmbComOpenAndXResponse(); - send( new SmbComOpenAndX( unc, access, flags, null ), response ); - f = response.fid; - } - - return f; - } - void open( int flags, int access, int attrs, int options ) throws SmbException { - if( isOpen() ) { - return; - } - fid = open0( flags, access, attrs, options ); - opened = true; - tree_num = tree.tree_num; - } - boolean isOpen() { - boolean ans = opened && isConnected() && tree_num == tree.tree_num; - return ans; - } - void close( int f, long lastWriteTime ) throws SmbException { - - if( log.level >= 3 ) - log.println( "close: " + f ); - - /* - * Close Request / Response - */ - - send( new SmbComClose( f, lastWriteTime ), blank_resp() ); - } - void close( long lastWriteTime ) throws SmbException { - if( isOpen() == false ) { - return; - } - close( fid, lastWriteTime ); - opened = false; - } - void close() throws SmbException { - close( 0L ); - } - -/** - * Returns the NtlmPasswordAuthentication object used as - * credentials with this file or pipe. This can be used to retrieve the - * username for example: - * - * String username = f.getPrincipal().getName(); - * - * The Principal object returned will never be null - * however the username can be null indication anonymous - * credentials were used (e.g. some IPC$ services). - */ - - public Principal getPrincipal() { - return auth; - } - -/** - * Returns the last component of the target URL. This will - * effectively be the name of the file or directory represented by this - *SmbFileor in the case of URLs that only specify a server - * or workgroup, the server or workgroup will be returned. The name of - * the root URLsmb://is alsosmb://. If this - * SmbFile refers to a workgroup, server, share, or directory, - * the name will include a trailing slash '/' so that composing new - * SmbFiles will maintain the trailing slash requirement. - * - * @return The last component of the URL associated with this SMB - * resource orsmb://if the resource issmb://- * itself. - */ - - public String getName() { - getUncPath0(); - if( canon.length() > 1 ) { - int i = canon.length() - 2; - while( canon.charAt( i ) != '/' ) { - i--; - } - return canon.substring( i + 1 ); - } else if( share != null ) { - return share + '/'; - } else if( url.getHost().length() > 0 ) { - return url.getHost() + '/'; - } else { - return "smb://"; - } - } - -/** - * Everything but the last component of the URL representing this SMB - * resource is effectivly it's parent. The root URLsmb://- * does not have a parent. In this casesmb://is returned. - * - * @return The parent directory of this SMB resource or - *smb://if the resource refers to the root of the URL - * hierarchy which incedentally is alsosmb://. - */ - - public String getParent() { - String str = url.getAuthority(); - - if( str.length() > 0 ) { - StringBuffer sb = new StringBuffer( "smb://" ); - - sb.append( str ); - - getUncPath0(); - if( canon.length() > 1 ) { - sb.append( canon ); - } else { - sb.append( '/' ); - } - - str = sb.toString(); - - int i = str.length() - 2; - while( str.charAt( i ) != '/' ) { - i--; - } - - return str.substring( 0, i + 1 ); - } - - return "smb://"; - } - -/** - * Returns the full uncanonicalized URL of this SMB resource. An - *SmbFileconstructed with the result of this method will - * result in anSmbFilethat is equal to the original. - * - * @return The uncanonicalized full URL of this SMB resource. - */ - - public String getPath() { - return url.toString(); - } - - String getUncPath0() { - if( unc == null ) { - char[] in = url.getPath().toCharArray(); - char[] out = new char[in.length]; - int length = in.length, i, o, state, s; - - /* The canonicalization routine - */ - state = 0; - o = 0; - for( i = 0; i < length; i++ ) { - switch( state ) { - case 0: - if( in[i] != '/' ) { - return null; - } - out[o++] = in[i]; - state = 1; - break; - case 1: - if( in[i] == '/' ) { - break; - } else if( in[i] == '.' && - (( i + 1 ) >= length || in[i + 1] == '/' )) { - i++; - break; - } else if(( i + 1 ) < length && - in[i] == '.' && - in[i + 1] == '.' && - (( i + 2 ) >= length || in[i + 2] == '/' )) { - i += 2; - if( o == 1 ) break; - do { - o--; - } while( o > 1 && out[o - 1] != '/' ); - break; - } - state = 2; - case 2: - if( in[i] == '/' ) { - state = 1; - } - out[o++] = in[i]; - break; - } - } - - canon = new String( out, 0, o ); - - if( o > 1 ) { - o--; - i = canon.indexOf( '/', 1 ); - if( i < 0 ) { - share = canon.substring( 1 ); - unc = "\\"; - } else if( i == o ) { - share = canon.substring( 1, i ); - unc = "\\"; - } else { - share = canon.substring( 1, i ); - unc = canon.substring( i, out[o] == '/' ? o : o + 1 ); - unc = unc.replace( '/', '\\' ); - } - } else { - share = null; - unc = "\\"; - } - } - return unc; - } -/** - * Retuns the Windows UNC style path with backslashs intead of forward slashes. - * - * @return The UNC path. - */ - public String getUncPath() { - getUncPath0(); - if( share == null ) { - return "\\\\" + url.getHost(); - } - return "\\\\" + url.getHost() + canon.replace( '/', '\\' ); - } -/** - * Returns the full URL of this SMB resource with '.' and '..' components - * factored out. AnSmbFileconstructed with the result of - * this method will result in anSmbFilethat is equal to - * the original. - * - * @return The canonicalized URL of this SMB resource. - */ - - public String getCanonicalPath() { - String str = url.getAuthority(); - getUncPath0(); - if( str.length() > 0 ) { - return "smb://" + url.getAuthority() + canon; - } - return "smb://"; - } - -/** - * Retrieves the share associated with this SMB resource. In - * the case ofsmb://,smb://workgroup/, - * andsmb://server/URLs which do not specify a share, - *nullwill be returned. - * - * @return The share component ornullif there is no share - */ - - public String getShare() { - return share; - } - - String getServerWithDfs() { - if (dfsReferral != null) { - return dfsReferral.server; - } - return getServer(); - } -/** - * Retrieve the hostname of the server for this SMB resource. If this - *SmbFilereferences a workgroup, the name of the workgroup - * is returned. If thisSmbFilerefers to the root of this - * SMB network hierarchy,nullis returned. - * - * @return The server or workgroup name ornullif this - *SmbFilerefers to the rootsmb://resource. - */ - - public String getServer() { - String str = url.getHost(); - if( str.length() == 0 ) { - return null; - } - return str; - } - -/** - * Returns type of of object this SmbFile represents. - * @return TYPE_FILESYSTEM, TYPE_WORKGROUP, TYPE_SERVER, TYPE_SHARE, - * TYPE_PRINTER, TYPE_NAMED_PIPE, or TYPE_COMM. - */ - public int getType() throws SmbException { - if( type == 0 ) { - if( getUncPath0().length() > 1 ) { - type = TYPE_FILESYSTEM; - } else if( share != null ) { - // treeConnect good enough to test service type - connect0(); - if( share.equals( "IPC$" )) { - type = TYPE_NAMED_PIPE; - } else if( tree.service.equals( "LPT1:" )) { - type = TYPE_PRINTER; - } else if( tree.service.equals( "COMM" )) { - type = TYPE_COMM; - } else { - type = TYPE_SHARE; - } - } else if( url.getAuthority() == null || url.getAuthority().length() == 0 ) { - type = TYPE_WORKGROUP; - } else { - UniAddress addr; - try { - addr = getAddress(); - } catch( UnknownHostException uhe ) { - throw new SmbException( url.toString(), uhe ); - } - if( addr.getAddress() instanceof NbtAddress ) { - int code = ((NbtAddress)addr.getAddress()).getNameType(); - if( code == 0x1d || code == 0x1b ) { - type = TYPE_WORKGROUP; - return type; - } - } - type = TYPE_SERVER; - } - } - return type; - } - boolean isWorkgroup0() throws UnknownHostException { - if( type == TYPE_WORKGROUP || url.getHost().length() == 0 ) { - type = TYPE_WORKGROUP; - return true; - } else { - getUncPath0(); - if( share == null ) { - UniAddress addr = getAddress(); - if( addr.getAddress() instanceof NbtAddress ) { - int code = ((NbtAddress)addr.getAddress()).getNameType(); - if( code == 0x1d || code == 0x1b ) { - type = TYPE_WORKGROUP; - return true; - } - } - type = TYPE_SERVER; - } - } - return false; - } - - Info queryPath( String path, int infoLevel ) throws SmbException { - connect0(); - - if (log.level >= 3) - log.println( "queryPath: " + path ); - - /* normally we'd check the negotiatedCapabilities for CAP_NT_SMBS - * however I can't seem to get a good last modified time from - * SMB_COM_QUERY_INFORMATION so if NT_SMBs are requested - * by the server than in this case that's what it will get - * regardless of what jcifs.smb.client.useNTSmbs is set - * to(overrides negotiatedCapabilities). - */ - - /* We really should do the referral before this in case - * the redirected target has different capabilities. But - * the way we have been doing that is to call exists() which - * calls this method so another technique will be necessary - * to support DFS referral _to_ Win95/98/ME. - */ - - if( tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS )) { - - /* - * Trans2 Query Path Information Request / Response - */ - - Trans2QueryPathInformationResponse response = - new Trans2QueryPathInformationResponse( infoLevel ); - send( new Trans2QueryPathInformation( path, infoLevel ), response ); - - return response.info; - } else { - - /* - * Query Information Request / Response - */ - - SmbComQueryInformationResponse response = - new SmbComQueryInformationResponse( - tree.session.transport.server.serverTimeZone * 1000 * 60L ); - send( new SmbComQueryInformation( path ), response ); - return response; - } - } - -/** - * Tests to see if the SMB resource exists. If the resource refers - * only to a server, this method determines if the server exists on the - * network and is advertising SMB services. If this resource refers to - * a workgroup, this method determines if the workgroup name is valid on - * the local SMB network. If thisSmbFilerefers to the root - *smb://resourcetrueis always returned. If - * thisSmbFileis a traditional file or directory, it will - * be queried for on the specified server as expected. - * - * @returntrueif the resource exists or is alive or - *falseotherwise - */ - - public boolean exists() throws SmbException { - - if( attrExpiration > System.currentTimeMillis() ) { - return isExists; - } - - attributes = ATTR_READONLY | ATTR_DIRECTORY; - createTime = 0L; - lastModified = 0L; - isExists = false; - - try { - if( url.getHost().length() == 0 ) { - } else if( share == null ) { - if( getType() == TYPE_WORKGROUP ) { - UniAddress.getByName( url.getHost(), true ); - } else { - UniAddress.getByName( url.getHost() ).getHostName(); - } - } else if( getUncPath0().length() == 1 || - share.equalsIgnoreCase( "IPC$" )) { - connect0(); // treeConnect is good enough - } else { - Info info = queryPath( getUncPath0(), - Trans2QueryPathInformationResponse.SMB_QUERY_FILE_BASIC_INFO ); - attributes = info.getAttributes(); - createTime = info.getCreateTime(); - lastModified = info.getLastWriteTime(); - } - - /* If any of the above fail, isExists will not be set true - */ - - isExists = true; - - } catch( UnknownHostException uhe ) { - } catch( SmbException se ) { - switch (se.getNtStatus()) { - case NtStatus.NT_STATUS_NO_SUCH_FILE: - case NtStatus.NT_STATUS_OBJECT_NAME_INVALID: - case NtStatus.NT_STATUS_OBJECT_NAME_NOT_FOUND: - case NtStatus.NT_STATUS_OBJECT_PATH_NOT_FOUND: - break; - default: - throw se; - } - } - - attrExpiration = System.currentTimeMillis() + attrExpirationPeriod; - - return isExists; - } - -/** - * Tests to see if the file thisSmbFilerepresents can be - * read. Because any file, directory, or other resource can be read if it - * exists, this method simply calls theexistsmethod. - * - * @returntrueif the file is read-only - */ - - public boolean canRead() throws SmbException { - if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for reading? - return true; - } - return exists(); // try opening and catch sharing violation? - } - -/** - * Tests to see if the file thisSmbFilerepresents - * exists and is not marked read-only. By default, resources are - * considered to be read-only and therefore forsmb://, - *smb://workgroup/, andsmb://server/resources - * will be read-only. - * - * @returntrueif the resource exists is not marked - * read-only - */ - - public boolean canWrite() throws SmbException { - if( getType() == TYPE_NAMED_PIPE ) { // try opening the pipe for writing? - return true; - } - return exists() && ( attributes & ATTR_READONLY ) == 0; - } - -/** - * Tests to see if the file thisSmbFilerepresents is a directory. - * - * @returntrueif thisSmbFileis a directory - */ - - public boolean isDirectory() throws SmbException { - if( getUncPath0().length() == 1 ) { - return true; - } - if (!exists()) return false; - return ( attributes & ATTR_DIRECTORY ) == ATTR_DIRECTORY; - } - -/** - * Tests to see if the file thisSmbFilerepresents is not a directory. - * - * @returntrueif thisSmbFileis not a directory - */ - - public boolean isFile() throws SmbException { - if( getUncPath0().length() == 1 ) { - return false; - } - exists(); - return ( attributes & ATTR_DIRECTORY ) == 0; - } - -/** - * Tests to see if the file this SmbFile represents is marked as - * hidden. This method will also return true for shares with names that - * end with '$' such asIPC$orC$. - * - * @returntrueif theSmbFileis marked as being hidden - */ - - public boolean isHidden() throws SmbException { - if( share == null ) { - return false; - } else if( getUncPath0().length() == 1 ) { - if( share.endsWith( "$" )) { - return true; - } - return false; - } - exists(); - return ( attributes & ATTR_HIDDEN ) == ATTR_HIDDEN; - } - -/** - * If the path of thisSmbFilefalls within a DFS volume, - * this method will return the referral path to which it maps. Otherwise - *nullis returned. - */ - - public String getDfsPath() throws SmbException { - resolveDfs(null); - if( dfsReferral == null ) { - return null; - } - String path = "smb:/" + dfsReferral.server + "/" + dfsReferral.share + unc; - path = path.replace( '\\', '/' ); - if (isDirectory()) { - path += '/'; - } - return path; - } - -/** - * Retrieve the time thisSmbFilewas created. The value - * returned is suitable for constructing a {@link Date} object - * (i.e. seconds since Epoch 1970). Times should be the same as those - * reported using the properties dialog of the Windows Explorer program. - * - * For Win95/98/Me this is actually the last write time. It is currently - * not possible to retrieve the create time from files on these systems. - * - * @return The number of milliseconds since the 00:00:00 GMT, January 1, - * 1970 as alongvalue - */ - public long createTime() throws SmbException { - if( getUncPath0().length() > 1 ) { - exists(); - return createTime; - } - return 0L; - } -/** - * Retrieve the last time the file represented by this - *SmbFilewas modified. The value returned is suitable for - * constructing a {@link Date} object (i.e. seconds since Epoch - * 1970). Times should be the same as those reported using the properties - * dialog of the Windows Explorer program. - * - * @return The number of milliseconds since the 00:00:00 GMT, January 1, - * 1970 as alongvalue - */ - public long lastModified() throws SmbException { - if( getUncPath0().length() > 1 ) { - exists(); - return lastModified; - } - return 0L; - } -/** - * List the contents of this SMB resource. The list returned by this - * method will be; - * - *- *
- * - * @return A- files and directories contained within this resource if the - * resource is a normal disk file directory, - *
- all available NetBIOS workgroups or domains if this resource is - * the top level URL
smb://, - *- all servers registered as members of a NetBIOS workgroup if this - * resource refers to a workgroup in a
smb://workgroup/URL, - *- all browseable shares of a server including printers, IPC - * services, or disk volumes if this resource is a server URL in the form - *
smb://server/, - *- or
nullif the resource cannot be resolved. - *String[]array of files and directories, - * workgroups, servers, or shares depending on the context of the - * resource URL - */ - public String[] list() throws SmbException { - return list( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); - } - -/** - * List the contents of this SMB resource. The list returned will be - * identical to the list returned by the parameterlesslist()- * method minus filenames filtered by the specified filter. - * - * @param filter a filename filter to exclude filenames from the results - * @throws SmbException - # @return An array of filenames - */ - public String[] list( SmbFilenameFilter filter ) throws SmbException { - return list( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); - } - -/** - * List the contents of this SMB resource as an array of - *SmbFileobjects. This method is much more efficient than - * the regularlistmethod when querying attributes of each - * file in the result set. - *- * The list of
SmbFiles returned by this method will be; - * - *- *
- * - * @return An array of- files and directories contained within this resource if the - * resource is a normal disk file directory, - *
- all available NetBIOS workgroups or domains if this resource is - * the top level URL
smb://, - *- all servers registered as members of a NetBIOS workgroup if this - * resource refers to a workgroup in a
smb://workgroup/URL, - *- all browseable shares of a server including printers, IPC - * services, or disk volumes if this resource is a server URL in the form - *
smb://server/, - *- or
nullif the resource cannot be resolved. - *SmbFileobjects representing file - * and directories, workgroups, servers, or shares depending on the context - * of the resource URL - */ - public SmbFile[] listFiles() throws SmbException { - return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); - } - -/** - * The CIFS protocol provides for DOS "wildcards" to be used as - * a performance enhancement. The client does not have to filter - * the names and the server does not have to return all directory - * entries. - *- * The wildcard expression may consist of two special meta - * characters in addition to the normal filename characters. The '*' - * character matches any number of characters in part of a name. If - * the expression begins with one or more '?'s then exactly that - * many characters will be matched whereas if it ends with '?'s - * it will match that many characters or less. - *
- * Wildcard expressions will not filter workgroup names or server names. - * - *
- * - * @param wildcard a wildcard expression - * @throws SmbException - * @return An array of- * winnt> ls c?o* - * clock.avi -rw-- 82944 Mon Oct 14 1996 1:38 AM - * Cookies drw-- 0 Fri Nov 13 1998 9:42 PM - * 2 items in 5ms - *SmbFileobjects representing file - * and directories, workgroups, servers, or shares depending on the context - * of the resource URL - */ - - public SmbFile[] listFiles( String wildcard ) throws SmbException { - return listFiles( wildcard, ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); - } -/** - * List the contents of this SMB resource. The list returned will be - * identical to the list returned by the parameterlesslistFiles()- * method minus files filtered by the specified filename filter. - * - * @param filter a filter to exclude files from the results - * @return An array of SmbFile objects - * @throws SmbException - */ - public SmbFile[] listFiles( SmbFilenameFilter filter ) throws SmbException { - return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, filter, null ); - } -/** - * List the contents of this SMB resource. The list returned will be - * identical to the list returned by the parameterlesslistFiles()- * method minus filenames filtered by the specified filter. - * - * @param filter a file filter to exclude files from the results - * @return An array of SmbFile objects - */ - public SmbFile[] listFiles( SmbFileFilter filter ) throws SmbException { - return listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, filter ); - } - String[] list( String wildcard, int searchAttributes, - SmbFilenameFilter fnf, SmbFileFilter ff ) throws SmbException { - ArrayList list = new ArrayList(); - doEnum(list, false, wildcard, searchAttributes, fnf, ff); - return (String[])list.toArray(new String[list.size()]); - } - SmbFile[] listFiles( String wildcard, int searchAttributes, - SmbFilenameFilter fnf, SmbFileFilter ff ) throws SmbException { - ArrayList list = new ArrayList(); - doEnum(list, true, wildcard, searchAttributes, fnf, ff); - return (SmbFile[])list.toArray(new SmbFile[list.size()]); - } - void doEnum(ArrayList list, - boolean files, - String wildcard, - int searchAttributes, - SmbFilenameFilter fnf, - SmbFileFilter ff) throws SmbException { - if (ff != null && ff instanceof DosFileFilter) { - DosFileFilter dff = (DosFileFilter)ff; - if (dff.wildcard != null) - wildcard = dff.wildcard; - searchAttributes = dff.attributes; - } - - try { - int hostlen = url.getHost().length(); - if (hostlen == 0 || getType() == TYPE_WORKGROUP) { - doNetServerEnum(list, files, wildcard, searchAttributes, fnf, ff); - } else if (share == null) { - doShareEnum(list, files, wildcard, searchAttributes, fnf, ff); - } else { - doFindFirstNext(list, files, wildcard, searchAttributes, fnf, ff); - } - } catch (UnknownHostException uhe) { - throw new SmbException(url.toString(), uhe); - } catch (MalformedURLException mue) { - throw new SmbException(url.toString(), mue); - } - } - void doShareEnum(ArrayList list, - boolean files, - String wildcard, - int searchAttributes, - SmbFilenameFilter fnf, - SmbFileFilter ff) throws SmbException, - UnknownHostException, - MalformedURLException { - String p = url.getPath(); - IOException last = null; - FileEntry[] entries; - UniAddress addr; - FileEntry e; - HashMap map; - - if (p.lastIndexOf('/') != (p.length() - 1)) - throw new SmbException(url.toString() + " directory must end with '/'"); - if (getType() != TYPE_SERVER) - throw new SmbException("The requested list operations is invalid: " + url.toString()); - - map = new HashMap(); - - if (dfs.isTrustedDomain(getServer(), auth)) { - /* The server name is actually the name of a trusted - * domain. Add DFS roots to the list. - */ - try { - entries = doDfsRootEnum(); - for (int ei = 0; ei < entries.length; ei++) { - e = entries[ei]; - if (map.containsKey(e) == false) - map.put(e, e); - } - } catch (IOException ioe) { - if (log.level >= 4) - ioe.printStackTrace(log); - } - } - - addr = getFirstAddress(); - while (addr != null) { - try { - doConnect(); - try { - entries = doMsrpcShareEnum(); - } catch(IOException ioe) { - if (log.level >= 3) - ioe.printStackTrace(log); - entries = doNetShareEnum(); - } - for (int ei = 0; ei < entries.length; ei++) { - e = entries[ei]; - if (map.containsKey(e) == false) - map.put(e, e); - } - break; - } catch(IOException ioe) { - if (log.level >= 3) - ioe.printStackTrace(log); - last = ioe; - } - addr = getNextAddress(); - } - - if (last != null && map.isEmpty()) { - if (last instanceof SmbException == false) - throw new SmbException(url.toString(), last); - throw (SmbException)last; - } - - Iterator iter = map.keySet().iterator(); - while (iter.hasNext()) { - e = (FileEntry)iter.next(); - String name = e.getName(); - if (fnf != null && fnf.accept(this, name) == false) - continue; - if (name.length() > 0) { - // if !files we don't need to create SmbFiles here - SmbFile f = new SmbFile(this, name, e.getType(), - ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L ); - if (ff != null && ff.accept(f) == false) - continue; - if (files) { - list.add(f); - } else { - list.add(name); - } - } - } - } - FileEntry[] doDfsRootEnum() throws IOException { - MsrpcDfsRootEnum rpc; - DcerpcHandle handle = null; - FileEntry[] entries; - - handle = DcerpcHandle.getHandle("ncacn_np:" + - getAddress().getHostAddress() + - "[\\PIPE\\netdfs]", auth); - try { - rpc = new MsrpcDfsRootEnum(getServer()); - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, true); - return rpc.getEntries(); - } finally { - try { - handle.close(); - } catch(IOException ioe) { - if (log.level >= 4) - ioe.printStackTrace(log); - } - } - } - FileEntry[] doMsrpcShareEnum() throws IOException { - MsrpcShareEnum rpc; - DcerpcHandle handle; - - rpc = new MsrpcShareEnum(url.getHost()); - - /* JCIFS will build a composite list of shares if the target host has - * multiple IP addresses such as when domain-based DFS is in play. Because - * of this, to ensure that we query each IP individually without re-resolving - * the hostname and getting a different IP, we must use the current addresses - * IP rather than just url.getHost() like we were using prior to 1.2.16. - */ - - handle = DcerpcHandle.getHandle("ncacn_np:" + - getAddress().getHostAddress() + - "[\\PIPE\\srvsvc]", auth); - - try { - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, true); - return rpc.getEntries(); - } finally { - try { - handle.close(); - } catch(IOException ioe) { - if (log.level >= 4) - ioe.printStackTrace(log); - } - } - } - FileEntry[] doNetShareEnum() throws SmbException { - SmbComTransaction req = new NetShareEnum(); - SmbComTransactionResponse resp = new NetShareEnumResponse(); - - send(req, resp); - - if (resp.status != SmbException.ERROR_SUCCESS) - throw new SmbException(resp.status, true); - - return resp.results; - } - void doNetServerEnum(ArrayList list, - boolean files, - String wildcard, - int searchAttributes, - SmbFilenameFilter fnf, - SmbFileFilter ff) throws SmbException, - UnknownHostException, - MalformedURLException { - int listType = url.getHost().length() == 0 ? 0 : getType(); - SmbComTransaction req; - SmbComTransactionResponse resp; - - if (listType == 0) { - connect0(); - req = new NetServerEnum2(tree.session.transport.server.oemDomainName, - NetServerEnum2.SV_TYPE_DOMAIN_ENUM ); - resp = new NetServerEnum2Response(); - } else if (listType == TYPE_WORKGROUP) { - req = new NetServerEnum2(url.getHost(), NetServerEnum2.SV_TYPE_ALL); - resp = new NetServerEnum2Response(); - } else { - throw new SmbException( "The requested list operations is invalid: " + url.toString() ); - } - - boolean more; - do { - int n; - - send(req, resp); - - if (resp.status != SmbException.ERROR_SUCCESS && - resp.status != SmbException.ERROR_MORE_DATA) { - throw new SmbException( resp.status, true ); - } - more = resp.status == SmbException.ERROR_MORE_DATA; - - n = more ? resp.numEntries - 1 : resp.numEntries; - for (int i = 0; i < n; i++) { - FileEntry e = resp.results[i]; - String name = e.getName(); - if (fnf != null && fnf.accept(this, name) == false) - continue; - if (name.length() > 0) { - // if !files we don't need to create SmbFiles here - SmbFile f = new SmbFile(this, name, e.getType(), - ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L ); - if (ff != null && ff.accept(f) == false) - continue; - if (files) { - list.add(f); - } else { - list.add(name); - } - } - } - if (getType() != TYPE_WORKGROUP) { - break; - } - req.subCommand = (byte)SmbComTransaction.NET_SERVER_ENUM3; - req.reset(0, ((NetServerEnum2Response)resp).lastName); - resp.reset(); - } while(more); - } - void doFindFirstNext( ArrayList list, - boolean files, - String wildcard, - int searchAttributes, - SmbFilenameFilter fnf, - SmbFileFilter ff ) throws SmbException, UnknownHostException, MalformedURLException { - SmbComTransaction req; - Trans2FindFirst2Response resp; - int sid; - String path = getUncPath0(); - String p = url.getPath(); - - if( p.lastIndexOf( '/' ) != ( p.length() - 1 )) { - throw new SmbException( url.toString() + " directory must end with '/'" ); - } - - req = new Trans2FindFirst2( path, wildcard, searchAttributes ); - resp = new Trans2FindFirst2Response(); - - if( log.level >= 3 ) - log.println( "doFindFirstNext: " + req.path ); - - send( req, resp ); - - sid = resp.sid; - req = new Trans2FindNext2( sid, resp.resumeKey, resp.lastName ); - - /* The only difference between first2 and next2 responses is subCommand - * so let's recycle the response object. - */ - resp.subCommand = SmbComTransaction.TRANS2_FIND_NEXT2; - - for( ;; ) { - for( int i = 0; i < resp.numEntries; i++ ) { - FileEntry e = resp.results[i]; - String name = e.getName(); - if( name.length() < 3 ) { - int h = name.hashCode(); - if( h == HASH_DOT || h == HASH_DOT_DOT ) { - if (name.equals(".") || name.equals("..")) - continue; - } - } - if( fnf != null && fnf.accept( this, name ) == false ) { - continue; - } - if( name.length() > 0 ) { - SmbFile f = new SmbFile( this, name, TYPE_FILESYSTEM, - e.getAttributes(), e.createTime(), e.lastModified(), e.length() ); - if( ff != null && ff.accept( f ) == false ) { - continue; - } - if( files ) { - list.add( f ); - } else { - list.add( name ); - } - } - } - - if( resp.isEndOfSearch || resp.numEntries == 0 ) { - break; - } - - req.reset( resp.resumeKey, resp.lastName ); - resp.reset(); - send( req, resp ); - } - - try { - send( new SmbComFindClose2( sid ), blank_resp() ); - } catch (SmbException se) { - if( log.level >= 4 ) - se.printStackTrace( log ); - } - } - -/** - * Changes the name of the file thisSmbFilerepresents to the name - * designated by theSmbFileargument. - * - * Remember:SmbFiles are immutible and therefore - * the path associated with thisSmbFileobject will not - * change). To access the renamed file it is necessary to construct a - * new SmbFile. - * - * @param dest AnSmbFilethat represents the new pathname - * @throws NullPointerException - * If thedestargument isnull- */ - public void renameTo( SmbFile dest ) throws SmbException { - if( getUncPath0().length() == 1 || dest.getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - resolveDfs(null); - dest.resolveDfs(null); - - if (!tree.equals(dest.tree)) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - if( log.level >= 3 ) - log.println( "renameTo: " + unc + " -> " + dest.unc ); - - attrExpiration = sizeExpiration = 0; - dest.attrExpiration = 0; - - /* - * Rename Request / Response - */ - - send( new SmbComRename( unc, dest.unc ), blank_resp() ); - } - - class WriterThread extends Thread { - byte[] b; - int n; - long off; - boolean ready; - SmbFile dest; - SmbException e = null; - boolean useNTSmbs; - SmbComWriteAndX reqx; - SmbComWrite req; - ServerMessageBlock resp; - - WriterThread() throws SmbException { - super( "JCIFS-WriterThread" ); - useNTSmbs = tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS ); - if( useNTSmbs ) { - reqx = new SmbComWriteAndX(); - resp = new SmbComWriteAndXResponse(); - } else { - req = new SmbComWrite(); - resp = new SmbComWriteResponse(); - } - ready = false; - } - - synchronized void write( byte[] b, int n, SmbFile dest, long off ) { - this.b = b; - this.n = n; - this.dest = dest; - this.off = off; - ready = false; - notify(); - } - - public void run() { - synchronized( this ) { - try { - for( ;; ) { - notify(); - ready = true; - while( ready ) { - wait(); - } - if( n == -1 ) { - return; - } - if( useNTSmbs ) { - reqx.setParam( dest.fid, off, n, b, 0, n ); - dest.send( reqx, resp ); - } else { - req.setParam( dest.fid, off, n, b, 0, n ); - dest.send( req, resp ); - } - } - } catch( SmbException e ) { - this.e = e; - } catch( Exception x ) { - this.e = new SmbException( "WriterThread", x ); - } - notify(); - } - } - } - void copyTo0( SmbFile dest, byte[][] b, int bsize, WriterThread w, - SmbComReadAndX req, SmbComReadAndXResponse resp ) throws SmbException { - int i; - - if( attrExpiration < System.currentTimeMillis() ) { - attributes = ATTR_READONLY | ATTR_DIRECTORY; - createTime = 0L; - lastModified = 0L; - isExists = false; - - Info info = queryPath( getUncPath0(), - Trans2QueryPathInformationResponse.SMB_QUERY_FILE_BASIC_INFO ); - attributes = info.getAttributes(); - createTime = info.getCreateTime(); - lastModified = info.getLastWriteTime(); - - /* If any of the above fails, isExists will not be set true - */ - - isExists = true; - attrExpiration = System.currentTimeMillis() + attrExpirationPeriod; - } - - if( isDirectory() ) { - SmbFile[] files; - SmbFile ndest; - - String path = dest.getUncPath0(); - if( path.length() > 1 ) { - try { - dest.mkdir(); - dest.setPathInformation( attributes, createTime, lastModified ); - } catch( SmbException se ) { - if( se.getNtStatus() != NtStatus.NT_STATUS_ACCESS_DENIED && - se.getNtStatus() != NtStatus.NT_STATUS_OBJECT_NAME_COLLISION ) { - throw se; - } - } - } - - files = listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); - try { - for( i = 0; i < files.length; i++ ) { - ndest = new SmbFile( dest, - files[i].getName(), - files[i].type, - files[i].attributes, - files[i].createTime, - files[i].lastModified, - files[i].size ); - files[i].copyTo0( ndest, b, bsize, w, req, resp ); - } - } catch( UnknownHostException uhe ) { - throw new SmbException( url.toString(), uhe ); - } catch( MalformedURLException mue ) { - throw new SmbException( url.toString(), mue ); - } - } else { - long off; - - try { - open( SmbFile.O_RDONLY, 0, ATTR_NORMAL, 0 ); - try { - dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC, - FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES, - attributes, 0 ); - } catch( SmbAuthException sae ) { - if(( dest.attributes & ATTR_READONLY ) != 0 ) { - /* Remove READONLY and try again - */ - dest.setPathInformation( dest.attributes & ~ATTR_READONLY, 0L, 0L ); - dest.open( SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC, - FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES, - attributes, 0 ); - } else { - throw sae; - } - } - - i = 0; - off = 0L; - for( ;; ) { - req.setParam( fid, off, bsize ); - resp.setParam( b[i], 0 ); - send( req, resp ); - - synchronized( w ) { - if( w.e != null ) { - throw w.e; - } - while( !w.ready ) { - try { - w.wait(); - } catch( InterruptedException ie ) { - throw new SmbException( dest.url.toString(), ie ); - } - } - if( w.e != null ) { - throw w.e; - } - if( resp.dataLength <= 0 ) { - break; - } - w.write( b[i], resp.dataLength, dest, off ); - } - - i = i == 1 ? 0 : 1; - off += resp.dataLength; - } - - dest.send( new Trans2SetFileInformation( - dest.fid, attributes, createTime, lastModified ), - new Trans2SetFileInformationResponse() ); - dest.close( 0L ); - } catch( SmbException se ) { - - if (ignoreCopyToException == false) - throw new SmbException("Failed to copy file from [" + this.toString() + "] to [" + dest.toString() + "]", se); - - if( log.level > 1 ) - se.printStackTrace( log ); - } finally { - close(); - } - } - } -/** - * This method will copy the file or directory represented by this - * SmbFile and it's sub-contents to the location specified by the - * dest parameter. This file and the destination file do not - * need to be on the same host. This operation does not copy extended - * file attibutes such as ACLs but it does copy regular attributes as - * well as create and last write times. This method is almost twice as - * efficient as manually copying as it employs an additional write - * thread to read and write data concurrently. - * - * It is not possible (nor meaningful) to copy entire workgroups or - * servers. - * - * @param dest the destination file or directory - * @throws SmbException - */ - public void copyTo( SmbFile dest ) throws SmbException { - SmbComReadAndX req; - SmbComReadAndXResponse resp; - WriterThread w; - int bsize; - byte[][] b; - - /* Should be able to copy an entire share actually - */ - if( share == null || dest.share == null) { - throw new SmbException( "Invalid operation for workgroups or servers" ); - } - - req = new SmbComReadAndX(); - resp = new SmbComReadAndXResponse(); - - connect0(); - dest.connect0(); - - /* At this point the maxBufferSize values are from the server - * exporting the volumes, not the one that we will actually - * end up performing IO with. If the server hosting the - * actual files has a smaller maxBufSize this could be - * incorrect. To handle this properly it is necessary - * to redirect the tree to the target server first before - * establishing buffer size. These exists() calls facilitate - * that. - */ - resolveDfs(null); - - /* It is invalid for the source path to be a child of the destination - * path or visa versa. - */ - try { - if (getAddress().equals( dest.getAddress() ) && - canon.regionMatches( true, 0, dest.canon, 0, - Math.min( canon.length(), dest.canon.length() ))) { - throw new SmbException( "Source and destination paths overlap." ); - } - } catch (UnknownHostException uhe) { - } - - w = new WriterThread(); - w.setDaemon( true ); - w.start(); - - /* Downgrade one transport to the lower of the negotiated buffer sizes - * so we can just send whatever is received. - */ - - SmbTransport t1 = tree.session.transport; - SmbTransport t2 = dest.tree.session.transport; - - if( t1.snd_buf_size < t2.snd_buf_size ) { - t2.snd_buf_size = t1.snd_buf_size; - } else { - t1.snd_buf_size = t2.snd_buf_size; - } - - bsize = Math.min( t1.rcv_buf_size - 70, t1.snd_buf_size - 70 ); - b = new byte[2][bsize]; - - try { - copyTo0( dest, b, bsize, w, req, resp ); - } finally { - w.write( null, -1, null, 0 ); - } - } - -/** - * This method will delete the file or directory specified by this - *SmbFile. If the target is a directory, the contents of - * the directory will be deleted as well. If a file within the directory or - * it's sub-directories is marked read-only, the read-only status will - * be removed and the file will be deleted. - * - * @throws SmbException - */ - public void delete() throws SmbException { - exists(); - getUncPath0(); - delete( unc ); - } - void delete( String fileName ) throws SmbException { - if( getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - if( System.currentTimeMillis() > attrExpiration ) { - attributes = ATTR_READONLY | ATTR_DIRECTORY; - createTime = 0L; - lastModified = 0L; - isExists = false; - - Info info = queryPath( getUncPath0(), - Trans2QueryPathInformationResponse.SMB_QUERY_FILE_BASIC_INFO ); - attributes = info.getAttributes(); - createTime = info.getCreateTime(); - lastModified = info.getLastWriteTime(); - - attrExpiration = System.currentTimeMillis() + attrExpirationPeriod; - isExists = true; - } - - if(( attributes & ATTR_READONLY ) != 0 ) { - setReadWrite(); - } - - /* - * Delete or Delete Directory Request / Response - */ - - if( log.level >= 3 ) - log.println( "delete: " + fileName ); - - if(( attributes & ATTR_DIRECTORY ) != 0 ) { - - /* Recursively delete directory contents - */ - - try { - SmbFile[] l = listFiles( "*", ATTR_DIRECTORY | ATTR_HIDDEN | ATTR_SYSTEM, null, null ); - for( int i = 0; i < l.length; i++ ) { - l[i].delete(); - } - } catch( SmbException se ) { - /* Oracle FilesOnline version 9.0.4 doesn't send '.' and '..' so - * listFiles may generate undesireable "cannot find - * the file specified". - */ - if( se.getNtStatus() != SmbException.NT_STATUS_NO_SUCH_FILE ) { - throw se; - } - } - - send( new SmbComDeleteDirectory( fileName ), blank_resp() ); - } else { - send( new SmbComDelete( fileName ), blank_resp() ); - } - - attrExpiration = sizeExpiration = 0; - } - -/** - * Returns the length of this SmbFile in bytes. If this object - * is a TYPE_SHARE the total capacity of the disk shared in - * bytes is returned. If this object is a directory or a type other than - * TYPE_SHARE, 0L is returned. - * - * @return The length of the file in bytes or 0 if this - *SmbFileis not a file. - * @throws SmbException - */ - - public long length() throws SmbException { - if( sizeExpiration > System.currentTimeMillis() ) { - return size; - } - - if( getType() == TYPE_SHARE ) { - Trans2QueryFSInformationResponse response; - int level = Trans2QueryFSInformationResponse.SMB_INFO_ALLOCATION; - - response = new Trans2QueryFSInformationResponse( level ); - send( new Trans2QueryFSInformation( level ), response ); - - size = response.info.getCapacity(); - } else if( getUncPath0().length() > 1 && type != TYPE_NAMED_PIPE ) { - Info info = queryPath( getUncPath0(), - Trans2QueryPathInformationResponse.SMB_QUERY_FILE_STANDARD_INFO ); - size = info.getSize(); - } else { - size = 0L; - } - sizeExpiration = System.currentTimeMillis() + attrExpirationPeriod; - return size; - } - -/** - * This method returns the free disk space in bytes of the drive this share - * represents or the drive on which the directory or file resides. Objects - * other than TYPE_SHARE or TYPE_FILESYSTEM will result - * in 0L being returned. - * - * @return the free disk space in bytes of the drive on which this file or - * directory resides - */ - public long getDiskFreeSpace() throws SmbException { - if( getType() == TYPE_SHARE || type == TYPE_FILESYSTEM ) { - int level = Trans2QueryFSInformationResponse.SMB_FS_FULL_SIZE_INFORMATION; - try { - return queryFSInformation(level); - } catch( SmbException ex ) { - switch (ex.getNtStatus()) { - case NtStatus.NT_STATUS_INVALID_INFO_CLASS: - case NtStatus.NT_STATUS_UNSUCCESSFUL: // NetApp Filer - // SMB_FS_FULL_SIZE_INFORMATION not supported by the server. - level = Trans2QueryFSInformationResponse.SMB_INFO_ALLOCATION; - return queryFSInformation(level); - } - throw ex; - } - } - return 0L; - } - - private long queryFSInformation( int level ) throws SmbException { - Trans2QueryFSInformationResponse response; - - response = new Trans2QueryFSInformationResponse( level ); - send( new Trans2QueryFSInformation( level ), response ); - - if( type == TYPE_SHARE ) { - size = response.info.getCapacity(); - sizeExpiration = System.currentTimeMillis() + attrExpirationPeriod; - } - - return response.info.getFree(); - } - -/** - * Creates a directory with the path specified by this - *SmbFile. For this method to be successful, the target - * must not already exist. This method will fail when - * used withsmb://,smb://workgroup/, - *smb://server/, orsmb://server/share/URLs - * because workgroups, servers, and shares cannot be dynamically created - * (although in the future it may be possible to create shares). - * - * @throws SmbException - */ - public void mkdir() throws SmbException { - String path = getUncPath0(); - - if( path.length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - /* - * Create Directory Request / Response - */ - - if( log.level >= 3 ) - log.println( "mkdir: " + path ); - - send( new SmbComCreateDirectory( path ), blank_resp() ); - - attrExpiration = sizeExpiration = 0; - } - -/** - * Creates a directory with the path specified by this SmbFile - * and any parent directories that do not exist. This method will fail - * when used withsmb://,smb://workgroup/, - *smb://server/, orsmb://server/share/URLs - * because workgroups, servers, and shares cannot be dynamically created - * (although in the future it may be possible to create shares). - * - * @throws SmbException - */ - public void mkdirs() throws SmbException { - SmbFile parent; - - try { - parent = new SmbFile( getParent(), auth ); - } catch( IOException ioe ) { - return; - } - if( parent.exists() == false ) { - parent.mkdirs(); - } - mkdir(); - } - -/** - * Create a new file but fail if it already exists. The check for - * existance of the file and it's creation are an atomic operation with - * respect to other filesystem activities. - */ - public void createNewFile() throws SmbException { - if( getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - close( open0( O_RDWR | O_CREAT | O_EXCL, 0, ATTR_NORMAL, 0 ), 0L ); - } - - void setPathInformation( int attrs, long ctime, long mtime ) throws SmbException { - int f, dir; - - exists(); - dir = attributes & ATTR_DIRECTORY; - - f = open0( O_RDONLY, FILE_WRITE_ATTRIBUTES, - dir, dir != 0 ? 0x0001 : 0x0040 ); - send( new Trans2SetFileInformation( f, attrs | dir, ctime, mtime ), - new Trans2SetFileInformationResponse() ); - close( f, 0L ); - - attrExpiration = 0; - } - -/** - * Set the create time of the file. The time is specified as milliseconds - * from Jan 1, 1970 which is the same as that which is returned by the - * createTime() method. - * - * This method does not apply to workgroups, servers, or shares. - * - * @param time the create time as milliseconds since Jan 1, 1970 - */ - public void setCreateTime( long time ) throws SmbException { - if( getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - setPathInformation( 0, time, 0L ); - } -/** - * Set the last modified time of the file. The time is specified as milliseconds - * from Jan 1, 1970 which is the same as that which is returned by the - * lastModified(), getLastModified(), and getDate() methods. - * - * This method does not apply to workgroups, servers, or shares. - * - * @param time the last modified time as milliseconds since Jan 1, 1970 - */ - public void setLastModified( long time ) throws SmbException { - if( getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - - setPathInformation( 0, 0L, time ); - } - -/** - * Return the attributes of this file. Attributes are represented as a - * bitset that must be masked with ATTR_* constants to determine - * if they are set or unset. The value returned is suitable for use with - * the setAttributes() method. - * - * @return the ATTR_* attributes associated with this file - * @throws SmbException - */ - public int getAttributes() throws SmbException { - if( getUncPath0().length() == 1 ) { - return 0; - } - exists(); - return attributes & ATTR_GET_MASK; - } - -/** - * Set the attributes of this file. Attributes are composed into a - * bitset by bitwise ORing the ATTR_* constants. Setting the - * value returned by getAttributes will result in both files - * having the same attributes. - * @throws SmbException - */ - public void setAttributes( int attrs ) throws SmbException { - if( getUncPath0().length() == 1 ) { - throw new SmbException( "Invalid operation for workgroups, servers, or shares" ); - } - setPathInformation( attrs & ATTR_SET_MASK, 0L, 0L ); - } - -/** - * Make this file read-only. This is shorthand for setAttributes( - * getAttributes() | ATTR_READ_ONLY ). - * - * @throws SmbException - */ - public void setReadOnly() throws SmbException { - setAttributes( getAttributes() | ATTR_READONLY ); - } - -/** - * Turn off the read-only attribute of this file. This is shorthand for - * setAttributes( getAttributes() & ~ATTR_READONLY ). - * - * @throws SmbException - */ - public void setReadWrite() throws SmbException { - setAttributes( getAttributes() & ~ATTR_READONLY ); - } - -/** - * Returns a {@link URL} for thisSmbFile. The - *URLmay be used as any otherURLmight to - * access an SMB resource. Currently only retrieving data and information - * is supported (i.e. no doOutput). - * - * @deprecated Use getURL() instead - * @return A new{@link URL}for thisSmbFile- * @throws MalformedURLException - */ - public URL toURL() throws MalformedURLException { - return url; - } - -/** - * Computes a hashCode for this file based on the URL string and IP - * address if the server. The hashing function uses the hashcode of the - * server address, the canonical representation of the URL, and does not - * compare authentication information. In essance, two - *SmbFileobjects that refer to - * the same file should generate the same hashcode provided it is possible - * to make such a determination. - * - * @return A hashcode for this abstract file - * @throws SmbException - */ - - public int hashCode() { - int hash; - try { - hash = getAddress().hashCode(); - } catch( UnknownHostException uhe ) { - hash = getServer().toUpperCase().hashCode(); - } - getUncPath0(); - return hash + canon.toUpperCase().hashCode(); - } - - protected boolean pathNamesPossiblyEqual(String path1, String path2) { - int p1, p2, l1, l2; - - // if unsure return this method returns true - - p1 = path1.lastIndexOf('/'); - p2 = path2.lastIndexOf('/'); - l1 = path1.length() - p1; - l2 = path2.length() - p2; - - // anything with dots voids comparison - if (l1 > 1 && path1.charAt(p1 + 1) == '.') - return true; - if (l2 > 1 && path2.charAt(p2 + 1) == '.') - return true; - - return l1 == l2 && path1.regionMatches(true, p1, path2, p2, l1); - } -/** - * Tests to see if twoSmbFileobjects are equal. Two - * SmbFile objects are equal when they reference the same SMB - * resource. More specifically, twoSmbFileobjects are - * equals if their server IP addresses are equal and the canonicalized - * representation of their URLs, minus authentication parameters, are - * case insensitivly and lexographically equal. - * - * For example, assuming the serverangusresolves to the - *192.168.1.15IP address, the below URLs would result in - *SmbFiles that are equal. - * - *- * - * @param obj Another- * smb://192.168.1.15/share/DIR/foo.txt - * smb://angus/share/data/../dir/foo.txt - *SmbFileobject to compare for equality - * @returntrueif the two objects refer to the same SMB resource - * andfalseotherwise - * @throws SmbException - */ - - public boolean equals( Object obj ) { - if (obj instanceof SmbFile) { - SmbFile f = (SmbFile)obj; - boolean ret; - - if (this == f) - return true; - - /* If uncertain, pathNamesPossiblyEqual returns true. - * Comparing canonical paths is definitive. - */ - if (pathNamesPossiblyEqual(url.getPath(), f.url.getPath())) { - - getUncPath0(); - f.getUncPath0(); - - if (canon.equalsIgnoreCase(f.canon)) { - try { - ret = getAddress().equals(f.getAddress()); - } catch( UnknownHostException uhe ) { - ret = getServer().equalsIgnoreCase(f.getServer()); - } - return ret; - } - } - } - - return false; - } -/* - public boolean equals( Object obj ) { - return obj instanceof SmbFile && obj.hashCode() == hashCode(); - } -*/ - -/** - * Returns the string representation of this SmbFile object. This will - * be the same as the URL used to construct thisSmbFile. - * This method will return the same value - * asgetPath. - * - * @return The original URL representation of this SMB resource - * @throws SmbException - */ - - public String toString() { - return url.toString(); - } - -/* URLConnection implementation */ -/** - * This URLConnection method just returns the result of length(). - * - * @return the length of this file or 0 if it refers to a directory - */ - - public int getContentLength() { - try { - return (int)(length() & 0xFFFFFFFFL); - } catch( SmbException se ) { - } - return 0; - } - -/** - * This URLConnection method just returns the result of lastModified. - * - * @return the last modified data as milliseconds since Jan 1, 1970 - */ - public long getDate() { - try { - return lastModified(); - } catch( SmbException se ) { - } - return 0L; - } - -/** - * This URLConnection method just returns the result of lastModified. - * - * @return the last modified data as milliseconds since Jan 1, 1970 - */ - public long getLastModified() { - try { - return lastModified(); - } catch( SmbException se ) { - } - return 0L; - } - -/** - * This URLConnection method just returns a new SmbFileInputStream created with this file. - * - * @throws IOException thrown by SmbFileInputStream constructor - */ - public InputStream getInputStream() throws IOException { - return new SmbFileInputStream( this ); - } - -/** - * This URLConnection method just returns a new SmbFileOutputStream created with this file. - * - * @throws IOException thrown by SmbFileOutputStream constructor - */ - public OutputStream getOutputStream() throws IOException { - return new SmbFileOutputStream( this ); - } - - private void processAces(ACE[] aces, boolean resolveSids) throws IOException { - String server = getServerWithDfs(); - int ai; - - if (resolveSids) { - SID[] sids = new SID[aces.length]; - String[] names = null; - - for (ai = 0; ai < aces.length; ai++) { - sids[ai] = aces[ai].sid; - } - - for (int off = 0; off < sids.length; off += 64) { - int len = sids.length - off; - if (len > 64) - len = 64; - SID.resolveSids(server, auth, sids, off, len); - } - } else { - for (ai = 0; ai < aces.length; ai++) { - aces[ai].sid.origin_server = server; - aces[ai].sid.origin_auth = auth; - } - } - } -/** - * Return an array of Access Control Entry (ACE) objects representing - * the security descriptor associated with this file or directory. - * If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned. - * @param resolveSids Attempt to resolve the SIDs within each ACE form - * their numeric representation to their corresponding account names. - */ - public ACE[] getSecurity(boolean resolveSids) throws IOException { - int f; - ACE[] aces; - - f = open0( O_RDONLY, READ_CONTROL, 0, isDirectory() ? 1 : 0 ); - - /* - * NtTrans Query Security Desc Request / Response - */ - - NtTransQuerySecurityDesc request = new NtTransQuerySecurityDesc( f, 0x04 ); - NtTransQuerySecurityDescResponse response = new NtTransQuerySecurityDescResponse(); - - try { - send( request, response ); - } finally { - close( f, 0L ); - } - - aces = response.securityDescriptor.aces; - if (aces != null) - processAces(aces, resolveSids); - - return aces; - } -/** - * Return an array of Access Control Entry (ACE) objects representing - * the share permissions on the share exporting this file or directory. - * If no DACL is present, null is returned. If the DACL is empty, an array with 0 elements is returned. - *- * Note that this is different from calling getSecurity on a - * share. There are actually two different ACLs for shares - the ACL on - * the share and the ACL on the folder being shared. - * Go to Computer Management - * > System Tools > Shared Folders > Shares and - * look at the Properties for a share. You will see two tabs - one - * for "Share Permissions" and another for "Security". These correspond to - * the ACLs returned by getShareSecurity and getSecurity - * respectively. - * @param resolveSids Attempt to resolve the SIDs within each ACE form - * their numeric representation to their corresponding account names. - */ - public ACE[] getShareSecurity(boolean resolveSids) throws IOException { - String p = url.getPath(); - MsrpcShareGetInfo rpc; - DcerpcHandle handle; - ACE[] aces; - - resolveDfs(null); - String server = getServerWithDfs(); - - rpc = new MsrpcShareGetInfo(server, tree.share); - handle = DcerpcHandle.getHandle("ncacn_np:" + server + "[\\PIPE\\srvsvc]", auth); - - try { - handle.sendrecv(rpc); - if (rpc.retval != 0) - throw new SmbException(rpc.retval, true); - aces = rpc.getSecurity(); - if (aces != null) - processAces(aces, resolveSids); - } finally { - try { - handle.close(); - } catch(IOException ioe) { - if (log.level >= 1) - ioe.printStackTrace(log); - } - } - - return aces; - } -/** - * Return an array of Access Control Entry (ACE) objects representing - * the security descriptor associated with this file or directory. - *
- * Initially, the SIDs within each ACE will not be resolved however when - * getType(), getDomainName(), getAccountName(), - * or toString() is called, the names will attempt to be - * resolved. If the names cannot be resolved (e.g. due to temporary - * network failure), the said methods will return default values (usually - * S-X-Y-Z strings of fragments of). - *
- * Alternatively getSecurity(true) may be used to resolve all - * SIDs together and detect network failures. - */ - public ACE[] getSecurity() throws IOException { - return getSecurity(false); - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileFilter.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileFilter.java deleted file mode 100644 index 47b90844b2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileFilter.java +++ /dev/null @@ -1,23 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen"
- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public interface SmbFileFilter { - public boolean accept( SmbFile file ) throws SmbException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileInputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileInputStream.java deleted file mode 100644 index 672082ec73..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileInputStream.java +++ /dev/null @@ -1,246 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.transport.TransportException; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InterruptedIOException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; - -/** - * This InputStream can read bytes from a file on an SMB file server. Offsets are 64 bits. - */ - -public class SmbFileInputStream extends InputStream { - - private long fp; - private int readSize, openFlags, access; - private byte[] tmp = new byte[1]; - - SmbFile file; - -/** - * Creates an {@link InputStream} for reading bytes from a file on - * an SMB server addressed by the urlparameter. See {@link - * SmbFile} for a detailed description and examples of the smb - * URL syntax. - * - * @param url An smb URL string representing the file to read from - */ - - public SmbFileInputStream( String url ) throws SmbException, MalformedURLException, UnknownHostException { - this( new SmbFile( url )); - } - -/** - * Creates an {@link InputStream} for reading bytes from a file on - * an SMB server represented by the {@link SmbFile} parameter. See - * {@link SmbFile} for a detailed description and examples of - * the smb URL syntax. - * - * @param file AnSmbFilespecifying the file to read from - */ - - public SmbFileInputStream( SmbFile file ) throws SmbException, MalformedURLException, UnknownHostException { - this( file, SmbFile.O_RDONLY ); - } - - SmbFileInputStream( SmbFile file, int openFlags ) throws SmbException, MalformedURLException, UnknownHostException { - this.file = file; - this.openFlags = openFlags & 0xFFFF; - this.access = (openFlags >>> 16) & 0xFFFF; - if (file.type != SmbFile.TYPE_NAMED_PIPE) { - file.open( openFlags, access, SmbFile.ATTR_NORMAL, 0 ); - this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); - } else { - file.connect0(); - } - readSize = Math.min( file.tree.session.transport.rcv_buf_size - 70, - file.tree.session.transport.server.maxBufferSize - 70 ); - } - - protected IOException seToIoe(SmbException se) { - IOException ioe = se; - Throwable root = se.getRootCause(); - if (root instanceof TransportException) { - ioe = (TransportException)root; - root = ((TransportException)ioe).getRootCause(); - } - if (root instanceof InterruptedException) { - ioe = new InterruptedIOException(root.getMessage()); - ioe.initCause(root); - } - return ioe; - } - -/** - * Closes this input stream and releases any system resources associated with the stream. - * - * @throws IOException if a network error occurs - */ - - public void close() throws IOException { - try { - file.close(); - tmp = null; - } catch (SmbException se) { - throw seToIoe(se); - } - } - -/** - * Reads a byte of data from this input stream. - * - * @throws IOException if a network error occurs - */ - - public int read() throws IOException { - // need oplocks to cache otherwise use BufferedInputStream - if( read( tmp, 0, 1 ) == -1 ) { - return -1; - } - return tmp[0] & 0xFF; - } - -/** - * Reads up to b.length bytes of data from this input stream into an array of bytes. - * - * @throws IOException if a network error occurs - */ - - public int read( byte[] b ) throws IOException { - return read( b, 0, b.length ); - } - -/** - * Reads up to len bytes of data from this input stream into an array of bytes. - * - * @throws IOException if a network error occurs - */ - - public int read( byte[] b, int off, int len ) throws IOException { - return readDirect(b, off, len); - } - public int readDirect( byte[] b, int off, int len ) throws IOException { - if( len <= 0 ) { - return 0; - } - long start = fp; - - if( tmp == null ) { - throw new IOException( "Bad file descriptor" ); - } - // ensure file is open - file.open( openFlags, access, SmbFile.ATTR_NORMAL, 0 ); - - /* - * Read AndX Request / Response - */ - - if( file.log.level >= 4 ) - file.log.println( "read: fid=" + file.fid + ",off=" + off + ",len=" + len ); - - SmbComReadAndXResponse response = new SmbComReadAndXResponse( b, off ); - - if( file.type == SmbFile.TYPE_NAMED_PIPE ) { - response.responseTimeout = 0; - } - - int r, n; - do { - r = len > readSize ? readSize : len; - - if( file.log.level >= 4 ) - file.log.println( "read: len=" + len + ",r=" + r + ",fp=" + fp ); - - try { -SmbComReadAndX request = new SmbComReadAndX( file.fid, fp, r, null ); -if( file.type == SmbFile.TYPE_NAMED_PIPE ) { - request.minCount = request.maxCount = request.remaining = 1024; -} - file.send( request, response ); - } catch( SmbException se ) { - if( file.type == SmbFile.TYPE_NAMED_PIPE && - se.getNtStatus() == NtStatus.NT_STATUS_PIPE_BROKEN ) { - return -1; - } - throw seToIoe(se); - } - if(( n = response.dataLength ) <= 0 ) { - return (int)((fp - start) > 0L ? fp - start : -1); - } - fp += n; - len -= n; - response.off += n; - } while( len > 0 && n == r ); - - return (int)(fp - start); - } -/** - * This stream class is unbuffered. Therefore this method will always - * return 0 for streams connected to regular files. However, a - * stream created from a Named Pipe this method will query the server using a - * "peek named pipe" operation and return the number of available bytes - * on the server. - */ - public int available() throws IOException { - SmbNamedPipe pipe; - TransPeekNamedPipe req; - TransPeekNamedPipeResponse resp; - - if( file.type != SmbFile.TYPE_NAMED_PIPE ) { - return 0; - } - - try { - pipe = (SmbNamedPipe)file; - file.open(SmbFile.O_EXCL, pipe.pipeType & 0xFF0000, SmbFile.ATTR_NORMAL, 0 ); - - req = new TransPeekNamedPipe( file.unc, file.fid ); - resp = new TransPeekNamedPipeResponse( pipe ); - - pipe.send( req, resp ); - if( resp.status == TransPeekNamedPipeResponse.STATUS_DISCONNECTED || - resp.status == TransPeekNamedPipeResponse.STATUS_SERVER_END_CLOSED ) { - file.opened = false; - return 0; - } - return resp.available; - } catch (SmbException se) { - throw seToIoe(se); - } - } -/** - * Skip n bytes of data on this stream. This operation will not result - * in any IO with the server. Unlink InputStream value less than - * the one provided will not be returned if it exceeds the end of the file - * (if this is a problem let us know). - */ - public long skip( long n ) throws IOException { - if (n > 0) { - fp += n; - return n; - } - return 0; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileOutputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileOutputStream.java deleted file mode 100644 index 7e4f3b6793..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFileOutputStream.java +++ /dev/null @@ -1,257 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.UnknownHostException; - -/** - * This OutputStreamcan write bytes to a file on an SMB file server. - */ - -public class SmbFileOutputStream extends OutputStream { - - private SmbFile file; - private boolean append, useNTSmbs; - private int openFlags, access, writeSize; - private long fp; - private byte[] tmp = new byte[1]; - private SmbComWriteAndX reqx; - private SmbComWriteAndXResponse rspx; - private SmbComWrite req; - private SmbComWriteResponse rsp; - -/** - * Creates an {@link OutputStream} for writing to a file - * on an SMB server addressed by the URL parameter. See {@link - * SmbFile} for a detailed description and examples of - * the smb URL syntax. - * - * @param url An smb URL string representing the file to write to - */ - - public SmbFileOutputStream( String url ) throws SmbException, MalformedURLException, UnknownHostException { - this( url, false ); - } - -/** - * Creates an {@link OutputStream} for writing bytes to a file on - * an SMB server represented by the {@link SmbFile} parameter. See - * {@link SmbFile} for a detailed description and examples of - * the smb URL syntax. - * - * @param file AnSmbFilespecifying the file to write to - */ - - public SmbFileOutputStream( SmbFile file ) throws SmbException, MalformedURLException, UnknownHostException { - this( file, false ); - } - -/** - * Creates an {@link OutputStream} for writing bytes to a file on an - * SMB server addressed by the URL parameter. See {@link SmbFile} - * for a detailed description and examples of the smb URL syntax. If the - * second argument istrue, then bytes will be written to the - * end of the file rather than the beginning. - * - * @param url An smb URL string representing the file to write to - * @param append Append to the end of file - */ - - public SmbFileOutputStream( String url, boolean append ) throws SmbException, MalformedURLException, UnknownHostException { - this( new SmbFile( url ), append ); - } - -/** - * Creates an {@link OutputStream} for writing bytes to a file - * on an SMB server addressed by theSmbFileparameter. See - * {@link SmbFile} for a detailed description and examples of - * the smb URL syntax. If the second argument istrue, then - * bytes will be written to the end of the file rather than the beginning. - * - * @param file AnSmbFilerepresenting the file to write to - * @param append Append to the end of file - */ - - public SmbFileOutputStream( SmbFile file, boolean append ) throws SmbException, MalformedURLException, UnknownHostException { - this( file, append, append ? SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_APPEND : - SmbFile.O_CREAT | SmbFile.O_WRONLY | SmbFile.O_TRUNC ); - } -/** - * Creates an {@link OutputStream} for writing bytes to a file - * on an SMB server addressed by theSmbFileparameter. See - * {@link SmbFile} for a detailed description and examples of - * the smb URL syntax. --The second parameter specifies how the file should be shared. If -
SmbFile.FILE_NO_SHAREis specified the client will -have exclusive access to the file. An additional open command -from jCIFS or another application will fail with the "file is being -accessed by another process" error. TheFILE_SHARE_READ, -FILE_SHARE_WRITE, andFILE_SHARE_DELETEmay be -combined with the bitwise OR '|' to specify that other peocesses may read, -write, and/or delete the file while the jCIFS user has the file open. - * - * @param url An smb URL representing the file to write to - * @param shareAccess File sharing flag:SmbFile.FILE_NOSHAREor any combination ofSmbFile.FILE_READ,SmbFile.FILE_WRITE, andSmbFile.FILE_DELETE- */ - - public SmbFileOutputStream( String url, int shareAccess ) throws SmbException, MalformedURLException, UnknownHostException { - this( new SmbFile( url, "", null, shareAccess ), false ); - } - - SmbFileOutputStream( SmbFile file, boolean append, int openFlags ) throws SmbException, MalformedURLException, UnknownHostException { - this.file = file; - this.append = append; - this.openFlags = openFlags; - this.access = (openFlags >>> 16) & 0xFFFF; - if( append ) { - try { - fp = file.length(); - } catch( SmbAuthException sae ) { - throw sae; - } catch( SmbException se ) { - fp = 0L; - } - } - if( file instanceof SmbNamedPipe && file.unc.startsWith( "\\pipe\\" )) { - file.unc = file.unc.substring( 5 ); - file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ), - new TransWaitNamedPipeResponse() ); - } - file.open( openFlags, access | SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 ); - this.openFlags &= ~(SmbFile.O_CREAT | SmbFile.O_TRUNC); /* in case close and reopen */ - writeSize = file.tree.session.transport.snd_buf_size - 70; - - useNTSmbs = file.tree.session.transport.hasCapability( ServerMessageBlock.CAP_NT_SMBS ); - if( useNTSmbs ) { - reqx = new SmbComWriteAndX(); - rspx = new SmbComWriteAndXResponse(); - } else { - req = new SmbComWrite(); - rsp = new SmbComWriteResponse(); - } - } - -/** - * Closes this output stream and releases any system resources associated - * with it. - * - * @throws IOException if a network error occurs - */ - - public void close() throws IOException { - file.close(); - tmp = null; - } - -/** - * Writes the specified byte to this file output stream. - * - * @throws IOException if a network error occurs - */ - - public void write( int b ) throws IOException { - tmp[0] = (byte)b; - write( tmp, 0, 1 ); - } - -/** - * Writes b.length bytes from the specified byte array to this - * file output stream. - * - * @throws IOException if a network error occurs - */ - - public void write( byte[] b ) throws IOException { - write( b, 0, b.length ); - } - - public boolean isOpen() - { - return file.isOpen(); - } - void ensureOpen() throws IOException { - // ensure file is open - if( file.isOpen() == false ) { - file.open( openFlags, access | SmbConstants.FILE_WRITE_DATA, SmbFile.ATTR_NORMAL, 0 ); - if( append ) { - fp = file.length(); - } - } - } -/** - * Writes len bytes from the specified byte array starting at - * offset off to this file output stream. - * - * @param b The array - * @throws IOException if a network error occurs - */ - - public void write( byte[] b, int off, int len ) throws IOException { - if( file.isOpen() == false && file instanceof SmbNamedPipe ) { - file.send( new TransWaitNamedPipe( "\\pipe" + file.unc ), - new TransWaitNamedPipeResponse() ); - } - writeDirect( b, off, len, 0 ); - } -/** - * Just bypasses TransWaitNamedPipe - used by DCERPC bind. - */ - public void writeDirect( byte[] b, int off, int len, int flags ) throws IOException { - if( len <= 0 ) { - return; - } - - if( tmp == null ) { - throw new IOException( "Bad file descriptor" ); - } - ensureOpen(); - - if( file.log.level >= 4 ) - file.log.println( "write: fid=" + file.fid + ",off=" + off + ",len=" + len ); - - int w; - do { - w = len > writeSize ? writeSize : len; - if( useNTSmbs ) { - reqx.setParam( file.fid, fp, len - w, b, off, w ); -if ((flags & 1) != 0) { - reqx.setParam( file.fid, fp, len, b, off, w ); - reqx.writeMode = 0x8; -} else { - reqx.writeMode = 0; -} - file.send( reqx, rspx ); - fp += rspx.count; - len -= rspx.count; - off += rspx.count; - } else { - req.setParam( file.fid, fp, len - w, b, off, w ); - fp += rsp.count; - len -= rsp.count; - off += rsp.count; - file.send( req, rsp ); - } - } while( len > 0 ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFilenameFilter.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFilenameFilter.java deleted file mode 100644 index 847ea6f412..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbFilenameFilter.java +++ /dev/null @@ -1,23 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public interface SmbFilenameFilter { - public boolean accept( SmbFile dir, String name ) throws SmbException; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbNamedPipe.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbNamedPipe.java deleted file mode 100644 index 673be97147..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbNamedPipe.java +++ /dev/null @@ -1,195 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * "Paul Walker" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.UnknownHostException; - -/** - * This class will allow a Java program to read and write data to Named - * Pipes and Transact NamedPipes. - * - * There are three Win32 function calls provided by the Windows SDK - * that are important in the context of using jCIFS. They are: - * - *
- *
- * - *CallNamedPipeA message-type pipe call that opens, - * writes to, reads from, and closes the pipe in a single operation. - *TransactNamedPipeA message-type pipe call that - * writes to and reads from an existing pipe descriptor in one operation. - *CreateFile,ReadFile, - *WriteFile, andCloseFileA byte-type pipe can - * be opened, written to, read from and closed using the standard Win32 - * file operations. - *The jCIFS API maps all of these operations into the standard Java - *
XxxputStreaminterface. A specialPIPE_TYPE- * flags is necessary to distinguish which type of Named Pipe behavior - * is desired. - * - *- *
- * - *- * - * SmbNamedPipeConstructor Examples- * Code Sample Description - * - * new SmbNamedPipe( "smb://server/IPC$/PIPE/foo", - * SmbNamedPipe.PIPE_TYPE_RDWR | - * SmbNamedPipe.PIPE_TYPE_CALL ); - *- * Open the Named Pipe foo for reading and writing. The pipe will behave like the CallNamedPipeinterface. - *- * - * new SmbNamedPipe( "smb://server/IPC$/foo", - * SmbNamedPipe.PIPE_TYPE_RDWR | - * SmbNamedPipe.PIPE_TYPE_TRANSACT ); - *- * Open the Named Pipe foo for reading and writing. The pipe will behave like the TransactNamedPipeinterface. - *- * - * new SmbNamedPipe( "smb://server/IPC$/foo", - * SmbNamedPipe.PIPE_TYPE_RDWR ); - *- * Open the Named Pipe foo for reading and writing. The pipe will - * behave as though the CreateFile,ReadFile, - *WriteFile, andCloseFileinterface was - * being used. - *See Using jCIFS to Connect to Win32 - * Named Pipes for a detailed description of how to use jCIFS with - * Win32 Named Pipe server processes. - * - */ - -public class SmbNamedPipe extends SmbFile { - - /** - * The pipe should be opened read-only. - */ - - public static final int PIPE_TYPE_RDONLY = O_RDONLY; - - /** - * The pipe should be opened only for writing. - */ - - public static final int PIPE_TYPE_WRONLY = O_WRONLY; - - /** - * The pipe should be opened for both reading and writing. - */ - - public static final int PIPE_TYPE_RDWR = O_RDWR; - - /** - * Pipe operations should behave like the
CallNamedPipeWin32 Named Pipe function. - */ - - public static final int PIPE_TYPE_CALL = 0x0100; - - /** - * Pipe operations should behave like theTransactNamedPipeWin32 Named Pipe function. - */ - - public static final int PIPE_TYPE_TRANSACT = 0x0200; - - public static final int PIPE_TYPE_DCE_TRANSACT = 0x0200 | 0x0400; - - InputStream pipeIn; - OutputStream pipeOut; - int pipeType; - - /** - * Open the Named Pipe resource specified by the url - * parameter. The pipeType parameter should be at least one of - * thePIPE_TYPEflags combined with the bitwise OR - * operator|. See the examples listed above. - */ - - public SmbNamedPipe( String url, int pipeType ) - throws MalformedURLException, UnknownHostException { - super( url ); - this.pipeType = pipeType; - type = TYPE_NAMED_PIPE; - } - public SmbNamedPipe( String url, int pipeType, NtlmPasswordAuthentication auth ) - throws MalformedURLException, UnknownHostException { - super( url, auth ); - this.pipeType = pipeType; - type = TYPE_NAMED_PIPE; - } - public SmbNamedPipe( URL url, int pipeType, NtlmPasswordAuthentication auth ) - throws MalformedURLException, UnknownHostException { - super( url, auth ); - this.pipeType = pipeType; - type = TYPE_NAMED_PIPE; - } - - /** - * Return theInputStreamused to read information - * from this pipe instance. Presumably data would first be written - * to theOutputStreamassociated with this Named - * Pipe instance although this is not a requirement (e.g. a - * read-only named pipe would write data to this stream on - * connection). Reading from this stream may block. Therefore it - * may be necessary that an addition thread be used to read and - * write to a Named Pipe. - */ - - public InputStream getNamedPipeInputStream() throws IOException { - if( pipeIn == null ) { - if(( pipeType & PIPE_TYPE_CALL ) == PIPE_TYPE_CALL || - ( pipeType & PIPE_TYPE_TRANSACT ) == PIPE_TYPE_TRANSACT ) { - pipeIn = new TransactNamedPipeInputStream( this ); - } else { - pipeIn = new SmbFileInputStream(this, - (pipeType & 0xFFFF00FF) | SmbFile.O_EXCL); - } - } - return pipeIn; - } - - /** - * Return theOutputStreamused to write - * information to this pipe instance. The act of writing data - * to this stream will result in response data recieved in the - *InputStreamassociated with this Named Pipe - * instance (unless of course it does not elicite a response or the pipe is write-only). - */ - - public OutputStream getNamedPipeOutputStream() throws IOException { - if( pipeOut == null ) { - if(( pipeType & PIPE_TYPE_CALL ) == PIPE_TYPE_CALL || - ( pipeType & PIPE_TYPE_TRANSACT ) == PIPE_TYPE_TRANSACT ) { - pipeOut = new TransactNamedPipeOutputStream( this ); - } else { - pipeOut = new SmbFileOutputStream(this, false, - (pipeType & 0xFFFF00FF) | SmbFile.O_EXCL ); - } - } - return pipeOut; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbRandomAccessFile.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbRandomAccessFile.java deleted file mode 100644 index d136f155ff..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbRandomAccessFile.java +++ /dev/null @@ -1,333 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Encdec; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; - -public class SmbRandomAccessFile implements DataOutput, DataInput { - - private static final int WRITE_OPTIONS = 0x0842; - - private SmbFile file; - private long fp; - private int openFlags, access = 0, readSize, writeSize, ch, options = 0; - private byte[] tmp = new byte[8]; - private SmbComWriteAndXResponse write_andx_resp = null; - - public SmbRandomAccessFile( String url, String mode, int shareAccess ) - throws SmbException, MalformedURLException, UnknownHostException { - this( new SmbFile( url, "", null, shareAccess ), mode ); - } - public SmbRandomAccessFile( SmbFile file, String mode ) - throws SmbException, MalformedURLException, UnknownHostException { - this.file = file; - if( mode.equals( "r" )) { - this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDONLY; - } else if( mode.equals( "rw" )) { - this.openFlags = SmbFile.O_CREAT | SmbFile.O_RDWR | SmbFile.O_APPEND; - write_andx_resp = new SmbComWriteAndXResponse(); - options = WRITE_OPTIONS; - access = SmbConstants.FILE_READ_DATA | SmbConstants.FILE_WRITE_DATA; - } else { - throw new IllegalArgumentException( "Invalid mode" ); - } - file.open( openFlags, access, SmbFile.ATTR_NORMAL, options ); - readSize = file.tree.session.transport.rcv_buf_size - 70; - writeSize = file.tree.session.transport.snd_buf_size - 70; - fp = 0L; - } - - public int read() throws SmbException { - if( read( tmp, 0, 1 ) == -1 ) { - return -1; - } - return tmp[0] & 0xFF; - } - public int read( byte b[] ) throws SmbException { - return read( b, 0, b.length ); - } - public int read( byte b[], int off, int len ) throws SmbException { - if( len <= 0 ) { - return 0; - } - long start = fp; - - // ensure file is open - if( file.isOpen() == false ) { - file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options ); - } - - int r, n; - SmbComReadAndXResponse response = new SmbComReadAndXResponse( b, off ); - do { - r = len > readSize ? readSize : len; - file.send( new SmbComReadAndX( file.fid, fp, r, null ), response ); - if(( n = response.dataLength ) <= 0 ) { - return (int)((fp - start) > 0L ? fp - start : -1); - } - fp += n; - len -= n; - response.off += n; - } while( len > 0 && n == r ); - - return (int)(fp - start); - } - public final void readFully( byte b[] ) throws SmbException { - readFully( b, 0, b.length ); - } - public final void readFully( byte b[], int off, int len ) throws SmbException { - int n = 0, count; - - do { - count = this.read( b, off + n, len - n ); - if( count < 0 ) throw new SmbException( "EOF" ); - n += count; - fp += count; - } while( n < len ); - } - public int skipBytes( int n ) throws SmbException { - if (n > 0) { - fp += n; - return n; - } - return 0; - } - - public void write( int b ) throws SmbException { - tmp[0] = (byte)b; - write( tmp, 0, 1 ); - } - public void write( byte b[] ) throws SmbException { - write( b, 0, b.length ); - } - public void write( byte b[], int off, int len ) throws SmbException { - if( len <= 0 ) { - return; - } - - // ensure file is open - if( file.isOpen() == false ) { - file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options ); - } - - int w; - do { - w = len > writeSize ? writeSize : len; - file.send( new SmbComWriteAndX( file.fid, fp, len - w, b, off, w, null ), write_andx_resp ); - fp += write_andx_resp.count; - len -= write_andx_resp.count; - off += write_andx_resp.count; - } while( len > 0 ); - } - public long getFilePointer() throws SmbException { - return fp; - } - public void seek( long pos ) throws SmbException { - fp = pos; - } - public long length() throws SmbException { - return file.length(); - } - public void setLength( long newLength ) throws SmbException { - // ensure file is open - if( file.isOpen() == false ) { - file.open( openFlags, 0, SmbFile.ATTR_NORMAL, options ); - } - SmbComWriteResponse rsp = new SmbComWriteResponse(); - file.send( new SmbComWrite( file.fid, (int)(newLength & 0xFFFFFFFFL), 0, tmp, 0, 0 ), rsp ); - } - public void close() throws SmbException { - file.close(); - } - - public final boolean readBoolean() throws SmbException { - if((read( tmp, 0, 1 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return tmp[0] != (byte)0x00; - } - public final byte readByte() throws SmbException { - if((read( tmp, 0, 1 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return tmp[0]; - } - public final int readUnsignedByte() throws SmbException { - if((read( tmp, 0, 1 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return tmp[0] & 0xFF; - } - public final short readShort() throws SmbException { - if((read( tmp, 0, 2 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_uint16be( tmp, 0 ); - } - public final int readUnsignedShort() throws SmbException { - if((read( tmp, 0, 2 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_uint16be( tmp, 0 ) & 0xFFFF; - } - public final char readChar() throws SmbException { - if((read( tmp, 0, 2 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return (char)Encdec.dec_uint16be( tmp, 0 ); - } - public final int readInt() throws SmbException { - if((read( tmp, 0, 4 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_uint32be( tmp, 0 ); - } - public final long readLong() throws SmbException { - if((read( tmp, 0, 8 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_uint64be( tmp, 0 ); - } - public final float readFloat() throws SmbException { - if((read( tmp, 0, 4 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_floatbe( tmp, 0 ); - } - public final double readDouble() throws SmbException { - if((read( tmp, 0, 8 )) < 0 ) { - throw new SmbException( "EOF" ); - } - return Encdec.dec_doublebe( tmp, 0 ); - } - public final String readLine() throws SmbException { - StringBuffer input = new StringBuffer(); - int c = -1; - boolean eol = false; - - while (!eol) { - switch( c = read() ) { - case -1: - case '\n': - eol = true; - break; - case '\r': - eol = true; - long cur = fp; - if( read() != '\n' ) { - fp = cur; - } - break; - default: - input.append( (char)c ); - break; - } - } - - if ((c == -1) && (input.length() == 0)) { - return null; - } - - return input.toString(); - } - - public final String readUTF() throws SmbException { - int size = readUnsignedShort(); - byte[] b = new byte[size]; - read( b, 0, size ); - try { - return Encdec.dec_utf8( b, 0, size ); - } catch( IOException ioe ) { - throw new SmbException( "", ioe ); - } - } - public final void writeBoolean( boolean v ) throws SmbException { - tmp[0] = (byte)(v ? 1 : 0); - write( tmp, 0, 1 ); - } - public final void writeByte( int v ) throws SmbException { - tmp[0] = (byte)v; - write( tmp, 0, 1 ); - } - public final void writeShort( int v ) throws SmbException { - Encdec.enc_uint16be( (short)v, tmp, 0 ); - write( tmp, 0, 2 ); - } - public final void writeChar( int v ) throws SmbException { - Encdec.enc_uint16be( (short)v, tmp, 0 ); - write( tmp, 0, 2 ); - } - public final void writeInt( int v ) throws SmbException { - Encdec.enc_uint32be( v, tmp, 0 ); - write( tmp, 0, 4 ); - } - public final void writeLong( long v ) throws SmbException { - Encdec.enc_uint64be( v, tmp, 0 ); - write( tmp, 0, 8 ); - } - public final void writeFloat( float v ) throws SmbException { - Encdec.enc_floatbe( v, tmp, 0 ); - write( tmp, 0, 4 ); - } - public final void writeDouble( double v ) throws SmbException { - Encdec.enc_doublebe( v, tmp, 0 ); - write( tmp, 0, 8 ); - } - public final void writeBytes( String s ) throws SmbException { - byte[] b = s.getBytes(); - write( b, 0, b.length ); - } - public final void writeChars( String s ) throws SmbException { - int clen = s.length(); - int blen = 2 * clen; - byte[] b = new byte[blen]; - char[] c = new char[clen]; - s.getChars( 0, clen, c, 0 ); - for( int i = 0, j = 0; i < clen; i++ ) { - b[j++] = (byte)(c[i] >>> 8); - b[j++] = (byte)(c[i] >>> 0); - } - write( b, 0, blen ); - } - public final void writeUTF( String str ) throws SmbException { - int len = str.length(); - int ch, size = 0; - byte[] dst; - - for( int i = 0; i < len; i++ ) { - ch = str.charAt( i ); - size += ch > 0x07F ? (ch > 0x7FF ? 3 : 2) : 1; - } - dst = new byte[size]; - writeShort( size ); - try { - Encdec.enc_utf8( str, dst, 0, size ); - } catch( IOException ioe ) { - throw new SmbException( "", ioe ); - } - write( dst, 0, size ); - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbSession.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbSession.java deleted file mode 100644 index 34a87a702d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbSession.java +++ /dev/null @@ -1,474 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.UniAddress; -import jcifs.netbios.NbtAddress; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Enumeration; -import java.util.Vector; - -public final class SmbSession { - - private static final String LOGON_SHARE = - Config.getProperty( "jcifs.smb.client.logonShare", null ); - private static final int LOOKUP_RESP_LIMIT = - Config.getInt( "jcifs.netbios.lookupRespLimit", 3 ); - private static final String DOMAIN = - Config.getProperty("jcifs.smb.client.domain", null); - private static final String USERNAME = - Config.getProperty("jcifs.smb.client.username", null); - private static final int CACHE_POLICY = - Config.getInt( "jcifs.netbios.cachePolicy", 60 * 10 ) * 60; /* 10 hours */ - - static NbtAddress[] dc_list = null; - static long dc_list_expiration; - static int dc_list_counter; - - private static NtlmChallenge interrogate( NbtAddress addr ) throws SmbException { - UniAddress dc = new UniAddress( addr ); - SmbTransport trans = SmbTransport.getSmbTransport( dc, 0 ); - if (USERNAME == null) { - trans.connect(); - if (SmbTransport.log.level >= 3) - SmbTransport.log.println( - "Default credentials (jcifs.smb.client.username/password)" + - " not specified. SMB signing may not work propertly." + - " Skipping DC interrogation." ); - } else { - SmbSession ssn = trans.getSmbSession( NtlmPasswordAuthentication.DEFAULT ); - ssn.getSmbTree( LOGON_SHARE, null ).treeConnect( null, null ); - } - return new NtlmChallenge( trans.server.encryptionKey, dc ); - } - public static NtlmChallenge getChallengeForDomain() - throws SmbException, UnknownHostException { - if( DOMAIN == null ) { - throw new SmbException( "A domain was not specified" ); - } -synchronized (DOMAIN) { - long now = System.currentTimeMillis(); - int retry = 1; - - do { - if (dc_list_expiration < now) { - NbtAddress[] list = NbtAddress.getAllByName( DOMAIN, 0x1C, null, null ); - dc_list_expiration = now + CACHE_POLICY * 1000L; - if (list != null && list.length > 0) { - dc_list = list; - } else { /* keep using the old list */ - dc_list_expiration = now + 1000 * 60 * 15; /* 15 min */ - if (SmbTransport.log.level >= 2) { - SmbTransport.log.println( "Failed to retrieve DC list from WINS" ); - } - } - } - - int max = Math.min( dc_list.length, LOOKUP_RESP_LIMIT ); - for (int j = 0; j < max; j++) { - int i = dc_list_counter++ % max; - if (dc_list[i] != null) { - try { - return interrogate( dc_list[i] ); - } catch (SmbException se) { - if (SmbTransport.log.level >= 2) { - SmbTransport.log.println( "Failed validate DC: " + dc_list[i] ); - if (SmbTransport.log.level > 2) - se.printStackTrace( SmbTransport.log ); - } - } - dc_list[i] = null; - } - } - - /* No DCs found, for retieval of list by expiring it and retry. - */ - dc_list_expiration = 0; - } while (retry-- > 0); - - dc_list_expiration = now + 1000 * 60 * 15; /* 15 min */ -} - - throw new UnknownHostException( - "Failed to negotiate with a suitable domain controller for " + DOMAIN ); - } - - public static byte[] getChallenge( UniAddress dc ) - throws SmbException, UnknownHostException { - return getChallenge(dc, 0); - } - - public static byte[] getChallenge( UniAddress dc, int port ) - throws SmbException, UnknownHostException { - SmbTransport trans = SmbTransport.getSmbTransport( dc, port ); - trans.connect(); - return trans.server.encryptionKey; - } -/** - * Authenticate arbitrary credentials represented by the - * NtlmPasswordAuthentication object against the domain controller - * specified by the UniAddress parameter. If the credentials are - * not accepted, an SmbAuthException will be thrown. If an error - * occurs an SmbException will be thrown. If the credentials are - * valid, the method will return without throwing an exception. See the - * last FAQ question. - * - * See also the jcifs.smb.client.logonShare property. - */ - public static void logon( UniAddress dc, - NtlmPasswordAuthentication auth ) throws SmbException { - logon(dc, 0, auth); - } - - public static void logon( UniAddress dc, int port, - NtlmPasswordAuthentication auth ) throws SmbException { - SmbTree tree = SmbTransport.getSmbTransport( dc, port ).getSmbSession( auth ).getSmbTree( LOGON_SHARE, null ); - if( LOGON_SHARE == null ) { - tree.treeConnect( null, null ); - } else { - Trans2FindFirst2 req = new Trans2FindFirst2( "\\", "*", SmbFile.ATTR_DIRECTORY ); - Trans2FindFirst2Response resp = new Trans2FindFirst2Response(); - tree.send( req, resp ); - } - } - - /* 0 - not connected - * 1 - connecting - * 2 - connected - * 3 - disconnecting - */ - int connectionState; - int uid; - Vector trees; - // Transport parameters allows trans to be removed from CONNECTIONS - private UniAddress address; - private int port, localPort; - private InetAddress localAddr; - - SmbTransport transport = null; - NtlmPasswordAuthentication auth; - long expiration; - String netbiosName = null; - - SmbSession( UniAddress address, int port, - InetAddress localAddr, int localPort, - NtlmPasswordAuthentication auth ) { - this.address = address; - this.port = port; - this.localAddr = localAddr; - this.localPort = localPort; - this.auth = auth; - trees = new Vector(); - connectionState = 0; - } - - synchronized SmbTree getSmbTree( String share, String service ) { - SmbTree t; - - if( share == null ) { - share = "IPC$"; - } - for( Enumeration e = trees.elements(); e.hasMoreElements(); ) { - t = (SmbTree)e.nextElement(); - if( t.matches( share, service )) { - return t; - } - } - t = new SmbTree( this, share, service ); - trees.addElement( t ); - return t; - } - boolean matches( NtlmPasswordAuthentication auth ) { - return this.auth == auth || this.auth.equals( auth ); - } - synchronized SmbTransport transport() { - if( transport == null ) { - transport = SmbTransport.getSmbTransport( address, port, localAddr, localPort, null ); - } - return transport; - } - void send( ServerMessageBlock request, - ServerMessageBlock response ) throws SmbException { -synchronized (transport()) { - if( response != null ) { - response.received = false; - } - - expiration = System.currentTimeMillis() + SmbTransport.SO_TIMEOUT; - sessionSetup( request, response ); - if( response != null && response.received ) { - return; - } - - if (request instanceof SmbComTreeConnectAndX) { - SmbComTreeConnectAndX tcax = (SmbComTreeConnectAndX)request; - if (netbiosName != null && tcax.path.endsWith("\\IPC$")) { - /* Some pipes may require that the hostname in the tree connect - * be the netbios name. So if we have the netbios server name - * from the NTLMSSP type 2 message, and the share is IPC$, we - * assert that the tree connect path uses the netbios hostname. - */ - tcax.path = "\\\\" + netbiosName + "\\IPC$"; - } - } - - request.uid = uid; - request.auth = auth; - try { - transport.send( request, response ); - } catch (SmbException se) { - if (request instanceof SmbComTreeConnectAndX) { - logoff(true); - } - request.digest = null; - throw se; - } -} - } - void sessionSetup( ServerMessageBlock andx, - ServerMessageBlock andxResponse ) throws SmbException { -synchronized (transport()) { - NtlmContext nctx = null; - SmbException ex = null; - SmbComSessionSetupAndX request; - SmbComSessionSetupAndXResponse response; - byte[] token = new byte[0]; - int state = 10; - - while (connectionState != 0) { - if (connectionState == 2 || connectionState == 3) // connected or disconnecting - return; - try { - transport.wait(); - } catch (InterruptedException ie) { - throw new SmbException(ie.getMessage(), ie); - } - } - connectionState = 1; // trying ... - - try { - transport.connect(); - - /* - * Session Setup And X Request / Response - */ - - if( transport.log.level >= 4 ) - transport.log.println( "sessionSetup: accountName=" + auth.username + ",primaryDomain=" + auth.domain ); - - /* We explicitly set uid to 0 here to prevent a new - * SMB_COM_SESSION_SETUP_ANDX from having it's uid set to an - * old value when the session is re-established. Otherwise a - * "The parameter is incorrect" error can occur. - */ - uid = 0; - - do { - switch (state) { - case 10: /* NTLM */ - if (auth != NtlmPasswordAuthentication.ANONYMOUS && - transport.hasCapability(SmbConstants.CAP_EXTENDED_SECURITY)) { - state = 20; /* NTLMSSP */ - break; - } - - request = new SmbComSessionSetupAndX( this, andx, auth ); - response = new SmbComSessionSetupAndXResponse( andxResponse ); - - /* Create SMB signature digest if necessary - * Only the first SMB_COM_SESSION_SETUP_ANX with non-null or - * blank password initializes signing. - */ - if (transport.isSignatureSetupRequired( auth )) { - if( auth.hashesExternal && NtlmPasswordAuthentication.DEFAULT_PASSWORD != NtlmPasswordAuthentication.BLANK ) { - /* preauthentication - */ - transport.getSmbSession( NtlmPasswordAuthentication.DEFAULT ).getSmbTree( LOGON_SHARE, null ).treeConnect( null, null ); - } else { - byte[] signingKey = auth.getSigningKey(transport.server.encryptionKey); - request.digest = new SigningDigest(signingKey, false); - } - } - - request.auth = auth; - - try { - transport.send( request, response ); - } catch (SmbAuthException sae) { - throw sae; - } catch (SmbException se) { - ex = se; - } - - if( response.isLoggedInAsGuest && - "GUEST".equalsIgnoreCase( auth.username ) == false && - transport.server.security != SmbConstants.SECURITY_SHARE && - auth != NtlmPasswordAuthentication.ANONYMOUS) { - throw new SmbAuthException( NtStatus.NT_STATUS_LOGON_FAILURE ); - } - - if (ex != null) - throw ex; - - uid = response.uid; - - if( request.digest != null ) { - /* success - install the signing digest */ - transport.digest = request.digest; - } - - connectionState = 2; - - state = 0; - - break; - case 20: - if (nctx == null) { - boolean doSigning = (transport.flags2 & ServerMessageBlock.FLAGS2_SECURITY_SIGNATURES) != 0; - nctx = new NtlmContext(auth, doSigning); - } - - if (SmbTransport.log.level >= 4) - SmbTransport.log.println(nctx); - - if (nctx.isEstablished()) { - - netbiosName = nctx.getNetbiosName(); - - connectionState = 2; - - state = 0; - break; - } - - try { - token = nctx.initSecContext(token, 0, token.length); - } catch (SmbException se) { - /* We must close the transport or the server will be expecting a - * Type3Message. Otherwise, when we send a Type1Message it will return - * "Invalid parameter". - */ - try { transport.disconnect(true); } catch (IOException ioe) {} - uid = 0; - throw se; - } - - if (token != null) { - request = new SmbComSessionSetupAndX(this, null, token); - response = new SmbComSessionSetupAndXResponse(null); - - if (transport.isSignatureSetupRequired( auth )) { - byte[] signingKey = nctx.getSigningKey(); - if (signingKey != null) - request.digest = new SigningDigest(signingKey, true); - } - - request.uid = uid; - uid = 0; - - try { - transport.send( request, response ); - } catch (SmbAuthException sae) { - throw sae; - } catch (SmbException se) { - ex = se; - /* Apparently once a successfull NTLMSSP login occurs, the - * server will return "Access denied" even if a logoff is - * sent. Unfortunately calling disconnect() doesn't always - * actually shutdown the connection before other threads - * have committed themselves (e.g. InterruptTest example). - */ - try { transport.disconnect(true); } catch (Exception e) {} - } - - if( response.isLoggedInAsGuest && - "GUEST".equalsIgnoreCase( auth.username ) == false) { - throw new SmbAuthException( NtStatus.NT_STATUS_LOGON_FAILURE ); - } - - if (ex != null) - throw ex; - - uid = response.uid; - - if (request.digest != null) { - /* success - install the signing digest */ - transport.digest = request.digest; - } - - token = response.blob; - } - - break; - default: - throw new SmbException("Unexpected session setup state: " + state); - } - } while (state != 0); - } catch (SmbException se) { - logoff(true); - connectionState = 0; - throw se; - } finally { - transport.notifyAll(); - } -} - } - void logoff( boolean inError ) { -synchronized (transport()) { - - if (connectionState != 2) // not-connected - return; - connectionState = 3; // disconnecting - - netbiosName = null; - - for( Enumeration e = trees.elements(); e.hasMoreElements(); ) { - SmbTree t = (SmbTree)e.nextElement(); - t.treeDisconnect( inError ); - } - - if( !inError && transport.server.security != ServerMessageBlock.SECURITY_SHARE ) { - /* - * Logoff And X Request / Response - */ - - SmbComLogoffAndX request = new SmbComLogoffAndX( null ); - request.uid = uid; - try { - transport.send( request, null ); - } catch( SmbException se ) { - } - uid = 0; - } - - connectionState = 0; - transport.notifyAll(); -} - } - public String toString() { - return "SmbSession[accountName=" + auth.username + - ",primaryDomain=" + auth.domain + - ",uid=" + uid + - ",connectionState=" + connectionState + "]"; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbShareInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbShareInfo.java deleted file mode 100644 index b0c2e5dcf4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbShareInfo.java +++ /dev/null @@ -1,82 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2007 "Michael B. Allen"
- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -public class SmbShareInfo implements FileEntry { - - protected String netName; - protected int type; - protected String remark; - - public SmbShareInfo() { - } - public SmbShareInfo(String netName, int type, String remark) - { - this.netName = netName; - this.type = type; - this.remark = remark; - } - public String getName() { - return netName; - } - public int getType() { - /* 0x80000000 means hidden but SmbFile.isHidden() checks for $ at end - */ - switch (type & 0xFFFF) { - case 1: - return SmbFile.TYPE_PRINTER; - case 3: - return SmbFile.TYPE_NAMED_PIPE; - } - return SmbFile.TYPE_SHARE; - } - public int getAttributes() { - return SmbFile.ATTR_READONLY | SmbFile.ATTR_DIRECTORY; - } - public long createTime() { - return 0L; - } - public long lastModified() { - return 0L; - } - public long length() { - return 0L; - } - - public boolean equals(Object obj) { - if (obj instanceof SmbShareInfo) { - SmbShareInfo si = (SmbShareInfo)obj; - return netName.equals(si.netName); - } - return false; - } - public int hashCode() { - int hashCode = netName.hashCode(); - return hashCode; - } - - public String toString() { - return new String( "SmbShareInfo[" + - "netName=" + netName + - ",type=0x" + Hexdump.toHexString( type, 8 ) + - ",remark=" + remark + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTransport.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTransport.java deleted file mode 100644 index 81f27d8651..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTransport.java +++ /dev/null @@ -1,829 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2005 "Michael B. Allen" - * "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.UniAddress; -import jcifs.netbios.Name; -import jcifs.netbios.NbtAddress; -import jcifs.netbios.NbtException; -import jcifs.netbios.SessionRequestPacket; -import jcifs.netbios.SessionServicePacket; -import jcifs.util.Encdec; -import jcifs.util.Hexdump; -import jcifs.util.LogStream; -import jcifs.util.transport.Request; -import jcifs.util.transport.Response; -import jcifs.util.transport.Transport; -import jcifs.util.transport.TransportException; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ConnectException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.NoRouteToHostException; -import java.net.Socket; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.ListIterator; - -public class SmbTransport extends Transport implements SmbConstants { - - static final byte[] BUF = new byte[0xFFFF]; - static final SmbComNegotiate NEGOTIATE_REQUEST = new SmbComNegotiate(); - static LogStream log = LogStream.getInstance(); - static HashMap dfsRoots = null; - - static synchronized SmbTransport getSmbTransport( UniAddress address, int port ) { - return getSmbTransport( address, port, LADDR, LPORT, null ); - } - static synchronized SmbTransport getSmbTransport( UniAddress address, int port, - InetAddress localAddr, int localPort, String hostName ) { - SmbTransport conn; - - synchronized( CONNECTIONS ) { - if( SSN_LIMIT != 1 ) { - ListIterator iter = CONNECTIONS.listIterator(); - while( iter.hasNext() ) { - conn = (SmbTransport)iter.next(); - if( conn.matches( address, port, localAddr, localPort, hostName ) && - ( SSN_LIMIT == 0 || conn.sessions.size() < SSN_LIMIT )) { - return conn; - } - } - } - - conn = new SmbTransport( address, port, localAddr, localPort ); - CONNECTIONS.add( 0, conn ); - } - - return conn; - } - - class ServerData { - byte flags; - int flags2; - int maxMpxCount; - int maxBufferSize; - int sessionKey; - int capabilities; - String oemDomainName; - int securityMode; - int security; - boolean encryptedPasswords; - boolean signaturesEnabled; - boolean signaturesRequired; - int maxNumberVcs; - int maxRawSize; - long serverTime; - int serverTimeZone; - int encryptionKeyLength; - byte[] encryptionKey; - byte[] guid; - } - - InetAddress localAddr; - int localPort; - UniAddress address; - Socket socket; - int port, mid; - OutputStream out; - InputStream in; - byte[] sbuf = new byte[512]; /* small local buffer */ - SmbComBlankResponse key = new SmbComBlankResponse(); - long sessionExpiration = System.currentTimeMillis() + SO_TIMEOUT; - LinkedList referrals = new LinkedList(); - SigningDigest digest = null; - LinkedList sessions = new LinkedList(); - ServerData server = new ServerData(); - /* Negotiated values */ - int flags2 = FLAGS2; - int maxMpxCount = MAX_MPX_COUNT; - int snd_buf_size = SND_BUF_SIZE; - int rcv_buf_size = RCV_BUF_SIZE; - int capabilities = CAPABILITIES; - int sessionKey = 0x00000000; - boolean useUnicode = USE_UNICODE; - String tconHostName = null; - - SmbTransport( UniAddress address, int port, InetAddress localAddr, int localPort ) { - this.address = address; - this.port = port; - this.localAddr = localAddr; - this.localPort = localPort; - } - - synchronized SmbSession getSmbSession() { - return getSmbSession( new NtlmPasswordAuthentication( null, null, null )); - } - synchronized SmbSession getSmbSession( NtlmPasswordAuthentication auth ) { - SmbSession ssn; - long now; - - ListIterator iter = sessions.listIterator(); - while( iter.hasNext() ) { - ssn = (SmbSession)iter.next(); - if( ssn.matches( auth )) { - ssn.auth = auth; - return ssn; - } - } - - /* logoff old sessions */ - if (SO_TIMEOUT > 0 && sessionExpiration < (now = System.currentTimeMillis())) { - sessionExpiration = now + SO_TIMEOUT; - iter = sessions.listIterator(); - while( iter.hasNext() ) { - ssn = (SmbSession)iter.next(); - if( ssn.expiration < now ) { - ssn.logoff( false ); - } - } - } - - ssn = new SmbSession( address, port, localAddr, localPort, auth ); - ssn.transport = this; - sessions.add( ssn ); - - return ssn; - } - boolean matches( UniAddress address, int port, InetAddress localAddr, int localPort, String hostName ) { - if (hostName == null) - hostName = address.getHostName(); - return (this.tconHostName == null || hostName.equalsIgnoreCase(this.tconHostName)) && - address.equals( this.address ) && - (port == 0 || port == this.port || - /* port 139 is ok if 445 was requested */ - (port == 445 && this.port == 139)) && - (localAddr == this.localAddr || - (localAddr != null && - localAddr.equals( this.localAddr ))) && - localPort == this.localPort; - } - boolean hasCapability( int cap ) throws SmbException { - try { - connect( RESPONSE_TIMEOUT ); - } catch( IOException ioe ) { - throw new SmbException( ioe.getMessage(), ioe ); - } - return (capabilities & cap) == cap; - } - boolean isSignatureSetupRequired( NtlmPasswordAuthentication auth ) { - return ( flags2 & ServerMessageBlock.FLAGS2_SECURITY_SIGNATURES ) != 0 && - digest == null && - auth != NtlmPasswordAuthentication.NULL && - NtlmPasswordAuthentication.NULL.equals( auth ) == false; - } - - void ssn139() throws IOException { - Name calledName = new Name( address.firstCalledName(), 0x20, null ); - do { -/* These Socket constructors attempt to connect before SO_TIMEOUT can be applied - if (localAddr == null) { - socket = new Socket( address.getHostAddress(), 139 ); - } else { - socket = new Socket( address.getHostAddress(), 139, localAddr, localPort ); - } - socket.setSoTimeout( SO_TIMEOUT ); -*/ - - socket = new Socket(); - if (localAddr != null) - socket.bind(new InetSocketAddress(localAddr, localPort)); - socket.connect(new InetSocketAddress(address.getHostAddress(), 139), CONN_TIMEOUT); - socket.setSoTimeout( SO_TIMEOUT ); - - out = socket.getOutputStream(); - in = socket.getInputStream(); - - SessionServicePacket ssp = new SessionRequestPacket( calledName, - NbtAddress.getLocalName() ); - out.write( sbuf, 0, ssp.writeWireFormat( sbuf, 0 )); - if (readn( in, sbuf, 0, 4 ) < 4) { - try { - socket.close(); - } catch(IOException ioe) { - } - throw new SmbException( "EOF during NetBIOS session request" ); - } - switch( sbuf[0] & 0xFF ) { - case SessionServicePacket.POSITIVE_SESSION_RESPONSE: - if( log.level >= 4 ) - log.println( "session established ok with " + address ); - return; - case SessionServicePacket.NEGATIVE_SESSION_RESPONSE: - int errorCode = (int)( in.read() & 0xFF ); - switch (errorCode) { - case NbtException.CALLED_NOT_PRESENT: - case NbtException.NOT_LISTENING_CALLED: - socket.close(); - break; - default: - disconnect( true ); - throw new NbtException( NbtException.ERR_SSN_SRVC, errorCode ); - } - break; - case -1: - disconnect( true ); - throw new NbtException( NbtException.ERR_SSN_SRVC, - NbtException.CONNECTION_REFUSED ); - default: - disconnect( true ); - throw new NbtException( NbtException.ERR_SSN_SRVC, 0 ); - } - } while(( calledName.name = address.nextCalledName()) != null ); - - throw new IOException( "Failed to establish session with " + address ); - } - private void negotiate( int port, ServerMessageBlock resp ) throws IOException { - /* We cannot use Transport.sendrecv() yet because - * the Transport thread is not setup until doConnect() - * returns and we want to supress all communication - * until we have properly negotiated. - */ - synchronized (sbuf) { - if (port == 139) { - ssn139(); - } else { - if (port == 0) - port = DEFAULT_PORT; // 445 -/* These Socket constructors attempt to connect before SO_TIMEOUT can be applied - if (localAddr == null) { - socket = new Socket( address.getHostAddress(), port ); - } else { - socket = new Socket( address.getHostAddress(), port, localAddr, localPort ); - } - socket.setSoTimeout( SO_TIMEOUT ); -*/ - socket = new Socket(); - if (localAddr != null) - socket.bind(new InetSocketAddress(localAddr, localPort)); - socket.connect(new InetSocketAddress(address.getHostAddress(), port), CONN_TIMEOUT); - socket.setSoTimeout( SO_TIMEOUT ); - - out = socket.getOutputStream(); - in = socket.getInputStream(); - } - - if (++mid == 32000) mid = 1; - NEGOTIATE_REQUEST.mid = mid; - int n = NEGOTIATE_REQUEST.encode( sbuf, 4 ); - Encdec.enc_uint32be( n & 0xFFFF, sbuf, 0 ); /* 4 byte ssn msg header */ - - if (log.level >= 4) { - log.println( NEGOTIATE_REQUEST ); - if (log.level >= 6) { - Hexdump.hexdump( log, sbuf, 4, n ); - } - } - - out.write( sbuf, 0, 4 + n ); - out.flush(); - /* Note the Transport thread isn't running yet so we can - * read from the socket here. - */ - if (peekKey() == null) /* try to read header */ - throw new IOException( "transport closed in negotiate" ); - int size = Encdec.dec_uint16be( sbuf, 2 ) & 0xFFFF; - if (size < 33 || (4 + size) > sbuf.length ) { - throw new IOException( "Invalid payload size: " + size ); - } - readn( in, sbuf, 4 + 32, size - 32 ); - resp.decode( sbuf, 4 ); - - if (log.level >= 4) { - log.println( resp ); - if (log.level >= 6) { - Hexdump.hexdump( log, sbuf, 4, n ); - } - } - } - } - public void connect() throws SmbException { - try { - super.connect( RESPONSE_TIMEOUT ); - } catch( TransportException te ) { - throw new SmbException( "Failed to connect: " + address, te ); - } - } - protected void doConnect() throws IOException { - /* - * Negotiate Protocol Request / Response - */ - - SmbComNegotiateResponse resp = new SmbComNegotiateResponse( server ); - try { - negotiate( port, resp ); - } catch( ConnectException ce ) { - port = (port == 0 || port == DEFAULT_PORT) ? 139 : DEFAULT_PORT; - negotiate( port, resp ); - } catch( NoRouteToHostException nr ) { - port = (port == 0 || port == DEFAULT_PORT) ? 139 : DEFAULT_PORT; - negotiate( port, resp ); - } - - if( resp.dialectIndex > 10 ) { - throw new SmbException( "This client does not support the negotiated dialect." ); - } - if ((server.capabilities & CAP_EXTENDED_SECURITY) != CAP_EXTENDED_SECURITY && - server.encryptionKeyLength != 8 && - LM_COMPATIBILITY == 0) { - throw new SmbException("Unexpected encryption key length: " + server.encryptionKeyLength); - } - - /* Adjust negotiated values */ - - tconHostName = address.getHostName(); - if (server.signaturesRequired || (server.signaturesEnabled && SIGNPREF)) { - flags2 |= ServerMessageBlock.FLAGS2_SECURITY_SIGNATURES; - } else { - flags2 &= 0xFFFF ^ ServerMessageBlock.FLAGS2_SECURITY_SIGNATURES; - } - maxMpxCount = Math.min( maxMpxCount, server.maxMpxCount ); - if (maxMpxCount < 1) maxMpxCount = 1; - snd_buf_size = Math.min( snd_buf_size, server.maxBufferSize ); - capabilities &= server.capabilities; - if ((server.capabilities & CAP_EXTENDED_SECURITY) == CAP_EXTENDED_SECURITY) - capabilities |= CAP_EXTENDED_SECURITY; // & doesn't copy high bit - - if ((capabilities & ServerMessageBlock.CAP_UNICODE) == 0) { - // server doesn't want unicode - if (FORCE_UNICODE) { - capabilities |= ServerMessageBlock.CAP_UNICODE; - } else { - useUnicode = false; - flags2 &= 0xFFFF ^ ServerMessageBlock.FLAGS2_UNICODE; - } - } - } - protected void doDisconnect( boolean hard ) throws IOException { - ListIterator iter = sessions.listIterator(); - try { - while (iter.hasNext()) { - SmbSession ssn = (SmbSession)iter.next(); - ssn.logoff( hard ); - } - socket.shutdownOutput(); - out.close(); - in.close(); - socket.close(); - } finally { - digest = null; - socket = null; - tconHostName = null; - } - } - - protected void makeKey( Request request ) throws IOException { - /* The request *is* the key */ - if (++mid == 32000) mid = 1; - ((ServerMessageBlock)request).mid = mid; - } - protected Request peekKey() throws IOException { - int n; - do { - if ((n = readn( in, sbuf, 0, 4 )) < 4) - return null; - } while (sbuf[0] == (byte)0x85); /* Dodge NetBIOS keep-alive */ - /* read smb header */ - if ((n = readn( in, sbuf, 4, 32 )) < 32) - return null; - if (log.level >= 4) { - log.println( "New data read: " + this ); - Hexdump.hexdump( log, sbuf, 4, 32 ); - } - - for ( ;; ) { - /* 01234567 - * 00SSFSMB - * 0 - 0's - * S - size of payload - * FSMB - 0xFF SMB magic # - */ - - if (sbuf[0] == (byte)0x00 && - sbuf[1] == (byte)0x00 && - sbuf[4] == (byte)0xFF && - sbuf[5] == (byte)'S' && - sbuf[6] == (byte)'M' && - sbuf[7] == (byte)'B') { - break; /* all good */ - } - /* out of phase maybe? */ - /* inch forward 1 byte and try again */ - for (int i = 0; i < 35; i++) { - sbuf[i] = sbuf[i + 1]; - } - int b; - if ((b = in.read()) == -1) return null; - sbuf[35] = (byte)b; - } - - key.mid = Encdec.dec_uint16le( sbuf, 34 ) & 0xFFFF; - - /* Unless key returned is null or invalid Transport.loop() always - * calls doRecv() after and no one else but the transport thread - * should call doRecv(). Therefore it is ok to expect that the data - * in sbuf will be preserved for copying into BUF in doRecv(). - */ - - return key; - } - - protected void doSend( Request request ) throws IOException { - synchronized (BUF) { - ServerMessageBlock smb = (ServerMessageBlock)request; - int n = smb.encode( BUF, 4 ); - Encdec.enc_uint32be( n & 0xFFFF, BUF, 0 ); /* 4 byte session message header */ - if (log.level >= 4) { - do { - log.println( smb ); - } while (smb instanceof AndXServerMessageBlock && - (smb = ((AndXServerMessageBlock)smb).andx) != null); - if (log.level >= 6) { - Hexdump.hexdump( log, BUF, 4, n ); - } - } - /* For some reason this can sometimes get broken up into another - * "NBSS Continuation Message" frame according to WireShark - */ - out.write( BUF, 0, 4 + n ); - } - } - protected void doSend0( Request request ) throws IOException { - try { - doSend( request ); - } catch( IOException ioe ) { - if (log.level > 2) - ioe.printStackTrace( log ); - try { - disconnect( true ); - } catch( IOException ioe2 ) { - ioe2.printStackTrace( log ); - } - throw ioe; - } - } - - protected void doRecv( Response response ) throws IOException { - ServerMessageBlock resp = (ServerMessageBlock)response; - resp.useUnicode = useUnicode; - resp.extendedSecurity = (capabilities & CAP_EXTENDED_SECURITY) == CAP_EXTENDED_SECURITY; - - synchronized (BUF) { - System.arraycopy( sbuf, 0, BUF, 0, 4 + HEADER_LENGTH ); - int size = Encdec.dec_uint16be( BUF, 2 ) & 0xFFFF; - if (size < (HEADER_LENGTH + 1) || (4 + size) > rcv_buf_size ) { - throw new IOException( "Invalid payload size: " + size ); - } - int errorCode = Encdec.dec_uint32le( BUF, 9 ) & 0xFFFFFFFF; - if (resp.command == ServerMessageBlock.SMB_COM_READ_ANDX && - (errorCode == 0 || - errorCode == 0x80000005)) { // overflow indicator normal for pipe - SmbComReadAndXResponse r = (SmbComReadAndXResponse)resp; - int off = HEADER_LENGTH; - /* WordCount thru dataOffset always 27 */ - readn( in, BUF, 4 + off, 27 ); off += 27; - resp.decode( BUF, 4 ); - /* EMC can send pad w/o data */ - int pad = r.dataOffset - off; - if (r.byteCount > 0 && pad > 0 && pad < 4) - readn( in, BUF, 4 + off, pad); - - if (r.dataLength > 0) - readn( in, r.b, r.off, r.dataLength ); /* read direct */ - } else { - readn( in, BUF, 4 + 32, size - 32 ); - resp.decode( BUF, 4 ); - if (resp instanceof SmbComTransactionResponse) { - ((SmbComTransactionResponse)resp).nextElement(); - } - } - - /* Verification fails (w/ W2K3 server at least) if status is not 0. This - * suggests MS doesn't compute the signature (correctly) for error responses - * (perhaps for DOS reasons). - */ - if (digest != null && resp.errorCode == 0) { - digest.verify( BUF, 4, resp ); - } - - if (log.level >= 4) { - log.println( response ); - if (log.level >= 6) { - Hexdump.hexdump( log, BUF, 4, size ); - } - } - } - } - protected void doSkip() throws IOException { - int size = Encdec.dec_uint16be( sbuf, 2 ) & 0xFFFF; - if (size < 33 || (4 + size) > rcv_buf_size ) { - /* log message? */ - in.skip( in.available() ); - } else { - in.skip( size - 32 ); - } - } - void checkStatus( ServerMessageBlock req, ServerMessageBlock resp ) throws SmbException { - resp.errorCode = SmbException.getStatusByCode( resp.errorCode ); - switch( resp.errorCode ) { - case NtStatus.NT_STATUS_OK: - break; - case NtStatus.NT_STATUS_ACCESS_DENIED: - case NtStatus.NT_STATUS_WRONG_PASSWORD: - case NtStatus.NT_STATUS_LOGON_FAILURE: - case NtStatus.NT_STATUS_ACCOUNT_RESTRICTION: - case NtStatus.NT_STATUS_INVALID_LOGON_HOURS: - case NtStatus.NT_STATUS_INVALID_WORKSTATION: - case NtStatus.NT_STATUS_PASSWORD_EXPIRED: - case NtStatus.NT_STATUS_ACCOUNT_DISABLED: - case NtStatus.NT_STATUS_ACCOUNT_LOCKED_OUT: - case NtStatus.NT_STATUS_TRUSTED_DOMAIN_FAILURE: - throw new SmbAuthException( resp.errorCode ); - case NtStatus.NT_STATUS_PATH_NOT_COVERED: - if( req.auth == null ) { - throw new SmbException( resp.errorCode, null ); - } - - DfsReferral dr = getDfsReferrals(req.auth, req.path, 1); - if (dr == null) - throw new SmbException(resp.errorCode, null); - - SmbFile.dfs.insert(req.path, dr); - throw dr; - case 0x80000005: /* STATUS_BUFFER_OVERFLOW */ - break; /* normal for DCERPC named pipes */ - case NtStatus.NT_STATUS_MORE_PROCESSING_REQUIRED: - break; /* normal for NTLMSSP */ - default: - throw new SmbException( resp.errorCode, null ); - } - if (resp.verifyFailed) { - throw new SmbException( "Signature verification failed." ); - } - } - void send( ServerMessageBlock request, ServerMessageBlock response ) throws SmbException { - - connect(); /* must negotiate before we can test flags2, useUnicode, etc */ - - request.flags2 |= flags2; - request.useUnicode = useUnicode; - request.response = response; /* needed by sign */ - if (request.digest == null) - request.digest = digest; /* for sign called in encode */ - - try { - if (response == null) { - doSend0( request ); - return; - } else if (request instanceof SmbComTransaction) { - response.command = request.command; - SmbComTransaction req = (SmbComTransaction)request; - SmbComTransactionResponse resp = (SmbComTransactionResponse)response; - - req.maxBufferSize = snd_buf_size; - resp.reset(); - - try { - BufferCache.getBuffers( req, resp ); - - /* - * First request w/ interim response - */ - - req.nextElement(); - if (req.hasMoreElements()) { - SmbComBlankResponse interim = new SmbComBlankResponse(); - super.sendrecv( req, interim, RESPONSE_TIMEOUT ); - if (interim.errorCode != 0) { - checkStatus( req, interim ); - } - req.nextElement(); - } else { - makeKey( req ); - } - - synchronized (this) { - response.received = false; - resp.isReceived = false; - try { - response_map.put( req, resp ); - - /* - * Send multiple fragments - */ - - do { - doSend0( req ); - } while( req.hasMoreElements() && req.nextElement() != null ); - - /* - * Receive multiple fragments - */ - - long timeout = RESPONSE_TIMEOUT; - resp.expiration = System.currentTimeMillis() + timeout; - while( resp.hasMoreElements() ) { - wait( timeout ); - timeout = resp.expiration - System.currentTimeMillis(); - if (timeout <= 0) { - throw new TransportException( this + - " timedout waiting for response to " + - req ); - } - } - if (response.errorCode != 0) { - checkStatus( req, resp ); - } - } catch( InterruptedException ie ) { - throw new TransportException( ie ); - } finally { - response_map.remove( req ); - } - } - } finally { - BufferCache.releaseBuffer( req.txn_buf ); - BufferCache.releaseBuffer( resp.txn_buf ); - } - - } else { - response.command = request.command; - super.sendrecv( request, response, RESPONSE_TIMEOUT ); - } - } catch( SmbException se ) { - throw se; - } catch( IOException ioe ) { - throw new SmbException( ioe.getMessage(), ioe ); - } - - checkStatus( request, response ); - } - public String toString() { - return super.toString() + "[" + address + ":" + port + "]"; - } - - /* DFS */ - - /* Split DFS path like \fs1.example.com\root5\link2\foo\bar.txt into at - * most 3 components (not including the first index which is always empty): - * result[0] = "" - * result[1] = "fs1.example.com" - * result[2] = "root5" - * result[3] = "link2\foo\bar.txt" - */ - void dfsPathSplit(String path, String[] result) - { - int ri = 0, rlast = result.length - 1; - int i = 0, b = 0, len = path.length(); - - do { - if (ri == rlast) { - result[rlast] = path.substring(b); - return; - } - if (i == len || path.charAt(i) == '\\') { - result[ri++] = path.substring(b, i); - b = i + 1; - } - } while (i++ < len); - - while (ri < result.length) { - result[ri++] = ""; - } - } - DfsReferral getDfsReferrals(NtlmPasswordAuthentication auth, - String path, - int rn) throws SmbException { - SmbTree ipc = getSmbSession( auth ).getSmbTree( "IPC$", null ); - Trans2GetDfsReferralResponse resp = new Trans2GetDfsReferralResponse(); - ipc.send( new Trans2GetDfsReferral( path ), resp ); - - if (resp.numReferrals == 0) { - return null; - } else if (rn == 0 || resp.numReferrals < rn) { - rn = resp.numReferrals; - } - - DfsReferral dr = new DfsReferral(); - - String[] arr = new String[4]; - long expiration = System.currentTimeMillis() + Dfs.TTL * 1000; - - int di = 0; - for ( ;; ) { - /* NTLM HTTP Authentication must be re-negotiated - * with challenge from 'server' to access DFS vol. */ - dr.resolveHashes = auth.hashesExternal; - dr.ttl = resp.referrals[di].ttl; - dr.expiration = expiration; - if (path.equals("")) { - dr.server = resp.referrals[di].path.substring(1).toLowerCase(); - } else { - dfsPathSplit(resp.referrals[di].node, arr); - dr.server = arr[1]; - dr.share = arr[2]; - dr.path = arr[3]; - } - dr.pathConsumed = resp.pathConsumed; - - di++; - if (di == rn) - break; - - dr.append(new DfsReferral()); - dr = dr.next; - } - - return dr.next; - } - DfsReferral[] __getDfsReferrals(NtlmPasswordAuthentication auth, - String path, - int rn) throws SmbException { - SmbTree ipc = getSmbSession( auth ).getSmbTree( "IPC$", null ); - Trans2GetDfsReferralResponse resp = new Trans2GetDfsReferralResponse(); - ipc.send( new Trans2GetDfsReferral( path ), resp ); - - if (rn == 0 || resp.numReferrals < rn) { - rn = resp.numReferrals; - } - - DfsReferral[] drs = new DfsReferral[rn]; - String[] arr = new String[4]; - long expiration = System.currentTimeMillis() + Dfs.TTL * 1000; - - for (int di = 0; di < drs.length; di++) { - DfsReferral dr = new DfsReferral(); - /* NTLM HTTP Authentication must be re-negotiated - * with challenge from 'server' to access DFS vol. */ - dr.resolveHashes = auth.hashesExternal; - dr.ttl = resp.referrals[di].ttl; - dr.expiration = expiration; - if (path.equals("")) { - dr.server = resp.referrals[di].path.substring(1).toLowerCase(); - } else { - dfsPathSplit(resp.referrals[di].node, arr); - dr.server = arr[1]; - dr.share = arr[2]; - dr.path = arr[3]; - } - dr.pathConsumed = resp.pathConsumed; - drs[di] = dr; - } - - return drs; - } - -// FileEntry[] getDfsRoots(String domainName, NtlmPasswordAuthentication auth) throws IOException { -// MsrpcDfsRootEnum rpc; -// DcerpcHandle handle = null; -// -// /* Procedure: -// * Lookup a DC in the target domain -// * Ask the DC for a referral for the domain (e.g. "\example.com") -// * Do NetrDfsEnumEx on the server returned in the referral to -// * get roots in target domain -// */ -// -// UniAddress dc = UniAddress.getByName(domainName); -// SmbTransport trans = SmbTransport.getSmbTransport(dc, 0); -// DfsReferral[] dr = trans.getDfsReferrals(auth, "\\" + domainName, 1); -// -// handle = DcerpcHandle.getHandle("ncacn_np:" + -// UniAddress.getByName(dr[0].server).getHostAddress() + -// "[\\PIPE\\netdfs]", auth); -// try { -// rpc = new MsrpcDfsRootEnum(domainName); -// handle.sendrecv(rpc); -// if (rpc.retval != 0) -// throw new SmbException(rpc.retval, true); -// return rpc.getEntries(); -// } finally { -// try { -// handle.close(); -// } catch(IOException ioe) { -// if (log.level >= 4) -// ioe.printStackTrace(log); -// } -// } -// } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTree.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTree.java deleted file mode 100644 index d7d9c7479e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/SmbTree.java +++ /dev/null @@ -1,218 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class SmbTree { - - private static int tree_conn_counter; - - /* 0 - not connected - * 1 - connecting - * 2 - connected - * 3 - disconnecting - */ - int connectionState; - int tid; - - String share; - String service = "?????"; - String service0; - SmbSession session; - boolean inDfs, inDomainDfs; - int tree_num; // used by SmbFile.isOpen - - SmbTree( SmbSession session, String share, String service ) { - this.session = session; - this.share = share.toUpperCase(); - if( service != null && service.startsWith( "??" ) == false ) { - this.service = service; - } - this.service0 = this.service; - this.connectionState = 0; - } - - boolean matches( String share, String service ) { - return this.share.equalsIgnoreCase( share ) && - ( service == null || service.startsWith( "??" ) || - this.service.equalsIgnoreCase( service )); - } - public boolean equals(Object obj) { - if (obj instanceof SmbTree) { - SmbTree tree = (SmbTree)obj; - return matches(tree.share, tree.service); - } - return false; - } - void send( ServerMessageBlock request, - ServerMessageBlock response ) throws SmbException { -synchronized (session.transport()) { - if( response != null ) { - response.received = false; - } - treeConnect( request, response ); - if( request == null || (response != null && response.received )) { - return; - } - if( service.equals( "A:" ) == false ) { - switch( request.command ) { - case ServerMessageBlock.SMB_COM_OPEN_ANDX: - case ServerMessageBlock.SMB_COM_NT_CREATE_ANDX: - case ServerMessageBlock.SMB_COM_READ_ANDX: - case ServerMessageBlock.SMB_COM_WRITE_ANDX: - case ServerMessageBlock.SMB_COM_CLOSE: - case ServerMessageBlock.SMB_COM_TREE_DISCONNECT: - break; - case ServerMessageBlock.SMB_COM_TRANSACTION: - case ServerMessageBlock.SMB_COM_TRANSACTION2: - switch( ((SmbComTransaction)request).subCommand & 0xFF ) { - case SmbComTransaction.NET_SHARE_ENUM: - case SmbComTransaction.NET_SERVER_ENUM2: - case SmbComTransaction.NET_SERVER_ENUM3: - case SmbComTransaction.TRANS_PEEK_NAMED_PIPE: - case SmbComTransaction.TRANS_WAIT_NAMED_PIPE: - case SmbComTransaction.TRANS_CALL_NAMED_PIPE: - case SmbComTransaction.TRANS_TRANSACT_NAMED_PIPE: - case SmbComTransaction.TRANS2_GET_DFS_REFERRAL: - break; - default: - throw new SmbException( "Invalid operation for " + service + " service" ); - } - break; - default: - throw new SmbException( "Invalid operation for " + service + " service" + request ); - } - } - request.tid = tid; - if( inDfs && !service.equals("IPC") && request.path != null && request.path.length() > 0 ) { - /* When DFS is in action all request paths are - * full UNC paths minus the first backslash like - * \server\share\path\to\file - * as opposed to normally - * \path\to\file - */ - request.flags2 = ServerMessageBlock.FLAGS2_RESOLVE_PATHS_IN_DFS; - request.path = '\\' + session.transport().tconHostName + '\\' + share + request.path; - } - try { - session.send( request, response ); - } catch( SmbException se ) { - if (se.getNtStatus() == se.NT_STATUS_NETWORK_NAME_DELETED) { - /* Someone removed the share while we were - * connected. Bastards! Disconnect this tree - * so that it reconnects cleanly should the share - * reappear in this client's lifetime. - */ - treeDisconnect( true ); - } - throw se; - } -} - } - void treeConnect( ServerMessageBlock andx, - ServerMessageBlock andxResponse ) throws SmbException { - -synchronized (session.transport()) { - String unc; - - while (connectionState != 0) { - if (connectionState == 2 || connectionState == 3) // connected or disconnecting - return; - try { - session.transport.wait(); - } catch (InterruptedException ie) { - throw new SmbException(ie.getMessage(), ie); - } - } - connectionState = 1; // trying ... - - try { - /* The hostname to use in the path is only known for - * sure if the NetBIOS session has been successfully - * established. - */ - - session.transport.connect(); - - unc = "\\\\" + session.transport.tconHostName + '\\' + share; - - /* IBM iSeries doesn't like specifying a service. Always reset - * the service to whatever was determined in the constructor. - */ - service = service0; - - /* - * Tree Connect And X Request / Response - */ - - if( session.transport.log.level >= 4 ) - session.transport.log.println( "treeConnect: unc=" + unc + ",service=" + service ); - - SmbComTreeConnectAndXResponse response = - new SmbComTreeConnectAndXResponse( andxResponse ); - SmbComTreeConnectAndX request = - new SmbComTreeConnectAndX( session, unc, service, andx ); - session.send( request, response ); - - tid = response.tid; - service = response.service; - inDfs = response.shareIsInDfs; - tree_num = tree_conn_counter++; - - connectionState = 2; // connected - } catch (SmbException se) { - treeDisconnect(true); - connectionState = 0; - throw se; - } -} - } - void treeDisconnect( boolean inError ) { -synchronized (session.transport()) { - - if (connectionState != 2) // not-connected - return; - connectionState = 3; // disconnecting - - if (!inError && tid != 0) { - try { - send( new SmbComTreeDisconnect(), null ); - } catch( SmbException se ) { - if (session.transport.log.level > 1) { - se.printStackTrace( session.transport.log ); - } - } - } - inDfs = false; - inDomainDfs = false; - - connectionState = 0; - - session.transport.notifyAll(); -} - } - - public String toString() { - return "SmbTree[share=" + share + - ",service=" + service + - ",tid=" + tid + - ",inDfs=" + inDfs + - ",inDomainDfs=" + inDomainDfs + - ",connectionState=" + connectionState + "]"; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TestLocking.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TestLocking.java deleted file mode 100644 index 0dd305a41a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TestLocking.java +++ /dev/null @@ -1,124 +0,0 @@ -package jcifs.smb; - -import java.io.IOException; -import java.io.InputStream; - -public class TestLocking implements Runnable -{ - - int numThreads = 1; - int numIter = 1; - long delay = 100; - String url = null; - int numComplete = 0; - long ltime = 0L; - - public void run() - { - try { - SmbFile f = new SmbFile(url); - SmbFile d = new SmbFile(f.getParent()); - byte[] buf = new byte[1024]; - - for (int ii = 0; ii < numIter; ii++) { - - synchronized (this) { - ltime = System.currentTimeMillis(); - wait(); - } - - try { - double r = Math.random(); - if (r < 0.333) { - f.exists(); -// System.out.print('e'); - } else if (r < 0.667) { - d.listFiles(); -// System.out.print('l'); - } else if (r < 1.0) { - InputStream in = f.getInputStream(); - while (in.read(buf) > 0) { -// System.out.print('r'); - } - in.close(); - } - } catch (IOException ioe) { - System.err.println(ioe.getMessage()); -//ioe.printStackTrace(System.err); - } - - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - numComplete++; - } - } - - public static void main(String[] args) throws Exception - { - if (args.length < 1) { - System.err.println("usage: TestLocking [-t ] [-i ] [-d ] url"); - System.exit(1); - } - - TestLocking t = new TestLocking(); - t.ltime = System.currentTimeMillis(); - - for (int ai = 0; ai < args.length; ai++) { - if (args[ai].equals("-t")) { - ai++; - t.numThreads = Integer.parseInt(args[ai]); - } else if (args[ai].equals("-i")) { - ai++; - t.numIter = Integer.parseInt(args[ai]); - } else if (args[ai].equals("-d")) { - ai++; - t.delay = Long.parseLong(args[ai]); - } else { - t.url = args[ai]; - } - } - - Thread[] threads = new Thread[t.numThreads]; - int ti; - - for (ti = 0; ti < t.numThreads; ti++) { - threads[ti] = new Thread(t); - System.out.print(threads[ti].getName()); - threads[ti].start(); - } - - while (t.numComplete < t.numThreads) { - long delay; - - do { - delay = 2L; - - synchronized (t) { - long expire = t.ltime + t.delay; - long ctime = System.currentTimeMillis(); - - if (expire > ctime) - delay = expire - ctime; - } - -if (delay > 2) -System.out.println("delay=" + delay); - Thread.sleep(delay); - } while (delay > 2); - - synchronized (t) { - t.notifyAll(); - } -//System.out.println("numComplete=" + t.numComplete + ",numThreads=" + t.numThreads); - } - - for (ti = 0; ti < t.numThreads; ti++) { - threads[ti].join(); - System.out.print(threads[ti].getName()); - } - - System.out.println(); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2.java deleted file mode 100644 index af6054fa84..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2.java +++ /dev/null @@ -1,119 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.Config; -import jcifs.util.Hexdump; - -class Trans2FindFirst2 extends SmbComTransaction { - - // flags - - private static final int FLAGS_CLOSE_AFTER_THIS_REQUEST = 0x01; - private static final int FLAGS_CLOSE_IF_END_REACHED = 0x02; - private static final int FLAGS_RETURN_RESUME_KEYS = 0x04; - private static final int FLAGS_RESUME_FROM_PREVIOUS_END = 0x08; - private static final int FLAGS_FIND_WITH_BACKUP_INTENT = 0x10; - - private static final int DEFAULT_LIST_SIZE = 65535; - private static final int DEFAULT_LIST_COUNT = 200; - - private int searchAttributes; - private int flags; - private int informationLevel; - private int searchStorageType = 0; - private String wildcard; - - // information levels - - static final int SMB_INFO_STANDARD = 1; - static final int SMB_INFO_QUERY_EA_SIZE = 2; - static final int SMB_INFO_QUERY_EAS_FROM_LIST = 3; - static final int SMB_FIND_FILE_DIRECTORY_INFO = 0x101; - static final int SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x102; - static final int SMB_FILE_NAMES_INFO = 0x103; - static final int SMB_FILE_BOTH_DIRECTORY_INFO = 0x104; - - static final int LIST_SIZE = Config.getInt( "jcifs.smb.client.listSize", DEFAULT_LIST_SIZE ); - static final int LIST_COUNT = Config.getInt( "jcifs.smb.client.listCount", DEFAULT_LIST_COUNT ); - - Trans2FindFirst2( String filename, String wildcard, int searchAttributes ) { - if( filename.equals( "\\" )) { - this.path = filename; - } else { - this.path = filename + "\\"; - } - this.wildcard = wildcard; - this.searchAttributes = searchAttributes & 0x37; /* generally ignored tho */ - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_FIND_FIRST2; - - flags = 0x00; - informationLevel = SMB_FILE_BOTH_DIRECTORY_INFO; - - totalDataCount = 0; - maxParameterCount = 10; - maxDataCount = LIST_SIZE; - maxSetupCount = 0; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( searchAttributes, dst, dstIndex ); - dstIndex += 2; - writeInt2( LIST_COUNT, dst, dstIndex ); - dstIndex += 2; - writeInt2( flags, dst, dstIndex ); - dstIndex += 2; - writeInt2( informationLevel, dst, dstIndex ); - dstIndex += 2; - writeInt4( searchStorageType, dst, dstIndex ); - dstIndex += 4; - dstIndex += writeString( path + wildcard, dst, dstIndex ); - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2FindFirst2[" + super.toString() + - ",searchAttributes=0x" + Hexdump.toHexString( searchAttributes, 2 ) + - ",searchCount=" + LIST_COUNT + - ",flags=0x" + Hexdump.toHexString( flags, 2 ) + - ",informationLevel=0x" + Hexdump.toHexString( informationLevel, 3 ) + - ",searchStorageType=" + searchStorageType + - ",filename=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2Response.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2Response.java deleted file mode 100644 index 35cd361c7f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindFirst2Response.java +++ /dev/null @@ -1,233 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.UnsupportedEncodingException; -import java.util.Date; - -class Trans2FindFirst2Response extends SmbComTransactionResponse { - - // information levels - - static final int SMB_INFO_STANDARD = 1; - static final int SMB_INFO_QUERY_EA_SIZE = 2; - static final int SMB_INFO_QUERY_EAS_FROM_LIST = 3; - static final int SMB_FIND_FILE_DIRECTORY_INFO = 0x101; - static final int SMB_FIND_FILE_FULL_DIRECTORY_INFO = 0x102; - static final int SMB_FILE_NAMES_INFO = 0x103; - static final int SMB_FILE_BOTH_DIRECTORY_INFO = 0x104; - - class SmbFindFileBothDirectoryInfo implements FileEntry { - int nextEntryOffset; - int fileIndex; - long creationTime; - long lastAccessTime; - long lastWriteTime; - long changeTime; - long endOfFile; - long allocationSize; - int extFileAttributes; - int fileNameLength; - int eaSize; - int shortNameLength; - String shortName; - String filename; - - public String getName() { - return filename; - } - public int getType() { - return SmbFile.TYPE_FILESYSTEM; - } - public int getAttributes() { - return extFileAttributes; - } - public long createTime() { - return creationTime; - } - public long lastModified() { - return lastWriteTime; - } - public long length() { - return endOfFile; - } - - public String toString() { - return new String( "SmbFindFileBothDirectoryInfo[" + - "nextEntryOffset=" + nextEntryOffset + - ",fileIndex=" + fileIndex + - ",creationTime=" + new Date( creationTime ) + - ",lastAccessTime=" + new Date( lastAccessTime ) + - ",lastWriteTime=" + new Date( lastWriteTime ) + - ",changeTime=" + new Date( changeTime ) + - ",endOfFile=" + endOfFile + - ",allocationSize=" + allocationSize + - ",extFileAttributes=" + extFileAttributes + - ",fileNameLength=" + fileNameLength + - ",eaSize=" + eaSize + - ",shortNameLength=" + shortNameLength + - ",shortName=" + shortName + - ",filename=" + filename + "]" ); - } - } - - int sid; - boolean isEndOfSearch; - int eaErrorOffset; - int lastNameOffset, lastNameBufferIndex; - String lastName; - int resumeKey; - - - Trans2FindFirst2Response() { - command = SMB_COM_TRANSACTION2; - subCommand = SmbComTransaction.TRANS2_FIND_FIRST2; - } - - String readString( byte[] src, int srcIndex, int len ) { - String str = null; - try { - if( useUnicode ) { - // should Unicode alignment be corrected for here? - str = new String( src, srcIndex, len, UNI_ENCODING ); - } else { - - /* On NT without Unicode the fileNameLength - * includes the '\0' whereas on win98 it doesn't. I - * guess most clients only support non-unicode so - * they don't run into this. - */ - - /* UPDATE: Maybe not! Could this be a Unicode alignment issue. I hope - * so. We cannot just comment out this method and use readString of - * ServerMessageBlock.java because the arguments are different, however - * one might be able to reduce this. - */ - - if( len > 0 && src[srcIndex + len - 1] == '\0' ) { - len--; - } - str = new String( src, srcIndex, len, ServerMessageBlock.OEM_ENCODING ); - } - } catch( UnsupportedEncodingException uee ) { - if( log.level > 1 ) - uee.printStackTrace( log ); - } - return str; - } - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - if( subCommand == SmbComTransaction.TRANS2_FIND_FIRST2 ) { - sid = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - } - numEntries = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - isEndOfSearch = ( buffer[bufferIndex] & 0x01 ) == 0x01 ? true : false; - bufferIndex += 2; - eaErrorOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - lastNameOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - return bufferIndex - start; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - SmbFindFileBothDirectoryInfo e; - - lastNameBufferIndex = bufferIndex + lastNameOffset; - - results = new SmbFindFileBothDirectoryInfo[numEntries]; - for( int i = 0; i < numEntries; i++ ) { - results[i] = e = new SmbFindFileBothDirectoryInfo(); - - e.nextEntryOffset = readInt4( buffer, bufferIndex ); - e.fileIndex = readInt4( buffer, bufferIndex + 4 ); - e.creationTime = readTime( buffer, bufferIndex + 8 ); - // e.lastAccessTime = readTime( buffer, bufferIndex + 16 ); - e.lastWriteTime = readTime( buffer, bufferIndex + 24 ); - // e.changeTime = readTime( buffer, bufferIndex + 32 ); - e.endOfFile = readInt8( buffer, bufferIndex + 40 ); - // e.allocationSize = readInt8( buffer, bufferIndex + 48 ); - e.extFileAttributes = readInt4( buffer, bufferIndex + 56 ); - e.fileNameLength = readInt4( buffer, bufferIndex + 60 ); - // e.eaSize = readInt4( buffer, bufferIndex + 64 ); - // e.shortNameLength = buffer[bufferIndex + 68] & 0xFF; - - /* With NT, the shortName is in Unicode regardless of what is negotiated. - */ - - // e.shortName = readString( buffer, bufferIndex + 70, e.shortNameLength ); - e.filename = readString( buffer, bufferIndex + 94, e.fileNameLength ); - - /* lastNameOffset ends up pointing to either to - * the exact location of the filename(e.g. Win98) - * or to the start of the entry containing the - * filename(e.g. NT). Ahhrg! In either case the - * lastNameOffset falls between the start of the - * entry and the next entry. - */ - - if( lastNameBufferIndex >= bufferIndex && ( e.nextEntryOffset == 0 || - lastNameBufferIndex < ( bufferIndex + e.nextEntryOffset ))) { - lastName = e.filename; - resumeKey = e.fileIndex; - } - - bufferIndex += e.nextEntryOffset; - } - - /* last nextEntryOffset for NT 4(but not 98) is 0 so we must - * use dataCount or our accounting will report an error for NT :~( - */ - - //return bufferIndex - start; - - return dataCount; - } - public String toString() { - String c; - if( subCommand == SmbComTransaction.TRANS2_FIND_FIRST2 ) { - c = "Trans2FindFirst2Response["; - } else { - c = "Trans2FindNext2Response["; - } - return new String( c + super.toString() + - ",sid=" + sid + - ",searchCount=" + numEntries + - ",isEndOfSearch=" + isEndOfSearch + - ",eaErrorOffset=" + eaErrorOffset + - ",lastNameOffset=" + lastNameOffset + - ",lastName=" + lastName + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindNext2.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindNext2.java deleted file mode 100644 index b0d8894236..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2FindNext2.java +++ /dev/null @@ -1,91 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class Trans2FindNext2 extends SmbComTransaction { - - private int sid, informationLevel, resumeKey, flags; - private String filename; - - Trans2FindNext2( int sid, int resumeKey, String filename ) { - this.sid = sid; - this.resumeKey = resumeKey; - this.filename = filename; - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_FIND_NEXT2; - informationLevel = Trans2FindFirst2.SMB_FILE_BOTH_DIRECTORY_INFO; - flags = 0x00; - maxParameterCount = 8; - maxDataCount = Trans2FindFirst2.LIST_SIZE; - maxSetupCount = 0; - } - - void reset( int resumeKey, String lastName ) { - super.reset(); - this.resumeKey = resumeKey; - this.filename = lastName; - flags2 = 0; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( sid, dst, dstIndex ); - dstIndex += 2; - writeInt2( Trans2FindFirst2.LIST_COUNT, dst, dstIndex ); - dstIndex += 2; - writeInt2( informationLevel, dst, dstIndex ); - dstIndex += 2; - writeInt4( resumeKey, dst, dstIndex ); - dstIndex += 4; - writeInt2( flags, dst, dstIndex ); - dstIndex += 2; - dstIndex += writeString( filename, dst, dstIndex ); - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2FindNext2[" + super.toString() + - ",sid=" + sid + - ",searchCount=" + Trans2FindFirst2.LIST_SIZE + - ",informationLevel=0x" + Hexdump.toHexString( informationLevel, 3 ) + - ",resumeKey=0x" + Hexdump.toHexString( resumeKey, 4 ) + - ",flags=0x" + Hexdump.toHexString( flags, 2 ) + - ",filename=" + filename + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferral.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferral.java deleted file mode 100644 index 29e7d9764d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferral.java +++ /dev/null @@ -1,66 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class Trans2GetDfsReferral extends SmbComTransaction { - - private int maxReferralLevel = 3; - - Trans2GetDfsReferral( String filename ) { - path = filename; - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_GET_DFS_REFERRAL; - totalDataCount = 0; - maxParameterCount = 0; - maxDataCount = 4096; - maxSetupCount = (byte)0x00; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( maxReferralLevel, dst, dstIndex ); - dstIndex += 2; - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2GetDfsReferral[" + super.toString() + - ",maxReferralLevel=0x" + maxReferralLevel + - ",filename=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferralResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferralResponse.java deleted file mode 100644 index e1108f5653..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2GetDfsReferralResponse.java +++ /dev/null @@ -1,139 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class Trans2GetDfsReferralResponse extends SmbComTransactionResponse { - - class Referral { - private int version; - private int size; - private int serverType; - private int flags; - private int proximity; - private int pathOffset; - private int altPathOffset; - private int nodeOffset; - private String altPath; - - int ttl; - String path = null; - String node = null; - - int readWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - version = readInt2( buffer, bufferIndex ); -if( version != 3 && version != 1 ) { - throw new RuntimeException( "Version " + version + " referral not supported. Please report this to jcifs at samba dot org." ); -} - bufferIndex += 2; - size = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - serverType = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - flags = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - if( version == 3 ) { - proximity = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - ttl = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - pathOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - altPathOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - nodeOffset = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - - path = readString( buffer, start + pathOffset, len, (flags2 & FLAGS2_UNICODE) != 0); - if (nodeOffset > 0) - node = readString( buffer, start + nodeOffset, len, (flags2 & FLAGS2_UNICODE) != 0); - } else if( version == 1 ) { - node = readString( buffer, bufferIndex, len, (flags2 & FLAGS2_UNICODE) != 0); - } - - return size; - } - - public String toString() { - return new String( "Referral[" + - "version=" + version + ",size=" + size + - ",serverType=" + serverType + ",flags=" + flags + - ",proximity=" + proximity + ",ttl=" + ttl + - ",pathOffset=" + pathOffset + ",altPathOffset=" + altPathOffset + - ",nodeOffset=" + nodeOffset + ",path=" + path + ",altPath=" + altPath + - ",node=" + node + "]" ); - } - } - - int pathConsumed; - int numReferrals; - int flags; - Referral[] referrals; - - Trans2GetDfsReferralResponse() { - subCommand = SmbComTransaction.TRANS2_GET_DFS_REFERRAL; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - int start = bufferIndex; - - pathConsumed = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - /* Samba 2.2.8a will reply with Unicode paths even though - * ASCII is negotiated so we must use flags2 (probably - * should anyway). - */ - if((flags2 & FLAGS2_UNICODE) != 0) { - pathConsumed /= 2; - } - numReferrals = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - flags = readInt2( buffer, bufferIndex ); - bufferIndex += 4; - - referrals = new Referral[numReferrals]; - for (int ri = 0; ri < numReferrals; ri++) { - referrals[ri] = new Referral(); - bufferIndex += referrals[ri].readWireFormat( buffer, bufferIndex, len ); - } - - return bufferIndex - start; - } - public String toString() { - return new String( "Trans2GetDfsReferralResponse[" + - super.toString() + ",pathConsumed=" + pathConsumed + - ",numReferrals=" + numReferrals + ",flags=" + flags + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformation.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformation.java deleted file mode 100644 index c3ec7ff230..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformation.java +++ /dev/null @@ -1,74 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class Trans2QueryFSInformation extends SmbComTransaction { - - private int informationLevel; - - Trans2QueryFSInformation( int informationLevel ) { - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_QUERY_FS_INFORMATION; - this.informationLevel = informationLevel; - totalParameterCount = 2; - totalDataCount = 0; - maxParameterCount = 0; - maxDataCount = 800; - maxSetupCount = 0; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( informationLevel, dst, dstIndex ); - dstIndex += 2; - - /* windows98 has what appears to be another 4 0's followed by the share - * name as a zero terminated ascii string "\TMP" + '\0' - * - * As is this works, but it deviates from the spec section 4.1.6.6 but - * maybe I should put it in. Wonder what NT does? - */ - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2QueryFSInformation[" + super.toString() + - ",informationLevel=0x" + Hexdump.toHexString( informationLevel, 3 ) + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformationResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformationResponse.java deleted file mode 100644 index 62f54eb67e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryFSInformationResponse.java +++ /dev/null @@ -1,162 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class Trans2QueryFSInformationResponse extends SmbComTransactionResponse { - - // information levels - static final int SMB_INFO_ALLOCATION = 1; - static final int SMB_QUERY_FS_SIZE_INFO = 0x103; - static final int SMB_FS_FULL_SIZE_INFORMATION = 1007; - - class SmbInfoAllocation implements AllocInfo { - long alloc; // Also handles SmbQueryFSSizeInfo - long free; - int sectPerAlloc; - int bytesPerSect; - - public long getCapacity() { - return alloc * sectPerAlloc * bytesPerSect; - } - public long getFree() { - return free * sectPerAlloc * bytesPerSect; - } - public String toString() { - return new String( "SmbInfoAllocation[" + - "alloc=" + alloc + ",free=" + free + - ",sectPerAlloc=" + sectPerAlloc + - ",bytesPerSect=" + bytesPerSect + "]" ); - } - } - - private int informationLevel; - - AllocInfo info; - - Trans2QueryFSInformationResponse( int informationLevel ) { - this.informationLevel = informationLevel; - command = SMB_COM_TRANSACTION2; - subCommand = SmbComTransaction.TRANS2_QUERY_FS_INFORMATION; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - switch( informationLevel ) { - case SMB_INFO_ALLOCATION: - return readSmbInfoAllocationWireFormat( buffer, bufferIndex ); - case SMB_QUERY_FS_SIZE_INFO: - return readSmbQueryFSSizeInfoWireFormat( buffer, bufferIndex ); - case SMB_FS_FULL_SIZE_INFORMATION: - return readFsFullSizeInformationWireFormat( buffer, bufferIndex ); - default: - return 0; - } - } - - int readSmbInfoAllocationWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - SmbInfoAllocation info = new SmbInfoAllocation(); - - bufferIndex += 4; // skip idFileSystem - - info.sectPerAlloc = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - info.alloc = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - info.free = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - info.bytesPerSect = readInt2( buffer, bufferIndex ); - bufferIndex += 4; - - this.info = info; - - return bufferIndex - start; - } - int readSmbQueryFSSizeInfoWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - SmbInfoAllocation info = new SmbInfoAllocation(); - - info.alloc = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - - info.free = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - - info.sectPerAlloc = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - info.bytesPerSect = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - this.info = info; - - return bufferIndex - start; - } - int readFsFullSizeInformationWireFormat( byte[] buffer, int bufferIndex ) - { - int start = bufferIndex; - - SmbInfoAllocation info = new SmbInfoAllocation(); - - // Read total allocation units. - info.alloc = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - - // read caller available allocation units - info.free = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - - // skip actual free units - bufferIndex += 8; - - info.sectPerAlloc = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - info.bytesPerSect = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - - this.info = info; - - return bufferIndex - start; - } - - public String toString() { - return new String( "Trans2QueryFSInformationResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformation.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformation.java deleted file mode 100644 index 37cc5d3c5a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformation.java +++ /dev/null @@ -1,73 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -class Trans2QueryPathInformation extends SmbComTransaction { - - private int informationLevel; - - Trans2QueryPathInformation( String filename, int informationLevel ) { - path = filename; - this.informationLevel = informationLevel; - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_QUERY_PATH_INFORMATION; - totalDataCount = 0; - maxParameterCount = 2; - maxDataCount = 40; - maxSetupCount = (byte)0x00; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( informationLevel, dst, dstIndex ); - dstIndex += 2; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; - dstIndex += writeString( path, dst, dstIndex ); - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2QueryPathInformation[" + super.toString() + - ",informationLevel=0x" + Hexdump.toHexString( informationLevel, 3 ) + - ",filename=" + path + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformationResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformationResponse.java deleted file mode 100644 index 091d31d5d3..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2QueryPathInformationResponse.java +++ /dev/null @@ -1,161 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import jcifs.util.Hexdump; - -import java.util.Date; - -class Trans2QueryPathInformationResponse extends SmbComTransactionResponse { - - // information levels - static final int SMB_QUERY_FILE_BASIC_INFO = 0x101; - static final int SMB_QUERY_FILE_STANDARD_INFO = 0x102; - - class SmbQueryFileBasicInfo implements Info { - long createTime; - long lastAccessTime; - long lastWriteTime; - long changeTime; - int attributes; - - public int getAttributes() { - return attributes; - } - public long getCreateTime() { - return createTime; - } - public long getLastWriteTime() { - return lastWriteTime; - } - public long getSize() { - return 0L; - } - public String toString() { - return new String( "SmbQueryFileBasicInfo[" + - "createTime=" + new Date( createTime ) + - ",lastAccessTime=" + new Date( lastAccessTime ) + - ",lastWriteTime=" + new Date( lastWriteTime ) + - ",changeTime=" + new Date( changeTime ) + - ",attributes=0x" + Hexdump.toHexString( attributes, 4 ) + "]" ); - } - } - class SmbQueryFileStandardInfo implements Info { - long allocationSize; - long endOfFile; - int numberOfLinks; - boolean deletePending; - boolean directory; - - public int getAttributes() { - return 0; - } - public long getCreateTime() { - return 0L; - } - public long getLastWriteTime() { - return 0L; - } - public long getSize() { - return endOfFile; - } - public String toString() { - return new String( "SmbQueryInfoStandard[" + - "allocationSize=" + allocationSize + - ",endOfFile=" + endOfFile + - ",numberOfLinks=" + numberOfLinks + - ",deletePending=" + deletePending + - ",directory=" + directory + "]" ); - } - } - - private int informationLevel; - - Info info; - - Trans2QueryPathInformationResponse( int informationLevel ) { - this.informationLevel = informationLevel; - subCommand = SmbComTransaction.TRANS2_QUERY_PATH_INFORMATION; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - // observed two zero bytes here with at least win98 - return 2; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - switch( informationLevel ) { - case SMB_QUERY_FILE_BASIC_INFO: - return readSmbQueryFileBasicInfoWireFormat( buffer, bufferIndex ); - case SMB_QUERY_FILE_STANDARD_INFO: - return readSmbQueryFileStandardInfoWireFormat( buffer, bufferIndex ); - default: - return 0; - } - } - int readSmbQueryFileStandardInfoWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - SmbQueryFileStandardInfo info = new SmbQueryFileStandardInfo(); - info.allocationSize = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - info.endOfFile = readInt8( buffer, bufferIndex ); - bufferIndex += 8; - info.numberOfLinks = readInt4( buffer, bufferIndex ); - bufferIndex += 4; - info.deletePending = ( buffer[bufferIndex++] & 0xFF ) > 0; - info.directory = ( buffer[bufferIndex++] & 0xFF ) > 0; - this.info = info; - - return bufferIndex - start; - } - int readSmbQueryFileBasicInfoWireFormat( byte[] buffer, int bufferIndex ) { - int start = bufferIndex; - - SmbQueryFileBasicInfo info = new SmbQueryFileBasicInfo(); - info.createTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - info.lastAccessTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - info.lastWriteTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - info.changeTime = readTime( buffer, bufferIndex ); - bufferIndex += 8; - info.attributes = readInt2( buffer, bufferIndex ); - bufferIndex += 2; - this.info = info; - - return bufferIndex - start; - } - public String toString() { - return new String( "Trans2QueryPathInformationResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformation.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformation.java deleted file mode 100644 index 08a3017ef6..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformation.java +++ /dev/null @@ -1,89 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class Trans2SetFileInformation extends SmbComTransaction { - - static final int SMB_FILE_BASIC_INFO = 0x101; - - private int fid; - private int attributes; - private long createTime, lastWriteTime; - - Trans2SetFileInformation( int fid, int attributes, long createTime, long lastWriteTime ) { - this.fid = fid; - this.attributes = attributes; - this.createTime = createTime; - this.lastWriteTime = lastWriteTime; - command = SMB_COM_TRANSACTION2; - subCommand = TRANS2_SET_FILE_INFORMATION; - maxParameterCount = 6; - maxDataCount = 0; - maxSetupCount = (byte)0x00; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - return 2; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeInt2( fid, dst, dstIndex ); - dstIndex += 2; - writeInt2( SMB_FILE_BASIC_INFO, dst, dstIndex ); - dstIndex += 2; - writeInt2( 0, dst, dstIndex ); - dstIndex += 2; - - return dstIndex - start; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - int start = dstIndex; - - writeTime( createTime, dst, dstIndex ); dstIndex += 8; - writeInt8( 0L, dst, dstIndex ); dstIndex += 8; - writeTime( lastWriteTime, dst, dstIndex ); dstIndex += 8; - writeInt8( 0L, dst, dstIndex ); dstIndex += 8; -/* Samba 2.2.7 needs ATTR_NORMAL - */ - writeInt2( 0x80 | attributes, dst, dstIndex ); dstIndex += 2; - /* 6 zeros observed with NT */ - writeInt8( 0L, dst, dstIndex ); dstIndex += 6; - - /* Also observed 4 byte alignment but we stick - * with the default for jCIFS which is 2 */ - - return dstIndex - start; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2SetFileInformation[" + super.toString() + - ",fid=" + fid + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformationResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformationResponse.java deleted file mode 100644 index c67e892337..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/Trans2SetFileInformationResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2003 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class Trans2SetFileInformationResponse extends SmbComTransactionResponse { - - Trans2SetFileInformationResponse() { - subCommand = SmbComTransaction.TRANS2_SET_FILE_INFORMATION; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "Trans2SetFileInformationResponse[" + - super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipe.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipe.java deleted file mode 100644 index 73b734899f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipe.java +++ /dev/null @@ -1,73 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransCallNamedPipe extends SmbComTransaction { - - private byte[] pipeData; - private int pipeDataOff, pipeDataLen; - - TransCallNamedPipe( String pipeName, byte[] data, int off, int len ) { - name = pipeName; - pipeData = data; - pipeDataOff = off; - pipeDataLen = len; - command = SMB_COM_TRANSACTION; - subCommand = TRANS_CALL_NAMED_PIPE; - timeout = 0xFFFFFFFF; - maxParameterCount = 0; - maxDataCount = 0xFFFF; - maxSetupCount = (byte)0x00; - setupCount = 2; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - // this says "Transaction priority" in netmon - dst[dstIndex++] = (byte)0x00; // no FID - dst[dstIndex++] = (byte)0x00; - return 4; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - if(( dst.length - dstIndex ) < pipeDataLen ) { - if( log.level >= 3 ) - log.println( "TransCallNamedPipe data too long for buffer" ); - return 0; - } - System.arraycopy( pipeData, pipeDataOff, dst, dstIndex, pipeDataLen ); - return pipeDataLen; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransCallNamedPipe[" + super.toString() + - ",pipeName=" + name + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipeResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipeResponse.java deleted file mode 100644 index dbffa4428b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransCallNamedPipeResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransCallNamedPipeResponse extends SmbComTransactionResponse { - - private SmbNamedPipe pipe; - - TransCallNamedPipeResponse( SmbNamedPipe pipe ) { - this.pipe = pipe; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - if( pipe.pipeIn != null ) { - TransactNamedPipeInputStream in = (TransactNamedPipeInputStream)pipe.pipeIn; - synchronized( in.lock ) { - in.receive( buffer, bufferIndex, len ); - in.lock.notify(); - } - } - return len; - } - public String toString() { - return new String( "TransCallNamedPipeResponse[" + super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipe.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipe.java deleted file mode 100644 index 5ed7f90c28..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipe.java +++ /dev/null @@ -1,63 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransPeekNamedPipe extends SmbComTransaction { - - private int fid; - - TransPeekNamedPipe( String pipeName, int fid ) { - name = pipeName; - this.fid = fid; - command = SMB_COM_TRANSACTION; - subCommand = TRANS_PEEK_NAMED_PIPE; - timeout = 0xFFFFFFFF; - maxParameterCount = 6; - maxDataCount = 1; - maxSetupCount = (byte)0x00; - setupCount = 2; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - // this says "Transaction priority" in netmon - writeInt2( fid, dst, dstIndex ); - return 4; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransPeekNamedPipe[" + super.toString() + - ",pipeName=" + name + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipeResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipeResponse.java deleted file mode 100644 index 8b935da075..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransPeekNamedPipeResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransPeekNamedPipeResponse extends SmbComTransactionResponse { - - private SmbNamedPipe pipe; - private int head; - - static final int STATUS_DISCONNECTED = 1; - static final int STATUS_LISTENING = 2; - static final int STATUS_CONNECTION_OK = 3; - static final int STATUS_SERVER_END_CLOSED = 4; - - int status, available; - - TransPeekNamedPipeResponse( SmbNamedPipe pipe ) { - this.pipe = pipe; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - available = readInt2( buffer, bufferIndex ); bufferIndex += 2; - head = readInt2( buffer, bufferIndex ); bufferIndex += 2; - status = readInt2( buffer, bufferIndex ); - return 6; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransPeekNamedPipeResponse[" + super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipe.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipe.java deleted file mode 100644 index d67189a25b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipe.java +++ /dev/null @@ -1,72 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransTransactNamedPipe extends SmbComTransaction { - - private byte[] pipeData; - private int pipeFid, pipeDataOff, pipeDataLen; - - TransTransactNamedPipe( int fid, byte[] data, int off, int len ) { - pipeFid = fid; - pipeData = data; - pipeDataOff = off; - pipeDataLen = len; - command = SMB_COM_TRANSACTION; - subCommand = TRANS_TRANSACT_NAMED_PIPE; - maxParameterCount = 0; - maxDataCount = 0xFFFF; - maxSetupCount = (byte)0x00; - setupCount = 2; - name = "\\PIPE\\"; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - writeInt2( pipeFid, dst, dstIndex ); - dstIndex += 2; - return 4; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - if(( dst.length - dstIndex ) < pipeDataLen ) { - if( log.level >= 3 ) - log.println( "TransTransactNamedPipe data too long for buffer" ); - return 0; - } - System.arraycopy( pipeData, pipeDataOff, dst, dstIndex, pipeDataLen ); - return pipeDataLen; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransTransactNamedPipe[" + super.toString() + - ",pipeFid=" + pipeFid + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipeResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipeResponse.java deleted file mode 100644 index 9dd16d0b3b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransTransactNamedPipeResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransTransactNamedPipeResponse extends SmbComTransactionResponse { - - private SmbNamedPipe pipe; - - TransTransactNamedPipeResponse( SmbNamedPipe pipe ) { - this.pipe = pipe; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - if( pipe.pipeIn != null ) { - TransactNamedPipeInputStream in = (TransactNamedPipeInputStream)pipe.pipeIn; - synchronized( in.lock ) { - in.receive( buffer, bufferIndex, len ); - in.lock.notify(); - } - } - return len; - } - public String toString() { - return new String( "TransTransactNamedPipeResponse[" + super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipe.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipe.java deleted file mode 100644 index fcc8368254..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipe.java +++ /dev/null @@ -1,60 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransWaitNamedPipe extends SmbComTransaction { - - TransWaitNamedPipe( String pipeName ) { - name = pipeName; - command = SMB_COM_TRANSACTION; - subCommand = TRANS_WAIT_NAMED_PIPE; - timeout = 0xFFFFFFFF; - maxParameterCount = 0; - maxDataCount = 0; - maxSetupCount = (byte)0x00; - setupCount = 2; - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - dst[dstIndex++] = subCommand; - dst[dstIndex++] = (byte)0x00; - dst[dstIndex++] = (byte)0x00; // no FID - dst[dstIndex++] = (byte)0x00; - return 4; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransWaitNamedPipe[" + super.toString() + - ",pipeName=" + name + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipeResponse.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipeResponse.java deleted file mode 100644 index 91862866a4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransWaitNamedPipeResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -class TransWaitNamedPipeResponse extends SmbComTransactionResponse { - - // not much to this one is there :~) - - TransWaitNamedPipeResponse() { - } - - int writeSetupWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeParametersWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int writeDataWireFormat( byte[] dst, int dstIndex ) { - return 0; - } - int readSetupWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readParametersWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - int readDataWireFormat( byte[] buffer, int bufferIndex, int len ) { - return 0; - } - public String toString() { - return new String( "TransWaitNamedPipeResponse[" + super.toString() + "]" ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeInputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeInputStream.java deleted file mode 100644 index 9f63a2d0a5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeInputStream.java +++ /dev/null @@ -1,135 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.UnknownHostException; - -class TransactNamedPipeInputStream extends SmbFileInputStream { - - private static final int INIT_PIPE_SIZE = 4096; - - private byte[] pipe_buf = new byte[INIT_PIPE_SIZE]; - private int beg_idx, nxt_idx, used; - private boolean dcePipe; - - Object lock; - - TransactNamedPipeInputStream( SmbNamedPipe pipe ) throws SmbException, - MalformedURLException, UnknownHostException { - super( pipe, ( pipe.pipeType & 0xFFFF00FF ) | SmbFile.O_EXCL ); - this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) != SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; - lock = new Object(); - } - public int read() throws IOException { - int result = -1; - - synchronized( lock ) { - try { - while( used == 0 ) { - lock.wait(); - } - } catch( InterruptedException ie ) { - throw new IOException( ie.getMessage() ); - } - result = pipe_buf[beg_idx] & 0xFF; - beg_idx = ( beg_idx + 1 ) % pipe_buf.length; - } - return result; - } - public int read( byte[] b ) throws IOException { - return read( b, 0, b.length ); - } - public int read( byte[] b, int off, int len ) throws IOException { - int result = -1; - int i; - - if( len <= 0 ) { - return 0; - } - synchronized( lock ) { - try { - while( used == 0 ) { - lock.wait(); - } - } catch( InterruptedException ie ) { - throw new IOException( ie.getMessage() ); - } - i = pipe_buf.length - beg_idx; - result = len > used ? used : len; - if( used > i && result > i ) { - System.arraycopy( pipe_buf, beg_idx, b, off, i ); - off += i; - System.arraycopy( pipe_buf, 0, b, off, result - i ); - } else { - System.arraycopy( pipe_buf, beg_idx, b, off, result ); - } - used -= result; - beg_idx = ( beg_idx + result ) % pipe_buf.length; - } - - return result; - } - public int available() throws IOException { - if( file.log.level >= 3 ) - file.log.println( "Named Pipe available() does not apply to TRANSACT Named Pipes" ); - return 0; - } - int receive( byte[] b, int off, int len ) { - int i; - - if( len > ( pipe_buf.length - used )) { - byte[] tmp; - int new_size; - - new_size = pipe_buf.length * 2; - if( len > ( new_size - used )) { - new_size = len + used; - } - tmp = pipe_buf; - pipe_buf = new byte[new_size]; - i = tmp.length - beg_idx; - if( used > i ) { /* 2 chunks */ - System.arraycopy( tmp, beg_idx, pipe_buf, 0, i ); - System.arraycopy( tmp, 0, pipe_buf, i, used - i ); - } else { - System.arraycopy( tmp, beg_idx, pipe_buf, 0, used ); - } - beg_idx = 0; - nxt_idx = used; - tmp = null; - } - - i = pipe_buf.length - nxt_idx; - if( len > i ) { - System.arraycopy( b, off, pipe_buf, nxt_idx, i ); - off += i; - System.arraycopy( b, off, pipe_buf, 0, len - i ); - } else { - System.arraycopy( b, off, pipe_buf, nxt_idx, len ); - } - nxt_idx = ( nxt_idx + len ) % pipe_buf.length; - used += len; - return len; - } - public int dce_read( byte[] b, int off, int len ) throws IOException { - return super.read(b, off, len); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeOutputStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeOutputStream.java deleted file mode 100644 index 70019d0fa4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/TransactNamedPipeOutputStream.java +++ /dev/null @@ -1,68 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -import java.io.IOException; - -class TransactNamedPipeOutputStream extends SmbFileOutputStream { - - private String path; - private SmbNamedPipe pipe; - private byte[] tmp = new byte[1]; - private boolean dcePipe; - - TransactNamedPipeOutputStream( SmbNamedPipe pipe ) throws IOException { - super(pipe, false, (pipe.pipeType & 0xFFFF00FF) | SmbFile.O_EXCL); - this.pipe = pipe; - this.dcePipe = ( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT ) == SmbNamedPipe.PIPE_TYPE_DCE_TRANSACT; - path = pipe.unc; - } - - public void close() throws IOException { - pipe.close(); - } - public void write( int b ) throws IOException { - tmp[0] = (byte)b; - write( tmp, 0, 1 ); - } - public void write( byte[] b ) throws IOException { - write( b, 0, b.length ); - } - public void write( byte[] b, int off, int len ) throws IOException { - if( len < 0 ) { - len = 0; - } - - if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_CALL ) == SmbNamedPipe.PIPE_TYPE_CALL ) { - pipe.send( new TransWaitNamedPipe( path ), - new TransWaitNamedPipeResponse() ); - pipe.send( new TransCallNamedPipe( path, b, off, len ), - new TransCallNamedPipeResponse( pipe )); - } else if(( pipe.pipeType & SmbNamedPipe.PIPE_TYPE_TRANSACT ) == - SmbNamedPipe.PIPE_TYPE_TRANSACT ) { - ensureOpen(); - TransTransactNamedPipe req = new TransTransactNamedPipe( pipe.fid, b, off, len ); - if (dcePipe) { - req.maxDataCount = 1024; - } - pipe.send( req, new TransTransactNamedPipeResponse( pipe )); - } - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/WinError.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/WinError.java deleted file mode 100644 index 586cf6caa2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/smb/WinError.java +++ /dev/null @@ -1,61 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2004 "Michael B. Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.smb; - -public interface WinError { - - /* Don't bother to edit this. Everthing within the interface - * block is automatically generated from the ntstatus package. - */ - - public static final int ERROR_SUCCESS = 0; - public static final int ERROR_ACCESS_DENIED = 5; - public static final int ERROR_REQ_NOT_ACCEP = 71; - public static final int ERROR_BAD_PIPE = 230; - public static final int ERROR_PIPE_BUSY = 231; - public static final int ERROR_NO_DATA = 232; - public static final int ERROR_PIPE_NOT_CONNECTED = 233; - public static final int ERROR_MORE_DATA = 234; - public static final int ERROR_NO_BROWSER_SERVERS_FOUND = 6118; - - static final int[] WINERR_CODES = { - ERROR_SUCCESS, - ERROR_ACCESS_DENIED, - ERROR_REQ_NOT_ACCEP, - ERROR_BAD_PIPE, - ERROR_PIPE_BUSY, - ERROR_NO_DATA, - ERROR_PIPE_NOT_CONNECTED, - ERROR_MORE_DATA, - ERROR_NO_BROWSER_SERVERS_FOUND, - }; - - static final String[] WINERR_MESSAGES = { - "The operation completed successfully.", - "Access is denied.", - "No more connections can be made to this remote computer at this time because there are already as many connections as the computer can accept.", - "The pipe state is invalid.", - "All pipe instances are busy.", - "The pipe is being closed.", - "No process is on the other end of the pipe.", - "More data is available.", - "The list of servers for this workgroup is not currently available.", - }; -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Base64.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Base64.java deleted file mode 100644 index 6623a766cd..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Base64.java +++ /dev/null @@ -1,94 +0,0 @@ -/* Encodes and decodes to and from Base64 notation. - * Copyright (C) 2003 "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -public class Base64 { - - private static final String ALPHABET = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - /** - * Base-64 encodes the supplied block of data. Line wrapping is not - * applied on output. - * - * @param bytes The block of data that is to be Base-64 encoded. - * @return A Stringcontaining the encoded data. - */ - public static String encode(byte[] bytes) { - int length = bytes.length; - if (length == 0) return ""; - StringBuffer buffer = - new StringBuffer((int) Math.ceil((double) length / 3d) * 4); - int remainder = length % 3; - length -= remainder; - int block; - int i = 0; - while (i < length) { - block = ((bytes[i++] & 0xff) << 16) | ((bytes[i++] & 0xff) << 8) | - (bytes[i++] & 0xff); - buffer.append(ALPHABET.charAt(block >>> 18)); - buffer.append(ALPHABET.charAt((block >>> 12) & 0x3f)); - buffer.append(ALPHABET.charAt((block >>> 6) & 0x3f)); - buffer.append(ALPHABET.charAt(block & 0x3f)); - } - if (remainder == 0) return buffer.toString(); - if (remainder == 1) { - block = (bytes[i] & 0xff) << 4; - buffer.append(ALPHABET.charAt(block >>> 6)); - buffer.append(ALPHABET.charAt(block & 0x3f)); - buffer.append("=="); - return buffer.toString(); - } - block = (((bytes[i++] & 0xff) << 8) | ((bytes[i]) & 0xff)) << 2; - buffer.append(ALPHABET.charAt(block >>> 12)); - buffer.append(ALPHABET.charAt((block >>> 6) & 0x3f)); - buffer.append(ALPHABET.charAt(block & 0x3f)); - buffer.append("="); - return buffer.toString(); - } - - /** - * Decodes the supplied Base-64 encoded string. - * - * @param string The Base-64 encoded string that is to be decoded. - * @return Abyte[]containing the decoded data block. - */ - public static byte[] decode(String string) { - int length = string.length(); - if (length == 0) return new byte[0]; - int pad = (string.charAt(length - 2) == '=') ? 2 : - (string.charAt(length - 1) == '=') ? 1 : 0; - int size = length * 3 / 4 - pad; - byte[] buffer = new byte[size]; - int block; - int i = 0; - int index = 0; - while (i < length) { - block = (ALPHABET.indexOf(string.charAt(i++)) & 0xff) << 18 | - (ALPHABET.indexOf(string.charAt(i++)) & 0xff) << 12 | - (ALPHABET.indexOf(string.charAt(i++)) & 0xff) << 6 | - (ALPHABET.indexOf(string.charAt(i++)) & 0xff); - buffer[index++] = (byte) (block >>> 16); - if (index < size) buffer[index++] = (byte) ((block >>> 8) & 0xff); - if (index < size) buffer[index++] = (byte) (block & 0xff); - } - return buffer; - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/DES.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/DES.java deleted file mode 100644 index e859484fbf..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/DES.java +++ /dev/null @@ -1,549 +0,0 @@ -// DesCipher - the DES encryption method -// -// The meat of this code is by Dave Zimmerman, and is: -// -// Copyright (c) 1996 Widget Workshop, Inc. All Rights Reserved. -// -// Permission to use, copy, modify, and distribute this software -// and its documentation for NON-COMMERCIAL or COMMERCIAL purposes and -// without fee is hereby granted, provided that this copyright notice is kept -// intact. -// -// WIDGET WORKSHOP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY -// OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -// TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE, OR NON-INFRINGEMENT. WIDGET WORKSHOP SHALL NOT BE LIABLE -// FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR -// DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -// -// THIS SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE OR RESALE AS ON-LINE -// CONTROL EQUIPMENT IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE -// PERFORMANCE, SUCH AS IN THE OPERATION OF NUCLEAR FACILITIES, AIRCRAFT -// NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL, DIRECT LIFE -// SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH THE FAILURE OF THE -// SOFTWARE COULD LEAD DIRECTLY TO DEATH, PERSONAL INJURY, OR SEVERE -// PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH RISK ACTIVITIES"). WIDGET WORKSHOP -// SPECIFICALLY DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR -// HIGH RISK ACTIVITIES. -// -// -// The rest is: -// -// Copyright (C) 1996 by Jef Poskanzer . All rights reserved. -// -// Copyright (C) 1996 by Wolfgang Platzer -// email: wplatzer@iaik.tu-graz.ac.at -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions 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. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// - -package jcifs.util; - -/** - * This code is derived from the above source - * JCIFS API - * Norbert Hranitzky - * - * and modified again by Michael B. Allen - */ - -public class DES { - - - private int[] encryptKeys = new int[32]; - private int[] decryptKeys = new int[32]; - - private int[] tempInts = new int[2]; - - - public DES( ) { - - } - - // Constructor, byte-array key. - public DES( byte[] key ) { - if( key.length == 7 ) { - byte[] key8 = new byte[8]; - makeSMBKey( key, key8 ); - setKey( key8 ); - } else { - setKey( key ); - } - } - - - public static void makeSMBKey(byte[] key7, byte[] key8) { - - int i; - - key8[0] = (byte) ( ( key7[0] >> 1) & 0xff); - key8[1] = (byte)(( ((key7[0] & 0x01) << 6) | (((key7[1] & 0xff)>>2) & 0xff)) & 0xff ); - key8[2] = (byte)(( ((key7[1] & 0x03) << 5) | (((key7[2] & 0xff)>>3) & 0xff)) & 0xff ); - key8[3] = (byte)(( ((key7[2] & 0x07) << 4) | (((key7[3] & 0xff)>>4) & 0xff)) & 0xff ); - key8[4] = (byte)(( ((key7[3] & 0x0F) << 3) | (((key7[4] & 0xff)>>5) & 0xff)) & 0xff ); - key8[5] = (byte)(( ((key7[4] & 0x1F) << 2) | (((key7[5] & 0xff)>>6) & 0xff)) & 0xff ); - key8[6] = (byte)(( ((key7[5] & 0x3F) << 1) | (((key7[6] & 0xff)>>7) & 0xff)) & 0xff ); - key8[7] = (byte)(key7[6] & 0x7F); - for (i=0;i<8;i++) { - key8[i] = (byte)( key8[i] << 1); - } - } - - /// Set the key. - public void setKey( byte[] key ) { - - // CHECK PAROTY TBD - deskey( key, true, encryptKeys ); - deskey( key, false, decryptKeys ); - } - - // Turn an 8-byte key into internal keys. - private void deskey( byte[] keyBlock, boolean encrypting, int[] KnL ) { - - int i, j, l, m, n; - int[] pc1m = new int[56]; - int[] pcr = new int[56]; - int[] kn = new int[32]; - - for ( j = 0; j < 56; ++j ) { - l = pc1[j]; - m = l & 07; - pc1m[j] = ( (keyBlock[l >>> 3] & bytebit[m]) != 0 )? 1: 0; - } - - for ( i = 0; i < 16; ++i ) { - - if ( encrypting ) - m = i << 1; - else - m = (15-i) << 1; - n = m+1; - kn[m] = kn[n] = 0; - for ( j = 0; j < 28; ++j ) { - l = j+totrot[i]; - if ( l < 28 ) - pcr[j] = pc1m[l]; - else - pcr[j] = pc1m[l-28]; - } - for ( j=28; j < 56; ++j ) { - l = j+totrot[i]; - if ( l < 56 ) - pcr[j] = pc1m[l]; - else - pcr[j] = pc1m[l-28]; - } - for ( j = 0; j < 24; ++j ) { - if ( pcr[pc2[j]] != 0 ) - kn[m] |= bigbyte[j]; - if ( pcr[pc2[j+24]] != 0 ) - kn[n] |= bigbyte[j]; - } - } - cookey( kn, KnL ); - } - - private void cookey( int[] raw, int KnL[] ) { - int raw0, raw1; - int rawi, KnLi; - int i; - - for ( i = 0, rawi = 0, KnLi = 0; i < 16; ++i ) { - raw0 = raw[rawi++]; - raw1 = raw[rawi++]; - KnL[KnLi] = (raw0 & 0x00fc0000) << 6; - KnL[KnLi] |= (raw0 & 0x00000fc0) << 10; - KnL[KnLi] |= (raw1 & 0x00fc0000) >>> 10; - KnL[KnLi] |= (raw1 & 0x00000fc0) >>> 6; - ++KnLi; - KnL[KnLi] = (raw0 & 0x0003f000) << 12; - KnL[KnLi] |= (raw0 & 0x0000003f) << 16; - KnL[KnLi] |= (raw1 & 0x0003f000) >>> 4; - KnL[KnLi] |= (raw1 & 0x0000003f); - ++KnLi; - } - } - - - /// Encrypt a block of eight bytes. - private void encrypt( byte[] clearText, int clearOff, byte[] cipherText, int cipherOff ) { - - squashBytesToInts( clearText, clearOff, tempInts, 0, 2 ); - des( tempInts, tempInts, encryptKeys ); - spreadIntsToBytes( tempInts, 0, cipherText, cipherOff, 2 ); - } - - /// Decrypt a block of eight bytes. - private void decrypt( byte[] cipherText, int cipherOff, byte[] clearText, int clearOff ) { - - squashBytesToInts( cipherText, cipherOff, tempInts, 0, 2 ); - des( tempInts, tempInts, decryptKeys ); - spreadIntsToBytes( tempInts, 0, clearText, clearOff, 2 ); - } - - // The DES function. - private void des( int[] inInts, int[] outInts, int[] keys ) { - - int fval, work, right, leftt; - int round; - int keysi = 0; - - leftt = inInts[0]; - right = inInts[1]; - - work = ((leftt >>> 4) ^ right) & 0x0f0f0f0f; - right ^= work; - leftt ^= (work << 4); - - work = ((leftt >>> 16) ^ right) & 0x0000ffff; - right ^= work; - leftt ^= (work << 16); - - work = ((right >>> 2) ^ leftt) & 0x33333333; - leftt ^= work; - right ^= (work << 2); - - work = ((right >>> 8) ^ leftt) & 0x00ff00ff; - leftt ^= work; - right ^= (work << 8); - right = (right << 1) | ((right >>> 31) & 1); - - work = (leftt ^ right) & 0xaaaaaaaa; - leftt ^= work; - right ^= work; - leftt = (leftt << 1) | ((leftt >>> 31) & 1); - - for ( round = 0; round < 8; ++round ) { - work = (right << 28) | (right >>> 4); - work ^= keys[keysi++]; - fval = SP7[ work & 0x0000003f ]; - fval |= SP5[(work >>> 8) & 0x0000003f ]; - fval |= SP3[(work >>> 16) & 0x0000003f ]; - fval |= SP1[(work >>> 24) & 0x0000003f ]; - work = right ^ keys[keysi++]; - fval |= SP8[ work & 0x0000003f ]; - fval |= SP6[(work >>> 8) & 0x0000003f ]; - fval |= SP4[(work >>> 16) & 0x0000003f ]; - fval |= SP2[(work >>> 24) & 0x0000003f ]; - leftt ^= fval; - work = (leftt << 28) | (leftt >>> 4); - work ^= keys[keysi++]; - fval = SP7[ work & 0x0000003f ]; - fval |= SP5[(work >>> 8) & 0x0000003f ]; - fval |= SP3[(work >>> 16) & 0x0000003f ]; - fval |= SP1[(work >>> 24) & 0x0000003f ]; - work = leftt ^ keys[keysi++]; - fval |= SP8[ work & 0x0000003f ]; - fval |= SP6[(work >>> 8) & 0x0000003f ]; - fval |= SP4[(work >>> 16) & 0x0000003f ]; - fval |= SP2[(work >>> 24) & 0x0000003f ]; - right ^= fval; - } - - right = (right << 31) | (right >>> 1); - work = (leftt ^ right) & 0xaaaaaaaa; - leftt ^= work; - right ^= work; - leftt = (leftt << 31) | (leftt >>> 1); - work = ((leftt >>> 8) ^ right) & 0x00ff00ff; - right ^= work; - leftt ^= (work << 8); - work = ((leftt >>> 2) ^ right) & 0x33333333; - right ^= work; - leftt ^= (work << 2); - work = ((right >>> 16) ^ leftt) & 0x0000ffff; - leftt ^= work; - right ^= (work << 16); - work = ((right >>> 4) ^ leftt) & 0x0f0f0f0f; - leftt ^= work; - right ^= (work << 4); - outInts[0] = right; - outInts[1] = leftt; - } - - - /// Encrypt a block of bytes. - public void encrypt( byte[] clearText, byte[] cipherText ) { - encrypt( clearText, 0, cipherText, 0 ); - } - - /// Decrypt a block of bytes. - public void decrypt( byte[] cipherText, byte[] clearText ) { - - decrypt( cipherText, 0, clearText, 0 ); - } - - /** - * encrypts an array where the length must be a multiple of 8 - */ - public byte[] encrypt(byte[] clearText) { - - int length = clearText.length; - - if (length % 8 != 0) { - System.out.println("Array must be a multiple of 8"); - return null; - } - - byte[] cipherText = new byte[length]; - int count = length / 8; - - for (int i=0; i
>> 24 ); - outBytes[outOff + i * 4 + 1] = (byte) ( inInts[inOff + i] >>> 16 ); - outBytes[outOff + i * 4 + 2] = (byte) ( inInts[inOff + i] >>> 8 ); - outBytes[outOff + i * 4 + 3] = (byte) inInts[inOff + i]; - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Encdec.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Encdec.java deleted file mode 100644 index 403aac64a1..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Encdec.java +++ /dev/null @@ -1,314 +0,0 @@ -/* encdec - encode and decode integers, times, and - * internationalized strings to and from popular binary formats - * http://www.ioplex.com/~miallen/encdec/ - * Copyright (c) 2003 Michael B. Allen - * - * The GNU Library General Public License - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, - * MA 02111-1307, USA - */ - -package jcifs.util; - -import java.io.IOException; -import java.util.Date; - -public class Encdec { - - public static final long MILLISECONDS_BETWEEN_1970_AND_1601 = 11644473600000L; - public static final long SEC_BETWEEEN_1904_AND_1970 = 2082844800L; - public static final int TIME_1970_SEC_32BE = 1; - public static final int TIME_1970_SEC_32LE = 2; - public static final int TIME_1904_SEC_32BE = 3; - public static final int TIME_1904_SEC_32LE = 4; - public static final int TIME_1601_NANOS_64LE = 5; - public static final int TIME_1601_NANOS_64BE = 6; - public static final int TIME_1970_MILLIS_64BE = 7; - public static final int TIME_1970_MILLIS_64LE = 8; - - /* Encode integers - */ - - public static int enc_uint16be( short s, byte[] dst, int di ) { - dst[di++] = (byte)((s >> 8) & 0xFF); - dst[di] = (byte)(s & 0xFF); - return 2; - } - public static int enc_uint32be( int i, byte[] dst, int di ) { - dst[di++] = (byte)((i >> 24) & 0xFF); - dst[di++] = (byte)((i >> 16) & 0xFF); - dst[di++] = (byte)((i >> 8) & 0xFF); - dst[di] = (byte)(i & 0xFF); - return 4; - } - public static int enc_uint16le( short s, byte[] dst, int di ) - { - dst[di++] = (byte)(s & 0xFF); - dst[di] = (byte)((s >> 8) & 0xFF); - return 2; - } - public static int enc_uint32le( int i, byte[] dst, int di ) - { - dst[di++] = (byte)(i & 0xFF); - dst[di++] = (byte)((i >> 8) & 0xFF); - dst[di++] = (byte)((i >> 16) & 0xFF); - dst[di] = (byte)((i >> 24) & 0xFF); - return 4; - } - - /* Decode integers - */ - - public static short dec_uint16be( byte[] src, int si ) - { - return (short)(((src[si] & 0xFF) << 8) | (src[si + 1] & 0xFF)); - } - public static int dec_uint32be( byte[] src, int si ) - { - return ((src[si] & 0xFF) << 24) | ((src[si + 1] & 0xFF) << 16) | - ((src[si + 2] & 0xFF) << 8) | (src[si + 3] & 0xFF); - } - public static short dec_uint16le( byte[] src, int si ) - { - return (short)((src[si] & 0xFF) | ((src[si + 1] & 0xFF) << 8)); - } - public static int dec_uint32le( byte[] src, int si ) - { - return (src[si] & 0xFF) | ((src[si + 1] & 0xFF) << 8) | - ((src[si + 2] & 0xFF) << 16) | ((src[si + 3] & 0xFF) << 24); - } - - /* Encode and decode 64 bit integers - */ - - public static int enc_uint64be( long l, byte[] dst, int di ) - { - enc_uint32be( (int)(l & 0xFFFFFFFFL), dst, di + 4 ); - enc_uint32be( (int)(( l >> 32L ) & 0xFFFFFFFFL), dst, di ); - return 8; - } - public static int enc_uint64le( long l, byte[] dst, int di ) - { - enc_uint32le( (int)(l & 0xFFFFFFFFL), dst, di ); - enc_uint32le( (int)(( l >> 32L ) & 0xFFFFFFFFL), dst, di + 4 ); - return 8; - } - public static long dec_uint64be( byte[] src, int si ) - { - long l; - l = dec_uint32be( src, si ) & 0xFFFFFFFFL; - l <<= 32L; - l |= dec_uint32be( src, si + 4 ) & 0xFFFFFFFFL; - return l; - } - public static long dec_uint64le( byte[] src, int si ) - { - long l; - l = dec_uint32le( src, si + 4 ) & 0xFFFFFFFFL; - l <<= 32L; - l |= dec_uint32le( src, si ) & 0xFFFFFFFFL; - return l; - } - - /* Encode floats - */ - - public static int enc_floatle( float f, byte[] dst, int di ) - { - return enc_uint32le( Float.floatToIntBits( f ), dst, di ); - } - public static int enc_floatbe( float f, byte[] dst, int di ) - { - return enc_uint32be( Float.floatToIntBits( f ), dst, di ); - } - - /* Decode floating point numbers - */ - - public static float dec_floatle( byte[] src, int si ) - { - return Float.intBitsToFloat( dec_uint32le( src, si )); - } - public static float dec_floatbe( byte[] src, int si ) - { - return Float.intBitsToFloat( dec_uint32be( src, si )); - } - - /* Encode and decode doubles - */ - - public static int enc_doublele( double d, byte[] dst, int di ) - { - return enc_uint64le( Double.doubleToLongBits( d ), dst, di ); - } - public static int enc_doublebe( double d, byte[] dst, int di ) - { - return enc_uint64be( Double.doubleToLongBits( d ), dst, di ); - } - public static double dec_doublele( byte[] src, int si ) - { - return Double.longBitsToDouble( dec_uint64le( src, si )); - } - public static double dec_doublebe( byte[] src, int si ) - { - return Double.longBitsToDouble( dec_uint64be( src, si )); - } - - /* Encode times - */ - - public static int enc_time( Date date, byte[] dst, int di, int enc ) - { - long t; - - switch( enc ) { - case TIME_1970_SEC_32BE: - return enc_uint32be( (int)(date.getTime() / 1000L), dst, di ); - case TIME_1970_SEC_32LE: - return enc_uint32le( (int)(date.getTime() / 1000L), dst, di ); - case TIME_1904_SEC_32BE: - return enc_uint32be( (int)((date.getTime() / 1000L + - SEC_BETWEEEN_1904_AND_1970) & 0xFFFFFFFF), dst, di ); - case TIME_1904_SEC_32LE: - return enc_uint32le( (int)((date.getTime() / 1000L + - SEC_BETWEEEN_1904_AND_1970) & 0xFFFFFFFF), dst, di ); - case TIME_1601_NANOS_64BE: - t = (date.getTime() + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L; - return enc_uint64be( t, dst, di ); - case TIME_1601_NANOS_64LE: - t = (date.getTime() + MILLISECONDS_BETWEEN_1970_AND_1601) * 10000L; - return enc_uint64le( t, dst, di ); - case TIME_1970_MILLIS_64BE: - return enc_uint64be( date.getTime(), dst, di ); - case TIME_1970_MILLIS_64LE: - return enc_uint64le( date.getTime(), dst, di ); - default: - throw new IllegalArgumentException( "Unsupported time encoding" ); - } - } - - /* Decode times - */ - - public static Date dec_time( byte[] src, int si, int enc ) - { - long t; - - switch( enc ) { - case TIME_1970_SEC_32BE: - return new Date( dec_uint32be( src, si ) * 1000L ); - case TIME_1970_SEC_32LE: - return new Date( dec_uint32le( src, si ) * 1000L ); - case TIME_1904_SEC_32BE: - return new Date((( dec_uint32be( src, si ) & 0xFFFFFFFFL) - - SEC_BETWEEEN_1904_AND_1970 ) * 1000L ); - case TIME_1904_SEC_32LE: - return new Date((( dec_uint32le( src, si ) & 0xFFFFFFFFL) - - SEC_BETWEEEN_1904_AND_1970 ) * 1000L ); - case TIME_1601_NANOS_64BE: - t = dec_uint64be( src, si ); - return new Date( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601); - case TIME_1601_NANOS_64LE: - t = dec_uint64le( src, si ); - return new Date( t / 10000L - MILLISECONDS_BETWEEN_1970_AND_1601); - case TIME_1970_MILLIS_64BE: - return new Date( dec_uint64be( src, si )); - case TIME_1970_MILLIS_64LE: - return new Date( dec_uint64le( src, si )); - default: - throw new IllegalArgumentException( "Unsupported time encoding" ); - } - } - - public static int enc_utf8( String str, byte[] dst, int di, int dlim ) throws IOException { - int start = di, ch; - int strlen = str.length(); - - for( int i = 0; di < dlim && i < strlen; i++ ) { - ch = str.charAt( i ); - if ((ch >= 0x0001) && (ch <= 0x007F)) { - dst[di++] = (byte)ch; - } else if (ch > 0x07FF) { - if((dlim - di) < 3 ) { - break; - } - dst[di++] = (byte)(0xE0 | ((ch >> 12) & 0x0F)); - dst[di++] = (byte)(0x80 | ((ch >> 6) & 0x3F)); - dst[di++] = (byte)(0x80 | ((ch >> 0) & 0x3F)); - } else { - if((dlim - di) < 2 ) { - break; - } - dst[di++] = (byte)(0xC0 | ((ch >> 6) & 0x1F)); - dst[di++] = (byte)(0x80 | ((ch >> 0) & 0x3F)); - } - } - - return di - start; - } - public static String dec_utf8( byte[] src, int si, int slim ) throws IOException { - char[] uni = new char[slim - si]; - int ui, ch; - - for( ui = 0; si < slim && (ch = src[si++] & 0xFF) != 0; ui++ ) { - if( ch < 0x80 ) { - uni[ui] = (char)ch; - } else if((ch & 0xE0) == 0xC0 ) { - if((slim - si) < 2 ) { - break; - } - uni[ui] = (char)((ch & 0x1F) << 6); - ch = src[si++] & 0xFF; - uni[ui] |= ch & 0x3F; - if ((ch & 0xC0) != 0x80 || uni[ui] < 0x80 ) { - throw new IOException( "Invalid UTF-8 sequence" ); - } - } else if((ch & 0xF0) == 0xE0 ) { - if((slim - si) < 3 ) { - break; - } - uni[ui] = (char)((ch & 0x0F) << 12); - ch = src[si++] & 0xFF; - if ((ch & 0xC0) != 0x80 ) { - throw new IOException( "Invalid UTF-8 sequence" ); - } else { - uni[ui] |= (ch & 0x3F) << 6; - ch = src[si++] & 0xFF; - uni[ui] |= ch & 0x3F; - if ((ch & 0xC0) != 0x80 || uni[ui] < 0x800) { - throw new IOException( "Invalid UTF-8 sequence" ); - } - } - } else { - throw new IOException( "Unsupported UTF-8 sequence" ); - } - } - - return new String( uni, 0, ui ); - } - public static String dec_ucs2le( byte[] src, int si, int slim, char[] buf ) throws IOException { - int bi; - - for( bi = 0; (si + 1) < slim; bi++, si += 2 ) { - buf[bi] = (char)dec_uint16le( src, si ); - if( buf[bi] == '\0' ) { - break; - } - } - - return new String( buf, 0, bi ); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/HMACT64.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/HMACT64.java deleted file mode 100644 index 5a3093fdff..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/HMACT64.java +++ /dev/null @@ -1,116 +0,0 @@ -/* HMACT64 keyed hashing algorithm - * Copyright (C) 2003 "Eric Glass" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -import java.security.MessageDigest; - -/** - * This is an implementation of the HMACT64 keyed hashing algorithm. - * HMACT64 is defined by Luke Leighton as a modified HMAC-MD5 (RFC 2104) - * in which the key is truncated at 64 bytes (rather than being hashed - * via MD5). - */ -public class HMACT64 extends MessageDigest implements Cloneable { - - private static final int BLOCK_LENGTH = 64; - - private static final byte IPAD = (byte) 0x36; - - private static final byte OPAD = (byte) 0x5c; - - private MessageDigest md5; - - private byte[] ipad = new byte[BLOCK_LENGTH]; - - private byte[] opad = new byte[BLOCK_LENGTH]; - - /** - * Creates an HMACT64 instance which uses the given secret key material. - * - * @param key The key material to use in hashing. - */ - public HMACT64(byte[] key) { - super("HMACT64"); - int length = Math.min(key.length, BLOCK_LENGTH); - for (int i = 0; i < length; i++) { - ipad[i] = (byte) (key[i] ^ IPAD); - opad[i] = (byte) (key[i] ^ OPAD); - } - for (int i = length; i < BLOCK_LENGTH; i++) { - ipad[i] = IPAD; - opad[i] = OPAD; - } - try { - md5 = MessageDigest.getInstance("MD5"); - } catch (Exception ex) { - throw new IllegalStateException(ex.getMessage()); - } - engineReset(); - } - - private HMACT64(HMACT64 hmac) throws CloneNotSupportedException { - super("HMACT64"); - this.ipad = hmac.ipad; - this.opad = hmac.opad; - this.md5 = (MessageDigest) hmac.md5.clone(); - } - - public Object clone() { - try { - return new HMACT64(this); - } catch (CloneNotSupportedException ex) { - throw new IllegalStateException(ex.getMessage()); - } - } - - protected byte[] engineDigest() { - byte[] digest = md5.digest(); - md5.update(opad); - return md5.digest(digest); - } - - protected int engineDigest(byte[] buf, int offset, int len) { - byte[] digest = md5.digest(); - md5.update(opad); - md5.update(digest); - try { - return md5.digest(buf, offset, len); - } catch (Exception ex) { - throw new IllegalStateException(); - } - } - - protected int engineGetDigestLength() { - return md5.getDigestLength(); - } - - protected void engineReset() { - md5.reset(); - md5.update(ipad); - } - - protected void engineUpdate(byte b) { - md5.update(b); - } - - protected void engineUpdate(byte[] input, int offset, int len) { - md5.update(input, offset, len); - } - -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Hexdump.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Hexdump.java deleted file mode 100644 index 025eb21216..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/Hexdump.java +++ /dev/null @@ -1,159 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2000 "Michael B. Allen" - * "Christopher R. Hertel" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -import java.io.PrintStream; - -/** - */ - -public class Hexdump { - - private static final String NL = System.getProperty( "line.separator" ); - private static final int NL_LENGTH = NL.length(); - - private static final char[] SPACE_CHARS = { - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' - }; - - public static final char[] HEX_DIGITS = { - '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', 'A', 'B', - 'C', 'D', 'E', 'F' - }; - -/** - * Generate "hexdump" output of the buffer at src like the following: - * - * - */ - - public static void hexdump( PrintStream ps, byte[] src, int srcIndex, int length ) { - if( length == 0 ) { - return; - } - - int s = length % 16; - int r = ( s == 0 ) ? length / 16 : length / 16 + 1; - char[] c = new char[r * (74 + NL_LENGTH)]; - char[] d = new char[16]; - int i; - int si = 0; - int ci = 0; - - do { - toHexChars( si, c, ci, 5 ); - ci += 5; - c[ci++] = ':'; - do { - if( si == length ) { - int n = 16 - s; - System.arraycopy( SPACE_CHARS, 0, c, ci, n * 3 ); - ci += n * 3; - System.arraycopy( SPACE_CHARS, 0, d, s, n ); - break; - } - c[ci++] = ' '; - i = src[srcIndex + si] & 0xFF; - toHexChars( i, c, ci, 2 ); - ci += 2; - if( i < 0 || Character.isISOControl( (char)i )) { - d[si % 16] = '.'; - } else { - d[si % 16] = (char)i; - } - } while(( ++si % 16 ) != 0 ); - c[ci++] = ' '; - c[ci++] = ' '; - c[ci++] = '|'; - System.arraycopy( d, 0, c, ci, 16 ); - ci += 16; - c[ci++] = '|'; - NL.getChars( 0, NL_LENGTH, c, ci ); - ci += NL_LENGTH; - } while( si < length ); - - ps.println( c ); - } - -/** - * This is an alternative to the- * 00000: 04 d2 29 00 00 01 00 00 00 00 00 01 20 45 47 46 |..)......... EGF| - * 00010: 43 45 46 45 45 43 41 43 41 43 41 43 41 43 41 43 |CEFEECACACACACAC| - * 00020: 41 43 41 43 41 43 41 43 41 43 41 41 44 00 00 20 |ACACACACACAAD.. | - * 00030: 00 01 c0 0c 00 20 00 01 00 00 00 00 00 06 20 00 |..... ........ .| - * 00040: ac 22 22 e1 |."". | - *java.lang.Integer.toHexString - * method. It is an efficient relative that also will pad the left side so - * that the result issizedigits. - */ - public static String toHexString( int val, int size ) { - char[] c = new char[size]; - toHexChars( val, c, 0, size ); - return new String( c ); - } - public static String toHexString( long val, int size ) { - char[] c = new char[size]; - toHexChars( val, c, 0, size ); - return new String( c ); - } - public static String toHexString( byte[] src, int srcIndex, int size ) { - char[] c = new char[size]; - size = ( size % 2 == 0 ) ? size / 2 : size / 2 + 1; - for( int i = 0, j = 0; i < size; i++ ) { - c[j++] = HEX_DIGITS[(src[i] >> 4 ) & 0x0F]; - if( j == c.length ) { - break; - } - c[j++] = HEX_DIGITS[src[i] & 0x0F]; - } - return new String( c ); - } - -/** - * This is the same as {@link Hexdump#toHexString(int val, int - * size)} but provides a more practical form when trying to avoid {@link - * String} concatenation and {@link StringBuffer}. - */ - public static void toHexChars( int val, char dst[], int dstIndex, int size ) { - while( size > 0 ) { - int i = dstIndex + size - 1; - if( i < dst.length ) { - dst[i] = HEX_DIGITS[val & 0x000F]; - } - if( val != 0 ) { - val >>>= 4; - } - size--; - } - } - public static void toHexChars( long val, char dst[], int dstIndex, int size ) { - while( size > 0 ) { - dst[dstIndex + size - 1] = HEX_DIGITS[(int)( val & 0x000FL )]; - if( val != 0 ) { - val >>>= 4; - } - size--; - } - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/LogStream.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/LogStream.java deleted file mode 100644 index 92e768b093..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/LogStream.java +++ /dev/null @@ -1,58 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2004 "Michael B. Allen"- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -import java.io.PrintStream; - -/** -0 - nothing -1 - critical [default] -2 - basic info can be logged under load -3 - almost everything -N - debugging - */ - -public class LogStream extends PrintStream { - - private static LogStream inst; - - public static int level = 1; - - public LogStream( PrintStream stream ) { - super( stream ); - } - - public static void setLevel( int level ) { - LogStream.level = level; - } - /** - * This must be called before getInstance is called or - * it will have no effect. - */ - public static void setInstance( PrintStream stream ) { - inst = new LogStream( stream ); - } - public static LogStream getInstance() { - if( inst == null ) { - setInstance( System.err ); - } - return inst; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MD4.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MD4.java deleted file mode 100644 index ce5889e159..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MD4.java +++ /dev/null @@ -1,299 +0,0 @@ -// This file is currently unlocked (change this line if you lock the file) -// -// $Log: MD4.java,v $ -// Revision 1.2 1998/01/05 03:41:19 iang -// Added references only. -// -// Revision 1.1.1.1 1997/11/03 22:36:56 hopwood -// + Imported to CVS (tagged as 'start'). -// -// Revision 0.1.0.0 1997/07/14 R. Naffah -// + original version -// -// $Endlog$ -/* - * Copyright (c) 1997 Systemics Ltd - * on behalf of the Cryptix Development Team. All rights reserved. - */ - -package jcifs.util; - -import java.security.MessageDigest; - -/** - * Implements the MD4 message digest algorithm in Java. - * - * References: - *
- *
- * - *- Ronald L. Rivest, - * " - * The MD4 Message-Digest Algorithm", - * IETF RFC-1320 (informational). - *
$Revision: 1.2 $ - * @author Raif S. Naffah - */ -public class MD4 extends MessageDigest implements Cloneable -{ -// MD4 specific object variables -//........................................................................... - - /** - * The size in bytes of the input block to the tranformation algorithm. - */ - private static final int BLOCK_LENGTH = 64; // = 512 / 8; - - /** - * 4 32-bit words (interim result) - */ - private int[] context = new int[4]; - - /** - * Number of bytes processed so far mod. 2 power of 64. - */ - private long count; - - /** - * 512 bits input buffer = 16 x 32-bit words holds until reaches 512 bits. - */ - private byte[] buffer = new byte[BLOCK_LENGTH]; - - /** - * 512 bits work buffer = 16 x 32-bit words - */ - private int[] X = new int[16]; - - -// Constructors -//........................................................................... - - public MD4 () { - super("MD4"); - engineReset(); - } - - /** - * This constructor is here to implement cloneability of this class. - */ - private MD4 (MD4 md) { - this(); - context = (int[])md.context.clone(); - buffer = (byte[])md.buffer.clone(); - count = md.count; - } - - -// Cloneable method implementation -//........................................................................... - - /** - * Returns a copy of this MD object. - */ - public Object clone() { return new MD4(this); } - - -// JCE methods -//........................................................................... - - /** - * Resets this object disregarding any temporary data present at the - * time of the invocation of this call. - */ - public void engineReset () { - // initial values of MD4 i.e. A, B, C, D - // as per rfc-1320; they are low-order byte first - context[0] = 0x67452301; - context[1] = 0xEFCDAB89; - context[2] = 0x98BADCFE; - context[3] = 0x10325476; - count = 0L; - for (int i = 0; i < BLOCK_LENGTH; i++) - buffer[i] = 0; - } - - /** - * Continues an MD4 message digest using the input byte. - */ - public void engineUpdate (byte b) { - // compute number of bytes still unhashed; ie. present in buffer - int i = (int)(count % BLOCK_LENGTH); - count++; // update number of bytes - buffer[i] = b; - if (i == BLOCK_LENGTH - 1) - transform(buffer, 0); - } - - /** - * MD4 block update operation. - *
- * Continues an MD4 message digest operation, by filling the buffer, - * transform(ing) data in 512-bit message block(s), updating the variables - * context and count, and leaving (buffering) the remaining bytes in buffer - * for the next update or finish. - * - * @param input input block - * @param offset start of meaningful bytes in input - * @param len count of bytes in input block to consider - */ - public void engineUpdate (byte[] input, int offset, int len) { - // make sure we don't exceed input's allocated size/length - if (offset < 0 || len < 0 || (long)offset + len > input.length) - throw new ArrayIndexOutOfBoundsException(); - - // compute number of bytes still unhashed; ie. present in buffer - int bufferNdx = (int)(count % BLOCK_LENGTH); - count += len; // update number of bytes - int partLen = BLOCK_LENGTH - bufferNdx; - int i = 0; - if (len >= partLen) { - System.arraycopy(input, offset, buffer, bufferNdx, partLen); - - - transform(buffer, 0); - - for (i = partLen; i + BLOCK_LENGTH - 1 < len; i+= BLOCK_LENGTH) - transform(input, offset + i); - bufferNdx = 0; - } - // buffer remaining input - if (i < len) - System.arraycopy(input, offset + i, buffer, bufferNdx, len - i); - } - - /** - * Completes the hash computation by performing final operations such - * as padding. At the return of this engineDigest, the MD engine is - * reset. - * - * @return the array of bytes for the resulting hash value. - */ - public byte[] engineDigest () { - // pad output to 56 mod 64; as RFC1320 puts it: congruent to 448 mod 512 - int bufferNdx = (int)(count % BLOCK_LENGTH); - int padLen = (bufferNdx < 56) ? (56 - bufferNdx) : (120 - bufferNdx); - - // padding is alwas binary 1 followed by binary 0s - byte[] tail = new byte[padLen + 8]; - tail[0] = (byte)0x80; - - // append length before final transform: - // save number of bits, casting the long to an array of 8 bytes - // save low-order byte first. - for (int i = 0; i < 8; i++) - tail[padLen + i] = (byte)((count * 8) >>> (8 * i)); - - engineUpdate(tail, 0, tail.length); - - byte[] result = new byte[16]; - // cast this MD4's context (array of 4 ints) into an array of 16 bytes. - for (int i = 0; i < 4; i++) - for (int j = 0; j < 4; j++) - result[i * 4 + j] = (byte)(context[i] >>> (8 * j)); - - // reset the engine - engineReset(); - return result; - } - - -// own methods -//........................................................................... - - /** - * MD4 basic transformation. - *
- * Transforms context based on 512 bits from input block starting - * from the offset'th byte. - * - * @param block input sub-array. - * @param offset starting position of sub-array. - */ - private void transform (byte[] block, int offset) { - - // encodes 64 bytes from input block into an array of 16 32-bit - // entities. Use A as a temp var. - for (int i = 0; i < 16; i++) - X[i] = (block[offset++] & 0xFF) | - (block[offset++] & 0xFF) << 8 | - (block[offset++] & 0xFF) << 16 | - (block[offset++] & 0xFF) << 24; - - - int A = context[0]; - int B = context[1]; - int C = context[2]; - int D = context[3]; - - A = FF(A, B, C, D, X[ 0], 3); - D = FF(D, A, B, C, X[ 1], 7); - C = FF(C, D, A, B, X[ 2], 11); - B = FF(B, C, D, A, X[ 3], 19); - A = FF(A, B, C, D, X[ 4], 3); - D = FF(D, A, B, C, X[ 5], 7); - C = FF(C, D, A, B, X[ 6], 11); - B = FF(B, C, D, A, X[ 7], 19); - A = FF(A, B, C, D, X[ 8], 3); - D = FF(D, A, B, C, X[ 9], 7); - C = FF(C, D, A, B, X[10], 11); - B = FF(B, C, D, A, X[11], 19); - A = FF(A, B, C, D, X[12], 3); - D = FF(D, A, B, C, X[13], 7); - C = FF(C, D, A, B, X[14], 11); - B = FF(B, C, D, A, X[15], 19); - - A = GG(A, B, C, D, X[ 0], 3); - D = GG(D, A, B, C, X[ 4], 5); - C = GG(C, D, A, B, X[ 8], 9); - B = GG(B, C, D, A, X[12], 13); - A = GG(A, B, C, D, X[ 1], 3); - D = GG(D, A, B, C, X[ 5], 5); - C = GG(C, D, A, B, X[ 9], 9); - B = GG(B, C, D, A, X[13], 13); - A = GG(A, B, C, D, X[ 2], 3); - D = GG(D, A, B, C, X[ 6], 5); - C = GG(C, D, A, B, X[10], 9); - B = GG(B, C, D, A, X[14], 13); - A = GG(A, B, C, D, X[ 3], 3); - D = GG(D, A, B, C, X[ 7], 5); - C = GG(C, D, A, B, X[11], 9); - B = GG(B, C, D, A, X[15], 13); - - A = HH(A, B, C, D, X[ 0], 3); - D = HH(D, A, B, C, X[ 8], 9); - C = HH(C, D, A, B, X[ 4], 11); - B = HH(B, C, D, A, X[12], 15); - A = HH(A, B, C, D, X[ 2], 3); - D = HH(D, A, B, C, X[10], 9); - C = HH(C, D, A, B, X[ 6], 11); - B = HH(B, C, D, A, X[14], 15); - A = HH(A, B, C, D, X[ 1], 3); - D = HH(D, A, B, C, X[ 9], 9); - C = HH(C, D, A, B, X[ 5], 11); - B = HH(B, C, D, A, X[13], 15); - A = HH(A, B, C, D, X[ 3], 3); - D = HH(D, A, B, C, X[11], 9); - C = HH(C, D, A, B, X[ 7], 11); - B = HH(B, C, D, A, X[15], 15); - - context[0] += A; - context[1] += B; - context[2] += C; - context[3] += D; - } - - // The basic MD4 atomic functions. - - private int FF (int a, int b, int c, int d, int x, int s) { - int t = a + ((b & c) | (~b & d)) + x; - return t << s | t >>> (32 - s); - } - private int GG (int a, int b, int c, int d, int x, int s) { - int t = a + ((b & (c | d)) | (c & d)) + x + 0x5A827999; - return t << s | t >>> (32 - s); - } - private int HH (int a, int b, int c, int d, int x, int s) { - int t = a + (b ^ c ^ d) + x + 0x6ED9EBA1; - return t << s | t >>> (32 - s); - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MimeMap.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MimeMap.java deleted file mode 100644 index b85e003103..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/MimeMap.java +++ /dev/null @@ -1,123 +0,0 @@ -/* jcifs smb client library in Java - * Copyright (C) 2002 "Michael B. Allen"
- * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -import java.io.IOException; -import java.io.InputStream; - -public class MimeMap { - - private static final int IN_SIZE = 7000; - - private static final int ST_START = 1; - private static final int ST_COMM = 2; - private static final int ST_TYPE = 3; - private static final int ST_GAP = 4; - private static final int ST_EXT = 5; - - private byte[] in; - private int inLen; - - public MimeMap() throws IOException { - int n; - - in = new byte[IN_SIZE]; - InputStream is = getClass().getClassLoader().getResourceAsStream( "jcifs/util/mime.map" ); - - inLen = 0; - while(( n = is.read( in, inLen, IN_SIZE - inLen )) != -1 ) { - inLen += n; - } - if( inLen < 100 || inLen == IN_SIZE ) { - throw new IOException( "Error reading jcifs/util/mime.map resource" ); - } - is.close(); - } - - public String getMimeType( String extension ) throws IOException { - return getMimeType( extension, "application/octet-stream" ); - } - public String getMimeType( String extension, String def ) throws IOException { - int state, t, x, i, off; - byte ch; - byte[] type = new byte[128]; - byte[] buf = new byte[16]; - byte[] ext = extension.toLowerCase().getBytes( "ASCII" ); - - state = ST_START; - t = x = i = 0; - for( off = 0; off < inLen; off++ ) { - ch = in[off]; - switch( state ) { - case ST_START: - if( ch == ' ' || ch == '\t' ) { - break; - } else if( ch == '#' ) { - state = ST_COMM; - break; - } - state = ST_TYPE; - case ST_TYPE: - if( ch == ' ' || ch == '\t' ) { - state = ST_GAP; - } else { - type[t++] = ch; - } - break; - case ST_COMM: - if( ch == '\n' ) { - t = x = i = 0; - state = ST_START; - } - break; - case ST_GAP: - if( ch == ' ' || ch == '\t' ) { - break; - } - state = ST_EXT; - case ST_EXT: - switch( ch ) { - case ' ': - case '\t': - case '\n': - case '#': - for( i = 0; i < x && x == ext.length && buf[i] == ext[i]; i++ ) { - ; - } - if( i == ext.length ) { - return new String( type, 0, t, "ASCII" ); - } - if( ch == '#' ) { - state = ST_COMM; - } else if( ch == '\n' ) { - t = x = i = 0; - state = ST_START; - } - x = 0; - break; - default: - buf[x++] = ch; - } - break; - } - } - return def; - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/RC4.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/RC4.java deleted file mode 100644 index 41eb634a0a..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/RC4.java +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2009 "Michael B Allen" - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -package jcifs.util; - -public class RC4 -{ - - byte[] s; - int i, j; - - public RC4() - { - } - public RC4(byte[] key) - { - init(key, 0, key.length); - } - - public void init(byte[] key, int ki, int klen) - { - s = new byte[256]; - - for (i = 0; i < 256; i++) - s[i] = (byte)i; - - for (i = j = 0; i < 256; i++) { - j = (j + key[ki + i % klen] + s[i]) & 0xff; - byte t = s[i]; - s[i] = s[j]; - s[j] = t; - } - - i = j = 0; - } - public void update(byte[] src, int soff, int slen, byte[] dst, int doff) - { - int slim; - - slim = soff + slen; - while (soff < slim) { - i = (i + 1) & 0xff; - j = (j + s[i]) & 0xff; - byte t = s[i]; - s[i] = s[j]; - s[j] = t; - dst[doff++] = (byte)(src[soff++] ^ s[(s[i] + s[j]) & 0xff]); - } - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/mime.map b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/mime.map deleted file mode 100644 index be0eb1059e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/mime.map +++ /dev/null @@ -1,94 +0,0 @@ -application/access mdf # Microsoft Access -#application/excel xls # Microsoft Excel -application/vnd.ms-excel xls # Microsoft Excel -application/font-tdpfr pfr # TrueDoc Portable Font Resource -application/futuresplash spl # Macromedia Flash -application/hep hep # Hummingbird Host Explorer Profiles -application/lotus-123 wks # Lotus 123 -application/mac-binhex40 hqx # Macintosh binhexed archives -application/mspowerpoint ppt # Microsoft Powerpoint -application/msword doc # Microsoft Word -application/octet-stream bin exe ani # Binary File -application/oda oda -application/pagemaker pm5 pt5 pm # PageMaker -application/pdf pdf # Adobe Acrobat -application/postscript ai eps ps # Postscript File -application/rtf rtf # Rich Text File -application/toolbook tbk # Toolbook -application/wordperfect wp # WordPerfect -application/wordperfect5.1 wp5 # WordPerfect Version 5.1 -application/wordperfect6.1 wp6 # WordPerfect Version 6.1 -application/wordperfectd wpd # WordPerfect -application/x-bcpio bcpio # -application/x-cpio cpio # -application/x-csh csh # C-Shell Program -application/x-director dcr # Director File -application/x-dvi dvi # TeX dvi Format -application/x-gtar gtar # Gzip and Tar file -application/x-gzip gz tgz # Gzip and Tar file -application/x-compress z # Gzip and Tar file -application/x-hdf hdf # NCSA HDF -application/x-ica ica # WinFrames -application/x-javascript js # Javascript -application/x-latex latex # Latex File -application/x-mif mif # -application/x-netcdf nc cdf # -#application/x-sh sh # sh Shell Program -application/x-shar shar # -application/x-shockwave-flash swf # Macromedia Shockwave file -application/x-spss sav spp sbs sps spo # SPSS -application/x-stuffit sit # Macintosh Stuff-It -application/x-sv4cpio sv4cpio # -application/x-sv4crc sv4crc # -application/x-tar tar # UNIX Tape Archive -application/x-tcl tcl # TCL Programming Language -application/x-tex tex # Tex/LaTeX -application/x-texinfo texinfo texi # TexInfo -application/x-troff t tr roff # Troff file -application/x-troff-man man # Troff with MAN macros -application/x-troff-me me # Troff with ME macros -application/x-troff-ms ms # Troff with MS macros -application/x-ustar ustar # Ustar file -application/vnd.ms-access mdb mda mde # MS Access -application/vnd.ms-project mpp # MS Project -application/x-wais-source src # WAIS Sources -application/zip zip jar # ZIP Compressed File -audio/basic au snd # Audio Sound File -audio/x-aiff aif aiff aifc # AIFF Sound File -audio/x-midi mid # MIDI Sound File -audio/x-pn-realaudio ra ram rm rpm # REALAUDIO Sound File -audio/x-wav wav # WAV Sound File -audio/x-mpegurl mp3 # MP3 Sound File -audio/mpeg3 mp3 # MP3 Sound File -audio/x-mpeg-3 mp3 # MP3 Sound File -audio/mpeg mp2 mpa mpg mpga # MP2 Sound File -audio/x-mpeg mp2 # MP2 Sound File -chemical/x-pdb pdb # PDB Chemistry Model File -chemical/x-xyz xyz # XYZ Chemistry Model File -drawing/x-dwf dwf # AutoCAD -image/gif gif # GIF image file -image/ief ief # Image Exchange -image/jpeg jpeg jpg jpe # JPG image file -image/png png # Portable Network Graphics -image/tiff tiff tif # TIFF image file -image/x-cmu-raster ras # -image/x-portable-anymap pnm # -image/x-portable-bitmap pbm # -image/x-portable-graymap pgm # -image/x-portable-pixmap ppm # -image/x-rgb rgb # RGB Image File -image/x-xbitmap xbm # X-bitmap Image File -image/x-xpixmap xpm # X-pixmap Image File -image/x-xwindowdump xwd # -text/css css # Cascading Style Sheet -text/html html htm # HTML Document -text/plain txt ini log in cfg m4 sh # Plain Text File -text/richtext rtx # Rich Text File -text/tab-separated-values tsv # -text/x-setext etx # -text/x-sgml sgml sgm # SGML Document -video/mpeg mpeg mpg mpe # MPEG Movie File -video/quicktime qt mov # Quicktime Movie File -video/x-ms-asf asf asx # Windows Media File -video/x-msvideo avi # AVI Movie File -video/x-sgi-movie movie # SGI Movie File diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Request.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Request.java deleted file mode 100644 index 3f3034d653..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Request.java +++ /dev/null @@ -1,4 +0,0 @@ -package jcifs.util.transport; - -public interface Request { -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Response.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Response.java deleted file mode 100644 index eba5d1cb2e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Response.java +++ /dev/null @@ -1,6 +0,0 @@ -package jcifs.util.transport; - -public abstract class Response { - public long expiration; - public boolean isReceived; -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Transport.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Transport.java deleted file mode 100644 index 5f5096c03f..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/Transport.java +++ /dev/null @@ -1,274 +0,0 @@ -package jcifs.util.transport; - -import jcifs.util.LogStream; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; - -/** - * This class simplifies communication for protocols that support - * multiplexing requests. It encapsulates a stream and some protocol - * knowledge (provided by a concrete subclass) so that connecting, - * disconnecting, sending, and receiving can be syncronized - * properly. Apparatus is provided to send and receive requests - * concurrently. - */ - -public abstract class Transport implements Runnable { - - static int id = 0; - static LogStream log = LogStream.getInstance(); - - public static int readn( InputStream in, - byte[] b, - int off, - int len ) throws IOException { - int i = 0, n = -5; - - while (i < len) { - n = in.read( b, off + i, len - i ); - if (n <= 0) { - break; - } - i += n; - } - - return i; - } - - /* state values - * 0 - not connected - * 1 - connecting - * 2 - run connected - * 3 - connected - * 4 - error - */ - int state = 0; - - String name = "Transport" + id++; - Thread thread; - TransportException te; - - protected HashMap response_map = new HashMap( 4 ); - - protected abstract void makeKey( Request request ) throws IOException; - protected abstract Request peekKey() throws IOException; - protected abstract void doSend( Request request ) throws IOException; - protected abstract void doRecv( Response response ) throws IOException; - protected abstract void doSkip() throws IOException; - - public synchronized void sendrecv( Request request, - Response response, - long timeout ) throws IOException { - makeKey( request ); - response.isReceived = false; - try { - response_map.put( request, response ); - doSend( request ); - response.expiration = System.currentTimeMillis() + timeout; - while (!response.isReceived) { - wait( timeout ); - timeout = response.expiration - System.currentTimeMillis(); - if (timeout <= 0) { - throw new TransportException( name + - " timedout waiting for response to " + - request ); - } - } - } catch( IOException ioe ) { - if (log.level > 2) - ioe.printStackTrace( log ); - try { - disconnect( true ); - } catch( IOException ioe2 ) { - ioe2.printStackTrace( log ); - } - throw ioe; - } catch( InterruptedException ie ) { - throw new TransportException( ie ); - } finally { - response_map.remove( request ); - } - } - private void loop() { - while( thread == Thread.currentThread() ) { - try { - Request key = peekKey(); - if (key == null) - throw new IOException( "end of stream" ); - synchronized (this) { - Response response = (Response)response_map.get( key ); - if (response == null) { - if (log.level >= 4) - log.println( "Invalid key, skipping message" ); - doSkip(); - } else { - doRecv( response ); - response.isReceived = true; - notifyAll(); - } - } - } catch( Exception ex ) { - String msg = ex.getMessage(); - boolean timeout = msg != null && msg.equals( "Read timed out" ); - /* If just a timeout, try to disconnect gracefully - */ - boolean hard = timeout == false; - - if (!timeout && log.level >= 3) - ex.printStackTrace( log ); - - try { - disconnect( hard ); - } catch( IOException ioe ) { - ioe.printStackTrace( log ); - } - } - } - } - - /* Build a connection. Only one thread will ever call this method at - * any one time. If this method throws an exception or the connect timeout - * expires an encapsulating TransportException will be thrown from connect - * and the transport will be in error. - */ - - protected abstract void doConnect() throws Exception; - - /* Tear down a connection. If the hard parameter is true, the diconnection - * procedure should not initiate or wait for any outstanding requests on - * this transport. - */ - - protected abstract void doDisconnect( boolean hard ) throws IOException; - - public synchronized void connect( long timeout ) throws TransportException { - try { - switch (state) { - case 0: - break; - case 3: - return; // already connected - case 4: - state = 0; - throw new TransportException( "Connection in error", te ); - default: - TransportException te = new TransportException( "Invalid state: " + state ); - state = 0; - throw te; - } - - state = 1; - te = null; - thread = new Thread( this, name ); - thread.setDaemon( true ); - - synchronized (thread) { - thread.start(); - thread.wait( timeout ); /* wait for doConnect */ - - switch (state) { - case 1: /* doConnect never returned */ - state = 0; - thread = null; - throw new TransportException( "Connection timeout" ); - case 2: - if (te != null) { /* doConnect throw Exception */ - state = 4; /* error */ - thread = null; - throw te; - } - state = 3; /* Success! */ - return; - } - } - } catch( InterruptedException ie ) { - state = 0; - thread = null; - throw new TransportException( ie ); - } finally { - /* This guarantees that we leave in a valid state - */ - if (state != 0 && state != 3 && state != 4) { - if (log.level >= 1) - log.println("Invalid state: " + state); - state = 0; - thread = null; - } - } - } - public synchronized void disconnect( boolean hard ) throws IOException { - IOException ioe = null; - - switch (state) { - case 0: /* not connected - just return */ - return; - case 2: - hard = true; - case 3: /* connected - go ahead and disconnect */ - if (response_map.size() != 0 && !hard) { - break; /* outstanding requests */ - } - try { - doDisconnect( hard ); - } catch (IOException ioe0) { - ioe = ioe0; - } - case 4: /* in error - reset the transport */ - thread = null; - state = 0; - break; - default: - if (log.level >= 1) - log.println("Invalid state: " + state); - thread = null; - state = 0; - break; - } - - if (ioe != null) - throw ioe; - } - public void run() { - Thread run_thread = Thread.currentThread(); - Exception ex0 = null; - - try { - /* We cannot synchronize (run_thread) here or the caller's - * thread.wait( timeout ) cannot reaquire the lock and - * return which would render the timeout effectively useless. - */ - doConnect(); - } catch( Exception ex ) { - ex0 = ex; // Defer to below where we're locked - return; - } finally { - synchronized (run_thread) { - if (run_thread != thread) { - /* Thread no longer the one setup for this transport -- - * doConnect returned too late, just ignore. - */ - if (ex0 != null) { - if (log.level >= 2) - ex0.printStackTrace(log); - } - return; - } - if (ex0 != null) { - te = new TransportException( ex0 ); - } - state = 2; // run connected - run_thread.notify(); - } - } - - /* Proccess responses - */ - loop(); - } - - public String toString() { - return name; - } -} diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/TransportException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/TransportException.java deleted file mode 100644 index 994fe7f071..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/jcifs/util/transport/TransportException.java +++ /dev/null @@ -1,38 +0,0 @@ -package jcifs.util.transport; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -public class TransportException extends IOException { - - private Throwable rootCause; - - public TransportException() { - } - public TransportException( String msg ) { - super( msg ); - } - public TransportException( Throwable rootCause ) { - this.rootCause = rootCause; - } - public TransportException( String msg, Throwable rootCause ) { - super( msg ); - this.rootCause = rootCause; - } - - public Throwable getRootCause() { - return rootCause; - } - public String toString() { - if( rootCause != null ) { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter( sw ); - rootCause.printStackTrace( pw ); - return super.toString() + "\n" + sw; - } else { - return super.toString(); - } - } -} - diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/Netlogon.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/Netlogon.java deleted file mode 100644 index e2b7acfd24..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/Netlogon.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; - -import jcifs.dcerpc.DcerpcBinding; -import jcifs.dcerpc.DcerpcHandle; -import jcifs.dcerpc.UnicodeString; -import jcifs.smb.SmbException; - -import org.ntlmv2.liferay.ntlm.msrpc.NetlogonAuthenticator; -import org.ntlmv2.liferay.ntlm.msrpc.NetlogonIdentityInfo; -import org.ntlmv2.liferay.ntlm.msrpc.NetlogonNetworkInfo; -import org.ntlmv2.liferay.ntlm.msrpc.NetlogonValidationSamInfo; -import org.ntlmv2.liferay.ntlm.msrpc.NetrLogonSamLogon; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @author Marcellus Tavares - * @author Michael C. Han - */ -public class Netlogon { - - public NtlmUserAccount logon( - String domain, String userName, String workstation, - byte[] serverChallenge, byte[] ntResponse, byte[] lmResponse) - throws NtlmLogonException { - - NetlogonConnection netlogonConnection = new NetlogonConnection(); - - try { - - netlogonConnection.connect( - _domainController, _domainControllerName, _ntlmServiceAccount, - _secureRandom); - - NetlogonAuthenticator netlogonAuthenticator = - netlogonConnection.computeNetlogonAuthenticator(); - - NetlogonIdentityInfo netlogonIdentityInfo = - new NetlogonIdentityInfo( - domain, 0x00000820, 0, 0, userName, workstation); - - NetlogonNetworkInfo netlogonNetworkInfo = new NetlogonNetworkInfo( - netlogonIdentityInfo, serverChallenge, ntResponse, lmResponse); - - NetrLogonSamLogon netrLogonSamLogon = new NetrLogonSamLogon( - _domainControllerName, _ntlmServiceAccount.getComputerName(), - netlogonAuthenticator, new NetlogonAuthenticator(), 2, - netlogonNetworkInfo, 2, new NetlogonValidationSamInfo(), 0); - - DcerpcHandle dcerpcHandle = netlogonConnection.getDcerpcHandle(); - - dcerpcHandle.sendrecv(netrLogonSamLogon); - - if (netrLogonSamLogon.getStatus() == 0) { - NetlogonValidationSamInfo netlogonValidationSamInfo = - netrLogonSamLogon.getNetlogonValidationSamInfo(); - - UnicodeString name = new UnicodeString( - netlogonValidationSamInfo.getEffectiveName(), false); - - return new NtlmUserAccount(name.toString()); - } - else { - SmbException smbe = new SmbException( - netrLogonSamLogon.getStatus(), false); - - throw new NtlmLogonException( - "Unable to authenticate user: " + smbe.getMessage()); - } - } - catch (NoSuchAlgorithmException e) { - throw new NtlmLogonException( - "Unable to authenticate due to invalid encryption algorithm", - e); - } - catch (IOException e) { - throw new NtlmLogonException( - "Unable to authenticate due to communication failure with " + - "server", - e); - } - finally { - try { - netlogonConnection.disconnect(); - } - catch (Exception e) { - _log.error("Unable to disconnect Netlogon connection", e); - } - } - } - - public void setConfiguration( - String domainController, String domainControllerName, - NtlmServiceAccount ntlmServiceAccount) { - - _domainController = domainController; - _domainControllerName = domainControllerName; - _ntlmServiceAccount = ntlmServiceAccount; - } - - private static Logger _log = LoggerFactory.getLogger(Netlogon.class); - - private String _domainController; - private String _domainControllerName; - private NtlmServiceAccount _ntlmServiceAccount; - private SecureRandom _secureRandom = new SecureRandom(); - - static { - DcerpcBinding.addInterface( - "netlogon", "12345678-1234-abcd-ef00-01234567cffb:1.0"); - } - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NetlogonConnection.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NetlogonConnection.java deleted file mode 100644 index 236f64a9ea..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NetlogonConnection.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - -import java.io.IOException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.security.SecureRandom; -import java.util.Arrays; - -import jcifs.dcerpc.DcerpcHandle; -import jcifs.smb.NtlmPasswordAuthentication; -import jcifs.util.DES; -import jcifs.util.Encdec; -import jcifs.util.HMACT64; -import jcifs.util.MD4; - -import org.ntlmv2.liferay.ntlm.msrpc.NetlogonAuthenticator; -import org.ntlmv2.liferay.ntlm.msrpc.NetrServerAuthenticate3; -import org.ntlmv2.liferay.ntlm.msrpc.NetrServerReqChallenge; - - -/* - ntlm.auth.enabled=false - ntlm.auth.domain.controller=127.0.0.1 - ntlm.auth.domain.controller.name=EXAMPLE - ntlm.auth.domain=EXAMPLE - ntlm.auth.negotiate.flags=0x600FFFFF - ntlm.auth.service.account=LIFERAY$@EXAMPLE.COM - ntlm.auth.service.password=test - - */ - -/** - * @author Michael C. Han - */ -public class NetlogonConnection { - - public NetlogonConnection() { - if (_negotiateFlags == 0) { - String negotiateFlags = "0x600FFFFF"; // <<<=== TODO / msc: make configurable - - if (negotiateFlags.startsWith("0x")) { - _negotiateFlags = Integer.valueOf( - negotiateFlags.substring(2), 16); - } - else { - _negotiateFlags = 0x600FFFFF; - } - } - } - - public NetlogonConnection( int negotiateFlags ) { - _negotiateFlags = negotiateFlags; - } - - public NetlogonAuthenticator computeNetlogonAuthenticator() { - int timestamp = (int)System.currentTimeMillis(); - - int input = Encdec.dec_uint32le(_clientCredential, 0) + timestamp; - - Encdec.enc_uint32le(input, _clientCredential, 0); - - byte[] credential = computeNetlogonCredential( - _clientCredential, _sessionKey); - - return new NetlogonAuthenticator(credential, timestamp); - } - - public void connect( - String domainController, String domainControllerName, - NtlmServiceAccount ntlmServiceAccount, SecureRandom secureRandom) - throws IOException, NtlmLogonException, NoSuchAlgorithmException { - - NtlmPasswordAuthentication ntlmPasswordAuthentication = - new NtlmPasswordAuthentication( - null, ntlmServiceAccount.getAccount(), - ntlmServiceAccount.getPassword()); - - String endpoint = "ncacn_np:" + domainController + "[\\PIPE\\NETLOGON]"; - - DcerpcHandle dcerpcHandle = DcerpcHandle.getHandle( - endpoint, ntlmPasswordAuthentication); - - setDcerpcHandle(dcerpcHandle); - - dcerpcHandle.bind(); - - byte[] clientChallenge = new byte[8]; - - secureRandom.nextBytes(clientChallenge); - - NetrServerReqChallenge netrServerReqChallenge = - new NetrServerReqChallenge( - domainControllerName, ntlmServiceAccount.getComputerName(), - clientChallenge, new byte[8]); - - dcerpcHandle.sendrecv(netrServerReqChallenge); - - MD4 md4 = new MD4(); - - md4.update(ntlmServiceAccount.getPassword().getBytes("UTF-16LE")); - - byte[] sessionKey = computeSessionKey( - md4.digest(), clientChallenge, - netrServerReqChallenge.getServerChallenge()); - - byte[] clientCredential = computeNetlogonCredential( - clientChallenge, sessionKey); - - NetrServerAuthenticate3 netrServerAuthenticate3 = - new NetrServerAuthenticate3( - domainControllerName, ntlmServiceAccount.getAccountName(), 2, - ntlmServiceAccount.getComputerName(), clientCredential, - new byte[8], _negotiateFlags); - - dcerpcHandle.sendrecv(netrServerAuthenticate3); - - byte[] serverCredential = computeNetlogonCredential( - netrServerReqChallenge.getServerChallenge(), sessionKey); - - if (!Arrays.equals( - serverCredential, - netrServerAuthenticate3.getServerCredential())) { - - throw new NtlmLogonException("Session key negotiation failed"); - } - - _clientCredential = clientCredential; - _sessionKey = sessionKey; - _negotiateFlags = netrServerAuthenticate3.getNegotiatedFlags(); - } - - public void disconnect() throws IOException { - if (_dcerpcHandle != null) { - _dcerpcHandle.close(); - } - } - - public byte[] getClientCredential() { - return _clientCredential; - } - - public DcerpcHandle getDcerpcHandle() { - return _dcerpcHandle; - } - - public byte[] getSessionKey() { - return _sessionKey; - } - - public int getNegotiateFlags() { - return _negotiateFlags; - } - - public void setDcerpcHandle(DcerpcHandle dcerpcHandle) { - _dcerpcHandle = dcerpcHandle; - } - - protected byte[] computeNetlogonCredential( - byte[] input, byte[] sessionKey) { - - byte[] k1 = new byte[7]; - byte[] k2 = new byte[7]; - - System.arraycopy(sessionKey, 0, k1, 0, 7); - System.arraycopy(sessionKey, 7, k2, 0, 7); - - DES k3 = new DES(k1); - DES k4 = new DES(k2); - - byte[] output1 = new byte[8]; - byte[] output2 = new byte[8]; - - k3.encrypt(input, output1); - k4.encrypt(output1, output2); - - return output2; - } - - protected byte[] computeSessionKey( - byte[] sharedSecret, byte[] clientChallenge, byte[] serverChallenge) - throws NoSuchAlgorithmException { - - MessageDigest messageDigest = MessageDigest.getInstance("MD5"); - - byte[] zeroes = {0, 0, 0, 0}; - - messageDigest.update(zeroes, 0, 4); - messageDigest.update(clientChallenge, 0, 8); - messageDigest.update(serverChallenge, 0, 8); - - HMACT64 hmact64 = new HMACT64(sharedSecret); - - hmact64.update(messageDigest.digest()); - - return hmact64.digest(); - } - - private int _negotiateFlags; - - private byte[] _clientCredential; - private DcerpcHandle _dcerpcHandle; - private byte[] _sessionKey; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmLogonException.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmLogonException.java deleted file mode 100644 index 4e97179b0b..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmLogonException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - - -/** - * @author Michael C. Han - */ -public class NtlmLogonException extends Exception { - - public NtlmLogonException() { - super(); - } - - public NtlmLogonException(String msg) { - super(msg); - } - - public NtlmLogonException(String msg, Throwable cause) { - super(msg, cause); - } - - public NtlmLogonException(Throwable cause) { - super(cause); - } - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmManager.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmManager.java deleted file mode 100644 index fcdf08ae12..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmManager.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -import jcifs.ntlmssp.NtlmFlags; -import jcifs.ntlmssp.Type1Message; -import jcifs.ntlmssp.Type2Message; -import jcifs.ntlmssp.Type3Message; -import jcifs.util.Encdec; - -import org.ntlmv2.liferay.util.NtlmV2ArrayUtil; - -/** - * @author Marcellus Tavares - * @author Michael C. Han - */ -public class NtlmManager { - - public NtlmManager( - String domain, String domainController, String domainControllerHostName, - String serviceAccount, String servicePassword) { - - setConfiguration( - domain, domainController, domainControllerHostName, serviceAccount, - servicePassword); - } - - public NtlmUserAccount authenticate(byte[] material, byte[] serverChallenge) - throws IOException, NoSuchAlgorithmException, NtlmLogonException { - - Type3Message type3Message = new Type3Message(material); - - if (type3Message.getFlag( - _NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY) && - (type3Message.getNTResponse().length == 24)) { - - MessageDigest messageDigest = MessageDigest.getInstance("MD5"); - - byte[] bytes = new byte[16]; - - System.arraycopy(serverChallenge, 0, bytes, 0, 8); - System.arraycopy(type3Message.getLMResponse(), 0, bytes, 8, 8); - - messageDigest.update(bytes); - - serverChallenge = messageDigest.digest(); - } - - return _netlogon.logon( - type3Message.getDomain(), type3Message.getUser(), - type3Message.getWorkstation(), serverChallenge, - type3Message.getNTResponse(), type3Message.getLMResponse()); - } - - public String getDomain() { - return _domain; - } - - public String getDomainController() { - return _domainController; - } - - public String getDomainControllerName() { - return _domainControllerHostName; - } - - public String getServiceAccount() { - return _ntlmServiceAccount.getAccount(); - } - - public String getServicePassword() { - return _ntlmServiceAccount.getPassword(); - } - - public byte[] negotiate(byte[] material, byte[] serverChallenge) - throws IOException { - return negotiateType2Message(material, serverChallenge).toByteArray(); - } - - public Type2Message negotiateType2Message(byte[] material, byte[] serverChallenge) - throws IOException { - - Type1Message type1Message = new Type1Message(material); - - Type2Message type2Message = new Type2Message( - type1Message.getFlags(), serverChallenge, _domain); - - if (type2Message.getFlag( - _NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY)) { - - type2Message.setFlag(NtlmFlags.NTLMSSP_NEGOTIATE_LM_KEY, false); - type2Message.setFlag(NtlmFlags.NTLMSSP_NEGOTIATE_TARGET_INFO, true); - type2Message.setTargetInformation(getTargetInformation()); - } - - return type2Message; - } - - public void setConfiguration( - String domain, String domainController, String domainControllerName, - String serviceAccount, String servicePassword) { - - _domain = domain; - _domainController = domainController; - _domainControllerHostName = domainControllerName; - _ntlmServiceAccount = new NtlmServiceAccount( - serviceAccount, servicePassword); - - _netlogon = new Netlogon(); - - _netlogon.setConfiguration( - domainController, domainControllerName, _ntlmServiceAccount); - } - - protected byte[] getAVPairBytes(int avId, String value) - throws UnsupportedEncodingException{ - - byte[] valueBytes = value.getBytes("UTF-16LE"); - byte[] avPairBytes = new byte[4 + valueBytes.length]; - - Encdec.enc_uint16le((short)avId, avPairBytes, 0); - Encdec.enc_uint16le((short)valueBytes.length, avPairBytes, 2); - - System.arraycopy(valueBytes, 0, avPairBytes, 4, valueBytes.length); - - return avPairBytes; - } - - protected byte[] getTargetInformation() throws UnsupportedEncodingException{ - byte[] computerName = getAVPairBytes( - 1, _ntlmServiceAccount.getComputerName()); - byte[] domainName = getAVPairBytes(2, _domain); - - byte[] targetInformation = NtlmV2ArrayUtil.append(computerName, domainName); - - byte[] eol = getAVPairBytes(0, " "); - - targetInformation = NtlmV2ArrayUtil.append(targetInformation, eol); - - return targetInformation; - } - - private static final int _NTLMSSP_NEGOTIATE_EXTENDED_SESSION_SECURITY = - 0x00080000; - - private String _domain; - private String _domainController; - private String _domainControllerHostName; - private Netlogon _netlogon; - private NtlmServiceAccount _ntlmServiceAccount; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmServiceAccount.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmServiceAccount.java deleted file mode 100644 index 9af722dbf5..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmServiceAccount.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -/** - * @author Marcellus Tavares - */ -public class NtlmServiceAccount { - - private static Logger log = LoggerFactory.getLogger(NtlmServiceAccount.class); - - public NtlmServiceAccount(String account, String password) { - setAccount(account); - setPassword(password); - } - - public String getAccount() { - return _account; - } - - public String getAccountName() { - return _accountName; - } - - public String getComputerName() { - return _computerName; - } - - public String getPassword() { - return _password; - } - - public void setAccount(String account) { - _account = account; - - _accountName = _account.substring(0, _account.indexOf("@")); - _computerName = _account.substring( - 0, _account.indexOf("$")); - log.info("--> account: " + _account); - log.info("--> accountName: " + _accountName); - log.info("--> computerName: " + _computerName); - } - - public void setPassword(String password) { - _password = password; - } - - private String _account; - private String _accountName; - private String _computerName; - private String _password; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmUserAccount.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmUserAccount.java deleted file mode 100644 index 8af216f5ba..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/NtlmUserAccount.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay; - -import java.io.Serializable; - -/** - * @author Marcellus Tavares - */ -public class NtlmUserAccount implements Serializable { - - public NtlmUserAccount(String userName) { - _userName = userName; - } - - public String getUserName() { - return _userName; - } - - private String _userName; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/GroupMembership.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/GroupMembership.java deleted file mode 100644 index b420f5f782..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/GroupMembership.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrObject; - -/** - * @author Marcellus Tavares - */ -public class GroupMembership extends NdrObject { - - public GroupMembership() { - } - - public GroupMembership(int relativeId, int attributes) { - _relativeId = relativeId; - _attributes = attributes; - } - - @Override - public void decode(NdrBuffer ndrBuffer) { - ndrBuffer.align(4); - - _relativeId = ndrBuffer.dec_ndr_long(); - _attributes = ndrBuffer.dec_ndr_long(); - } - - @Override - public void encode(NdrBuffer ndrBuffer) { - ndrBuffer.align(4); - - ndrBuffer.enc_ndr_long(_relativeId); - ndrBuffer.enc_ndr_long(_attributes); - } - - public int getAttributes() { - return _attributes; - } - - public int getRelativeId() { - return _relativeId; - } - - private int _attributes; - private int _relativeId; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonAuthenticator.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonAuthenticator.java deleted file mode 100644 index f67a5222f4..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonAuthenticator.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrObject; - -/** - * @author Marcellus Tavares - */ -public class NetlogonAuthenticator extends NdrObject { - - public NetlogonAuthenticator() { - _credential = new byte[8]; - } - - public NetlogonAuthenticator(byte[] credential, int timestamp) { - _credential = credential; - _timestamp = timestamp; - } - - @Override - public void decode(NdrBuffer ndrBuffer) { - ndrBuffer.align(4); - - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - _timestamp = ndrBuffer.dec_ndr_long(); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - _credential[i] = (byte) ndrBuffer.dec_ndr_small(); - } - } - @Override - public void encode(NdrBuffer ndrBuffer) { - ndrBuffer.align(4); - - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - ndrBuffer.enc_ndr_long(_timestamp); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - ndrBuffer.enc_ndr_small(_credential[i]); - } - } - - private byte[] _credential; - private int _timestamp; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonIdentityInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonIdentityInfo.java deleted file mode 100644 index 7d47845c2d..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonIdentityInfo.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.UnicodeString; -import jcifs.dcerpc.rpc; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrObject; - -/** - * @author Marcellus Tavares - */ -public class NetlogonIdentityInfo extends NdrObject { - - public NetlogonIdentityInfo( - String logonDomainName, int parameterControl, int reservedLow, - int reservedHigh, String userName, String workstation) { - - _logonDomainName = new UnicodeString(logonDomainName, false); - _parameterControl= parameterControl; - _reservedLow = reservedLow; - _reservedHigh = reservedHigh; - _userName = new UnicodeString(userName, false); - _workstation = new UnicodeString(workstation, false); - } - - @Override - public void decode(NdrBuffer ndrBuffer) { - } - - @Override - public void encode(NdrBuffer ndrBuffer) { - ndrBuffer.enc_ndr_short(_logonDomainName.length); - ndrBuffer.enc_ndr_short(_logonDomainName.maximum_length); - ndrBuffer.enc_ndr_referent(_logonDomainName.buffer, 1); - ndrBuffer.enc_ndr_long(_parameterControl); - ndrBuffer.enc_ndr_long(_reservedLow); - ndrBuffer.enc_ndr_long(_reservedHigh); - ndrBuffer.enc_ndr_short(_userName.length); - ndrBuffer.enc_ndr_short(_userName.maximum_length); - ndrBuffer.enc_ndr_referent(_userName.buffer, 1); - ndrBuffer.enc_ndr_short(_workstation.length); - ndrBuffer.enc_ndr_short(_workstation.maximum_length); - ndrBuffer.enc_ndr_referent(_workstation.buffer, 1); - } - - public void encodeLogonDomainName(NdrBuffer ndrBuffer) { - encodeUnicodeString(ndrBuffer, _logonDomainName); - } - - public void encodeUserName(NdrBuffer ndrBuffer) { - encodeUnicodeString(ndrBuffer, _userName); - } - - public void encodeWorkStationName(NdrBuffer ndrBuffer) { - encodeUnicodeString(ndrBuffer, _workstation); - } - - protected void encodeUnicodeString( - NdrBuffer ndrBuffer, rpc.unicode_string string ) { - - ndrBuffer = ndrBuffer.deferred; - - int stringBufferl = string.length / 2; - int stringBuffers = string.maximum_length / 2; - - ndrBuffer.enc_ndr_long(stringBuffers); - ndrBuffer.enc_ndr_long(0); - ndrBuffer.enc_ndr_long(stringBufferl); - - int stringBufferIndex = ndrBuffer.index; - - ndrBuffer.advance(2 * stringBufferl); - - ndrBuffer = ndrBuffer.derive(stringBufferIndex); - - for (int _i = 0; _i < stringBufferl; _i++) { - ndrBuffer.enc_ndr_short(string.buffer[_i]); - } - } - - private rpc.unicode_string _logonDomainName; - private int _parameterControl; - private int _reservedHigh; - private int _reservedLow; - private rpc.unicode_string _userName; - private rpc.unicode_string _workstation; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonNetworkInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonNetworkInfo.java deleted file mode 100644 index 6c06882482..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonNetworkInfo.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrObject; - -/** - * @author Marcellus Tavares - */ -public class NetlogonNetworkInfo extends NdrObject { - - public NetlogonNetworkInfo( - NetlogonIdentityInfo netlogonIdentityInfo, byte[] lmChallenge, - byte[] ntChallengeResponse, byte[] lmChallengeResponse) { - - _netlogonIdentityInfo = netlogonIdentityInfo; - _lmChallenge = lmChallenge; - _ntChallengeResponse = ntChallengeResponse; - _lmChallengeResponse = lmChallengeResponse; - } - - @Override - public void decode(NdrBuffer ndrBuffer) { - } - - @Override - public void encode(NdrBuffer ndrBuffer) { - ndrBuffer.align(4); - - _netlogonIdentityInfo.encode(ndrBuffer); - - int lmChallengeIndex = ndrBuffer.index; - - ndrBuffer.advance(8); - - ndrBuffer.enc_ndr_short((short)_ntChallengeResponse.length); - ndrBuffer.enc_ndr_short((short)_ntChallengeResponse.length); - ndrBuffer.enc_ndr_referent(_ntChallengeResponse, 1); - - ndrBuffer.enc_ndr_short((short)_lmChallengeResponse.length); - ndrBuffer.enc_ndr_short((short)_lmChallengeResponse.length); - ndrBuffer.enc_ndr_referent(_lmChallengeResponse, 1); - - _netlogonIdentityInfo.encodeLogonDomainName(ndrBuffer); - _netlogonIdentityInfo.encodeUserName(ndrBuffer); - _netlogonIdentityInfo.encodeWorkStationName(ndrBuffer); - - ndrBuffer = ndrBuffer.derive(lmChallengeIndex); - - for (int i = 0; i < 8; i++) { - ndrBuffer.enc_ndr_small(_lmChallenge[i]); - } - - encodeChallengeResponse(ndrBuffer, _ntChallengeResponse); - encodeChallengeResponse(ndrBuffer, _lmChallengeResponse); - } - - protected void encodeChallengeResponse( - NdrBuffer ndrBuffer, byte[] challenge) { - - ndrBuffer = ndrBuffer.deferred; - - ndrBuffer.enc_ndr_long(challenge.length); - ndrBuffer.enc_ndr_long(0); - ndrBuffer.enc_ndr_long(challenge.length); - - int index = ndrBuffer.index; - - ndrBuffer.advance(challenge.length); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < challenge.length; i++) { - ndrBuffer.enc_ndr_small(challenge[i]); - } - } - - private byte[] _lmChallenge; - private byte[] _lmChallengeResponse; - private NetlogonIdentityInfo _netlogonIdentityInfo; - private byte[] _ntChallengeResponse; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonValidationSamInfo.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonValidationSamInfo.java deleted file mode 100644 index d0a61d9e55..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetlogonValidationSamInfo.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.rpc; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; -import jcifs.dcerpc.ndr.NdrObject; - -/** - * @author Marcellus Tavares - */ -public class NetlogonValidationSamInfo extends NdrObject { - - public NetlogonValidationSamInfo() { - _effectiveName = new rpc.unicode_string(); - _fullName = new rpc.unicode_string(); - _logonScript = new rpc.unicode_string(); - _profilePath = new rpc.unicode_string(); - _homeDirectory = new rpc.unicode_string(); - _homeDirectoryDrive = new rpc.unicode_string(); - _logonServer = new rpc.unicode_string(); - _logonDomainName = new rpc.unicode_string(); - _userSessionKey = new byte[16]; - _logonDomain = new rpc.sid_t(); - } - - @Override - public void decode(NdrBuffer ndrBuffer) throws NdrException { - _logonTime = ndrBuffer.dec_ndr_hyper(); - _logoffTime = ndrBuffer.dec_ndr_hyper(); - _kickoffTime = ndrBuffer.dec_ndr_hyper(); - _passwordLastSet = ndrBuffer.dec_ndr_hyper(); - _passwordCanChange = ndrBuffer.dec_ndr_hyper(); - _passwordMustChange = ndrBuffer.dec_ndr_hyper(); - - _effectiveName.length = (short)ndrBuffer.dec_ndr_short(); - _effectiveName.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int effectiveNamePtr = ndrBuffer.dec_ndr_long(); - - _fullName.length = (short)ndrBuffer.dec_ndr_short(); - _fullName.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int fullNamePtr = ndrBuffer.dec_ndr_long(); - - _logonScript.length = (short)ndrBuffer.dec_ndr_short(); - _logonScript.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int logonScriptPtr = ndrBuffer.dec_ndr_long(); - - _profilePath.length = (short)ndrBuffer.dec_ndr_short(); - _profilePath.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int profilePathPtr = ndrBuffer.dec_ndr_long(); - - _homeDirectory.length = (short)ndrBuffer.dec_ndr_short(); - _homeDirectory.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int homeDirectoryPtr = ndrBuffer.dec_ndr_long(); - - _homeDirectoryDrive.length = (short)ndrBuffer.dec_ndr_short(); - _homeDirectoryDrive.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int homeDirectoryDrivePtr = ndrBuffer.dec_ndr_long(); - - _logonCount = (short)ndrBuffer.dec_ndr_short(); - _badPasswordCount = (short)ndrBuffer.dec_ndr_short(); - - _userId = ndrBuffer.dec_ndr_long(); - _primaryGroupId = ndrBuffer.dec_ndr_long(); - - _groupCount = ndrBuffer.dec_ndr_long(); - - int groupIdsPtr = ndrBuffer.dec_ndr_long(); - - _userFlags = ndrBuffer.dec_ndr_long(); - - int userSessionKeyI = ndrBuffer.index; - - ndrBuffer.advance(16); - - _logonServer.length = (short)ndrBuffer.dec_ndr_short(); - _logonServer.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int logonServerPtr = ndrBuffer.dec_ndr_long(); - - _logonDomainName.length = (short)ndrBuffer.dec_ndr_short(); - _logonDomainName.maximum_length = (short)ndrBuffer.dec_ndr_short(); - - int logonDomainNamePtr = ndrBuffer.dec_ndr_long(); - - int logonDomainPtr = ndrBuffer.dec_ndr_long(); - - ndrBuffer.advance(40); - - if (effectiveNamePtr > 0) { - decodeUnicodeString(ndrBuffer, _effectiveName); - } - - if (fullNamePtr > 0) { - decodeUnicodeString(ndrBuffer, _fullName); - } - - if (logonScriptPtr > 0) { - decodeUnicodeString(ndrBuffer, _logonScript); - } - - if (profilePathPtr > 0) { - decodeUnicodeString(ndrBuffer, _profilePath); - } - - if (homeDirectoryPtr > 0) { - decodeUnicodeString(ndrBuffer, _homeDirectory); - } - - if (homeDirectoryDrivePtr > 0) { - decodeUnicodeString(ndrBuffer, _homeDirectoryDrive); - } - - if (groupIdsPtr > 0) { - _groupIds = new GroupMembership[_groupCount]; - - ndrBuffer = ndrBuffer.deferred; - - int groupIdsS = ndrBuffer.dec_ndr_long(); - int groupIdsI = ndrBuffer.index; - - ndrBuffer.advance(8 * groupIdsS); - - ndrBuffer = ndrBuffer.derive(groupIdsI); - - for (int i = 0; i < groupIdsS; i++) { - if (_groupIds[i] == null) { - _groupIds[i] = new GroupMembership(); - } - - _groupIds[i].decode(ndrBuffer); - } - } - - ndrBuffer = ndrBuffer.derive(userSessionKeyI); - - for (int i = 0; i < 16; i++) { - _userSessionKey[i] = (byte) ndrBuffer.dec_ndr_small(); - } - - if (logonServerPtr > 0) { - decodeUnicodeString(ndrBuffer, _logonServer); - } - - if (logonDomainNamePtr > 0) { - decodeUnicodeString(ndrBuffer, _logonDomainName); - } - - if (logonDomainPtr > 0) { - ndrBuffer = ndrBuffer.deferred; - - _logonDomain.decode(ndrBuffer); - } - } - - @Override - public void encode(NdrBuffer ndrBuffer) { - } - - public short getBadPasswordCount() { - return _badPasswordCount; - } - - public rpc.unicode_string getEffectiveName() { - return _effectiveName; - } - - public rpc.unicode_string getFullName() { - return _fullName; - } - - public int getGroupCount() { - return _groupCount; - } - - public GroupMembership[] getGroupIds() { - return _groupIds; - } - - public rpc.unicode_string getHomeDirectory() { - return _homeDirectory; - } - - public rpc.unicode_string getHomeDirectoryDrive() { - return _homeDirectoryDrive; - } - - public long getKickoffTime() { - return _kickoffTime; - } - - public long getLogoffTime() { - return _logoffTime; - } - - public short getLogonCount() { - return _logonCount; - } - - public rpc.sid_t getLogonDomain() { - return _logonDomain; - } - - public rpc.unicode_string getLogonDomainName() { - return _logonDomainName; - } - - public rpc.unicode_string getLogonScript() { - return _logonScript; - } - - public rpc.unicode_string getLogonServer() { - return _logonServer; - } - - public long getLogonTime() { - return _logonTime; - } - - public long getPasswordCanChange() { - return _passwordCanChange; - } - - public long getPasswordLastSet() { - return _passwordLastSet; - } - - public long getPasswordMustChange() { - return _passwordMustChange; - } - - public int getPrimaryGroupId() { - return _primaryGroupId; - } - - public rpc.unicode_string getProfilePath() { - return _profilePath; - } - - public int getUserFlags() { - return _userFlags; - } - - public int getUserId() { - return _userId; - } - - public byte[] getUserSessionKey() { - return _userSessionKey; - } - - protected void decodeUnicodeString( - NdrBuffer ndrBuffer, rpc.unicode_string string) { - - ndrBuffer = ndrBuffer.deferred; - - int bufferS = ndrBuffer.dec_ndr_long(); - - ndrBuffer.dec_ndr_long(); - - int bufferL = ndrBuffer.dec_ndr_long(); - int bufferI = ndrBuffer.index; - - ndrBuffer.advance(2 * bufferL); - - if (string.buffer == null) { - string.buffer = new short[bufferS]; - } - - ndrBuffer = ndrBuffer.derive(bufferI); - - for (int i = 0; i < bufferL; i++) { - string.buffer[i] = (short)ndrBuffer.dec_ndr_short(); - } - } - - @SuppressWarnings("unused") - private short _badPasswordCount; - - private rpc.unicode_string _effectiveName; - private rpc.unicode_string _fullName; - private int _groupCount; - private GroupMembership[] _groupIds; - private rpc.unicode_string _homeDirectory; - private rpc.unicode_string _homeDirectoryDrive; - - @SuppressWarnings("unused") - private long _kickoffTime; - - @SuppressWarnings("unused") - private long _logoffTime; - - @SuppressWarnings("unused") - private short _logonCount; - - private rpc.sid_t _logonDomain; - private rpc.unicode_string _logonDomainName; - private rpc.unicode_string _logonScript; - private rpc.unicode_string _logonServer; - - @SuppressWarnings("unused") - private long _logonTime; - - @SuppressWarnings("unused") - private long _passwordCanChange; - - @SuppressWarnings("unused") - private long _passwordLastSet; - - @SuppressWarnings("unused") - private long _passwordMustChange; - - @SuppressWarnings("unused") - private int _primaryGroupId; - - private rpc.unicode_string _profilePath; - - @SuppressWarnings("unused") - private int _userFlags; - - @SuppressWarnings("unused") - private int _userId; - - private byte[] _userSessionKey; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrLogonSamLogon.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrLogonSamLogon.java deleted file mode 100644 index 551f3fb74e..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrLogonSamLogon.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; -import jcifs.dcerpc.ndr.NdrException; - -/** - * @author Marcellus Tavares - */ -public class NetrLogonSamLogon extends DcerpcMessage { - - public NetrLogonSamLogon( - String logonServer, String computerName, - NetlogonAuthenticator netlogonAuthenticator, - NetlogonAuthenticator returnNetlogonAuthenticator, int logonLevel, - NetlogonNetworkInfo netlogonNetworkInfo, int validationLevel, - NetlogonValidationSamInfo netlogonValidationSamInfo, - int authoritative) { - - _logonServer = logonServer; - _computerName = computerName; - _authenticator = netlogonAuthenticator; - _returnAuthenticator = returnNetlogonAuthenticator; - _logonLevel = (short)logonLevel; - _logonInformation = netlogonNetworkInfo; - _validationLevel = (short)validationLevel; - _validationInformation = netlogonValidationSamInfo; - _authoritative = (byte)authoritative; - - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - @Override - public void decode_out(NdrBuffer ndrBuffer) throws NdrException { - int returnAuthenticator = ndrBuffer.dec_ndr_long(); - - if (returnAuthenticator > 0) { - _returnAuthenticator.decode(ndrBuffer); - } - - ndrBuffer.dec_ndr_short(); - - int validationInformation = ndrBuffer.dec_ndr_long(); - - if (validationInformation > 0) { - ndrBuffer = ndrBuffer.deferred; - _validationInformation.decode(ndrBuffer); - } - - _authoritative = (byte)ndrBuffer.dec_ndr_small(); - _status = ndrBuffer.dec_ndr_long(); - } - - @Override - public void encode_in(NdrBuffer ndrBuffer) { - ndrBuffer.enc_ndr_referent(_logonServer, 1); - ndrBuffer.enc_ndr_string(_logonServer); - - ndrBuffer.enc_ndr_referent(_computerName, 1); - ndrBuffer.enc_ndr_string(_computerName); - - ndrBuffer.enc_ndr_referent(_authenticator, 1); - - _authenticator.encode(ndrBuffer); - - ndrBuffer.enc_ndr_referent(_returnAuthenticator, 1); - - _returnAuthenticator.encode(ndrBuffer); - - ndrBuffer.enc_ndr_short(_logonLevel); - ndrBuffer.enc_ndr_short(_logonLevel); - - ndrBuffer.enc_ndr_referent(_logonInformation, 1); - - _logonInformation.encode(ndrBuffer); - - ndrBuffer.enc_ndr_short(_validationLevel); - } - - public NetlogonValidationSamInfo getNetlogonValidationSamInfo() { - return _validationInformation; - } - - @Override - public int getOpnum() { - return 2; - } - - public int getStatus() { - return _status; - } - - private NetlogonAuthenticator _authenticator; - - @SuppressWarnings("unused") - private byte _authoritative; - - private String _computerName; - private NetlogonNetworkInfo _logonInformation; - private short _logonLevel; - private String _logonServer; - private NetlogonAuthenticator _returnAuthenticator; - private int _status; - private NetlogonValidationSamInfo _validationInformation; - private short _validationLevel; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerAuthenticate3.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerAuthenticate3.java deleted file mode 100644 index 5344d03025..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerAuthenticate3.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; - -/** - * @author Marcellus Tavares - */ -public class NetrServerAuthenticate3 extends DcerpcMessage { - - public NetrServerAuthenticate3( - String primaryName, String accountName, int secureChannelType, - String computerName, byte[] clientCredential, byte[] serverCredential, - int negotiateFlags) { - - _primaryName = primaryName; - _accountName = accountName; - _secureChannelType = (short) secureChannelType; - _computerName = computerName; - _clientCredential = clientCredential; - _serverCredential = serverCredential; - _negotiateFlags = negotiateFlags; - - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - @Override - public void decode_out(NdrBuffer ndrBuffer) { - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - _serverCredential[i] = (byte) ndrBuffer.dec_ndr_small(); - } - - _negotiateFlags = ndrBuffer.dec_ndr_long(); - _accountRid = ndrBuffer.dec_ndr_long(); - _status = ndrBuffer.dec_ndr_long(); - } - - @Override - public void encode_in(NdrBuffer ndrBuffer) { - ndrBuffer.enc_ndr_referent(_primaryName, 1); - ndrBuffer.enc_ndr_string(_primaryName); - ndrBuffer.enc_ndr_string(_accountName); - ndrBuffer.enc_ndr_short(_secureChannelType); - ndrBuffer.enc_ndr_string(_computerName); - - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - NdrBuffer derivedNrdBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - derivedNrdBuffer.enc_ndr_small(_clientCredential[i]); - } - - ndrBuffer.enc_ndr_long(_negotiateFlags); - } - - public int getAccountRid() { - return _accountRid; - } - - public int getNegotiatedFlags() { - return _negotiateFlags; - } - - @Override - public int getOpnum() { - return 26; - } - - public byte[] getServerCredential() { - return _serverCredential; - } - - public int getStatus() { - return _status; - } - - private String _accountName; - private int _accountRid; - private byte[] _clientCredential; - private String _computerName; - private int _negotiateFlags; - private String _primaryName; - private short _secureChannelType; - private byte[] _serverCredential; - private int _status; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerReqChallenge.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerReqChallenge.java deleted file mode 100644 index 3fc6093bbe..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/ntlm/msrpc/NetrServerReqChallenge.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.ntlm.msrpc; - -import jcifs.dcerpc.DcerpcMessage; -import jcifs.dcerpc.ndr.NdrBuffer; - -/** - * @author Marcellus Tavares - */ -public class NetrServerReqChallenge extends DcerpcMessage { - - public NetrServerReqChallenge( - String primaryName, String computerName, byte[] clientChallenge, - byte[] serverChallenge) { - - _primaryName = primaryName; - _computerName = computerName; - _clientChallenge = clientChallenge; - _serverChallenge = serverChallenge; - - ptype = 0; - flags = DCERPC_FIRST_FRAG | DCERPC_LAST_FRAG; - } - - @Override - public void decode_out(NdrBuffer ndrBuffer) { - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - _serverChallenge[i] = (byte) ndrBuffer.dec_ndr_small(); - } - - _status = ndrBuffer.dec_ndr_long(); - } - - @Override - public void encode_in(NdrBuffer ndrBuffer) { - ndrBuffer.enc_ndr_referent(_primaryName, 1); - ndrBuffer.enc_ndr_string(_primaryName); - ndrBuffer.enc_ndr_string(_computerName); - - int index = ndrBuffer.index; - - ndrBuffer.advance(8); - - ndrBuffer = ndrBuffer.derive(index); - - for (int i = 0; i < 8; i++) { - ndrBuffer.enc_ndr_small(_clientChallenge[i]); - } - } - - @Override - public int getOpnum() { - return 4; - } - - public byte[] getServerChallenge() { - return _serverChallenge; - } - - public int getStatus() { - return _status; - } - - private byte[] _clientChallenge; - private String _computerName; - private String _primaryName; - private byte[] _serverChallenge; - private int _status; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/HttpHeaders.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/HttpHeaders.java deleted file mode 100644 index a74c4f2604..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/HttpHeaders.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.util; - -/** - * @author Brian Wing Shun Chan - */ -public interface HttpHeaders { - - // Names - - public static final String ACCEPT = "ACCEPT"; - - public static final String ACCEPT_ENCODING = "Accept-Encoding"; - - public static final String ACCEPT_RANGES = "Accept-Ranges"; - - public static final String AUTHORIZATION = "Authorization"; - - public static final String CACHE_CONTROL = "Cache-Control"; - - public static final String COOKIE = "Cookie"; - - public static final String CONNECTION = "Connection"; - - public static final String CONTENT_DISPOSITION = "Content-Disposition"; - - public static final String CONTENT_ENCODING = "Content-Encoding"; - - public static final String CONTENT_ID = "Content-ID"; - - public static final String CONTENT_LENGTH = "Content-Length"; - - public static final String CONTENT_RANGE = "Content-Range"; - - public static final String CONTENT_TYPE = "Content-Type"; - - public static final String EXPIRES = "Expires"; - - public static final String ETAG = "ETag"; - - public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; - - public static final String IF_NONE_MATCH = "If-None-Match"; - - public static final String KEEP_ALIVE = "Keep-Alive"; - - public static final String LAST_MODIFIED = "Last-Modified"; - - public static final String LIFERAY_EMAIL_ADDRESS = "LIFERAY_EMAIL_ADDRESS"; - - public static final String LIFERAY_SCREEN_NAME = "LIFERAY_SCREEN_NAME"; - - public static final String LIFERAY_USER_ID = "LIFERAY_USER_ID"; - - public static final String LOCATION = "Location"; - - public static final String PRAGMA = "Pragma"; - - public static final String RANGE = "Range"; - - public static final String USER_AGENT = "User-Agent"; - - public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; - - // Values - - public static final String ACCEPT_RANGES_BYTES_VALUE = "bytes"; - - public static final String CONNECTION_CLOSE_VALUE = "close"; - - public static final String CACHE_CONTROL_DEFAULT_VALUE = - "max-age=315360000, public"; - - public static final String CACHE_CONTROL_NO_CACHE_VALUE = - "private, no-cache, no-store, must-revalidate"; - - public static final String CACHE_CONTROL_PUBLIC_VALUE = "public"; - - /** - * @deprecated Use CONNECTION_CLOSE_VALUE. - */ - public static final String CLOSE = CONNECTION_CLOSE_VALUE; - - public static final String EXPIRES_DEFAULT_VALUE = "315360000"; - - public static final String PRAGMA_NO_CACHE_VALUE = "no-cache"; - - public static final String PRAGMA_PUBLIC_VALUE = "public"; - - /** - * @deprecated UseCACHE_CONTROL_PUBLIC_VALUE. - */ - public static final String PUBLIC = CACHE_CONTROL_PUBLIC_VALUE; - -} \ No newline at end of file diff --git a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/NtlmV2ArrayUtil.java b/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/NtlmV2ArrayUtil.java deleted file mode 100644 index 13808d7dd2..0000000000 --- a/openam-authentication/openam-auth-ntlmv2/openam-auth-ntlmv2-lib/src/main/java/org/ntlmv2/liferay/util/NtlmV2ArrayUtil.java +++ /dev/null @@ -1,1211 +0,0 @@ -/** - * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. - * - * This library is free software; you can redistribute it and/or modify it under - * the terms of the GNU Lesser General Public License as published by the Free - * Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more - * details. - */ - -package org.ntlmv2.liferay.util; - -import java.lang.reflect.Array; -import java.text.DateFormat; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -/** - * @author Brian Wing Shun Chan - */ -public class NtlmV2ArrayUtil { - - public static boolean[] append(boolean[]... arrays) { - int length = 0; - - for (boolean[] array : arrays) { - length += array.length; - } - - boolean[] newArray = new boolean[length]; - - int previousLength = 0; - - for (boolean[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static byte[] append(byte[]... arrays) { - int length = 0; - - for (byte[] array : arrays) { - length += array.length; - } - - byte[] newArray = new byte[length]; - - int previousLength = 0; - - for (byte[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static byte[] append(byte[] array, byte value) { - byte[] newArray = new byte[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static char[] append(char[]... arrays) { - int length = 0; - - for (char[] array : arrays) { - length += array.length; - } - - char[] newArray = new char[length]; - - int previousLength = 0; - - for (char[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static char[] append(char[] array, char value) { - char[] newArray = new char[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static double[] append(double[]... arrays) { - int length = 0; - - for (double[] array : arrays) { - length += array.length; - } - - double[] newArray = new double[length]; - - int previousLength = 0; - - for (double[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static double[] append(double[] array, double value) { - double[] newArray = new double[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static float[] append(float[]... arrays) { - int length = 0; - - for (float[] array : arrays) { - length += array.length; - } - - float[] newArray = new float[length]; - - int previousLength = 0; - - for (float[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static float[] append(float[] array, float value) { - float[] newArray = new float[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static int[] append(int[]... arrays) { - int length = 0; - - for (int[] array : arrays) { - length += array.length; - } - - int[] newArray = new int[length]; - - int previousLength = 0; - - for (int[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static int[] append(int[] array, int value) { - int[] newArray = new int[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static long[] append(long[]... arrays) { - int length = 0; - - for (long[] array : arrays) { - length += array.length; - } - - long[] newArray = new long[length]; - - int previousLength = 0; - - for (long[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static long[] append(long[] array, long value) { - long[] newArray = new long[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public static short[] append(short[]... arrays) { - int length = 0; - - for (short[] array : arrays) { - length += array.length; - } - - short[] newArray = new short[length]; - - int previousLength = 0; - - for (short[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static short[] append(short[] array, short value) { - short[] newArray = new short[array.length + 1]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[newArray.length - 1] = value; - - return newArray; - } - - public staticT[] append(T[]... arrays) { - int length = 0; - - for (T[] array : arrays) { - length += array.length; - } - - Class> arraysClass = arrays.getClass(); - - T[] newArray = (T[])Array.newInstance( - arraysClass.getComponentType(), length); - - int previousLength = 0; - - for (T[] array : arrays) { - System.arraycopy(array, 0, newArray, previousLength, array.length); - - previousLength += array.length; - } - - return newArray; - } - - public static T[] append(T[] array, T value) { - Class> arrayClass = array.getClass(); - - T[] newArray = (T[])Array.newInstance( - arrayClass.getComponentType(), array.length + 1); - - System.arraycopy(array, 0, newArray, 0, array.length); - - newArray[array.length] = value; - - return newArray; - } - - public static T[] append(T[] array1, T[] array2) { - Class> array1Class = array1.getClass(); - - T[] newArray = (T[])Array.newInstance( - array1Class.getComponentType(), array1.length + array2.length); - - System.arraycopy(array1, 0, newArray, 0, array1.length); - - System.arraycopy(array2, 0, newArray, array1.length, array2.length); - - return newArray; - } - - public static T[][] append(T[][] array1, T[] value) { - Class> array1Class = array1.getClass(); - - T[][] newArray = (T[][])Array.newInstance( - array1Class.getComponentType(), array1.length + 1); - - System.arraycopy(array1, 0, newArray, 0, array1.length); - - newArray[array1.length] = value; - - return newArray; - } - - public static T[][] append(T[][] array1, T[][] array2) { - Class> array1Class = array1.getClass(); - - T[][] newArray = (T[][])Array.newInstance( - array1Class.getComponentType(), array1.length + array2.length); - - System.arraycopy(array1, 0, newArray, 0, array1.length); - System.arraycopy(array2, 0, newArray, array1.length, array2.length); - - return newArray; - } - - public static boolean[] clone(boolean[] array) { - boolean[] newArray = new boolean[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static boolean[] clone(boolean[] array, int from, int to) { - boolean[] newArray = new boolean[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static byte[] clone(byte[] array) { - byte[] newArray = new byte[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static byte[] clone(byte[] array, int from, int to) { - byte[] newArray = new byte[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static char[] clone(char[] array) { - char[] newArray = new char[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static char[] clone(char[] array, int from, int to) { - char[] newArray = new char[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static double[] clone(double[] array) { - double[] newArray = new double[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static double[] clone(double[] array, int from, int to) { - double[] newArray = new double[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static float[] clone(float[] array) { - float[] newArray = new float[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static float[] clone(float[] array, int from, int to) { - float[] newArray = new float[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static int[] clone(int[] array) { - int[] newArray = new int[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static int[] clone(int[] array, int from, int to) { - int[] newArray = new int[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static long[] clone(long[] array) { - long[] newArray = new long[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static long[] clone(long[] array, int from, int to) { - long[] newArray = new long[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static short[] clone(short[] array) { - short[] newArray = new short[array.length]; - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static short[] clone(short[] array, int from, int to) { - short[] newArray = new short[to - from]; - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static T[] clone(T[] array) { - Class> arrayClass = array.getClass(); - - T[] newArray = (T[])Array.newInstance( - arrayClass.getComponentType(), array.length); - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static T[] clone(T[] array, int from, int to) { - Class> arrayClass = array.getClass(); - - T[] newArray = (T[])Array.newInstance( - arrayClass.getComponentType(), to - from); - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static T[][] clone(T[][] array) { - Class> arrayClass = array.getClass(); - - T[][] newArray = (T[][])Array.newInstance( - arrayClass.getComponentType(), array.length); - - System.arraycopy(array, 0, newArray, 0, array.length); - - return newArray; - } - - public static T[][] clone(T[][] array, int from, int to) { - Class> arrayClass = array.getClass(); - - T[][] newArray = (T[][])Array.newInstance( - arrayClass.getComponentType(), to - from); - - System.arraycopy( - array, from, newArray, 0, - Math.min(array.length - from, newArray.length)); - - return newArray; - } - - public static void combine( - Object[] array1, Object[] array2, Object[] combinedArray) { - - System.arraycopy(array1, 0, combinedArray, 0, array1.length); - - System.arraycopy( - array2, 0, combinedArray, array1.length, array2.length); - } - - public static boolean contains(boolean[] array, boolean value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(byte[] array, byte value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(char[] array, char value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(double[] array, double value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(float[] array, float value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(int[] array, int value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(long[] array, long value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static boolean contains(Object[] array, Object value) { - if ((array == null) || (array.length == 0) || (value == null)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value.equals(array[i])) { - return true; - } - } - - return false; - } - - public static boolean contains(short[] array, short value) { - if ((array == null) || (array.length == 0)) { - return false; - } - - for (int i = 0; i < array.length; i++) { - if (value == array[i]) { - return true; - } - } - - return false; - } - - public static String[] distinct(String[] array) { - return distinct(array, null); - } - - public static String[] distinct( - String[] array, Comparator comparator) { - - if ((array == null) || (array.length == 0)) { - return array; - } - - Set set = null; - - if (comparator == null) { - set = new TreeSet (); - } - else { - set = new TreeSet (comparator); - } - - for (int i = 0; i < array.length; i++) { - String s = array[i]; - - if (!set.contains(s)) { - set.add(s); - } - } - - return set.toArray(new String[set.size()]); - } - - public static int getLength(Object[] array) { - if (array == null) { - return 0; - } - else { - return array.length; - } - } - - public static Object getValue(Object[] array, int pos) { - if ((array == null) || (array.length <= pos)) { - return null; - } - else { - return array[pos]; - } - } - - public static boolean[] remove(boolean[] array, boolean value) { - List list = new ArrayList (); - - for (int i = 0; i < array.length; i++) { - if (value != array[i]) { - list.add(new Boolean(array[i])); - } - } - - return toArray(list.toArray(new Boolean[list.size()])); - } - - public static byte[] remove(byte[] array, byte value) { - List list = new ArrayList (); - - for (int i = 0; i < array.length; i++) { - if (value != array[i]) { - list.add(new Byte(array[i])); - } - } - - return toArray(list.toArray(new Byte[list.size()])); - } - - public static char[] remove(char[] array, char value) { - List