Callback for creation of add dialogs.
Will be invoked once the presenter has loaded the resource description.
@param address
@param isSingleton
@param securityContext
@param description
197227
public void showAddDialog(final ModelNode address, boolean isSingleton, SecurityContext securityContext, ModelNode description) {

        String resourceAddress = AddressUtils.asKey(address, isSingleton);

        if(securityContext.getOperationPriviledge(resourceAddress, "add").isGranted()) {
            _showAddDialog(address, isSingleton, securityContext, description);
        }
        else
        {
            Feedback.alert(Console.CONSTANTS.unauthorized(),
                    Console.CONSTANTS.unauthorizedAdd());
        }

    }
1083441
public void restoreSecurityContext(CacheContext context) {
		SavedAuthorization cached = context.get(CacheContext.SECURITY_CONTEXT_KEY, SavedAuthorization.class);
		if (cached != null) {
			log.debug("Restoring security context {}", cached);
			securityManager.restoreSecurityContext(cached);
		} else {
			securityManager.clearSecurityContext();
		}
	}
1035450
private void initialize(final SecurityContext securityContext,  Document document) throws FrameworkException {

		for (final Node child : document.getChildren()) {

			if (child instanceof OperationDefinition) {

				final OperationDefinition operationDefinition = (OperationDefinition)child;
				final SelectionSet selectionSet               = operationDefinition.getSelectionSet();

				for (final Selection selection : selectionSet.getSelections()) {

					if (selection instanceof Field) {

						queries.add(new GraphQLQuery(securityContext, (Field)selection));

					} else {

						logger.warn("Unknown selection set element {} in GraphQL query, ignoring.", selection.getClass());
					}
				}

			} else {

				logger.warn("Unknown document element {} in GraphQL query, ignoring.", child.getClass());
			}
		}
	}
225830
@Override
    public ApplicationDescriptor securityRole(String roleName, String description) {
        Node security = model.createChild("security-role");
        if (roleName != null) {
            security.createChild("role-name").text(roleName);
        }
        if (description != null) {
            security.createChild("description").text(description);
        }
        return this;
    }
1185853
void launchAddServiceProviderDialog(final String federation) {
        ComboBoxItem securityDomains = new ComboBoxItem("security-domain", "Security Domain");
        securityDomains.setRequired(true);
        securityDomains.setValueMap(this.securityDomains);

        DefaultWindow dialog = new DefaultWindow(Console.MESSAGES.newTitle("Service Provider"));
        ResourceDescription resourceDescription = descriptionRegistry.lookup(SERVICE_PROVIDER_TEMPLATE);
        //noinspection Duplicates
        AddResourceDialog addDialog = new AddResourceDialog(securityContext, resourceDescription,
                new AddResourceDialog.Callback() {
                    @Override
                    public void onAdd(ModelNode payload) {
                        dialog.hide();

                        String name = payload.get("name").asString();
                        ResourceAddress address = SERVICE_PROVIDER_TEMPLATE.resolve(statementContext, federation, name);
                        payload.get(OP).set(ADD);
                        payload.get(ADDRESS).set(address);
                        dispatcher.execute(new DMRAction(payload), new SimpleCallback<DMRResponse>() {
                            @Override
                            public void onFailure(Throwable caught) {
                                super.onFailure(caught);
                                readServiceProvider(federation);
                            }

                            @Override
                            public void onSuccess(DMRResponse dmrResponse) {
                                Console.info(Console.MESSAGES.successfullyAdded((name)));
                                readServiceProvider(federation);
                            }
                        });
                    }

                    @Override
                    public void onCancel() {
                        dialog.hide();
                    }
                })
                .addFactory("security-domain", attributeDescription -> securityDomains)
                .include();

        dialog.setWidth(640);
        dialog.setHeight(480);
        dialog.setWidget(addDialog);
        dialog.setGlassEnabled(true);
        dialog.center();
    }
