Class SessionHelper

java.lang.Object
com.ptc.arbortext.windchill.siscore.SessionHelper

public class SessionHelper extends Object
Reliable implementations for temporarily switching principals as well as turning access enforcement on and off
Supported API: true
Extendable: false
  • Method Details

    • temporaryPrincipal

      public static AutoCloseable temporaryPrincipal(WTPrincipal newPrincipal) throws WTException
      Change user context to new user for a clearly delimited scope, restoring the previous SessionContext upon leaving this scope. Usage:
          try (AutoCloseable tempSession = PrincipalHelper.temporaryPrincipal(newUser)) {
            ... use temporary SessionContext ...
            ... previous SessionContext is always restored when leaving this scope ...
          }
       
      AutoCloseable

      Supported API: true
      Extendable: false
      Throws:
      WTException
    • temporaryPrincipal

      public static AutoCloseable temporaryPrincipal(String newPrincipalName) throws WTException
      Change user context to new user for a clearly delimited scope, restoring the previous SessionContext upon leaving this scope. Usage:
          try (AutoCloseable tempSession = PrincipalHelper.temporaryPrincipal("demo")) {
            ... use temporary SessionContext ...
            ... previous SessionContext is always restored when leaving this scope ...
          }
       
      AutoCloseable

      Supported API: true
      Extendable: false
      Throws:
      WTException
    • temporaryAdministrator

      public static AutoCloseable temporaryAdministrator() throws WTException
      Change user context to administrator for a clearly delimited scope, restoring the previous SessionContext upon leaving this scope. Usage:
          try (AutoCloseable tempSession = PrincipalHelper.temporaryAdministrator()) {
            ... use temporary SessionContext ...
            ... previous SessionContext is always restored when leaving this scope ...
          }
       
      AutoCloseable

      Supported API: true
      Extendable: false
      Throws:
      WTException
    • temporaryAccessEnforcement

      public static AutoCloseable temporaryAccessEnforcement(boolean newAccessEnforcement) throws WTException
      Change access enforcement for a clearly delimited scope, restoring the previous SessionContext upon leaving this scope. Usage:
          try (AutoCloseable tempSession = PrincipalHelper.temporaryAccessEnforcement(true)) {
            ... use temporary SessionContext ...
            ... previous SessionContext is always restored when leaving this scope ...
          }
       
      AutoCloseable

      Supported API: true
      Extendable: false
      Throws:
      WTException