java.lang.SecurityException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中java.lang.SecurityException.getMessage()方法的一些代码示例,展示了SecurityException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SecurityException.getMessage()方法的具体详情如下:
包路径:java.lang.SecurityException
类名称:SecurityException
方法名:getMessage

SecurityException.getMessage介绍

暂无

代码示例

代码示例来源:origin: apache/rocketmq

protected static ClassLoader getClassLoader(Class<?> clazz) {
  try {
    return clazz.getClassLoader();
  } catch (SecurityException e) {
    LOG.error("Unable to get classloader for class {} due to security restrictions !",
      clazz, e.getMessage());
    throw e;
  }
}

代码示例来源:origin: stagemonitor/stagemonitor

@Override
public String getValue(String key) {
  try {
    return System.getProperty(key);
  } catch (SecurityException e) {
    logger.warn("Could not get Java system property, because of a SecurityException: {}", e.getMessage());
    return null;
  }
}

代码示例来源:origin: prestodb/presto

throw new IllegalArgumentException("Cannot access "+member+" (from class "+declClass.getName()+"; failed to set access: "+se.getMessage());

代码示例来源:origin: redisson/redisson

throw new IllegalArgumentException("Cannot access "+member+" (from class "+declClass.getName()+"; failed to set access: "+se.getMessage());

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

/**
 * Method called to check if we can use the passed method or constructor
 * (wrt access restriction -- public methods can be called, others
 * usually not); and if not, if there is a work-around for
 * the problem.
 */
public static void checkAndFixAccess(Member member)
{
  // We know all members are also accessible objects...
  AccessibleObject ao = (AccessibleObject) member;
  /* 14-Jan-2009, tatu: It seems safe and potentially beneficial to
   *   always to make it accessible (latter because it will force
   *   skipping checks we have no use for...), so let's always call it.
   */
  //if (!ao.isAccessible()) {
  try {
    ao.setAccessible(true);
  } catch (SecurityException se) {
    /* 17-Apr-2009, tatu: Related to [JACKSON-101]: this can fail on
     *    platforms like EJB and Google App Engine); so let's
     *    only fail if we really needed it...
     */
    if (!ao.isAccessible()) {
      Class<?> declClass = member.getDeclaringClass();
      throw new IllegalArgumentException("Can not access "+member+" (from class "+declClass.getName()+"; failed to set access: "+se.getMessage());
    }
  }
  //}
}

代码示例来源:origin: org.apache.ant/ant

private Constructor<? extends ProjectHelper> getProjectHelperBySystemProperty() {
  String helperClass = System.getProperty(ProjectHelper.HELPER_PROPERTY);
  try {
    if (helperClass != null) {
      return getHelperConstructor(helperClass);
    }
  } catch (SecurityException e) {
    System.err.println("Unable to load ProjectHelper class \""
              + helperClass + " specified in system property "
              + ProjectHelper.HELPER_PROPERTY + " ("
              + e.getMessage() + ")");
    if (DEBUG) {
      e.printStackTrace(System.err); //NOSONAR
    }
  }
  return null;
}

代码示例来源:origin: RobotiumTech/robotium

/**
 * Tells Robotium to send a key code: Right, Left, Up, Down, Enter or other.
 * 
 * @param keycode the key code to be sent. Use {@link KeyEvent#KEYCODE_ENTER}, {@link KeyEvent#KEYCODE_MENU}, {@link KeyEvent#KEYCODE_DEL}, {@link KeyEvent#KEYCODE_DPAD_RIGHT} and so on
 */
public void sendKeyCode(int keycode)
{
  sleeper.sleep();
  try{
    inst.sendCharacterSync(keycode);
  }catch(SecurityException e){
    Assert.fail("Can not complete action! ("+(e != null ? e.getClass().getName()+": "+e.getMessage() : "null")+")");
  }
}

代码示例来源:origin: oracle/helidon

private Optional<String> validateHmacSha256(SecurityEnvironment env,
                      InboundClientDefinition clientDefinition) {
  try {
    byte[] signature = signHmacSha256(env, clientDefinition.hmacSharedSecret().orElse(EMPTY_BYTES), null);
    if (!Arrays.equals(signature, this.signatureBytes)) {
      return Optional.of("Signature is not valid");
    }
    return Optional.empty();
  } catch (SecurityException e) {
    LOGGER.log(Level.FINEST, "Failed to validate hmac-sha256", e);
    return Optional.of("Failed to validate hmac-sha256: " + e.getMessage());
  }
}

