Esempio n. 1
0
        /// <summary>
        /// Returns a <seealso cref="Callable"/> object that, when
        /// called, runs the given privileged exception action and returns
        /// its result. </summary>
        /// <param name="action"> the privileged exception action to run </param>
        /// <returns> a callable object </returns>
        /// <exception cref="NullPointerException"> if action null </exception>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static Callable<Object> callable(final java.security.PrivilegedExceptionAction<?> action)
        public static Callable <Object> Callable(PrivilegedExceptionAction <T1> action)
        {
            if (action == null)
            {
                throw new NullPointerException();
            }
            return(new CallableAnonymousInnerClassHelper2(action));
        }
Esempio n. 2
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 private object OperateDelegationToken <_T0>(PrivilegedExceptionAction <_T0> action)
 {
     // Set up the retry operation
     TimelineClientImpl.TimelineClientRetryOp tokenRetryOp = new _TimelineClientRetryOp_444
                                                                 (this, action);
     // Try pass the request, if fail, keep retrying
     // Only retry on connection exceptions
     return(connectionRetry.RetryOn(tokenRetryOp));
 }
Esempio n. 3
0
 public static object doPrivileged(Type accessController, PrivilegedExceptionAction action)
 {
     try
     {
         return(action.run());
     }
     catch (global::java.lang.Exception ex)
     {
         throw new PrivilegedActionException(ex);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Performs the specified {@code PrivilegedExceptionAction} with
        /// privileges enabled and restricted by the specified
        /// {@code AccessControlContext} and with a privilege scope limited by
        /// specified {@code Permission} arguments.
        ///
        /// The action is performed with the intersection of the permissions
        /// possessed by the caller's protection domain, and those possessed
        /// by the domains represented by the specified
        /// {@code AccessControlContext}.
        /// <para>
        /// If the action's {@code run} method throws an (unchecked) exception,
        /// it will propagate through this method.
        /// </para>
        /// <para>
        /// If a security manager is installed and the specified
        /// {@code AccessControlContext} was not created by system code and the
        /// caller's {@code ProtectionDomain} has not been granted the
        /// {@literal "createAccessControlContext"}
        /// <seealso cref="java.security.SecurityPermission"/>, then the action is performed
        /// with no permissions.
        ///
        /// </para>
        /// </summary>
        /// @param <T> the type of the value returned by the
        ///                  PrivilegedExceptionAction's {@code run} method. </param>
        /// <param name="action"> the action to be performed. </param>
        /// <param name="context"> an <i>access control context</i>
        ///                representing the restriction to be applied to the
        ///                caller's domain's privileges before performing
        ///                the specified action.  If the context is
        ///                {@code null},
        ///                then no additional restriction is applied. </param>
        /// <param name="perms"> the {@code Permission} arguments which limit the
        ///              scope of the caller's privileges. The number of arguments
        ///              is variable.
        /// </param>
        /// <returns> the value returned by the action's {@code run} method.
        /// </returns>
        /// <exception cref="PrivilegedActionException"> if the specified action's
        ///         {@code run} method threw a <i>checked</i> exception </exception>
        /// <exception cref="NullPointerException"> if action or perms or any element of
        ///         perms is {@code null}
        /// </exception>
        /// <seealso cref= #doPrivileged(PrivilegedAction) </seealso>
        /// <seealso cref= #doPrivileged(PrivilegedAction,AccessControlContext)
        ///
        /// @since 1.8 </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @CallerSensitive public static <T> T doPrivileged(PrivilegedExceptionAction<T> action, AccessControlContext context, Permission... perms) throws PrivilegedActionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public static T doPrivileged <T>(PrivilegedExceptionAction <T> action, AccessControlContext context, params Permission[] perms)
        {
            AccessControlContext parent = Context;

            if (perms == null)
            {
                throw new NullPointerException("null permissions parameter");
            }
            Class caller = Reflection.CallerClass;

            return(AccessController.doPrivileged(action, CreateWrapper(null, caller, parent, context, perms)));
        }
Esempio n. 5
0
        /// <summary>
        /// Performs the specified {@code PrivilegedExceptionAction} with
        /// privileges enabled.  The action is performed with <i>all</i> of the
        /// permissions possessed by the caller's protection domain.
        ///
        /// <para> If the action's {@code run} method throws an <i>unchecked</i>
        /// exception, it will propagate through this method.
        ///
        /// </para>
        /// <para> This method preserves the current AccessControlContext's
        /// DomainCombiner (which may be null) while the action is performed.
        ///
        /// </para>
        /// </summary>
        /// @param <T> the type of the value returned by the
        ///                  PrivilegedExceptionAction's {@code run} method.
        /// </param>
        /// <param name="action"> the action to be performed.
        /// </param>
        /// <returns> the value returned by the action's {@code run} method
        /// </returns>
        /// <exception cref="PrivilegedActionException"> if the specified action's
        ///         {@code run} method threw a <i>checked</i> exception </exception>
        /// <exception cref="NullPointerException"> if the action is {@code null}
        /// </exception>
        /// <seealso cref= #doPrivileged(PrivilegedAction) </seealso>
        /// <seealso cref= #doPrivileged(PrivilegedExceptionAction,AccessControlContext) </seealso>
        /// <seealso cref= java.security.DomainCombiner
        ///
        /// @since 1.6 </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @CallerSensitive public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action) throws PrivilegedActionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public static T doPrivilegedWithCombiner <T>(PrivilegedExceptionAction <T> action)
        {
            AccessControlContext acc = StackAccessControlContext;

            if (acc == null)
            {
                return(AccessController.doPrivileged(action));
            }
            DomainCombiner dc = acc.AssignedCombiner;

            return(AccessController.doPrivileged(action, PreserveCombiner(dc, Reflection.CallerClass)));
        }
Esempio n. 6
0
 /// <exception cref="System.IO.IOException"/>
 private static T DoAsUser <T>(UserGroupInformation ugi, PrivilegedExceptionAction <
                                   T> action)
 {
     try
     {
         return(ugi.DoAs(action));
     }
     catch (Exception ie)
     {
         throw new IOException(ie);
     }
 }
Esempio n. 7
0
 private void ShouldThrow(PrivilegedExceptionAction <object> action, Type except)
 {
     try
     {
         action.Run();
         NUnit.Framework.Assert.Fail("action did not throw " + except);
     }
     catch (Exception th)
     {
         Log.Info("Caught an exception: ", th);
         Assert.Equal("action threw wrong exception", except, th.GetType
                          ());
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Performs the specified {@code PrivilegedExceptionAction} with
        /// privileges enabled and restricted by the specified
        /// {@code AccessControlContext} and with a privilege scope limited by
        /// specified {@code Permission} arguments.
        ///
        /// The action is performed with the intersection of the permissions
        /// possessed by the caller's protection domain, and those possessed
        /// by the domains represented by the specified
        /// {@code AccessControlContext}.
        /// <para>
        /// If the action's {@code run} method throws an (unchecked) exception,
        /// it will propagate through this method.
        ///
        /// </para>
        /// <para> This method preserves the current AccessControlContext's
        /// DomainCombiner (which may be null) while the action is performed.
        /// </para>
        /// <para>
        /// If a security manager is installed and the specified
        /// {@code AccessControlContext} was not created by system code and the
        /// caller's {@code ProtectionDomain} has not been granted the
        /// {@literal "createAccessControlContext"}
        /// <seealso cref="java.security.SecurityPermission"/>, then the action is performed
        /// with no permissions.
        ///
        /// </para>
        /// </summary>
        /// @param <T> the type of the value returned by the
        ///                  PrivilegedExceptionAction's {@code run} method. </param>
        /// <param name="action"> the action to be performed. </param>
        /// <param name="context"> an <i>access control context</i>
        ///                representing the restriction to be applied to the
        ///                caller's domain's privileges before performing
        ///                the specified action.  If the context is
        ///                {@code null},
        ///                then no additional restriction is applied. </param>
        /// <param name="perms"> the {@code Permission} arguments which limit the
        ///              scope of the caller's privileges. The number of arguments
        ///              is variable.
        /// </param>
        /// <returns> the value returned by the action's {@code run} method.
        /// </returns>
        /// <exception cref="PrivilegedActionException"> if the specified action's
        ///         {@code run} method threw a <i>checked</i> exception </exception>
        /// <exception cref="NullPointerException"> if action or perms or any element of
        ///         perms is {@code null}
        /// </exception>
        /// <seealso cref= #doPrivileged(PrivilegedAction) </seealso>
        /// <seealso cref= #doPrivileged(PrivilegedAction,AccessControlContext) </seealso>
        /// <seealso cref= java.security.DomainCombiner
        ///
        /// @since 1.8 </seealso>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @CallerSensitive public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action, AccessControlContext context, Permission... perms) throws PrivilegedActionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public static T doPrivilegedWithCombiner <T>(PrivilegedExceptionAction <T> action, AccessControlContext context, params Permission[] perms)
        {
            AccessControlContext parent = Context;
            DomainCombiner       dc     = parent.Combiner;

            if (dc == null && context != null)
            {
                dc = context.Combiner;
            }
            if (perms == null)
            {
                throw new NullPointerException("null permissions parameter");
            }
            Class caller = Reflection.CallerClass;

            return(AccessController.doPrivileged(action, CreateWrapper(dc, caller, parent, context, perms)));
        }
Esempio n. 9
0
 public CallableAnonymousInnerClassHelper2(PrivilegedExceptionAction <T1> action)
 {
     this.Action = action;
 }
Esempio n. 10
0
 public static extern <T> T doPrivileged(PrivilegedExceptionAction <T> action, AccessControlContext context);
Esempio n. 11
0
 public static extern <T> T doPrivileged(PrivilegedExceptionAction <T> action);
Esempio n. 12
0
 public _TimelineClientRetryOp_444(TimelineClientImpl _enclosing, PrivilegedExceptionAction
                                   <object> action)
 {
     this._enclosing = _enclosing;
     this.action     = action;
 }
Esempio n. 13
0
 /// <summary>Perform the given action as the daemon's current user.</summary>
 /// <remarks>
 /// Perform the given action as the daemon's current user. If an
 /// InterruptedException is thrown, it is converted to an IOException.
 /// </remarks>
 /// <param name="action">the action to perform</param>
 /// <returns>the result of the action</returns>
 /// <exception cref="System.IO.IOException">in the event of error</exception>
 public static T DoAsCurrentUser <T>(PrivilegedExceptionAction <T> action)
 {
     return(DoAsUser(UserGroupInformation.GetCurrentUser(), action));
 }
Esempio n. 14
0
 public static object doPrivileged(Type accessController, PrivilegedExceptionAction action, AccessControlContext context)
 {
     return(doPrivileged(accessController, action));
 }