use of org.structr.core.Services in project structr by structr.
the class IndexingTest method start.
@BeforeClass
public static void start() {
Services.enableUpdateIndexConfiguration();
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService HttpService SchemaService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet");
Settings.RestAuthenticator.setValue(SuperUserAuthenticator.class.getName());
Settings.RestResourceProvider.setValue(DefaultResourceProvider.class.getName());
Settings.RestServletPath.setValue(restUrl);
Settings.RestUserClass.setValue("");
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
sleep(10000L);
}
use of org.structr.core.Services in project structr by structr.
the class StructrGraphQLTest method start.
@BeforeClass
public static void start() {
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService HttpService SchemaService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("GraphQLServlet");
Settings.GraphQLAuthenticator.setValue(SuperUserAuthenticator.class.getName());
Settings.GraphQLResourceProvider.setValue(DefaultResourceProvider.class.getName());
Settings.GraphQLServletPath.setValue(restUrl);
// Settings.LogSchemaOutput.setValue(true);
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
// sleep again to wait for schema initialization
try {
Thread.sleep(2000);
} catch (Throwable t) {
}
}
use of org.structr.core.Services in project structr by structr.
the class LicensingTest method startSystem.
@BeforeClass
public static void startSystem() {
Services.disableTestingMode();
final Date now = new Date();
final long timestamp = now.getTime();
basePath = "/tmp/structr-test-" + timestamp;
Settings.Services.setValue("NodeService LogService SchemaService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
}
use of org.structr.core.Services in project structr by structr.
the class RestAuthenticator method initializeAndExamineRequest.
// ~--- methods --------------------------------------------------------
/**
* Examine request and try to find a user.
*
* First, check session id, then try external (OAuth) authentication,
* finally, check standard login by credentials.
*
* @param request
* @param response
* @return security context
* @throws FrameworkException
*/
@Override
public SecurityContext initializeAndExamineRequest(final HttpServletRequest request, final HttpServletResponse response) throws FrameworkException {
SecurityContext securityContext;
Principal user = SessionHelper.checkSessionAuthentication(request);
if (user == null) {
user = getUser(request, true);
}
if (user == null) {
// If no user could be determined, assume frontend access
securityContext = SecurityContext.getInstance(user, request, AccessMode.Frontend);
} else {
if (user instanceof SuperUser) {
securityContext = SecurityContext.getSuperUserInstance(request);
} else {
securityContext = SecurityContext.getInstance(user, request, AccessMode.Backend);
SessionHelper.clearInvalidSessions(user);
}
}
securityContext.setAuthenticator(this);
// Check CORS settings (Cross-origin resource sharing, see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
final String origin = request.getHeader("Origin");
if (!StringUtils.isBlank(origin)) {
final Services services = Services.getInstance();
response.setHeader("Access-Control-Allow-Origin", origin);
// allow cross site resource sharing (read only)
final String maxAge = Settings.AccessControlMaxAge.getValue();
if (StringUtils.isNotBlank(maxAge)) {
response.setHeader("Access-Control-MaxAge", maxAge);
}
final String allowMethods = Settings.AccessControlAllowMethods.getValue();
if (StringUtils.isNotBlank(allowMethods)) {
response.setHeader("Access-Control-Allow-Methods", allowMethods);
}
final String allowHeaders = Settings.AccessControlAllowHeaders.getValue();
if (StringUtils.isNotBlank(allowHeaders)) {
response.setHeader("Access-Control-Allow-Headers", allowHeaders);
}
final String allowCredentials = Settings.AccessControlAllowCredentials.getValue();
if (StringUtils.isNotBlank(allowCredentials)) {
response.setHeader("Access-Control-Allow-Credentials", allowCredentials);
}
final String exposeHeaders = Settings.AccessControlExposeHeaders.getValue();
if (StringUtils.isNotBlank(exposeHeaders)) {
response.setHeader("Access-Control-Expose-Headers", exposeHeaders);
}
}
examined = true;
return securityContext;
}
use of org.structr.core.Services in project structr by structr.
the class HtmlServletObjectResolvingTest method start.
public static void start(final Map<String, Object> additionalConfig) {
final long timestamp = System.currentTimeMillis();
basePath = "/tmp/structr-test-" + timestamp + "-" + System.nanoTime();
Settings.HtmlResolveProperties.setValue("TestOne.anInt, TestOne.aString, TestOne.aDouble");
Settings.Services.setValue("NodeService HttpService SchemaService");
Settings.ConnectionUrl.setValue(Settings.TestingConnectionUrl.getValue());
// example for new configuration setup
Settings.BasePath.setValue(basePath);
Settings.DatabasePath.setValue(basePath + "/db");
Settings.FilesPath.setValue(basePath + "/files");
Settings.RelationshipCacheSize.setValue(1000);
Settings.NodeCacheSize.setValue(1000);
Settings.SuperUserName.setValue("superadmin");
Settings.SuperUserPassword.setValue("sehrgeheim");
Settings.ApplicationTitle.setValue("structr unit test app" + timestamp);
Settings.ApplicationHost.setValue(host);
Settings.HttpPort.setValue(httpPort);
Settings.Servlets.setValue("JsonRestServlet WebSocketServlet HtmlServlet");
final Services services = Services.getInstance();
// wait for service layer to be initialized
do {
try {
Thread.sleep(100);
} catch (Throwable t) {
}
} while (!services.isInitialized());
securityContext = SecurityContext.getSuperUserInstance();
app = StructrApp.getInstance(securityContext);
graphDbCommand = app.command(GraphDatabaseCommand.class);
}
Aggregations