SecuredAssembler extends ModelAssembler implements AssemblerConstants { @Override public Model open(Assembler a, Resource root, Mode mode) { Resource rootModel = getUniqueResource( root, BASE_MODEL ); if (rootModel == null) { throw new AssemblerException( root, String.format( NO_X_PROVIDED, BASE_MODEL, root )); } Model baseModel = a.openModel(rootModel, Mode.ANY); Literal modelName = getUniqueLiteral( root, JA.modelName ); if (modelName == null) { throw new AssemblerException( root, String.format( NO_X_PROVIDED, JA.modelName, root )); } Literal factoryName = getUniqueLiteral( root, EVALUATOR_FACTORY ); Resource evaluatorImpl = getUniqueResource( root, EVALUATOR_IMPL ); if (factoryName == null && evaluatorImpl == null) { throw new AssemblerException( root, String.format( "Either a %s or a %s must be provided for %s" , EVALUATOR_FACTORY, EVALUATOR_IMPL, root )); } if (factoryName != null && evaluatorImpl != null) { throw new AssemblerException( root, String.format( "May not specify both a %s and a %s for %s" , EVALUATOR_FACTORY, EVALUATOR_IMPL, root )); } SecurityEvaluator securityEvaluator = null; if (factoryName != null) { securityEvaluator = executeEvaluatorFactory( root, factoryName ); } if (evaluatorImpl != null) { securityEvaluator = getEvaluatorImpl( a, evaluatorImpl ); } return Factory.getInstance(securityEvaluator, modelName.asLiteral().getString(), baseModel); }  static synchronized void init(); @Override Model open(Assembler a, Resource root, Mode mode);  }
@Test public void testCreation() throws Exception { Resource r = model.createResource( "http: Object o = assembler.open( r ); Assert.assertTrue( o instanceof Model); Assert.assertTrue( o instanceof SecuredModel ); }
@Test public void testCreationWithArgs() throws Exception { Resource r = model.createResource( "http: Object o = assembler.open( r ); Assert.assertTrue( o instanceof Model); Assert.assertTrue( o instanceof SecuredModel ); }
@Test public void testSecurityEvaluatorWithStringArgs() throws Exception { Resource r = model.createResource( "http: Object o = assembler.open( r ); Assert.assertTrue( o instanceof SecurityEvaluator ); Assert.assertTrue( o instanceof StaticSecurityEvaluator ); }
@Test public void testSecurityEvaluatorWithModelArgs() throws Exception { Resource r = model.createResource( "http: Object o = assembler.open( r ); Assert.assertTrue( o instanceof SecurityEvaluator ); Assert.assertTrue( o instanceof ModelBasedSecurityEvaluator ); }