use of org.glassfish.api.admin.AccessRequired.AccessCheck in project Payara by payara.
the class CommandSecurityChecker method addAccessChecksFromReSTEndpoint.
private void addAccessChecksFromReSTEndpoint(final RestEndpoint restEndpoint, final List<AccessCheckWork> accessChecks, final boolean isTaggable) {
if (!restEndpoint.useForAuthorization()) {
return;
}
final String action = optypeToAction.get(restEndpoint.opType());
/*
* For the moment, if there is no RestParam then the config bean class given
* in the anno is an unnamed singleton target of the action. If there is a RestParam
* then the target is (probably) the unnamed singleton parent of the config bean class given
* and the new child's type is the config bean class.
*/
String resource;
// if (restEndpoint.params().length == 0) {
resource = resourceNameFromRestEndpoint(restEndpoint.configBean(), restEndpoint.path(), locator);
// } else {
// // TODO need to do something with the endpoint params
// resource = resourceNameFromRestEndpoint(restEndpoint.configBean(),
// restEndpoint.path(),
// locator);
// }
final AccessCheck a = new AccessCheck(resource, action);
String tag = null;
if (isTaggable) {
tag = " @RestEndpoint " + restEndpoint.configBean().getName() + ", op=" + restEndpoint.opType();
}
accessChecks.add(new AccessCheckWork(a, tag));
}
use of org.glassfish.api.admin.AccessRequired.AccessCheck in project Payara by payara.
the class CommandSecurityChecker method addAccessChecksFromAnno.
private void addAccessChecksFromAnno(final AccessRequired ar, final AdminCommand command, final List<AccessCheckWork> accessChecks, final Class<?> currentClass, final boolean isTaggable) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
for (final String resource : ar.resource()) {
final String translatedResource = processTokens(resource, command);
for (final String action : ar.action()) {
final AccessCheck a = new AccessCheck(translatedResource, action);
String tag = null;
if (isTaggable) {
tag = " @AccessRequired on " + currentClass.getName() + LINE_SEP;
}
accessChecks.add(new AccessCheckWork(a, tag));
}
}
}
use of org.glassfish.api.admin.AccessRequired.AccessCheck in project Payara by payara.
the class GenericDeleteCommand method getAccessChecks.
@Override
public Collection<? extends AccessCheck> getAccessChecks() {
final Collection<AccessCheck> checks = new ArrayList<AccessCheck>();
parentBean = habitat.getService((Class<? extends ConfigBeanProxy>) parentType);
name = "";
if (resolver instanceof TypeAndNameResolver) {
name = ((TypeAndNameResolver) resolver).name();
}
checks.add(new AccessCheck(parentBean, targetType, name, "delete"));
return checks;
}
use of org.glassfish.api.admin.AccessRequired.AccessCheck in project Payara by payara.
the class GenericListCommand method getAccessChecks.
@Override
public Collection<? extends AccessCheck> getAccessChecks() {
final Collection<AccessCheck> checks = new ArrayList<AccessCheck>();
checks.add(new AccessCheck(AccessRequired.Util.resourceNameFromConfigBeanProxy(parentBean), "read"));
if (longOpt) {
try {
List<ConfigBeanProxy> children = (List<ConfigBeanProxy>) targetMethod.invoke(parentBean);
for (ConfigBeanProxy child : children) {
if (name == null || name.equals(Dom.unwrap(child).getKey())) {
checks.add(new AccessCheck(AccessRequired.Util.resourceNameFromConfigBeanProxy(child), "read"));
}
}
} catch (Exception ex) {
String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericListCommand.accesschecks", "Exception while creating access checks for generic command {0}: {1}", commandName, ex.getMessage());
LogHelper.log(logger, Level.SEVERE, ConfigApiLoggerInfo.ACCESS_CHK_CREATE_FAILED, ex, commandName);
throw new RuntimeException(msg, ex);
}
}
return checks;
}
use of org.glassfish.api.admin.AccessRequired.AccessCheck in project Payara by payara.
the class CreateLifecycleModuleCommand method getAccessChecks.
@Override
public Collection<? extends AccessCheck> getAccessChecks() {
final List<AccessCheck> accessChecks = new ArrayList<AccessCheck>();
/*
* One check for the life cycle module itself.
*/
accessChecks.add(new AccessCheck(DeploymentCommandUtils.APPLICATION_RESOURCE_NAME, "create"));
/*
* One check for the target.
*/
accessChecks.add(new AccessCheck(DeploymentCommandUtils.getTargetResourceNameForNewAppRef(domain, target), "create"));
return accessChecks;
}
Aggregations