[jboss-cvs] JBossAS SVN: r76791 - in projects/security/security-negotiation/trunk: jboss-negotiation and 20 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 7 16:42:08 EDT 2008
Author: darran.lofthouse at jboss.com
Date: 2008-08-07 16:42:08 -0400 (Thu, 07 Aug 2008)
New Revision: 76791
Added:
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.classpath
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.project
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/pom.xml
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/Constants.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/NTLMClient.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/DecoderData.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlags.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlagsDecoder.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessage.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessageDecoder.java
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/resources/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/
projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/NegotiationMessageDecoderTest.java
Modified:
projects/security/security-negotiation/trunk/jboss-negotiation-toolkit/src/main/java/org/jboss/security/negotiation/toolkit/BasicNegotiationServlet.java
projects/security/security-negotiation/trunk/jboss-negotiation/pom.xml
projects/security/security-negotiation/trunk/parent/pom.xml
projects/security/security-negotiation/trunk/pom.xml
Log:
[SECURITY-270] Adding new NTLM module.
Modified: projects/security/security-negotiation/trunk/jboss-negotiation/pom.xml
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation/pom.xml 2008-08-07 20:36:33 UTC (rev 76790)
+++ projects/security/security-negotiation/trunk/jboss-negotiation/pom.xml 2008-08-07 20:42:08 UTC (rev 76791)
@@ -30,6 +30,12 @@
<!-- Do not add version information here, use ../parent/pom.xml instead -->
<dependencies>
+ <!-- Local Dependencies -->
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-negotiation-ntlm</artifactId>
+ </dependency>
+
<!-- Global dependencies -->
<dependency>
<groupId>apache-codec</groupId>
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm
___________________________________________________________________
Name: svn:ignore
+ target
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.classpath
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.classpath (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.classpath 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/resources"/>
+ <classpathentry kind="src" path="src/tests/java"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbosssx/4.2.2.GA/jbosssx-4.2.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-common/4.2.2.GA/jboss-common-4.2.2.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-codec/commons-codec/1.2/commons-codec-1.2.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/web/jbossweb/2.1.0.GA/jbossweb-2.1.0.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/web/servlet-api/2.1.0.GA/servlet-api-2.1.0.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-jmx/4.2.2.GA/jboss-jmx-4.2.2.GA.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jboss-negotiation"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.project
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.project (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/.project 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jboss-negotiation-ntlm</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/pom.xml
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/pom.xml (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/pom.xml 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,50 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-negotiation-project</artifactId>
+ <version>2.0.3-Beta2</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-negotiation-ntlm</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Negotiation</name>
+ <url>http://www.jboss.org</url>
+ <description>JBoss Negotiation Library</description>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>true</testFailureIgnore>
+ <includes>
+ <include>**/**TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- Do not add version information here, use ../parent/pom.xml instead -->
+ <dependencies>
+ <!-- Local Dependencies -->
+ <!-- <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-negotiation</artifactId>
+ </dependency> -->
+
+ <!-- Global dependencies -->
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/pom.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/Constants.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/Constants.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/Constants.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm;
+
+/**
+ * NTLM constants.
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class Constants
+{
+
+ public static final byte[] SIGNATURE = new byte[]
+ {'N', 'T', 'L', 'M', 'S', 'S', 'P', 0};
+
+ public static final byte[] NEGOTIATE_MESSAGE_TYPE = new byte[]
+ {1, 0, 0, 0};
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/Constants.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/NTLMClient.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/NTLMClient.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/NTLMClient.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.security.negotiation.ntlm;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+
+/**
+ * A simple client to test calling an NTLM enabled web application.
+ *
+ * Based on the example in: -
+ * http://java.sun.com/javase/6/docs/technotes/guides/net/http-auth.html
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class NTLMClient
+{
+ public static final String USERNAME = "darran";
+
+ public static final String PASSWORD = "password";
+
+ public static final String URL = "http://localhost:8080/jboss-negotiation-toolkit/BasicNegotiation";
+
+ static class NTLMAuthenticator extends Authenticator
+ {
+
+ @Override
+ protected URL getRequestingURL()
+ {
+ return super.getRequestingURL();
+ }
+
+ @Override
+ protected RequestorType getRequestorType()
+ {
+ return super.getRequestorType();
+ }
+
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication()
+ {
+ return new PasswordAuthentication(USERNAME, PASSWORD.toCharArray());
+ }
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ Authenticator.setDefault(new NTLMAuthenticator());
+ URL url = new URL(NTLMClient.URL);
+ InputStream ins = url.openConnection().getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(ins));
+ String str;
+ while ((str = reader.readLine()) != null)
+ {
+ System.out.println(str);
+ }
+ }
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/NTLMClient.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/DecoderData.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/DecoderData.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/DecoderData.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+/**
+ * A simple class to allow state to be passed to the method calls while allowing the
+ * Decoder to use static methods.
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+class DecoderData
+{
+ int read = 0;
+
+ NegotiateMessage message = new NegotiateMessage();
+}
\ No newline at end of file
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/DecoderData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlags.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlags.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlags.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+/**
+ * Representation of NTLM NegotiateFlags
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class NegotiateFlags
+{
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlags.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlagsDecoder.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlagsDecoder.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlagsDecoder.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Decoder to decode the NegotiateFlags field.
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+class NegotiateFlagsDecoder
+{
+
+ // TODO - Write real decoding once we have a client sending valid flags !!
+ static void readNegotiateFlags(final InputStream is, final DecoderData data) throws IOException
+ {
+ byte[] dataRead = new byte[4];
+ NegotiateFlags flags = new NegotiateFlags();
+ data.message.setNegotiateFlags(flags);
+
+ System.out.println("\nNegotiateFlags - ");
+ for (byte current : dataRead)
+ {
+ System.out.print("'" + current + "', ");
+ }
+ System.out.println();
+ }
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateFlagsDecoder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessage.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessage.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessage.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+/**
+ * Representation of an NTLM NEGOTIATIE_MESSAGE
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class NegotiateMessage
+{
+
+ private NegotiateFlags negotiateFlags;
+
+ private String domainName;
+
+ private String workstationName;
+
+ public NegotiateFlags getNegotiateFlags()
+ {
+ return negotiateFlags;
+ }
+
+ public void setNegotiateFlags(NegotiateFlags negotiateFlags)
+ {
+ this.negotiateFlags = negotiateFlags;
+ }
+
+ public String getDomainName()
+ {
+ return domainName;
+ }
+
+ public void setDomainName(String domainName)
+ {
+ this.domainName = domainName;
+ }
+
+ public String getWorkstationName()
+ {
+ return workstationName;
+ }
+
+ public void setWorkstationName(String workstationName)
+ {
+ this.workstationName = workstationName;
+ }
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessageDecoder.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessageDecoder.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessageDecoder.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import org.jboss.security.negotiation.ntlm.Constants;
+
+/**
+ * A Decoder to decode the NegotiateMessage
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class NegotiateMessageDecoder
+{
+
+ private static void readVerifySignature(final InputStream is, final DecoderData data) throws IOException
+ {
+ byte[] expected = Constants.SIGNATURE;
+ byte[] dataRead = new byte[expected.length];
+
+ is.read(dataRead);
+ if (Arrays.equals(expected, dataRead) == false)
+ {
+ throw new IOException("Invalid signature, expected '" + new String(expected) + "' actual '"
+ + new String(dataRead) + "'");
+ }
+ data.read += dataRead.length;
+ }
+
+ private static void readVerifyMessageType(final InputStream is, final DecoderData data) throws IOException
+ {
+ byte[] expected = Constants.NEGOTIATE_MESSAGE_TYPE;
+ byte[] dataRead = new byte[expected.length];
+
+ is.read(dataRead);
+ if (Arrays.equals(expected, dataRead) == false)
+ {
+ throw new IOException("Invalid MessageType, expected '" + new String(expected) + "' actual '"
+ + new String(dataRead) + "'");
+ }
+ data.read += dataRead.length;
+ }
+
+ public static NegotiateMessage decode(final byte[] token) throws IOException
+ {
+ System.out.println("Token - ");
+ for (byte current : token)
+ {
+ if (current == 0)
+ {
+ continue;
+ }
+ System.out.print("'" + (char) current + "', ");
+ }
+ DecoderData data = new DecoderData();
+ ByteArrayInputStream bais = new ByteArrayInputStream(token);
+
+ readVerifySignature(bais, data);
+ readVerifyMessageType(bais, data);
+ NegotiateFlagsDecoder.readNegotiateFlags(bais, data);
+
+ return data.message;
+ }
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/main/java/org/jboss/security/negotiation/ntlm/encoding/NegotiateMessageDecoder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/NegotiationMessageDecoderTest.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/NegotiationMessageDecoderTest.java (rev 0)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/NegotiationMessageDecoderTest.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -0,0 +1,44 @@
+/*
+ * Copyright © 2008 Red Hat Middleware, LLC. or third-party contributors as indicated
+ * by the @author tags or express copyright attribution statements applied by the
+ * authors. All third-party contributions are distributed under license by Red Hat
+ * Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify, copy,
+ * or redistribute it subject to the terms and conditions of the GNU Lesser General
+ * Public License, v. 2.1. This program is distributed in the hope that it will be
+ * useful, but WITHOUT A 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.jboss.security.negotiation.ntlm.encoding;
+
+import org.jboss.util.Base64;
+
+import junit.framework.TestCase;
+
+/**
+ * Test case to test the NegotiationMessageDecoder
+ *
+ * @author darran.lofthouse at jboss.com
+ * @since 7th August 2008
+ */
+public class NegotiationMessageDecoderTest extends TestCase
+{
+
+ /**
+ * Simple test case to test decoding an NTLM message
+ * created by Java.
+ */
+ public void testDecode() throws Exception
+ {
+ String message = "TlRMTVNTUAABAAAAA7IAAAYABgAoAAAACAAIACAAAABLRVJCRVJPU2RvbWFpbg==";
+ byte[] requestMessage = Base64.decode(message);
+
+ NegotiateMessage negMessage = NegotiateMessageDecoder.decode(requestMessage);
+ }
+
+}
Property changes on: projects/security/security-negotiation/trunk/jboss-negotiation-ntlm/src/tests/java/org/jboss/security/negotiation/ntlm/encoding/NegotiationMessageDecoderTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/security/security-negotiation/trunk/jboss-negotiation-toolkit/src/main/java/org/jboss/security/negotiation/toolkit/BasicNegotiationServlet.java
===================================================================
--- projects/security/security-negotiation/trunk/jboss-negotiation-toolkit/src/main/java/org/jboss/security/negotiation/toolkit/BasicNegotiationServlet.java 2008-08-07 20:36:33 UTC (rev 76790)
+++ projects/security/security-negotiation/trunk/jboss-negotiation-toolkit/src/main/java/org/jboss/security/negotiation/toolkit/BasicNegotiationServlet.java 2008-08-07 20:42:08 UTC (rev 76791)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.Arrays;
import java.util.List;
import javax.servlet.ServletException;
@@ -65,7 +66,7 @@
if (authHeader == null)
{
log.info("No Authorization Header, sending 401");
- resp.setHeader("WWW-Authenticate", "Negotiate");
+ resp.setHeader("WWW-Authenticate", "NTLM");
resp.sendError(401);
return;
@@ -122,14 +123,23 @@
private void writeHeaderDetail(final String authHeader, final PrintWriter writer) throws IOException, GSSException
{
- if (authHeader.startsWith("Negotiate ") == false)
+ String requestHeader;
+ if (authHeader.startsWith("Negotiate "))
{
- writer.println("<p><b>Header WWW-Authenticate does not beging with 'Negotiate'!</b></p>");
+ // Drop the 'Negotiate ' from the header.
+ requestHeader = authHeader.substring(10);
+ }
+ else if (authHeader.startsWith("NTLM "))
+ {
+ // Drop the 'NTLM ' from the header.
+ requestHeader = authHeader.substring(5);
+ }
+ else
+ {
+ writer.println("<p><b>Header WWW-Authenticate does not beging with 'Negotiate' or 'NTLM'!</b></p>");
return;
}
- // Drop the 'Negotiate ' from the header.
- String requestHeader = authHeader.substring(10);
byte[] reqToken = Base64.decode(requestHeader);
if (reqToken[0] == 0x60)
@@ -174,18 +184,32 @@
writer.print(new String(Base64.encodeBytes(mechTokenMic)));
}
writer.println("<br>");
+
+ return;
}
- else if (reqToken[0] == (byte) 0xa1)
+
+ if (reqToken[0] == (byte) 0xa1)
{
writer.println("<p><b>Unexpected NegTokenTarg, first token should be NegTokenInit!</b></p>");
return;
}
- else
+
+ byte[] ntlmHeader = "NTLMSSP".getBytes();
+ if (reqToken.length > 7)
{
- writer.println("<p><b>Unsupported negotiation mechanism, possibly NTLM!</b></p>");
- return;
+ byte[] reqHeader = new byte[7];
+ System.arraycopy(reqToken, 0, reqHeader, 0, 7);
+
+ if (Arrays.equals(ntlmHeader, reqHeader))
+ {
+ writer.println("<h3>NTLM</h3>");
+
+ return;
+ }
+
}
+ writer.println("<p><b>Unsupported negotiation mechanism</b></p>");
}
}
Modified: projects/security/security-negotiation/trunk/parent/pom.xml
===================================================================
--- projects/security/security-negotiation/trunk/parent/pom.xml 2008-08-07 20:36:33 UTC (rev 76790)
+++ projects/security/security-negotiation/trunk/parent/pom.xml 2008-08-07 20:42:08 UTC (rev 76791)
@@ -102,6 +102,11 @@
<artifactId>jboss-negotiation</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.security</groupId>
+ <artifactId>jboss-negotiation-ntlm</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- External Dependencies -->
<dependency>
Modified: projects/security/security-negotiation/trunk/pom.xml
===================================================================
--- projects/security/security-negotiation/trunk/pom.xml 2008-08-07 20:36:33 UTC (rev 76790)
+++ projects/security/security-negotiation/trunk/pom.xml 2008-08-07 20:42:08 UTC (rev 76791)
@@ -16,6 +16,7 @@
<modules>
<module>parent</module>
<module>jboss-negotiation</module>
+ <module>jboss-negotiation-ntlm</module>
<module>jboss-negotiation-toolkit</module>
</modules>
<scm>
More information about the jboss-cvs-commits
mailing list