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

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

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

SecurityException.<init>介绍

[英]Constructs a new SecurityException that includes the current stack trace.
[中]构造包含当前堆栈跟踪的新SecurityException。

代码示例

代码示例来源:origin: jenkinsci/jenkins

private boolean noFalse(String op, File f, boolean b) {
  if (!b)
    throw new SecurityException("agent may not " + op + " " + f+"\nSee https://jenkins.io/redirect/security-144 for more details");
  return true;
}

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

private void assertEncryptedIfRequired()
{
  if ( encryptionRequired && !encrypted )
  {
    throw new SecurityException( "An unencrypted connection attempt was made where encryption is required." );
  }
}

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

/**
 * Enforces that the caller has notification policy access.
 *
 * @see NotificationManager#isNotificationPolicyAccessGranted()
 * @throws SecurityException if the caller doesn't have notification policy access
 */
private void enforcePolicyAccess() {
 if (!isNotificationPolicyAccessGranted) {
  throw new SecurityException("Notification policy access denied");
 }
}

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

private void checkPermissionGrantStateInitialized(PackageInfo packageInfo) {
 if (packageInfo.requestedPermissionsFlags == null) {
  // In the real OS this would never be null, but tests don't necessarily initialize this
  // structure.
  throw new SecurityException(
    "Permission grant state (PackageInfo.requestedPermissionFlags) "
      + "is null. This operation requires this variable to be initialized.");
 }
}

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

private void checkReadPhoneStatePermission() {
 if (!readPhoneStatePermission) {
  throw new SecurityException();
 }
}

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

private void verifyCanAccessUser(UserHandle userHandle) {
 if (!targetUserProfiles.contains(userHandle)) {
  throw new SecurityException(
    "Not allowed to access "
      + userHandle
      + " (did you forget to call addTargetUserProfile?)");
 }
}

代码示例来源:origin: jenkinsci/jenkins

private void notifyRejected(@CheckForNull Class<?> clazz, @CheckForNull String clazzName, String message) {
    Throwable cause = null;
    if (LOGGER.isLoggable(Level.FINE)) {
      cause = new SecurityException("Class rejected by the class filter: " +
          (clazz != null ? clazz.getName() : clazzName));
    }
    LOGGER.log(Level.WARNING, message, cause);

    // TODO: add a Telemetry implementation (JEP-304)
  }
}

代码示例来源:origin: google/guava

@Override
public void checkAccess(Thread t) {
 throw new SecurityException();
}

代码示例来源:origin: jenkinsci/jenkins

@Restricted(NoExternalUse.class)
public static String validateIconSize(String iconSize) throws SecurityException {
  if (!ICON_SIZE.matcher(iconSize).matches()) {
    throw new SecurityException("invalid iconSize");
  }
  return iconSize;
}

代码示例来源:origin: jenkinsci/jenkins

@Override
public void check(RoleSensitive subject, @Nonnull Collection<Role> expected) throws SecurityException {
  final String name = subject.getClass().getName();
  if (expected.contains(Roles.MASTER)) {
    LOGGER.log(Level.FINE, "Executing {0} is allowed since it is targeted for the master role", name);
    return;    // known to be safe
  }
  if (isWhitelisted(subject,expected)) {
    // this subject is dubious, but we are letting it through as per whitelisting
    LOGGER.log(Level.FINE, "Explicitly allowing {0} to be sent from agent to master", name);
    return;
  }
  throw new SecurityException("Sending " + name + " from agent to master is prohibited.\nSee https://jenkins.io/redirect/security-144 for more details");
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Attempts to lift the security restriction on the underlying channel.
 * This requires the administer privilege on the server.
 *
 * @throws SecurityException
 *      If we fail to upgrade the connection.
 */
public void upgrade() {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  if (execute(Arrays.asList("groovy", "="),
      new ByteArrayInputStream("hudson.remoting.Channel.current().setRestricted(false)".getBytes()),
      out,out)!=0)
    throw new SecurityException(out.toString()); // failed to upgrade
}

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

private void enforceProfileOwner(ComponentName admin) {
 if (!admin.equals(profileOwner)) {
  throw new SecurityException("[" + admin + "] is not a profile owner");
 }
}

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

@Override
 protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
  throw new SecurityException("Halt! Who goes there?");
 }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Sign a message and base64 encode the signature.
 */
public String sign(String msg) {
  try {
    RSAPrivateKey key = getPrivateKey();
    Signature sig = Signature.getInstance(SIGNING_ALGORITHM + "with" + key.getAlgorithm());
    sig.initSign(key);
    sig.update(msg.getBytes("UTF-8"));
    return hudson.remoting.Base64.encode(sig.sign());
  } catch (GeneralSecurityException e) {
    throw new SecurityException(e);
  } catch (UnsupportedEncodingException e) {
    throw new AssertionError(e);    // UTF-8 is mandatory
  }
}

代码示例来源:origin: google/guava

@Override
 public void checkPermission(Permission p) {
  if (readClassPathFiles.implies(p)) {
   throw new SecurityException("Disallowed: " + p);
  }
 }
};

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

private void enforceDeviceOwnerOrProfileOwner(ComponentName admin) {
 if (!admin.equals(deviceOwner) && !admin.equals(profileOwner)) {
  throw new SecurityException("[" + admin + "] is neither a device owner nor a profile owner.");
 }
}

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

@Implementation
@NonNull
protected PackageInstaller.Session openSession(int sessionId) throws IOException {
 if (!sessionInfos.containsKey(sessionId)) {
  throw new SecurityException("Invalid session Id: " + sessionId);
 }
 PackageInstaller.Session session = new PackageInstaller.Session(null);
 ShadowSession shadowSession = Shadow.extract(session);
 shadowSession.setShadowPackageInstaller(sessionId, this);
 sessions.put(sessionId, session);
 return session;
}

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

@Implementation
protected void commit(@NonNull IntentSender statusReceiver) {
 this.statusReceiver = statusReceiver;
 if (outputStreamOpen) {
  throw new SecurityException("OutputStream still open");
 }
 shadowPackageInstaller.setSessionSucceeds(sessionId);
}

代码示例来源:origin: bumptech/glide

@Implementation
 @Override
 public NetworkInfo getActiveNetworkInfo() {
  if (!isNetworkPermissionGranted) {
   throw new SecurityException();
  }
  return super.getActiveNetworkInfo();
 }
}

代码示例来源:origin: jenkinsci/jenkins

@Override
  public void validateCrumb(StaplerRequest request, String submittedCrumb) {
    CrumbIssuer ci = Jenkins.getInstance().getCrumbIssuer();
    if (ci==null) {
      DEFAULT.validateCrumb(request,submittedCrumb);
    } else {
      if (!ci.validateCrumb(request, ci.getDescriptor().getCrumbSalt(), submittedCrumb))
        throw new SecurityException("Crumb didn't match");
    }
  }
});

相关文章