Java源码示例:org.jenkinsci.remoting.RoleChecker

示例1
public static void jvctsPerform(
    final ViolationsToGitHubConfig configUnexpanded,
    final FilePath fp,
    final Run<?, ?> build,
    final TaskListener listener) {
  final PrintStream logger = listener.getLogger();
  try {
    final EnvVars env = build.getEnvironment(listener);
    final ViolationsToGitHubConfig configExpanded = expand(configUnexpanded, env);
    logger.println("---");
    logger.println("--- Jenkins Violation Comments to GitHub ---");
    logger.println("---");
    logConfiguration(configExpanded, build, listener);

    final Optional<StandardCredentials> credentials =
        findCredentials(
            build.getParent(), configExpanded.getCredentialsId(), configExpanded.getGitHubUrl());

    if (!isNullOrEmpty(configExpanded.getoAuth2Token())) {
      logger.println("Using OAuth2Token");
    } else if (credentials.isPresent()) {
      final StandardCredentials standardCredentials = credentials.get();
      if (standardCredentials instanceof StandardUsernamePasswordCredentials) {
        logger.println("Using username / password");
      } else if (standardCredentials instanceof StringCredentials) {
        logger.println("Using OAuth2Token credential style");
      }
    } else {
      throw new IllegalStateException("No credentials found!");
    }

    logger.println("Running Jenkins Violation Comments To GitHub");
    logger.println("PR " + configExpanded.getPullRequestId());

    fp.act(
        new FileCallable<Void>() {

          private static final long serialVersionUID = 6166111757469534436L;

          @Override
          public void checkRoles(final RoleChecker checker) throws SecurityException {}

          @Override
          public Void invoke(final File workspace, final VirtualChannel channel)
              throws IOException, InterruptedException {
            setupFindBugsMessages();
            listener.getLogger().println("Workspace: " + workspace.getAbsolutePath());
            doPerform(configExpanded, workspace, credentials.orNull(), listener);
            return null;
          }
        });
  } catch (final Exception e) {
    Logger.getLogger(JvctgPerformer.class.getName()).log(SEVERE, "", e);
    final StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    logger.println(sw.toString());
    return;
  }
}
 
示例2
@Override
public void checkRoles(final RoleChecker checker) throws SecurityException {}
 
示例3
public static void jvctsPerform(
    final ProxyConfigDetails proxyConfigDetails,
    final ViolationsToBitbucketServerConfig configUnexpanded,
    final FilePath fp,
    final Run<?, ?> build,
    final TaskListener listener) {
  try {
    final EnvVars env = build.getEnvironment(listener);
    final ViolationsToBitbucketServerConfig configExpanded = expand(configUnexpanded, env);
    listener.getLogger().println("---");
    listener.getLogger().println("--- Jenkins Violation Comments to Bitbucket Server ---");
    listener.getLogger().println("---");
    logConfiguration(configExpanded, build, listener);

    final Optional<StandardCredentials> credentials =
        findCredentials(
            build.getParent(),
            configExpanded.getCredentialsId(),
            configExpanded.getBitbucketServerUrl());

    if (!credentials.isPresent()) {
      listener.getLogger().println("Credentials not found!");
      return;
    }

    listener.getLogger().println("Pull request: " + configExpanded.getPullRequestId());

    fp.act(
        new FileCallable<Void>() {

          private static final long serialVersionUID = 6166111757469534436L;

          @Override
          public void checkRoles(final RoleChecker checker) throws SecurityException {}

          @Override
          public Void invoke(final File workspace, final VirtualChannel channel)
              throws IOException, InterruptedException {
            setupFindBugsMessages();
            listener.getLogger().println("Workspace: " + workspace.getAbsolutePath());
            doPerform(
                proxyConfigDetails, configExpanded, workspace, credentials.orNull(), listener);
            return null;
          }
        });
  } catch (final Exception e) {
    Logger.getLogger(JvctbPerformer.class.getName()).log(SEVERE, "", e);
    final StringWriter sw = new StringWriter();
    e.printStackTrace(new PrintWriter(sw));
    listener.getLogger().println(sw.toString());
    return;
  }
}
 
示例4
/**
 * List model to choose the ZAP session to use. It's called on the remote machine (if present)
 * to load all session files in the build's workspace.
 * 
 * @return a {@link ListBoxModel}. It can be empty if the workspace doesn't contain any ZAP sessions.
 * @throws InterruptedException 
 * @throws IOException 
 */
public ListBoxModel doFillFilenameLoadSessionItems() throws IOException, InterruptedException {
	ListBoxModel items = new ListBoxModel();
	
	// No workspace before the first build, so workspace is null
	if(workspace != null) {
		Collection<String> sessionsInString = workspace.act(new FileCallable<Collection<String>>() {
			private static final long serialVersionUID = 1328740269013881941L;
	
			public Collection<String> invoke(File f, VirtualChannel channel) {
				
				// List all files with FILE_SESSION_EXTENSION on the machine where the workspace is located
				Collection<File> colFiles = FileUtils.listFiles(f,
						FileFilterUtils.suffixFileFilter(FILE_SESSION_EXTENSION),
						TrueFileFilter.INSTANCE);
				
				Collection<String> colString = new ArrayList<String>();
				
				// "Transform" File into String
				for (File file : colFiles) {
					colString.add(file.getAbsolutePath());
					// The following line is to remove the full path to the workspace,
					// keep just the relative path to the session
					//colString.add(file.getAbsolutePath().replace(workspace.getRemote() + File.separatorChar, ""));
				}
				return colString;
			}
	
			@Override
			public void checkRoles(RoleChecker checker) throws SecurityException {
				// Nothing to do
			}
		});
	
		items.add(""); // To not load a session, add a blank choice
		
		for (String s : sessionsInString) {
			items.add(s);
		}
	}
	
	return items;
}
 
示例5
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
	// Nothing to do
}
 
示例6
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
	// Nothing to do
}
 
示例7
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
	// Nothing to do
}
 
示例8
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
	// Nothing to do
}
 
示例9
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
	// Nothing to do
}
 
示例10
@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
}
 
示例11
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
}
 
示例12
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
}
 
示例13
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
    //ignore for now
}
 
示例14
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
    //ignore for now
}
 
示例15
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
    //ignore for now
}
 
示例16
@Override
public void checkRoles(RoleChecker roleChecker) throws SecurityException {
    //ignore for now
}
 
示例17
@Override
public void checkRoles(RoleChecker arg0) throws SecurityException {
}
 
示例18
@Override
public void checkRoles(RoleChecker rc) throws SecurityException {
    throw new UnsupportedOperationException("unexpected call to checkRoles in private static Work class");
}
 
示例19
@Override
public void checkRoles(final RoleChecker roleChecker) throws SecurityException {

}
 
示例20
@Override
public void checkRoles(final RoleChecker roleChecker) throws SecurityException {

}