Esempio n. 1
0
 /// <exception cref="NSch.JSchException"></exception>
 public virtual byte[] Init(byte[] token, int s, int l)
 {
     try
     {
         // Without setting "javax.security.auth.useSubjectCredsOnly" to "false",
         // Sun's JVM for Un*x will show messages to stderr in
         // processing context.initSecContext().
         // This hack is not thread safe ;-<.
         // If that property is explicitly given as "true" or "false",
         // this hack must not be invoked.
         if (useSubjectCredsOnly == null)
         {
             SetSystemProperty(pUseSubjectCredsOnly, "false");
         }
         return(context.InitSecContext(token, 0, l));
     }
     catch (GSSException ex)
     {
         throw new JSchException(ex.ToString());
     }
     catch (SecurityException ex)
     {
         throw new JSchException(ex.ToString());
     }
     finally
     {
         if (useSubjectCredsOnly == null)
         {
             // By the default, it must be "true".
             SetSystemProperty(pUseSubjectCredsOnly, "true");
         }
     }
 }
Esempio n. 2
0
        /// <exception cref="Sharpen.GSSException"></exception>
        protected internal virtual byte[] GenerateGSSToken(byte[] input, Oid oid, string
                                                           authServer)
        {
            byte[] token = input;
            if (token == null)
            {
                token = new byte[0];
            }
            GSSManager manager    = GetManager();
            GSSName    serverName = manager.CreateName("HTTP@" + authServer, GSSName.NtHostbasedService
                                                       );

            Sharpen.GSSContext gssContext = manager.CreateContext(serverName.Canonicalize(oid
                                                                                          ), oid, null, Sharpen.GSSContext.DefaultLifetime);
            gssContext.RequestMutualAuth(true);
            gssContext.RequestCredDeleg(true);
            return(gssContext.InitSecContext(token, 0, token.Length));
        }