use of org.kohsuke.accmod.Restricted in project configuration-as-code-plugin by jenkinsci.
the class Attribute method calculateIfSecret.
// TODO: consider Boolean and third condition
/**
* This is a method which tries to guess whether an attribute is {@link Secret}.
* @param targetClass Class of the target object. {@code null} if unknown
* @param fieldName Field name
* @return {@code true} if the attribute is secret
* {@code false} if not or if there is no conclusive answer.
*/
@Restricted(NoExternalUse.class)
public static boolean calculateIfSecret(@CheckForNull Class<?> targetClass, @NonNull String fieldName) {
if (targetClass == Secret.class) {
// Class is final, so the check is safe
LOGGER.log(Level.FINER, "Attribute {0}#{1} is secret, because it has a Secret type", new Object[] { targetClass.getName(), fieldName });
return true;
}
if (targetClass == null) {
LOGGER.log(Level.FINER, "Attribute {0} is assumed to be non-secret, because there is no class instance in the call. " + "This call is used only for fast-fetch caching, and the result may be adjusted later", new Object[] { fieldName });
// All methods below require a known target class
return false;
}
// TODO: Cache decisions?
Method m = locateGetter(targetClass, fieldName);
if (m != null && m.getReturnType() == Secret.class) {
LOGGER.log(Level.FINER, "Attribute {0}#{1} is secret, because there is a getter {2} which returns a Secret type", new Object[] { targetClass.getName(), fieldName, m });
return true;
}
Field f = locatePublicField(targetClass, fieldName);
if (f != null && f.getType() == Secret.class) {
LOGGER.log(Level.FINER, "Attribute {0}#{1} is secret, because there is a public field {2} which has a Secret type", new Object[] { targetClass.getName(), fieldName, f });
return true;
}
f = locatePrivateFieldInHierarchy(targetClass, fieldName);
if (f != null && f.getType() == Secret.class) {
LOGGER.log(Level.FINER, "Attribute {0}#{1} is secret, because there is a private field {2} which has a Secret type", new Object[] { targetClass.getName(), fieldName, f });
return true;
}
// TODO(oleg_nenashev): Consider setters? Gonna be more interesting since there might be many of them
LOGGER.log(Level.FINER, "Attribute {0}#{1} is not a secret, because all checks have passed", new Object[] { targetClass.getName(), fieldName });
return false;
}
use of org.kohsuke.accmod.Restricted in project configuration-as-code-plugin by jenkinsci.
the class MergeStrategyAction method doIndex.
@Restricted(NoExternalUse.class)
public HttpResponse doIndex() {
JSONArray array = new JSONArray();
ExtensionList<MergeStrategy> mergeStrategyList = Jenkins.get().getExtensionList(MergeStrategy.class);
array.addAll(mergeStrategyList);
return HttpResponses.okJSON(array);
}
Aggregations