1772
private void updateAccessInformation(final SecurityContext securityContext, final PropertyContainer propertyContainer) throws FrameworkException {

		try {

			if (securityContext.modifyAccessTime()) {

				final Principal user = securityContext.getUser(false);
				String modifiedById  = null;

				if (user != null) {

					if (user instanceof SuperUser) {

						// "virtual" UUID of superuser
						modifiedById = Principal.SUPERUSER_ID;

					} else {

						modifiedById = user.getUuid();
					}

					propertyContainer.setProperty(AbstractNode.lastModifiedBy.dbName(), modifiedById);
				}

				propertyContainer.setProperty(AbstractNode.lastModifiedDate.dbName(), System.currentTimeMillis());
			}


		} catch (Throwable t) {

			// fail without throwing an exception here
			logger.warn("", t);
		}
	}
38969
public final void setSecurityUseridSentBySystem(boolean value) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setSecurityUseridSentBySystem", Boolean.valueOf(value));
        jmo.setBooleanField(JsHdrAccess.SECURITYSENTBYSYSTEM, value);
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setSecurityUseridSentBySystem");
    }
210796
public void setSbbContext(SbbContext context) {
		sbbContext = (SbbContextExt) context;
		sipActivityContextInterfaceFactory = (SipActivityContextInterfaceFactory) sbbContext
				.getActivityContextInterfaceFactory(sipRATypeID);
		sleeSipProvider = (SleeSipProvider) sbbContext
				.getResourceAdaptorInterface(sipRATypeID, sipRALink);
		addressFactory = sleeSipProvider.getAddressFactory();
		headerFactory = sleeSipProvider.getHeaderFactory();
		messageFactory = sleeSipProvider.getMessageFactory();
		timerFacility = sbbContext.getTimerFacility();
	}
220071
@Override
	public void addSecurityConstraintMappings(
			final SecurityConstraintMappingModel model) {
		final ServletContextHandler context = server.getOrCreateContext(model);
		final SecurityHandler securityHandler = context.getSecurityHandler();
		if (securityHandler == null) {
			throw new IllegalStateException(
					"Internal error: Cannot find the security handler. Please report.");
		}
		String mappingMethod = model.getMapping();
		String constraintName = model.getConstraintName();
		String url = model.getUrl();
		String dataConstraint = model.getDataConstraint();
		List<String> roles = model.getRoles();
		boolean authentication = model.isAuthentication();

		ConstraintMapping newConstraintMapping = new ConstraintMapping();
		newConstraintMapping.setMethod(mappingMethod);
		newConstraintMapping.setPathSpec(url);
		Constraint constraint = new Constraint();
		constraint.setAuthenticate(authentication);
		constraint.setName(constraintName);
		constraint.setRoles(roles.toArray(new String[roles.size()]));

		if (dataConstraint == null || "NONE".equals(dataConstraint)) {
			constraint.setDataConstraint(Constraint.DC_NONE);
		} else if ("INTEGRAL".equals(dataConstraint)) {
			constraint.setDataConstraint(Constraint.DC_INTEGRAL);
		} else if ("CONFIDENTIAL".equals(dataConstraint)) {
			constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
		} else {
			LOG.warn("Unknown user-data-constraint:" + dataConstraint);
			constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
		}

		newConstraintMapping.setConstraint(constraint);

		((ConstraintSecurityHandler) securityHandler)
				.addConstraintMapping(newConstraintMapping);
	}
1268177
public void addServiceDescriptor(KEY key, MethodDescriptor<KEY> serviceDescriptor) {
        Preconditions.checkNotNull(key, "Key cannot be null");
        Preconditions.checkState(instance != null, "ServiceRegistry not init yet");

        //        if (serviceDescriptors.containsKey(key)) {
        //            LOG.warn("Ignore key=" + key + " since it is already registered with "
        //                    + serviceDescriptor);
        //        }

        this.serviceDescriptors.putIfAbsent(key, serviceDescriptor);
    }
857123
private void addHttpSessionIdListener(HttpSessionIdListener listener, boolean securityCheckNeeded) throws SecurityException {
        if (securityCheckNeeded) {
            SecurityManager sm = System.getSecurityManager();
            if (sm != null) {
                sm.checkPermission(perm);
            }
        }
        
        ((IHttpSessionContext31)this.getSessionContext()).addHttpSessionIdListener(listener, name);
    }