代码示例来源:origin: apache/hive

private HiveAuthorizationTaskFactory createAuthorizationTaskFactory(HiveConf conf, Hive db) {
 Class<? extends HiveAuthorizationTaskFactory> authProviderClass = conf.
   getClass(HiveConf.ConfVars.HIVE_AUTHORIZATION_TASK_FACTORY.varname,
     HiveAuthorizationTaskFactoryImpl.class,
     HiveAuthorizationTaskFactory.class);
 String msg = "Unable to create instance of " + authProviderClass.getName() + ": ";
 try {
  Constructor<? extends HiveAuthorizationTaskFactory> constructor =
    authProviderClass.getConstructor(HiveConf.class, Hive.class);
  return constructor.newInstance(conf, db);
 } catch (NoSuchMethodException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 } catch (SecurityException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 } catch (InstantiationException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 } catch (IllegalAccessException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 } catch (IllegalArgumentException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 } catch (InvocationTargetException e) {
  throw new IllegalStateException(msg + e.getMessage(), e);
 }
}

代码示例来源:origin: quartz-scheduler/quartz

private static void set(Object target, String method, String value)
    throws SchedulerException {
  final Method setter;
  try {
    setter = target.getClass().getMethod(method, String.class);
  } catch (SecurityException e) {
    LOGGER.error("A SecurityException occured: " + e.getMessage(), e);
    return;
  } catch (NoSuchMethodException e) {
    // This probably won't happen since the interface has the method
    LOGGER.warn(target.getClass().getName()
        + " does not contain public method " + method + "(String)");
    return;
  }
  if (Modifier.isAbstract(setter.getModifiers())) {
    // expected if method not implemented (but is present on
    // interface)
    LOGGER.warn(target.getClass().getName()
        + " does not implement " + method
        + "(String)");
    return;
  }
  try {
    setter.invoke(target, value);
  } catch (InvocationTargetException ite) {
    throw new SchedulerException(ite.getTargetException());
  } catch (Exception e) {
    throw new SchedulerException(e);
  }
}

代码示例来源:origin: quartz-scheduler/quartz

private static void set(Object target, String method, String value)
    throws SchedulerException {
  final Method setter;
  try {
    setter = target.getClass().getMethod(method, String.class);
  } catch (SecurityException e) {
    LOGGER.error("A SecurityException occured: " + e.getMessage(), e);
    return;
  } catch (NoSuchMethodException e) {
    // This probably won't happen since the interface has the method
    LOGGER.warn(target.getClass().getName()
        + " does not contain public method " + method + "(String)");
    return;
  }
  if (Modifier.isAbstract(setter.getModifiers())) {
    // expected if method not implemented (but is present on
    // interface)
    LOGGER.warn(target.getClass().getName()
        + " does not implement " + method
        + "(String)");
    return;
  }
  try {
    setter.invoke(target, value);
  } catch (InvocationTargetException ite) {
    throw new SchedulerException(ite.getTargetException());
  } catch (Exception e) {
    throw new SchedulerException(e);
  }
}

代码示例来源:origin: liuyangming/ByteTCC

public void run() {
  long nextMillis = System.currentTimeMillis() + CONSTANTS_SECOND_MILLIS * 60;
  while (this.released == false) {
    if (System.currentTimeMillis() < nextMillis) {
      this.waitForMillis(100);
    } else {
      int number = 0;
      try {
        number = (Integer) this.commandDispatcher.dispatch(new Callable<Object>() {
          public Object call() throws Exception {
            return timingExecution(CONSTANTS_MAX_HANDLE_RECORDS);
          }
        });
      } catch (SecurityException rex) {
        logger.debug(rex.getMessage());
      } catch (Exception rex) {
        logger.error("Error occurred while cleaning up resources.", rex);
        nextMillis = System.currentTimeMillis() + CONSTANTS_SECOND_MILLIS * 30;
        continue;
      }
      if (number < CONSTANTS_MAX_HANDLE_RECORDS) {
        nextMillis = System.currentTimeMillis() + CONSTANTS_SECOND_MILLIS * 30;
      } // end-if (number < CONSTANTS_MAX_HANDLE_RECORDS)
    }
  }
}

