@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);
	}
@ 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 ) ; }
PAXWEB-210: create security constraints