diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2014-08-07 23:09:54 +0400 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2014-08-08 01:01:53 +0400 |
commit | c685b217646d271e70063173171a98159109ab2b (patch) | |
tree | ee128dabc576ca0cdebe4523dea6b0a3f4f0cbeb /mcs/class/Novell.Directory.Ldap | |
parent | 5f4b8c2cf4295e82196b0a93908638de9fce2992 (diff) |
[Cleanup] Removed files that imported Java namespaces
They were once part of a special Java target profile, but this is no longer used today.
Diffstat (limited to 'mcs/class/Novell.Directory.Ldap')
10 files changed, 0 insertions, 865 deletions
diff --git a/mcs/class/Novell.Directory.Ldap/Makefile b/mcs/class/Novell.Directory.Ldap/Makefile index 725938c3522..7ecbff311e9 100644 --- a/mcs/class/Novell.Directory.Ldap/Makefile +++ b/mcs/class/Novell.Directory.Ldap/Makefile @@ -24,14 +24,6 @@ $(RESULTCODE_MESSAGES): Novell.Directory.Ldap.Utilclass/ResultCodeMessages.txt EXTRA_DISTFILES = \ Novell.Directory.Ldap.Rfc2251/RfcLdapURL.cs \ - Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs \ - Novell.Directory.Ldap.Security.jvm/ChangeLog \ - Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs \ - Novell.Directory.Ldap.Security.jvm/SecureStream.cs \ - Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs \ - Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs \ Novell.Directory.Ldap.Utilclass/ExceptionMessages.resx \ Novell.Directory.Ldap.Utilclass/ExceptionMessages.txt \ Novell.Directory.Ldap.Utilclass/ResultCodeMessages.resx \ diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes deleted file mode 100644 index f4322cac4e6..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/AuthenticationCallbackHandler.cs -crlf -/CreateContextPrivilegedAction.cs -crlf -/ExchangeTokenPrivilegedAction.cs -crlf -/Krb5Helper.cs -crlf -/SecureStream.cs -crlf -/UnwrapPrivilegedAction.cs -crlf -/WrapPrivilegedAction.cs -crlf diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs deleted file mode 100644 index 486ab61b5e2..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.AuthenticationCallbackHandler.cs -// -// Authors: -// Boris Kirzner <borsk@mainsoft.com> -// Konstantin Triger <kostat@mainsoft.com> -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//
-
-using System;
-
-using javax.security.auth.callback;
-using java.io;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class AuthenticationCallbackHandler : CallbackHandler
- {
-
- #region Fields
-
- private readonly string _username;
- private readonly string _password;
-
- #endregion //Fields
-
- #region Constructors
-
- public AuthenticationCallbackHandler(string username, string password)
- {
- _username = username;
- _password = password;
- }
-
- #endregion // Constructors
-
- #region Methods
-
- public void handle(Callback [] callbacks)
- {
- for (int i = 0; i < callbacks.Length; i++) {
- if (callbacks [i] is NameCallback) {
- NameCallback nc = (NameCallback) callbacks [i];
- nc.setName (_username);
- }
- else if (callbacks [i] is PasswordCallback) {
- PasswordCallback pc = (PasswordCallback) callbacks [i];
- pc.setPassword (_password.ToCharArray ());
- }
- else {
- throw new UnsupportedCallbackException (callbacks [i], "Unrecognized Callback");
- }
- }
- }
-
- #endregion // Methods
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog deleted file mode 100644 index be95898738f..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ChangeLog +++ /dev/null @@ -1,27 +0,0 @@ -2005-11-06 Konstantin Triger <kostat@mainsoft.com> - - * SecureStream.cs, CreateContextPrivilegedAction.cs, Krb5Helper.cs: - create GSSCredential only once, cleanup - -2005-11-03 Konstantin Triger <kostat@mainsoft.com> - - * CreateContextPrivilegedAction.cs: always require mutual auth; - require integrity by default. - * Krb5Helper.cs: for wrap/unwrap: always create MessageProp with - pribState set. - -2005-14-08 Boris Kirzner <borisk@mainsoft.com> - * Krb5Helper.cs: ExchangeTokens does proper final handshaking. Wrap/Unwrap - perform no action if no integrity and encryption accured. - * SecureStream.cs: Private convertion methods became internal, used by - Krb5Helper. - -2005-28-07 Boris Kirzner <borisk@mainsoft.com> - * Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/SecureStream.cs, - Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs, - Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs, - Novell.Directory.Ldap.Security.jvm/AuthenticationCallbackHandler.cs: added - new classes implementing kerberos authntication support. diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs deleted file mode 100644 index 73b280f5581..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/CreateContextPrivilegedAction.cs +++ /dev/null @@ -1,105 +0,0 @@ -// -// Novell.Directory.Ldap.Security.CreateContextPrivilegedAction.cs -// -// Authors: -// Boris Kirzner <borsk@mainsoft.com> -// Konstantin Triger <kostat@mainsoft.com> -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//
-
-using System;
-
-using java.security;
-using org.ietf.jgss;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class CreateContextPrivilegedAction : PrivilegedAction
- {
- #region Fields
-
- private readonly bool _encryption;
- private readonly bool _signing;
- private readonly bool _delegation;
- private readonly string _name;
- private readonly string _clientName;
- private readonly string _mech;
-
- #endregion //Fields
-
- #region Constructors
-
- public CreateContextPrivilegedAction(string name, string clientName, string mech, bool encryption, bool signing, bool delegation)
- {
- _name = name;
- _clientName = clientName;
- _mech = mech;
- _encryption = encryption;
- _signing = signing;
- _delegation = delegation;
- }
-
- #endregion // Constructors
-
- #region Methods
-
- public object run()
- {
- try {
- Oid krb5Oid = new Oid (_mech);
- GSSManager manager = GSSManager.getInstance ();
- GSSName clientName =
- manager.createName(_clientName, GSSName__Finals.NT_USER_NAME);
- GSSCredential clientCreds =
- manager.createCredential(clientName,
- GSSContext__Finals.INDEFINITE_LIFETIME,
- krb5Oid,
- GSSCredential__Finals.INITIATE_ONLY);
-
-// try {
- GSSName serverName = manager.createName (_name, GSSName__Finals.NT_HOSTBASED_SERVICE, krb5Oid);
- GSSContext context = manager.createContext (serverName, krb5Oid, clientCreds, GSSContext__Finals.INDEFINITE_LIFETIME);
-
- context.requestMutualAuth(true);
- context.requestConf (_encryption);
- if (!_encryption || _signing)
- context.requestInteg (!_encryption || _signing);
- context.requestCredDeleg (_delegation);
-
- return context;
-// }
-// finally {
-// // Calling this throws GSSException: Operation unavailable...
-// clientCreds.dispose();
-// }
- }
- catch (GSSException e) {
- throw new PrivilegedActionException (e);
- }
- }
-
- #endregion // Methods
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs deleted file mode 100644 index b806967f333..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/ExchangeTokenPrivilegedAction.cs +++ /dev/null @@ -1,73 +0,0 @@ -// -// Novell.Directory.Ldap.Security.ExchangeTokenPrivilegedAction.cs -// -// Authors: -// Boris Kirzner <borsk@mainsoft.com> -// Konstantin Triger <kostat@mainsoft.com> -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//
-
-using System;
-
-using org.ietf.jgss;
-using java.security;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class ExchangeTokenPrivilegedAction : PrivilegedAction
- {
- #region Fields
-
- private readonly sbyte [] _token;
- private readonly GSSContext _context;
-
- #endregion // Fields
-
- #region Constructors
-
- public ExchangeTokenPrivilegedAction(GSSContext context, sbyte [] token)
- {
- _token = token;
- _context = context;
- }
-
- #endregion // Constructors
-
- #region Methods
-
- public object run()
- {
- try {
- sbyte [] token = _context.initSecContext (_token, 0, _token.Length);
- return token;
- }
- catch (GSSException e) {
- throw new PrivilegedActionException (e);
- }
- }
-
- #endregion // Methods
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs deleted file mode 100644 index 9b58ff50d9e..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/Krb5Helper.cs +++ /dev/null @@ -1,197 +0,0 @@ -//
-// Novell.Directory.Ldap.Security.Krb5Helper.cs
-//
-// Authors:
-// Boris Kirzner <borsk@mainsoft.com>
-// Konstantin Triger <kostat@mainsoft.com>
-//
-// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using vmw.common;
-
-using java.security;
-using javax.security.auth;
-using org.ietf.jgss;
-
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class Krb5Helper : IDisposable
- {
- enum QOP {
- NO_PROTECTION = 1,
- INTEGRITY_ONLY_PROTECTION = 2,
- PRIVACY_PROTECTION = 4
- }
-
- #region Fields
-
- internal static readonly sbyte [] EmptyToken = new sbyte [0];
-
- private readonly bool _encryption;
- private readonly bool _signing;
- private readonly bool _delegation;
-
- private readonly GSSContext _context;
-
- #endregion // Fields
-
- #region Constructors
-
- public Krb5Helper(string name, string clientName, Subject subject, AuthenticationTypes authenticationTypes, string mech)
- {
- _encryption = (authenticationTypes & AuthenticationTypes.Sealing) != 0;
- _signing = (authenticationTypes & AuthenticationTypes.Signing) != 0;
- _delegation = (authenticationTypes & AuthenticationTypes.Delegation) != 0;
-
- CreateContextPrivilegedAction action = new CreateContextPrivilegedAction (name, clientName, mech,_encryption,_signing,_delegation);
- try {
- _context = (GSSContext) Subject.doAs (subject,action);
- }
- catch (PrivilegedActionException e) {
- throw new LdapException ("Problem performing token exchange with the server",LdapException.OTHER,"",e.getCause());
- }
- }
-
- #endregion // Constructors
-
- #region Properties
-
- internal GSSContext Context
- {
- get { return _context; }
- }
-
- #endregion // Properties
-
- #region Methods
-
- public sbyte [] ExchangeTokens(sbyte [] clientToken)
- {
- if (Context.isEstablished ()) {
- if (clientToken == null || clientToken.Length == 0)
- return Krb5Helper.EmptyToken;
-
- //final handshake
- byte [] challengeData = (byte []) TypeUtils.ToByteArray (clientToken);
- byte [] gssOutToken = Unwrap (challengeData, 0, challengeData.Length, new MessageProp (false));
-
- QOP myCop = QOP.NO_PROTECTION;
-
- if (_encryption)
- myCop = QOP.PRIVACY_PROTECTION;
- else if (_signing || (((QOP)gssOutToken [0] & QOP.INTEGRITY_ONLY_PROTECTION) != 0))
- myCop = QOP.INTEGRITY_ONLY_PROTECTION;
-
- if ((myCop & (QOP)gssOutToken [0]) == 0)
- throw new LdapException ("Server does not support the requested security level", 80, "");
-
- int srvMaxBufSize = SecureStream.NetworkByteOrderToInt (gssOutToken, 1, 3);
-
- //int rawSendSize = Context.getWrapSizeLimit(0, _encryption, srvMaxBufSize);
-
- byte [] gssInToken = new byte [4];
- gssInToken [0] = (byte) myCop;
-
- SecureStream.IntToNetworkByteOrder (srvMaxBufSize, gssInToken, 1, 3);
-
- gssOutToken = Wrap (gssInToken, 0, gssInToken.Length, new MessageProp (true));
-
- return TypeUtils.ToSByteArray (gssOutToken);
- }
-
- sbyte [] token = Context.initSecContext (clientToken, 0, clientToken.Length);
-
- if (Context.isEstablished ()) {
-
- if (Context.getConfState () != _encryption)
- throw new LdapException ("Encryption protocol was not established layer between client and server", 80, "");
-
- if (Context.getCredDelegState () != _delegation)
- throw new LdapException ("Credential delegation was not established layer between client and server", 80, "");
-
- if (_signing && (Context.getIntegState () != _signing))
- throw new LdapException ("Signing protocol was not established layer between client and server", 80, "");
-
- if (token == null)
- return EmptyToken;
- }
- return token;
- }
-
- public byte [] Wrap(byte [] outgoing, int start, int len)
- {
- return Wrap (outgoing, start, len, new MessageProp(true));
- }
-
- public byte [] Wrap(byte [] outgoing, int start, int len, MessageProp messageProp)
- {
- if (!Context.isEstablished ())
- throw new LdapException ("GSSAPI authentication not completed",LdapException.OTHER,"");
-
- if (!(Context.getConfState () || Context.getIntegState ())) {
- // in the case no encryption and no integrity required - return the original data
- byte [] buff = new byte [len];
- Array.Copy (outgoing, start, buff, 0, len);
- return buff;
- }
-
- sbyte [] result = Context.wrap (TypeUtils.ToSByteArray (outgoing), start, len, messageProp);
- return (byte []) TypeUtils.ToByteArray (result);
- }
-
- public byte [] Unwrap(byte [] incoming, int start, int len)
- {
- return Unwrap (incoming, start, len, new MessageProp(true));
- }
-
- public byte [] Unwrap(byte [] incoming, int start, int len, MessageProp messageProp)
- {
- if (!Context.isEstablished ())
- throw new LdapException ("GSSAPI authentication not completed",LdapException.OTHER,"");
-
- if (!(Context.getConfState () || Context.getIntegState ())) {
- // in the case no encryption and no integrity required - return the original data
- byte [] buff = new byte [len];
- Array.Copy (incoming, start, buff, 0, len);
- return buff;
- }
-
- sbyte [] result = Context.unwrap (TypeUtils.ToSByteArray (incoming), start, len, messageProp);
- return (byte []) TypeUtils.ToByteArray (result);
- }
-
- #endregion // Methods
-
- #region IDisposable Members
-
- public void Dispose() {
- Context.dispose();
- }
-
- #endregion
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs deleted file mode 100644 index 08a37e6718c..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/SecureStream.cs +++ /dev/null @@ -1,208 +0,0 @@ -//
-// Novell.Directory.Ldap.Security.SecureStream.cs
-//
-// Authors:
-// Boris Kirzner <borsk@mainsoft.com>
-// Konstantin Triger <kostat@mainsoft.com>
-//
-// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
-//
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.IO;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class SecureStream : Stream
- {
- #region Fields
-
- private readonly Stream _stream;
- private readonly Krb5Helper _helper;
-
- private readonly byte [] _lenBuf = new byte [4];
- private byte [] _buffer;
- private int _bufferPosition;
-
- #endregion // Fields
-
- #region Constructors
-
- public SecureStream(Stream stream, Krb5Helper helper): base ()
- {
- _stream = stream;
- _helper = helper;
- }
-
- #endregion // Constructors
-
- #region Properties
-
- public override bool CanRead
- {
- get { return _stream.CanRead; }
- }
-
- public override bool CanSeek
- {
- get { return _stream.CanSeek; }
- }
-
- public override bool CanWrite
- {
- get { return _stream.CanWrite; }
- }
-
- public override long Length
- {
- get { throw new NotSupportedException (); }
- }
-
- public override long Position
- {
- get { throw new NotSupportedException (); }
- set { throw new NotSupportedException (); }
- }
-
- #endregion // Properties
-
- #region Methods
-
- public override void Flush()
- {
- _stream.Flush ();
- }
-
- public override int Read( byte [] buffer, int offset, int count)
- {
- if (_buffer == null || _bufferPosition >= _buffer.Length) {
- int actual = Fill ();
- while (actual == 0)
- actual = Fill ();
-
- if (actual == -1)
- return -1;
- }
-
- int available = _buffer.Length - _bufferPosition;
- if (count > available) {
- Array.Copy (_buffer, _bufferPosition, buffer, offset, available);
- _bufferPosition = _buffer.Length;
- return available;
- }
- else {
- Array.Copy (_buffer, _bufferPosition, buffer, offset, count);
- _bufferPosition += count;
- return count;
- }
- }
-
- public override void Close() {
- _stream.Close();
- _helper.Dispose();
- }
-
- private int Fill()
- {
- int actual = ReadAll (_lenBuf, 4);
-
- if (actual != 4)
- return -1;
-
- int length = NetworkByteOrderToInt (_lenBuf, 0, 4);
-
-// if (length > _recvMaxBufSize)
-// throw new LdapException(length + " exceeds the negotiated receive buffer size limit: " + _recvMaxBufSize, 80, "");
-
- byte [] rawBuffer = new byte [length];
- actual = ReadAll (rawBuffer, length);
-
- if (actual != length)
- throw new LdapException("Expected to read " + length + " bytes, but get " + actual, 80, "");
-
- _buffer = _helper.Unwrap (rawBuffer, 0, length);
- _bufferPosition = 0;
- return _buffer.Length;
- }
-
- private int ReadAll(byte [] buffer, int total)
- {
- int count = 0;
- int pos = 0;
- while (total > 0) {
- count = _stream.Read (buffer, pos, total);
-
- if (count == -1)
- break;
- //return ((pos == 0) ? -1 : pos);
-
- pos += count;
- total -= count;
- }
- return pos;
- }
-
- public override long Seek(long offset, SeekOrigin loc)
- {
- return _stream.Seek (offset, loc);
- }
-
- public override void SetLength(long value)
- {
- _stream.SetLength (value);
- }
-
- public override void Write(byte [] buffer, int offset, int count)
- {
- // FIXME: use GSSCOntext.getWrapSizeLimit to divide the buffer
- // Generate wrapped token
- byte [] wrappedToken = _helper.Wrap (buffer, offset, count);
- // Write out length
- IntToNetworkByteOrder (wrappedToken.Length, _lenBuf, 0, 4);
- _stream.Write (_lenBuf, 0, 4);
- // Write out wrapped token
- _stream.Write (wrappedToken, 0, wrappedToken.Length);
- }
-
- internal static int NetworkByteOrderToInt(byte [] buf, int start, int count)
- {
- int answer = 0;
- for (int i = 0; i < count; i++) {
- answer <<= 8;
- answer |= ((int)buf [start + i] & 0xff);
- }
- return answer;
- }
-
- internal static void IntToNetworkByteOrder(int num, byte [] buf, int start, int count)
- {
- for (int i = count-1; i >= 0; i--) {
- buf [start + i] = (byte)(num & 0xff);
- num >>= 8;
- }
- }
-
- #endregion // Methods
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs deleted file mode 100644 index 7320678c9b9..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/UnwrapPrivilegedAction.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.UnwrapPrivilegedAction.cs -// -// Authors: -// Boris Kirzner <borsk@mainsoft.com> -// Konstantin Triger <kostat@mainsoft.com> -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//
-
-using System;
-using vmw.common;
-
-using java.security;
-using org.ietf.jgss;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class UnwrapPrivilegedAction : PrivilegedAction
- {
- #region Fields
-
- private readonly byte [] _buffer;
- private readonly int _start;
- private readonly int _len;
- private readonly GSSContext _context;
- private readonly MessageProp _messageProperties;
-
- #endregion // Fields
-
- #region Constructors
-
- public UnwrapPrivilegedAction(GSSContext context, byte [] buffer, int start, int len, MessageProp messageProperties)
- {
- _buffer = buffer;
- _start = start;
- _len = len;
- _context = context;
- _messageProperties = messageProperties;
- }
-
- #endregion // Constructors
-
- #region Methods
-
- public object run()
- {
- try {
- sbyte [] result = _context.unwrap (TypeUtils.ToSByteArray (_buffer), _start, _len, _messageProperties);
- return (byte []) TypeUtils.ToByteArray (result);
- }
- catch (GSSException e) {
- throw new PrivilegedActionException (e);
- }
- }
-
- #endregion // Methods
- }
-}
diff --git a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs b/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs deleted file mode 100644 index 8ec5a616765..00000000000 --- a/mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap.Security.jvm/WrapPrivilegedAction.cs +++ /dev/null @@ -1,80 +0,0 @@ -// -// Novell.Directory.Ldap.Security.WrapPrivilegedAction.cs -// -// Authors: -// Boris Kirzner <borsk@mainsoft.com> -// Konstantin Triger <kostat@mainsoft.com> -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -//
-
-using System;
-using vmw.common;
-
-using java.security;
-using org.ietf.jgss;
-
-namespace Novell.Directory.Ldap.Security
-{
- internal class WrapPrivilegedAction : PrivilegedAction
- {
- #region Fields
-
- private readonly byte [] _buffer;
- private readonly int _start;
- private readonly int _len;
- private readonly GSSContext _context;
- private readonly MessageProp _messageProperties;
-
- #endregion // Fields
-
- #region Constructors
-
- public WrapPrivilegedAction(GSSContext context, byte [] buffer, int start, int len, MessageProp messageProperties)
- {
- _buffer = buffer;
- _start = start;
- _len = len;
- _context = context;
- _messageProperties = messageProperties;
- }
-
- #endregion // Constructors
-
- #region Methods
-
- public object run()
- {
- try {
- sbyte [] result = _context.wrap (TypeUtils.ToSByteArray (_buffer), _start, _len, _messageProperties);
- return (byte []) TypeUtils.ToByteArray (result);
- }
- catch (GSSException e) {
- throw new PrivilegedActionException (e);
- }
- }
-
- #endregion // Methods
- }
-}
|