@Override public void reroute(OfficeFlowSourceNode flowSourceNode) { this.officeArchitect.link(flowSourceNode, this.routingSection.getOfficeSectionInput(HANDLER_INPUT_NAME)); }
@Override public OfficeManagedObject addHttpObject(Class<?> objectClass, String... acceptedContentTypes) { // Determine if already registered OfficeManagedObject object = this.httpObjects.get(objectClass); if (object == null) { // Not registered, so register OfficeManagedObjectSource mos = this.officeArchitect.addOfficeManagedObjectSource(objectClass.getName(), new HttpObjectManagedObjectSource<>(objectClass, acceptedContentTypes, this.singletonObjectParserList)); object = mos.addOfficeManagedObject(objectClass.getName(), ManagedObjectScope.PROCESS); this.httpObjects.put(objectClass, object); } // Return the object return object; }
@Override public OfficeFlowSinkNode secureFlow(Class<?> argumentType, OfficeFlowSinkNode secureFlowSink, OfficeFlowSinkNode insecureFlowSink) { // Obtain the office architect OfficeArchitect office = HttpSecurityArchitectEmployer.this.officeArchitect; // Create the section to handle access logic String sectionName = HttpSecurityArchitectEmployer.this.nextUniqueName(); OfficeSection section = office.addOfficeSection(sectionName, new HttpFlowSecurerSectionSource( new HttpFlowSecurerAnnotation(qualifier, anyRoles, allRoles, argumentType)), null); // Link office.link(section.getOfficeSectionOutput(HttpFlowSecurerSectionSource.SECURE_OUTPUT_NAME), secureFlowSink); office.link(section.getOfficeSectionOutput(HttpFlowSecurerSectionSource.INSECURE_OUTPUT_NAME), insecureFlowSink); // Return the sink to secure flow decision return section.getOfficeSectionInput(HttpFlowSecurerSectionSource.INPUT_NAME); } });
}); compiler.office((context) -> { context.getOfficeArchitect().enableAutoWireTeams(); context.addSection("SECTION", sectionLogicClass); OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); mos.addOfficeManagedObject("mo", ManagedObjectScope.THREAD); OfficeManagedObjectPool pool = context.getOfficeArchitect().addManagedObjectPool("POOL", ThreadLocalJdbcConnectionPoolSource.class.getName()); context.getOfficeArchitect().link(mos, pool);
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); if (managedObjectSourceClass == this.getDataSourceManagedObjectSourceClass()) { architect.link(mos, architect.addManagedObjectPool("POOL", ThreadLocalJdbcConnectionPoolSource.class.getName()));
OfficeManagedObjectSource httpChallengeContextMos = this.officeArchitect.addOfficeManagedObjectSource( HttpChallengeContext.class.getSimpleName(), new HttpChallengeContextManagedObjectSource()); OfficeManagedObject httpChallengeContext = httpChallengeContextMos } catch (NoAcceptHandlersException ex) { throw this.officeArchitect .addIssue("Failed to create " + HttpSecurity.class.getSimpleName() + " negotiator", ex); .addOfficeEscalation(AuthenticationRequiredException.class.getName()); OfficeSection handleAuthenticationRequiredSection = this.officeArchitect.addOfficeSection( "AuthenticationRequiredHandler", new HandleAuthenticationRequiredSectionSource(httpSecurityNames, negotiator), null); this.officeArchitect.link( handleAuthenticationRequiredSection.getOfficeSectionObject(HttpChallengeContext.class.getSimpleName()), httpChallengeContext); this.officeArchitect.link(authenticationRequiredEscalation, handleAuthenticationRequiredSection .getOfficeSectionInput(HandleAuthenticationRequiredSectionSource.HANDLE_INPUT)); for (HttpSecurityBuilderImpl<?, ?, ?, ?, ?> security : this.securities) { this.officeArchitect.link(handleAuthenticationRequiredSection.getOfficeSectionOutput(security.name), security.section.getOfficeSectionInput(HttpSecuritySectionSource.INPUT_CHALLENGE)); OfficeManagedObjectSource defaultHttpAuthenticationMos = this.officeArchitect.addOfficeManagedObjectSource( defaultHttpAuthenticationName, new DefaultHttpAuthenticationManagedObjectSource(negotiator, httpSecurityNames)); .addOfficeManagedObject(defaultHttpAuthenticationName, ManagedObjectScope.PROCESS); for (HttpSecurityBuilderImpl<?, ?, ?, ?, ?> security : this.securities) { this.officeArchitect.link(defaultHttpAuthentication.getOfficeManagedObjectDependency(security.name), security.httpAuthentication);
} catch (IllegalArgumentException ex) { architect.addIssue("Invalid managed object scope '" + managedObjectScopeName + "' for managed object " + managedObjectName); return; // invalid managed object so do not load OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource(managedObjectName, managedObjectSourceClassName); OfficeManagedObjectPool pool = architect.addManagedObjectPool(managedObjectName + "_pool", poolModel.getManagedObjectPoolSourceClassName()); this.loadProperties(pool, poolModel.getPropertySources(), context); architect.link(mos, pool); architect.link(mos.getOfficeManagedObjectFlow(flow.getName()), architect.getOfficeSection(flow.getSection()).getOfficeSectionInput(flow.getInput()));
this.officeArchitect.enableAutoWireObjects(); OfficeManagedObjectSource httpSessionMos = this.officeArchitect.addOfficeManagedObjectSource("HTTP_SESSION", HttpSessionManagedObjectSource.class.getName()); httpSessionMos.setTimeout(10 * 1000); // TODO make configurable .addOfficeManagedObjectSource("HTTP_APPLICATION_STATE", new HttpApplicationStateManagedObjectSource(this.contextPath)) .addOfficeManagedObject("HTTP_APPLICATION_STATE", ManagedObjectScope.PROCESS); this.officeArchitect .addOfficeManagedObjectSource("HTTP_REQUEST_STATE", new HttpRequestStateManagedObjectSource(argumentParsers)) .addOfficeManagedObject("HTTP_REQUEST_STATE", ManagedObjectScope.PROCESS); ObjectResponseManagedObjectSource objectResponseMos = new ObjectResponseManagedObjectSource( this.objectResponderFactories); this.officeArchitect.addOfficeManagedObjectSource("OBJECT_RESPONSE", objectResponseMos) .addOfficeManagedObject("OBJECT_RESPONSE", ManagedObjectScope.PROCESS); this.routing.setHttpEscalationHandler(objectResponseMos); this.officeArchitect.link(interceptionOutput, interceptor.flowSinkNode); this.officeArchitect.link(interceptionOutput, routingInput); this.officeArchitect.addManagedFunctionAugmentor((context) -> { ManagedFunctionType<?, ?> functionType = context.getManagedFunctionType(); for (ManagedFunctionObjectType<?> functionParameterType : functionType.getObjectTypes()) { this.officeArchitect.link(chainOutput, servicer.flowSinkNode);
OfficeManagedObjectSource authenticationContextMos = office.addOfficeManagedObjectSource( authenticationContextName, new AuthenticationContextManagedObjectSource<>(this.name, this.security)); authenticationContextMos.setTimeout(this.timeout); office.link(authenticationContextMos.getOfficeManagedObjectFlow("AUTHENTICATE"), this.section.getOfficeSectionInput("ManagedObjectAuthenticate")); office.link(authenticationContextMos.getOfficeManagedObjectFlow("LOGOUT"), this.section.getOfficeSectionInput("ManagedObjectLogout")); OfficeManagedObject authenticationContext = authenticationContextMos OfficeManagedObjectSource authenticationMos = office.addOfficeManagedObjectSource(authenticationName, new AuthenticationManagedObjectSource<>(this.name, this.security, this.type)); OfficeManagedObject authentication = authenticationMos.addOfficeManagedObject(authenticationName, ManagedObjectScope.PROCESS); office.link(authentication.getOfficeManagedObjectDependency("AUTHENTICATION_CONTEXT"), authenticationContext); } else { String httpAuthenticationName = this.name + "_HttpAuthentication"; OfficeManagedObjectSource httpAuthenticationMos = office.addOfficeManagedObjectSource( httpAuthenticationName, new HttpAuthenticationManagedObjectSource<>(this.type)); this.httpAuthentication = httpAuthenticationMos.addOfficeManagedObject(httpAuthenticationName, ManagedObjectScope.PROCESS); office.link(this.httpAuthentication.getOfficeManagedObjectDependency("AUTHENTICATION"), authentication); OfficeManagedObjectSource accessControlMos = office.addOfficeManagedObjectSource(accessControlName, new AccessControlManagedObjectSource<>(this.name, accessControlType)); accessControlMos.setTimeout(this.timeout);
/** * Instantiate. * * @param securityName {@link HttpSecurity} name. * @param properties {@link PropertyList}. */ private HttpSecurityBuilderImpl(String securityName, HttpSecuritySource<A, AC, C, O, F> securitySource, PropertyList properties) { this.name = securityName; this.source = securitySource; this.properties = properties; // Create the section for the HTTP Security this.section = HttpSecurityArchitectEmployer.this.officeArchitect .addOfficeSection(securityName + "_HttpSecurity", new HttpSecuritySectionSource<>(this), null); }
@Override public CompileError addIssue(String issueDescription) { return officeArchitect.addIssue(issueDescription); } };
@Override public void loadWoofTeamsUsage(WoofTeamsUsageContext context) throws Exception { // Obtain the architect and extension context OfficeArchitect architect = context.getOfficeArchitect(); // Load the teams this.loadWoofTeams(() -> context.getConfiguration(), () -> architect.enableAutoWireTeams(), (teamName, teamSize, teamSourceClassName, typeQualifications, teamModel) -> { // Add the team OfficeTeam team = architect.addOfficeTeam(teamName); // Load the type qualification for (AutoWire autoWire : typeQualifications) { team.addTypeQualification(autoWire.getQualifier(), autoWire.getType()); } }); }
administration = this.officeArchitect.addOfficeAdministration(key.getName(), new HttpAccessAdministrationSource(anyRoles, allRoles)); administrators.put(key, administration); throw this.officeArchitect.addIssue("No " + HttpSecurity.class.getSimpleName() + " configured for qualifier '" + httpSecurityName + "'");
sections.linkToSectionInput(() -> officeArchitect.addOfficeEscalation(exceptionClassName), exceptionModel.getWoofSectionInput(), (link) -> link.getWoofSectionInput()); templates.linkToTemplate(() -> officeArchitect.addOfficeEscalation(exceptionClassName), exceptionModel.getWoofTemplate(), (link) -> link.getWoofTemplate(), exceptionClassName); securities.linkToSecurity(() -> officeArchitect.addOfficeEscalation(exceptionClassName), exceptionModel.getWoofSecurity(), (link) -> link.getWoofSecurity()); resources.linkToResource(() -> officeArchitect.addOfficeEscalation(exceptionClassName), exceptionModel.getWoofResource(), (link) -> link.getWoofResource()); httpContinuations.linkToHttpContinuation(() -> officeArchitect.addOfficeEscalation(exceptionClassName), exceptionModel.getWoofHttpContinuation(), (link) -> link.getWoofHttpContinuation(), exceptionClassName); sections.linkToSectionInput(() -> officeArchitect.addOfficeStart(String.valueOf(startIndex[0]++)), startModel.getWoofSectionInput(), (link) -> link.getWoofSectionInput()); OfficeGovernance governance = officeArchitect.addOfficeGovernance(governanceName, governanceSourceClassName); for (PropertyModel property : govModel.getProperties()) {
}); compiler.office((context) -> { context.getOfficeArchitect().enableAutoWireTeams(); context.addSection("SECTION", sectionLogicClass); context.addManagedObject("tag", NewThread.class, ManagedObjectScope.THREAD); OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", managedObjectSourceClass.getName()); mos.addOfficeManagedObject("mo", ManagedObjectScope.THREAD); OfficeManagedObjectPool pool = context.getOfficeArchitect().addManagedObjectPool("POOL", ThreadLocalJdbcConnectionPoolSource.class.getName()); context.getOfficeArchitect().link(mos, pool);
OfficeManagedObjectSource mos = architect.addOfficeManagedObjectSource("mo", this.getConnectionManagedObjectSourceClass().getName()); this.loadConnectionProperties(mos); architect.link(mos, architect.addManagedObjectPool("POOL", ThreadLocalJdbcConnectionPoolSource.class.getName()));
@Override protected WebTemplate addTemplate(boolean isSecure, String applicationPath, PropertyList properties) { // Add the section for the template WebTemplateSectionSource webTemplateSectionSource = new WebTemplateSectionSource(); OfficeSection templateSection = this.officeArchitect.addOfficeSection(applicationPath, webTemplateSectionSource, applicationPath); // Add the template WebTemplateImpl template = new WebTemplateImpl(isSecure, applicationPath, webTemplateSectionSource, templateSection, properties); this.templates.add(template); // Return the template return template; }
this.officeArchitect.addIssue("Parameter must be " + String.class.getName() + " but was " + objectType.getName() + " for function " + context.getManagedFunctionName());
}); compile.office((context) -> { context.getOfficeArchitect().enableAutoWireTeams(); context.addManagedObject("tag", NewThread.class, ManagedObjectScope.THREAD); .addOfficeManagedObjectSource("connection", ConnectionManagedObjectSource.class.getName()); this.loadDatabaseProperties(connectionMos); connectionMos.addOfficeManagedObject("connection", ManagedObjectScope.THREAD); OfficeManagedObjectPool pool = context.getOfficeArchitect().addManagedObjectPool("POOL", ThreadLocalJdbcConnectionPoolSource.class.getName()); context.getOfficeArchitect().link(connectionMos, pool); .addOfficeManagedObjectSource("dataSource", DataSourceManagedObjectSource.class.getName()); this.loadDatabaseProperties(dataSourceMos); dataSourceMos.addOfficeManagedObject("dataSource", ManagedObjectScope.THREAD); OfficeManagedObjectSource jpaMos = context.getOfficeArchitect().addOfficeManagedObjectSource("JPA", this.getJpaManagedObjectSourceClass().getName()); this.loadJpaProperties(jpaMos);
OfficeManagedObjectSource mos = context.getOfficeArchitect().addOfficeManagedObjectSource("mo", connectionMosClass.getName()); propertyLoader.accept(mos); OfficeManagedObjectPool pool = context.getOfficeArchitect().addManagedObjectPool("POOL", new GetConnectionManagedObjectPoolSource()); context.getOfficeArchitect().link(mos, pool); }); OfficeFloor officeFloor = compiler.compileAndOpenOfficeFloor();