예제 #1
0
  @Inject
  public ConsoleConfigHandlerImpl(
      DNWrapper dnUtils, PrivilegedAction<SSOToken> ssoTokenPrivilegedAction) {
    this.dnUtils = dnUtils;
    changeListeners = new CopyOnWriteArrayList<>();

    try {
      configManager =
          new ServiceConfigManager(ssoTokenPrivilegedAction.run(), SERVICE_NAME, SERVICE_VERSION);
      configManager.addListener(new ConfigChangeHandler());
    } catch (SMSException | SSOException e) {
      throw new ConfigRetrievalException("Unable to retrieve the config manager", e);
    }
  }
예제 #2
0
파일: User.java 프로젝트: Shmuma/hbase
 @Override
 public <T> T runAs(PrivilegedAction<T> action) {
   T result = null;
   UserGroupInformation previous = null;
   try {
     previous = (UserGroupInformation) callStatic("getCurrentUGI");
     try {
       if (ugi != null) {
         callStatic(
             "setCurrentUser", new Class[] {UserGroupInformation.class}, new Object[] {ugi});
       }
       result = action.run();
     } finally {
       callStatic(
           "setCurrentUser", new Class[] {UserGroupInformation.class}, new Object[] {previous});
     }
   } catch (RuntimeException re) {
     throw re;
   } catch (Exception e) {
     throw new UndeclaredThrowableException(e, "Unexpected exception in runAs()");
   }
   return result;
 }
예제 #3
0
 public static <T> T run(PrivilegedAction<T> action) {
   return (System.getSecurityManager() != null)
       ? AccessController.doPrivileged(action)
       : action.run();
 }