本文整理了Java中hudson.security.Permission.fromId()
方法的一些代码示例,展示了Permission.fromId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Permission.fromId()
方法的具体详情如下:
包路径:hudson.security.Permission
类名称:Permission
方法名:fromId
[英]Convert the ID representation into Permission object.
[中]将ID表示转换为权限对象。
代码示例来源:origin: jenkinsci/configuration-as-code-plugin
/**
* Attempt to match a given permission to what is defined in the UI.
* @param id String of the form "Title/Permission" (Look in the UI) for a particular permission
* @return a matched permission
*/
@CheckForNull
public static Permission findPermission(String id) {
final String resolvedId = findPermissionId(id);
return resolvedId != null ? Permission.fromId(resolvedId) : null;
}
代码示例来源:origin: groupon/DotCi
@Override
public Object decode(Class targetClass, Object fromDBObject, MappedField optionalExtraInfo) {
if (fromDBObject == null) return null;
return Permission.fromId((String) fromDBObject);
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p, shortForm.substring(idx + 1));
}
代码示例来源:origin: io.jenkins/configuration-as-code
/**
* Attempt to match a given permission to what is defined in the UI.
* @param id String of the form "Title/Permission" (Look in the UI) for a particular permission
* @return a matched permission
*/
@CheckForNull
public static Permission findPermission(String id) {
final String resolvedId = findPermissionId(id);
return resolvedId != null ? Permission.fromId(resolvedId) : null;
}
代码示例来源:origin: hudson/hudson-2.x
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p,shortForm.substring(idx+1));
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p,shortForm.substring(idx+1));
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p, shortForm.substring(idx + 1));
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p == null) {
throw new IllegalArgumentException("Failed to parse '" + shortForm + "' --- no such permission");
}
add(p, shortForm.substring(idx + 1));
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p,shortForm.substring(idx+1));
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p==null)
throw new IllegalArgumentException("Failed to parse '"+shortForm+"' --- no such permission");
add(p, shortForm.substring(idx + 1));
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Works like {@link #add(Permission, String)} but takes both parameters
* from a single string of the form <tt>PERMISSIONID:sid</tt>
*/
private void add(String shortForm) {
int idx = shortForm.indexOf(':');
Permission p = Permission.fromId(shortForm.substring(0, idx));
if (p != null) {
add(p, shortForm.substring(idx + 1));
} else {
// This should not happen if Hudson is fully initialized.
// But Initial Setup also loads Security setup before Hudson Initialization
if (Hudson.getInstance() != null) {
throw new IllegalArgumentException("Failed to parse '" + shortForm + "' --- no such permission");
}
}
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
public AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
GlobalMatrixAuthorizationStrategy gmas = create();
for (Map.Entry<String, JSONObject> r : (Set<Map.Entry<String, JSONObject>>) formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
for (Map.Entry<String, Boolean> e : (Set<Map.Entry<String, Boolean>>) r.getValue().entrySet()) {
if (e.getValue()) {
Permission p = Permission.fromId(e.getKey());
gmas.add(p, sid);
}
}
}
return gmas;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@Override
public AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
GlobalMatrixAuthorizationStrategy gmas = create();
for(Map.Entry<String,JSONObject> r : (Set<Map.Entry<String,JSONObject>>)formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
for(Map.Entry<String,Boolean> e : (Set<Map.Entry<String,Boolean>>)r.getValue().entrySet()) {
if(e.getValue()) {
Permission p = Permission.fromId(e.getKey());
gmas.add(p,sid);
}
}
}
return gmas;
}
代码示例来源:origin: hudson/hudson-2.x
@Override
public AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
GlobalMatrixAuthorizationStrategy gmas = create();
for(Map.Entry<String,JSONObject> r : (Set<Map.Entry<String,JSONObject>>)formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
for(Map.Entry<String,Boolean> e : (Set<Map.Entry<String,Boolean>>)r.getValue().entrySet()) {
if(e.getValue()) {
Permission p = Permission.fromId(e.getKey());
gmas.add(p,sid);
}
}
}
return gmas;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
public AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException {
GlobalMatrixAuthorizationStrategy gmas = create();
for(Map.Entry<String,JSONObject> r : (Set<Map.Entry<String,JSONObject>>)formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
for(Map.Entry<String,Boolean> e : (Set<Map.Entry<String,Boolean>>)r.getValue().entrySet()) {
if(e.getValue()) {
Permission p = Permission.fromId(e.getKey());
gmas.add(p,sid);
}
}
}
return gmas;
}
代码示例来源:origin: hudson/hudson-2.x
@Override
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
formData = formData.getJSONObject("useProjectSecurity");
if (formData.isNullObject())
return null;
AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty();
for (Map.Entry<String, Object> r : (Set<Map.Entry<String, Object>>) formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
if (r.getValue() instanceof JSONObject) {
for (Map.Entry<String, Boolean> e : (Set<Map.Entry<String, Boolean>>) ((JSONObject) r
.getValue()).entrySet()) {
if (e.getValue()) {
Permission p = Permission.fromId(e.getKey());
amp.add(p, sid);
}
}
}
}
return amp;
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
@Override
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
formData = formData.getJSONObject("useProjectSecurity");
if (formData.isNullObject()) {
return null;
}
AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty();
for (Map.Entry<String, Object> r : (Set<Map.Entry<String, Object>>) formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
if (r.getValue() instanceof JSONObject) {
for (Map.Entry<String, Boolean> e : (Set<Map.Entry<String, Boolean>>) ((JSONObject) r
.getValue()).entrySet()) {
if (e.getValue()) {
Permission p = Permission.fromId(e.getKey());
amp.add(p, sid);
}
}
}
}
return amp;
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
@Override
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
formData = formData.getJSONObject("useProjectSecurity");
if (formData.isNullObject())
return null;
AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty();
for (Map.Entry<String, Object> r : (Set<Map.Entry<String, Object>>) formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
if (r.getValue() instanceof JSONObject) {
for (Map.Entry<String, Boolean> e : (Set<Map.Entry<String, Boolean>>) ((JSONObject) r
.getValue()).entrySet()) {
if (e.getValue()) {
Permission p = Permission.fromId(e.getKey());
amp.add(p, sid);
}
}
}
}
return amp;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
@Override
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) throws FormException {
formData = formData.getJSONObject("useProjectSecurity");
if (formData.isNullObject())
return null;
AuthorizationMatrixProperty amp = new AuthorizationMatrixProperty();
for (Map.Entry<String, Object> r : (Set<Map.Entry<String, Object>>) formData.getJSONObject("data").entrySet()) {
String sid = r.getKey();
if (r.getValue() instanceof JSONObject) {
for (Map.Entry<String, Boolean> e : (Set<Map.Entry<String, Boolean>>) ((JSONObject) r
.getValue()).entrySet()) {
if (e.getValue()) {
Permission p = Permission.fromId(e.getKey());
amp.add(p, sid);
}
}
}
}
return amp;
}
代码示例来源:origin: jenkinsci/workflow-cps-plugin
@Initializer(after=InitMilestone.EXTENSIONS_AUGMENTED, before=InitMilestone.JOB_LOADED) // same time as Jenkins global config is loaded (e.g., AuthorizationStrategy)
public static void assertPermissionId() {
String thePermissionId = "hudson.model.Run.Replay";
// An AuthorizationStrategy may be loading a permission by name during Jenkins startup.
Permission thePermission = Permission.fromId(thePermissionId);
// Make sure it finds this addition, even though the PermissionGroup is in core.
assertEquals(ReplayAction.REPLAY, thePermission);
assertEquals(thePermissionId, thePermission.getId());
}
内容来源于网络,如有侵权,请联系作者删除!