1324472
private static void addDescription(Entry entry, String description) {
        try {
            entry.add(SchemaConstants.OBJECT_CLASS_ATTRIBUTE, SchemaConstants.DESCRIPTIVE_OBJECT_OC);
            if (description == null) {
                entry.add(SchemaConstants.EMPTY_FLAG_ATTRIBUTE, String.valueOf(false)); // case 1
            } else if (description.isEmpty()) {
                entry.add(SchemaConstants.EMPTY_FLAG_ATTRIBUTE, String.valueOf(true)); // case 2
            } else {
                entry.add(SchemaConstants.STRING_ATTRIBUTE, description); // case 3
            }
        } catch (LdapException e) {
            throw new LdapRuntimeException(e);
        }
    }
242005
private boolean accept(SecurityContext securityContext, T element) {

		boolean ret = true;

		for(Filter<T> predicate : filters) {

			predicate.setSecurityContext(securityContext);
			ret &= predicate.accept(element);
		}

		return(ret);
	}
1052839
@Process(actionType = ModifySaslSecurity.class)
    public void modifySaslSecurity(final ModifySaslSecurity action, final Dispatcher.Channel channel) {

        final List<Property> connectors = getModelsFor(action.getConnectorAddress());
        Outcome<FunctionContext> outcome = new Outcome<FunctionContext>() {
            @Override
            public void onFailure(FunctionContext context) {
                channel.nack(context.getError());
            }

            @Override
            public void onSuccess(FunctionContext context) {
                lastModifiedInstance = action.getConnectorName();
                read(action.getConnectorAddress().getResourceType(), connectors, channel);
            }
        };

        // It's not guaranteed that the security singleton already exists. If the parent connector
        // was created by the console, it does exists. However if the parent connector was created using
        // the CLI we need to create the security singleton before we try to modify it.
        AddressTemplate securityAddress = action.getConnectorAddress().append("security=" + SASL_SINGLETON);
        new Async<FunctionContext>(new Progress.Nop()).waterfall(new FunctionContext(), outcome,
                new VerifySaslSingleton(dispatcher, statementContext, action.getConnectorName(), securityAddress),
                new CreateSaslSingleton(dispatcher, statementContext, action.getConnectorName(), securityAddress) {
                    @Override
                    public void execute(Control<FunctionContext> control) {
                        int status = control.getContext().pop();
                        if (status == 200) {
                            control.proceed();
                        } else {
                            super.execute(control);
                        }
                    }
                },
                new ModifySaslSingleton(dispatcher, statementContext, action.getConnectorName(), securityAddress,
                        action.getChangedValues()));
    }
