本文整理了Java中jenkins.model.Jenkins.isUseSecurity()
方法的一些代码示例,展示了Jenkins.isUseSecurity()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.isUseSecurity()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:isUseSecurity
[英]A convenience method to check if there's some security restrictions in place.
[中]一种检查是否存在某些安全限制的方便方法。
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns true if the configuration of this subsystem becomes relevant.
* Unless this option is relevant, we don't let users choose this.
*/
public boolean isRelevant() {
return jenkins.hasPermission(Jenkins.RUN_SCRIPTS) && jenkins.isUseSecurity();
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* If the security is not enabled, there's no point in having
* this type of views.
*/
@Override
public boolean isInstantiable() {
return Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public boolean isActivated() {
return !Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: jenkinsci/jenkins
@Override public boolean permit(StaplerRequest req, Object bean) {
return INSECURE || !Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: jenkinsci/jenkins
|| !Jenkins.getInstance().isUseSecurity()) {
代码示例来源:origin: jenkinsci/jenkins
public static void checkPermission(Job<?,?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
if (!Jenkins.getInstance().isUseSecurity())
return; // everyone is authorized
if(token!=null && token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
if (providedToken != null && providedToken.equals(token.token))
return;
if (providedToken != null)
throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided());
}
project.checkPermission(Item.BUILD);
if (req.getMethod().equals("POST")) {
return;
}
if (req.getAttribute(ApiTokenProperty.class.getName()) instanceof User) {
return;
}
rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
rsp.addHeader("Allow", "POST");
throw HttpResponses.forwardToView(project, "requirePOST.jelly");
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Returns true if the configuration of this subsystem becomes relevant.
* Unless this option is relevant, we don't let users choose this.
*/
public boolean isRelevant() {
return jenkins.hasPermission(Jenkins.RUN_SCRIPTS) && jenkins.isUseSecurity();
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* If the security is not enabled, there's no point in having
* this type of views.
*/
@Override
public boolean isInstantiable() {
return Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
public boolean isActivated() {
return !Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override public boolean permit(StaplerRequest req, Object bean) {
return INSECURE || !Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: jenkinsci/instant-messaging-plugin
private boolean isAuthenticationNeeded() {
return this.authentication != null && Jenkins.getInstance().isUseSecurity();
}
代码示例来源:origin: jenkinsci/mesos-plugin
/**
* Slave needs to go through authentication while connecting through jnlp if security is enabled in jenkins.
* This method gets secret (for jnlp authentication) from jenkins, constructs command line argument and returns it.
*
* @param slaveName the slave name in jenkins
* @return jenkins slave secret corresponding to slave name in the format '-secret <secret>'
*/
private String getJnlpSecret(String slaveName) {
String jnlpSecret = "";
if(getJenkins().isUseSecurity()) {
jnlpSecret = String.format(JNLP_SECRET_FORMAT, jenkins.slaves.JnlpSlaveAgentProtocol.SLAVE_SECRET.mac(slaveName));
}
return jnlpSecret;
}
代码示例来源:origin: jenkinsci/email-ext-plugin
public Object readResolve() {
if (Jenkins.getActiveInstance().isUseSecurity()
&& (!StringUtils.isBlank(this.postsendScript) || !StringUtils.isBlank(this.presendScript))) {
setPostsendScript(this.postsendScript);
setPresendScript(this.presendScript);
setClasspath(this.classpath);
}
return this;
}
}
代码示例来源:origin: com.cisco.step.jenkins.plugins/jenkow-plugin
@Override
public UserQuery createUserQuery() {
if (jenkins.isUseSecurity())
return new JenkowUserQueryImpl(jenkins.getSecurityRealm());
else
return new AnonymousUserQueryImpl();
}
代码示例来源:origin: jenkinsci/email-ext-plugin
if (Jenkins.getActiveInstance().isUseSecurity()
&& (!StringUtils.isBlank(this.defaultPostsendScript)) || !StringUtils.isBlank(this.defaultPresendScript)) {
setDefaultPostsendScript(this.defaultPostsendScript);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public static void checkPermission(Job<?,?> project, BuildAuthorizationToken token, StaplerRequest req, StaplerResponse rsp) throws IOException {
if (!Jenkins.getInstance().isUseSecurity())
return; // everyone is authorized
if(token!=null && token.token != null) {
//check the provided token
String providedToken = req.getParameter("token");
if (providedToken != null && providedToken.equals(token.token))
return;
if (providedToken != null)
throw new AccessDeniedException(Messages.BuildAuthorizationToken_InvalidTokenProvided());
}
project.checkPermission(Item.BUILD);
if (req.getMethod().equals("POST")) {
return;
}
if (req.getAttribute(ApiTokenProperty.class.getName()) instanceof User) {
return;
}
rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
rsp.addHeader("Allow", "POST");
throw HttpResponses.forwardToView(project, "requirePOST.jelly");
}
代码示例来源:origin: jenkinsci/email-ext-plugin
final String userAddress = EmailRecipientUtils.getUserConfiguredEmail(user);
if (userAddress != null) {
if (Jenkins.getActiveInstance().isUseSecurity()) {
try {
Authentication auth = user.impersonate();
代码示例来源:origin: jenkinsci/email-ext-plugin
public void setDefaultClasspath(List<GroovyScriptPath> defaultClasspath) throws FormException {
if (Jenkins.getActiveInstance().isUseSecurity()) {
ScriptApproval approval = ScriptApproval.get();
ApprovalContext context = ApprovalContext.create().withCurrentUser();
for (GroovyScriptPath path : defaultClasspath) {
URL u = path.asURL();
if (u != null) {
try {
approval.configuring(new ClasspathEntry(u.toString()), context);
} catch (MalformedURLException e) {
throw new FormException(e, "ext_mailer_default_classpath");
}
}
}
}
this.defaultClasspath = defaultClasspath;
}
代码示例来源:origin: jenkinsci/email-ext-plugin
public void setClasspath(List<GroovyScriptPath> classpath) {
if (classpath != null && !classpath.isEmpty() && Jenkins.getActiveInstance().isUseSecurity()) {
//Prepare the classpath for approval
ScriptApproval scriptApproval = ScriptApproval.get();
ApprovalContext context = ApprovalContext.create().withCurrentUser();
StaplerRequest request = Stapler.getCurrentRequest();
if (request != null) {
context = context.withItem(request.findAncestorObject(Item.class));
}
for (GroovyScriptPath path : classpath) {
URL pUrl = path.asURL();
if (pUrl != null) {
//At least we can try to catch some of them, but some might need token expansion
try {
scriptApproval.configuring(new ClasspathEntry(pUrl.toString()), context);
} catch (MalformedURLException e) {
//At least we tried, but we shouldn't end up here since path.asURL() would have returned null
assert false : e;
}
}
}
}
this.classpath = classpath;
}
代码示例来源:origin: jenkinsci/email-ext-plugin
boolean useSecurity = Jenkins.getActiveInstance().isUseSecurity();
if (!classpathList.isEmpty()) {
GroovyClassLoader gloader = new GroovyClassLoader(loader);
内容来源于网络,如有侵权,请联系作者删除!