代码示例来源:origin: querydsl/querydsl

@Override
@SuppressWarnings("unchecked")
public T newInstance(Object... args) {
  try {
    for (Function<Object[], Object[]> transformer : transformers) {
      args = transformer.apply(args);
    }
    return (T) constructor.newInstance(args);
  } catch (SecurityException e) {
    throw new ExpressionException(e.getMessage(), e);
  } catch (InstantiationException e) {
    throw new ExpressionException(e.getMessage(), e);
  } catch (IllegalAccessException e) {
    throw new ExpressionException(e.getMessage(), e);
  } catch (InvocationTargetException e) {
    throw new ExpressionException(e.getMessage(), e);
  }
}

代码示例来源:origin: commons-logging/commons-logging

if (isDiagnosticsEnabled()) {
  logDiagnostic("Unable to get classloader for class '" + clazz +
         "' due to security restrictions - " + ex.getMessage());

代码示例来源:origin: apache/activemq

protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception {
  List<Subscription> rc = new ArrayList<Subscription>();
  // Add all consumers that are interested in the destination.
  for (Iterator<Subscription> iter = subscriptions.values().iterator(); iter.hasNext();) {
    Subscription sub = iter.next();
    if (sub.matches(dest.getActiveMQDestination())) {
      try {
        ConnectionContext originalContext = sub.getContext() != null ? sub.getContext() : context;
        dest.addSubscription(originalContext, sub);
        rc.add(sub);
      } catch (SecurityException e) {
        if (sub.isWildcard()) {
          LOG.debug("Subscription denied for " + sub + " to destination " +
            dest.getActiveMQDestination() +  ": " + e.getMessage());
        } else {
          throw e;
        }
      }
    }
  }
  return rc;
}

代码示例来源:origin: org.apache.ant/ant

/**
 * Exit is treated in a special way in order to be able to return the exit code
 * towards tasks.
 * An ExitException is thrown instead of a simple SecurityException to indicate the exit
 * code.
 * Overridden from java.lang.SecurityManager
 * @param status The exit status requested.
 */
@Override
public void checkExit(final int status) {
  final java.security.Permission perm = new RuntimePermission("exitVM", null);
  try {
    checkPermission(perm);
  } catch (final SecurityException e) {
    throw new ExitException(e.getMessage(), status);
  }
}

代码示例来源:origin: commons-logging/commons-logging

"the compatibility was caused by a classloader conflict: " + e.getMessage());
} catch (LinkageError e) {

代码示例来源:origin: commons-logging/commons-logging

if (isDiagnosticsEnabled()) {
  logDiagnostic("No access allowed to system property '" +
    LOG_PROPERTY + "' - " + e.getMessage());
if (isDiagnosticsEnabled()) {
  logDiagnostic("No access allowed to system property '" +
    LOG_PROPERTY_OLD + "' - " + e.getMessage());

代码示例来源:origin: apache/nifi

@Override
public ValidationResult validate(String subject, String input, ValidationContext context) {
  if (context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(input)) {
    return new ValidationResult.Builder().subject(subject).input(input).explanation("Expression Language Present").valid(true).build();
  }
  final String[] files = input.split(",");
  for (String filename : files) {
    try {
      final File file = new File(filename.trim());
      final boolean valid = file.exists() && file.isFile();
      if (!valid) {
        final String message = "File " + file + " does not exist or is not a file";
        return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation(message).build();
      }
    } catch (SecurityException e) {
      final String message = "Unable to access " + filename + " due to " + e.getMessage();
      return new ValidationResult.Builder().subject(subject).input(input).valid(false).explanation(message).build();
    }
  }
  return new ValidationResult.Builder().subject(subject).input(input).valid(true).build();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void thrownExceptionIsParceled() throws Exception {
 TestThrowingBinder testThrowingBinder = new TestThrowingBinder();
 Parcel data = Parcel.obtain();
 Parcel reply = Parcel.obtain();
 testThrowingBinder.transact(2, data, reply, 3);
 try {
  reply.readException();
  fail();  // Expect thrown
 } catch (SecurityException e) {
  assertThat(e.getMessage()).isEqualTo("Halt! Who goes there?");
 }
}

相关文章