572853
void launchAddFederationDialog() {
        ResourceDescription resourceDescription = StaticResourceDescription
                .from(PICKET_LINK_RESOURCES.newFederationDescription());
        ComboBoxItem securityDomains = new ComboBoxItem("security-domain", "Security Domain");
        securityDomains.setRequired(false);
        securityDomains.setValueMap(this.securityDomains);

        DefaultWindow dialog = new DefaultWindow(Console.MESSAGES.newTitle("Federation"));
        ModelNodeFormBuilder.FormAssets assets = new ModelNodeFormBuilder()
                .setResourceDescription(resourceDescription)
                .addFactory("security-domain", attributeDescription -> securityDomains)
                .setSecurityContext(securityContext)
                .unsorted()
                .build();
        assets.getForm().setEnabled(true);
        assets.getForm().addFormValidator(new IdentityProviderEditor.IdentityProviderFormValidator());

        DialogueOptions options = new DialogueOptions(
                event -> {
                    FormValidation validation = assets.getForm().validate();
                    if (!validation.hasErrors()) {
                        dialog.hide();

                        ModelNode payload = assets.getForm().getUpdatedEntity();
                        String name = payload.get(NAME).asString();
                        String ip = payload.get("identity-provider").asString();

                        Operation addFederation = new Operation.Builder(ADD,
                                FEDERATION_TEMPLATE.resolve(statementContext, name)).build();
                        Operation addIdentityProvider = new Operation.Builder(ADD,
                                IDENTITY_PROVIDER_TEMPLATE.resolve(statementContext, name, ip))
                                .param("security-domain", payload.get("security-domain").asString())
                                .param("external", payload.get("external").asBoolean())
                                .param("url", payload.get("url").asString())
                                .build();
                        dispatcher.execute(new DMRAction(new Composite(addFederation, addIdentityProvider)),
                                new SimpleCallback<DMRResponse>() {
                                    @Override
                                    public void onFailure(final Throwable caught) {
                                        super.onFailure(caught);
                                        readFederations();
                                    }

                                    @Override
                                    public void onSuccess(final DMRResponse dmrResponse) {
                                        Console.info(Console.MESSAGES.successfullyAdded((name)));
                                        readFederations();
                                    }
                                });
                    }
                },
                event -> dialog.hide()
        );

        VerticalPanel layout = new VerticalPanel();
        layout.setStyleName("fill-layout-width window-content");
        ContentDescription text = new ContentDescription(resourceDescription.get(DESCRIPTION).asString());
        layout.add(text);
        layout.add(assets.getHelp().asWidget());
        layout.add(assets.getForm().asWidget());

        ScrollPanel scroll = new ScrollPanel(layout);
        LayoutPanel content = new LayoutPanel();
        content.addStyleName("fill-layout");
        content.add(scroll);
        content.add(options);
        content.getElement().setAttribute("style", "margin-bottom:10px");
        content.setWidgetTopHeight(scroll, 0, Style.Unit.PX, 92, Style.Unit.PCT);
        content.setWidgetBottomHeight(options, 0, Style.Unit.PX, 35, Style.Unit.PX);

        dialog.setWidth(640);
        dialog.setHeight(480);
        dialog.setWidget(new TrappedFocusPanel(content));
        dialog.setGlassEnabled(true);
        dialog.center();
    }
818452
public void doOuterCallback(SecurityContext securityContext) throws FrameworkException {

		if ((status & (STATE_DELETED | STATE_DELETED_PASSIVELY)) == 0) {

			if ((status & STATE_PROPAGATED_MODIFICATION) == STATE_PROPAGATED_MODIFICATION) {
				object.propagatedModification(securityContext);
			}

			if ((status & STATE_LOCATION_MODIFIED) == STATE_LOCATION_MODIFIED) {
				object.locationModified(securityContext);
			}

			if ((status & STATE_SECURITY_MODIFIED) == STATE_SECURITY_MODIFIED) {
				object.securityModified(securityContext);
			}

			if ((status & STATE_OWNER_MODIFIED) == STATE_OWNER_MODIFIED) {
				object.ownerModified(securityContext);
			}
		}

		// examine only the last 4 bits here
		switch (status & 0x000f) {

			case 15:
			case 14:
			case 13:
			case 12:
			case 11:
			case 10:
			case  9:
			case  8: // since all values >= 8 mean that the object was passively deleted, no action has to be taken
				 // (no callback for passive deletion!)
				break;

			case  7: // created, modified, deleted, poor guy => no callback
				break;

			case  6: // created, modified => only creation callback will be called
				object.afterCreation(securityContext);
				break;

			case  5: // created, deleted => no callback
				break;

			case  4: // created => creation callback
				object.afterCreation(securityContext);
				break;

			case  3: // modified, deleted => deletion callback
				object.afterDeletion(securityContext, removedProperties);
				break;

			case  2: // modified => modification callback
				object.afterModification(securityContext);
				break;

			case  1: // deleted => deletion callback
				object.afterDeletion(securityContext, removedProperties);
				break;

			case  0: // no action, no callback
				break;

			default:
				break;
		}
	}
140094
private void create(final AddressTemplate addressTemplate, final String instanceName, final ModelNode newModel,
                        final List<Property> list, final Dispatcher.Channel channel) {
        operationDelegate.onCreateResource(addressTemplate, instanceName, newModel,
                new CrudOperationDelegate.Callback() {
                    @Override
                    public void onFailure(AddressTemplate template, String name, Throwable t) {
                        channel.nack(t);
                    }

                    @Override
                    public void onSuccess(AddressTemplate addressTemplate, String name) {
                        lastModifiedInstance = instanceName;
                        read(addressTemplate.getResourceType(), list, channel);
                    }
                });
    }