Removed files not in gitignore

This commit is contained in:
Norbi Peti 2016-07-28 09:23:37 +02:00
parent aa5873963d
commit 73ef29e2df
35 changed files with 1409 additions and 2014 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.BROWSER_CONTAINER/Browser SDK"/>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.JSNATIVE_CONTAINER/JS Native Types"/>
<buildpathentry kind="con" path="org.eclipse.dltk.mod.launching.INTERPRETER_CONTAINER"/>
<buildpathentry kind="src" path="src"/>
</buildpath>
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.BROWSER_CONTAINER/Browser SDK"/>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.JSNATIVE_CONTAINER/JS Native Types"/>
<buildpathentry kind="con" path="org.eclipse.dltk.mod.launching.INTERPRETER_CONTAINER"/>
<buildpathentry kind="src" path="src"/>
</buildpath>

View file

@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="main/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View file

@ -1,29 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ChatServer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.vjet.eclipse.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.vjet.core.nature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ChatServer</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.vjet.eclipse.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.vjet.core.nature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,106 +1,106 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.8

View file

@ -1,2 +1,2 @@
eclipse.preferences.version=1
initialized_project_from_v4classpath=true
eclipse.preferences.version=1
initialized_project_from_v4classpath=true

View file

@ -1,17 +1,17 @@
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.rootLogger=debug, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

View file

@ -1,12 +1,12 @@
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ChatServerPU">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:chatserver;create=true" /><property
name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ChatServerPU">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:chatserver;create=true" /><property
name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>

View file

@ -1,10 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="SpellCheckingInspection" enabled="true" level="TYPO" enabled_by_default="true">
<option name="processCode" value="false" />
<option name="processLiterals" value="false" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

View file

@ -1,7 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pages.iml" filepath="$PROJECT_DIR$/.idea/pages.iml" />
</modules>
</component>
</project>

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>

View file

@ -1,566 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="588ba1ca-220a-4913-8e8c-5657fa1c845f" name="Default" comment="">
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/css/style.css" afterPath="$PROJECT_DIR$/css/style.css" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/index.html" afterPath="$PROJECT_DIR$/index.html" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/js/login.js" afterPath="$PROJECT_DIR$/js/login.js" />
</list>
<ignored path="pages.iws" />
<ignored path=".idea/workspace.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
<component name="CreatePatchCommitExecutor">
<option name="PATCH_PATH" value="" />
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="pages" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="index.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1043">
<caret line="82" column="30" selection-start-line="82" selection-start-column="30" selection-end-line="82" selection-end-column="30" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="jquery-3.1.0.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/jquery-3.1.0.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="login.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/login.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
<folding>
<element signature="n#!!doc;n#login#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="utils.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/utils.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding>
<element signature="n#!!doc;n#getFormData#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="style.css" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/css/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="91">
<caret line="19" column="24" selection-start-line="19" selection-start-column="24" selection-end-line="19" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="register.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/js/register.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
<folding>
<element signature="n#!!doc;n#register#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="notfound.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/notfound.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="message.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/js/message.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="JavaScript File" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/userbox.js" />
<option value="$PROJECT_DIR$/userbox.html" />
<option value="$PROJECT_DIR$/js/userbox.js" />
<option value="$PROJECT_DIR$/js/message.js" />
<option value="$PROJECT_DIR$/register.html" />
<option value="$PROJECT_DIR$/js/utils.js" />
<option value="$PROJECT_DIR$/js/register.js" />
<option value="$PROJECT_DIR$/js/login.js" />
<option value="$PROJECT_DIR$/css/style.css" />
<option value="$PROJECT_DIR$/index.html" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" />
<component name="JsBuildToolPackageJson" detection-done="true" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="-8" />
<option name="y" value="-8" />
<option name="width" value="1936" />
<option name="height" value="1056" />
</component>
<component name="ProjectInspectionProfilesVisibleTreeState">
<entry key="Project Default">
<profile-state>
<expanded-state>
<State>
<id />
</State>
<State>
<id>Spelling</id>
</State>
</expanded-state>
<selected-state>
<State>
<id>SpellCheckingInspection</id>
</State>
</selected-state>
</profile-state>
</entry>
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<OptionsSetting value="true" id="Add" />
<OptionsSetting value="true" id="Remove" />
<OptionsSetting value="true" id="Checkout" />
<OptionsSetting value="true" id="Update" />
<OptionsSetting value="true" id="Status" />
<OptionsSetting value="true" id="Edit" />
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="js" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="pages" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="css" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="HbShouldOpenHtmlAsHb" value="" />
<property name="settings.editor.selected.configurable" value="preferences.toDoOptions" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth0" value="72" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder0" value="0" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth1" value="72" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder1" value="1" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth2" value="72" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder2" value="2" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatWidth3" value="709" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_flatOrder3" value="3" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth0" value="73" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder0" value="0" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth1" value="62" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder1" value="1" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth2" value="68" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder2" value="2" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeWidth3" value="722" />
<property name="FileHistory.git4idea.history.GitHistoryProvider_treeOrder3" value="3" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\Norbert_Szatmari\workspace\chatserver\pages\js" />
</key>
</component>
<component name="RunManager" selected="JavaScript Debug.index.html">
<configuration default="false" name="message.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-node="project" path-to-js-file="message.js" working-dir="$PROJECT_DIR$/js">
<method />
</configuration>
<configuration default="false" name="index.html" type="JavascriptDebugType" factoryName="JavaScript Debug" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/pages/index.html">
<method />
</configuration>
<configuration default="true" type="DartCommandLineRunConfigurationType" factoryName="Dart Command Line Application">
<method />
</configuration>
<configuration default="true" type="DartTestRunConfigurationType" factoryName="Dart Test">
<method />
</configuration>
<configuration default="true" type="JavaScriptTestRunnerKarma" factoryName="Karma">
<config-file value="" />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
<configuration default="true" type="JavascriptDebugType" factoryName="JavaScript Debug">
<method />
</configuration>
<configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" path-to-node="project" working-dir="">
<method />
</configuration>
<configuration default="true" type="cucumber.js" factoryName="Cucumber.js">
<option name="cucumberJsArguments" value="" />
<option name="executablePath" />
<option name="filePath" />
<method />
</configuration>
<configuration default="true" type="js.build_tools.gulp" factoryName="Gulp.js">
<node-interpreter>project</node-interpreter>
<node-options />
<gulpfile />
<tasks />
<arguments />
<envs />
<method />
</configuration>
<configuration default="true" type="js.build_tools.npm" factoryName="npm">
<command value="run-script" />
<scripts />
<node-interpreter value="project" />
<envs />
<method />
</configuration>
<configuration default="true" type="mocha-javascript-test-runner" factoryName="Mocha">
<node-interpreter>project</node-interpreter>
<node-options />
<working-directory />
<pass-parent-env>true</pass-parent-env>
<envs />
<ui>bdd</ui>
<extra-mocha-options />
<test-kind>DIRECTORY</test-kind>
<test-directory />
<recursive>false</recursive>
<method />
</configuration>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="Node.js.message.js" />
<item index="1" class="java.lang.String" itemvalue="JavaScript Debug.index.html" />
</list>
<recent_temporary>
<list size="2">
<item index="0" class="java.lang.String" itemvalue="JavaScript Debug.index.html" />
<item index="1" class="java.lang.String" itemvalue="Node.js.message.js" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="SpellCheckerSettings" BundledDictionaries="1" BundledDictionary0="english.dic" Folders="0" Dictionaries="0" />
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="588ba1ca-220a-4913-8e8c-5657fa1c845f" name="Default" comment="" />
<created>1469522327377</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1469522327377</updated>
<workItem from="1469522328775" duration="6392000" />
<workItem from="1469535953166" duration="2597000" />
<workItem from="1469602650261" duration="15397000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="24386000" />
</component>
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.18020834" sideWeight="0.5" order="1" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32911393" sideWeight="0.50416666" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32911393" sideWeight="0.49583334" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32911393" sideWeight="0.49583334" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="Vcs.Log.UiProperties">
<option name="RECENTLY_FILTERED_USER_GROUPS">
<collection />
</option>
<option name="RECENTLY_FILTERED_BRANCH_GROUPS">
<collection />
</option>
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="15" column="59" selection-start-line="15" selection-start-column="59" selection-end-line="15" selection-end-column="59" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/login.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="34">
<caret line="4" column="26" selection-start-line="4" selection-start-column="26" selection-end-line="4" selection-end-column="26" />
<folding>
<element signature="n#!!doc;n#login#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/register.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="55" selection-start-line="16" selection-start-column="55" selection-end-line="16" selection-end-column="55" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/notfound.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/message.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/userbox.js" />
<entry file="file://$PROJECT_DIR$/register.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="16" column="55" selection-start-line="16" selection-start-column="55" selection-end-line="16" selection-end-column="55" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/notfound.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/message.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/userbox.html" />
<entry file="file://$PROJECT_DIR$/js/userbox.js" />
<entry file="file://$PROJECT_DIR$/js/jquery-3.1.0.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/message.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="0" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/register.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="68">
<caret line="4" column="27" selection-start-line="4" selection-start-column="27" selection-end-line="4" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/utils.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="187">
<caret line="13" column="0" selection-start-line="13" selection-start-column="0" selection-end-line="13" selection-end-column="0" />
<folding>
<element signature="n#!!doc;n#getFormData#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/notfound.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/css/style.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="91">
<caret line="19" column="24" selection-start-line="19" selection-start-column="24" selection-end-line="19" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1043">
<caret line="82" column="30" selection-start-line="82" selection-start-column="30" selection-end-line="82" selection-end-column="30" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/login.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="153">
<caret line="11" column="13" selection-start-line="11" selection-start-column="13" selection-end-line="11" selection-end-column="13" />
<folding>
<element signature="n#!!doc;n#login#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/js/register.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="17" column="0" selection-start-line="17" selection-start-column="0" selection-end-line="17" selection-end-column="0" />
<folding>
<element signature="n#!!doc;n#register#0" expanded="false" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

View file

@ -1,44 +1,44 @@
body {
background-color: #EEE;
}
#errormsg, #successmsg {
display: none;
}
#errormsg {
background-color: #8c0000;
border-color: #ff0000;
border-style: solid;
border-width: 2px;
color: #ff0000;
}
#successmsg {
background-color: #188c00;
border-color: #00ff00;
border-style: solid;
border-width: 2px;
color: #00ff00;
}
#sidebar {
float: right;
width: 300px;
}
#loginregisterbox {
margin: auto;
width: 300px;
}
#usercontent {
margin: auto;
width: 75%;
}
#msginput {
width: 100%;
height: 30px;
max-width: 100%;
body {
background-color: #EEE;
}
#errormsg, #successmsg {
display: none;
}
#errormsg {
background-color: #8c0000;
border-color: #ff0000;
border-style: solid;
border-width: 2px;
color: #ff0000;
}
#successmsg {
background-color: #188c00;
border-color: #00ff00;
border-style: solid;
border-width: 2px;
color: #00ff00;
}
#sidebar {
float: right;
width: 300px;
}
#loginregisterbox {
margin: auto;
width: 300px;
}
#usercontent {
margin: auto;
width: 75%;
}
#msginput {
width: 100%;
height: 30px;
max-width: 100%;
}

View file

@ -1,86 +1,86 @@
<!DOCTYPE html>
<head>
<title>ChatServer</title>
<script src="js/jquery-3.1.0.js"></script>
<script src="js/utils.js"></script>
<script src="js/message.js"></script>
<script src="js/login.js"></script>
<script src="js/register.js"></script>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div id="errormsg">
</div>
<div id="sidebar">
<div id="userbox">
Logged in as
<username/>
</div>
</div>
<div id="loginregisterbox">
<div id="loginbox">
<h2>Login</h2>
<form>
<table>
<tr>
<td>E-mail:</td>
<td>
<input type="email" name="email">
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td>
<input type="button" value="Login" onclick="login(this.form)">
</td>
</tr>
</table>
</form>
</div>
<div id="registerbox">
<h2>Register</h2>
<form>
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="name"/>
</td>
</tr>
<tr>
<td>E-mail:</td>
<td>
<input type="email" name="email"/>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="pass"/>
</td>
</tr>
<tr>
<td>Password confirm</td>
<td>
<input type="password" name="pass2"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="Register" onclick="register(this.form)"/>
</td>
</tr>
</table>
</form>
</div>
</div>
<div id="usercontent">
<div id="channelmessages"></div>
<textarea id="msginput"></textarea>
</div>
</body>
<!DOCTYPE html>
<head>
<title>ChatServer</title>
<script src="js/jquery-3.1.0.js"></script>
<script src="js/utils.js"></script>
<script src="js/message.js"></script>
<script src="js/login.js"></script>
<script src="js/register.js"></script>
<link rel="stylesheet" href="css/style.css"/>
</head>
<body>
<div id="errormsg">
</div>
<div id="sidebar">
<div id="userbox">
Logged in as
<username/>
</div>
</div>
<div id="loginregisterbox">
<div id="loginbox">
<h2>Login</h2>
<form>
<table>
<tr>
<td>E-mail:</td>
<td>
<input type="email" name="email">
</td>
</tr>
<tr>
<td>Password:</td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td>
<input type="button" value="Login" onclick="login(this.form)">
</td>
</tr>
</table>
</form>
</div>
<div id="registerbox">
<h2>Register</h2>
<form>
<table>
<tr>
<td>Name:</td>
<td>
<input type="text" name="name"/>
</td>
</tr>
<tr>
<td>E-mail:</td>
<td>
<input type="email" name="email"/>
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="pass"/>
</td>
</tr>
<tr>
<td>Password confirm</td>
<td>
<input type="password" name="pass2"/>
</td>
</tr>
<tr>
<td>
<input type="button" value="Register" onclick="register(this.form)"/>
</td>
</tr>
</table>
</form>
</div>
</div>
<div id="usercontent">
<div id="channelmessages"></div>
<textarea id="msginput"></textarea>
</div>
</body>

View file

@ -1,17 +1,17 @@
/**
* Created by Norbi on 2016-07-26.
*/
function login(form) { //TODO: Detect Enter
var json = JSON.stringify(getFormData($(form)));
$.ajax({
url: "/login", data: json, method: "POST", success: function (result) {
if (result != "Success") {
var errormsg = document.getElementById("errormsg");
errormsg.innerHTML = result;
errormsg.style = "display: block";
}
else
location.reload(true);
}
});
}
/**
* Created by Norbi on 2016-07-26.
*/
function login(form) { //TODO: Detect Enter
var json = JSON.stringify(getFormData($(form)));
$.ajax({
url: "/login", data: json, method: "POST", success: function (result) {
if (result != "Success") {
var errormsg = document.getElementById("errormsg");
errormsg.innerHTML = result;
errormsg.style = "display: block";
}
else
location.reload(true);
}
});
}

View file

@ -1,4 +1,4 @@
$('#msginput').keypress(function(e) {
if (e.which == '\r'.charCodeAt(0))
document.write(document.getElementById("msginput").value);
});
$('#msginput').keypress(function(e) {
if (e.which == '\r'.charCodeAt(0))
document.write(document.getElementById("msginput").value);
});

View file

@ -1,17 +1,17 @@
/**
* Created by Norbi on 2016-07-27.
*/
function register(form) {
var json = JSON.stringify(getFormData($(form)));
$.ajax({
url: "/register", data: json, method: "POST", success: function (result) {
if (result != "Success") {
var errormsg = document.getElementById("errormsg");
errormsg.innerHTML = result;
errormsg.style = "display: block";
}
else
location.reload(true);
}
});
}
/**
* Created by Norbi on 2016-07-27.
*/
function register(form) {
var json = JSON.stringify(getFormData($(form)));
$.ajax({
url: "/register", data: json, method: "POST", success: function (result) {
if (result != "Success") {
var errormsg = document.getElementById("errormsg");
errormsg.innerHTML = result;
errormsg.style = "display: block";
}
else
location.reload(true);
}
});
}

View file

@ -1,13 +1,13 @@
/**
* Created by Norbi on 2016-07-27.
*/
function getFormData($form) {
var unindexed_array = $form.serializeArray();
var indexed_array = {};
$.map(unindexed_array, function (n, i) {
indexed_array[n['name']] = n['value'];
});
return indexed_array;
}
/**
* Created by Norbi on 2016-07-27.
*/
function getFormData($form) {
var unindexed_array = $form.serializeArray();
var indexed_array = {};
$.map(unindexed_array, function (n, i) {
indexed_array[n['name']] = n['value'];
});
return indexed_array;
}

View file

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<h1>404 Not found</h1>
<p>The requested page cannot be found.</p>
</html>
<!DOCTYPE html>
<html>
<h1>404 Not found</h1>
<p>The requested page cannot be found.</p>
</html>

154
pom.xml
View file

@ -1,78 +1,78 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ChatServer</groupId>
<artifactId>ChatServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.12.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ChatServer</groupId>
<artifactId>ChatServer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.12.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.12.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.1.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<scope>runtime</scope>
</dependency>
<dependency>
<!-- jsoup HTML parser library @ http://jsoup.org/ -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20160212</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>

View file

@ -1,178 +1,178 @@
package io.github.norbipeti.chat.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.UUID;
import java.util.function.Function;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
import io.github.norbipeti.chat.server.page.Page;
public class IOHelper {
public static void SendResponse(int code, String content, HttpExchange exchange) throws IOException {
exchange.sendResponseHeaders(code, content.length());
IOUtils.write(content, exchange.getResponseBody(), StandardCharsets.UTF_8);
exchange.getResponseBody().close();
}
public static boolean SendPage(int code, Page page, HttpExchange exchange) throws IOException {
String content = GetPage(page, exchange);
SendResponse(code, content, exchange);
return true;
}
public static String GetPage(Page page, HttpExchange exchange) throws IOException {
File file = new File(page.GetHTMLPath());
if (!file.exists()) {
SendResponse(501,
"<h1>501 Not Implemented</h1><p>The page \"" + page.GetName() + "\" cannot be found on disk.</h1>",
exchange);
return null;
}
return ReadFile(file);
}
public static String ReadFile(File file) throws FileNotFoundException, IOException {
FileInputStream inputStream = new FileInputStream(file);
String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
return content;
}
@Deprecated
public static HashMap<String, String> GetPOST(HttpExchange exchange) throws IOException {
if (exchange.getRequestBody().available() == 0)
return new HashMap<>();
try {
String[] content = IOUtils.toString(exchange.getRequestBody(), StandardCharsets.ISO_8859_1).split("\\&");
HashMap<String, String> vars = new HashMap<>();
for (String var : content) {
String[] spl = var.split("\\=");
if (spl.length == 1)
vars.put(spl[0], "");
else
vars.put(spl[0], spl[1]);
}
return vars;
} catch (Exception e) {
e.printStackTrace();
return new HashMap<>();
}
}
public static JSONObject GetPOSTJSON(HttpExchange exchange) throws IOException {
if (exchange.getRequestBody().available() == 0)
return null;
try {
String content = IOUtils.toString(exchange.getRequestBody(), StandardCharsets.ISO_8859_1);
JSONObject obj = new JSONObject(content);
return obj;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean SendModifiedPage(int code, Page page, Function<Document, Document> modifyfunc,
HttpExchange exchange) throws IOException {
String content = GetPage(page, exchange);
if (content == null)
return false;
Document doc = Jsoup.parse(content);
doc = modifyfunc.apply(doc);
SendResponse(200, doc.html(), exchange);
return true;
}
public static void LoginUser(HttpExchange exchange, User user, DataProvider provider) {
provider.SetValues(() -> user.setSessionid(UUID.randomUUID()));
System.out.println("Logging in user: " + user);
ZonedDateTime expiretime = ZonedDateTime.now(ZoneId.of("GMT")).plus(Period.of(2, 0, 0));
exchange.getResponseHeaders().add("Set-Cookie",
"user_id=" + user.getId() + "; expires=" + expiretime.format(DateTimeFormatter.RFC_1123_DATE_TIME));
exchange.getResponseHeaders().add("Set-Cookie",
"session_id=" + user.getSessionid() + "; expires=" + expiretime);
}
public static void LogoutUser(HttpExchange exchange, User user) {
user.setSessionid(new UUID(0, 0));
SendLogoutHeaders(exchange);
}
private static void SendLogoutHeaders(HttpExchange exchange) {
String expiretime = "Sat, 19 Mar 2016 23:33:00 GMT";
exchange.getResponseHeaders().add("Set-Cookie", "user_id=del; expires=" + expiretime);
exchange.getResponseHeaders().add("Set-Cookie", "session_id=del; expires=" + expiretime);
}
public static void Redirect(String url, HttpExchange exchange) throws IOException {
exchange.getResponseHeaders().add("Location", url);
IOHelper.SendResponse(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange);
}
public static HashMap<String, String> GetCookies(HttpExchange exchange) {
if (!exchange.getRequestHeaders().containsKey("Cookie"))
return new HashMap<>();
HashMap<String, String> map = new HashMap<>();
for (String cheader : exchange.getRequestHeaders().get("Cookie")) {
String[] spl = cheader.split("\\;\\s*");
for (String s : spl) {
String[] kv = s.split("\\=");
if (kv.length < 2)
continue;
map.put(kv[0], kv[1]);
}
}
return map;
}
/**
* Get logged in user. It may also send logout headers if the cookies are
* invalid.
*
* @param exchange
* @return The logged in user or null if not logged in.
*/
public static User GetLoggedInUser(HttpExchange exchange) {
HashMap<String, String> cookies = GetCookies(exchange);
System.out.println("Cookies: " + cookies);
if (!cookies.containsKey("user_id") || !cookies.containsKey("session_id"))
return null;
System.out.println("Cookies found");
try (DataProvider provider = new DataProvider()) {
User user = provider.getUser(Long.parseLong(cookies.get("user_id")));
System.out.println("User: " + user);
System.out.println("session_id: " + cookies.get("session_id"));
if (user != null)
System.out.println("Equals: " + UUID.fromString(cookies.get("session_id")).equals(user.getSessionid()));
if (user != null && cookies.get("session_id") != null
&& UUID.fromString(cookies.get("session_id")).equals(user.getSessionid()))
return user;
else
SendLogoutHeaders(exchange);
}
return null;
}
public static void SendResponse(int code, Function<Document, Document> action, HttpExchange exchange)
throws IOException {
Document doc = new Document("");
doc = action.apply(doc);
SendResponse(200, doc.html(), exchange);
}
}
package io.github.norbipeti.chat.server;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.Period;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.UUID;
import java.util.function.Function;
import org.apache.commons.io.IOUtils;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
import io.github.norbipeti.chat.server.page.Page;
public class IOHelper {
public static void SendResponse(int code, String content, HttpExchange exchange) throws IOException {
exchange.sendResponseHeaders(code, content.length());
IOUtils.write(content, exchange.getResponseBody(), StandardCharsets.UTF_8);
exchange.getResponseBody().close();
}
public static boolean SendPage(int code, Page page, HttpExchange exchange) throws IOException {
String content = GetPage(page, exchange);
SendResponse(code, content, exchange);
return true;
}
public static String GetPage(Page page, HttpExchange exchange) throws IOException {
File file = new File(page.GetHTMLPath());
if (!file.exists()) {
SendResponse(501,
"<h1>501 Not Implemented</h1><p>The page \"" + page.GetName() + "\" cannot be found on disk.</h1>",
exchange);
return null;
}
return ReadFile(file);
}
public static String ReadFile(File file) throws FileNotFoundException, IOException {
FileInputStream inputStream = new FileInputStream(file);
String content = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
return content;
}
@Deprecated
public static HashMap<String, String> GetPOST(HttpExchange exchange) throws IOException {
if (exchange.getRequestBody().available() == 0)
return new HashMap<>();
try {
String[] content = IOUtils.toString(exchange.getRequestBody(), StandardCharsets.ISO_8859_1).split("\\&");
HashMap<String, String> vars = new HashMap<>();
for (String var : content) {
String[] spl = var.split("\\=");
if (spl.length == 1)
vars.put(spl[0], "");
else
vars.put(spl[0], spl[1]);
}
return vars;
} catch (Exception e) {
e.printStackTrace();
return new HashMap<>();
}
}
public static JSONObject GetPOSTJSON(HttpExchange exchange) throws IOException {
if (exchange.getRequestBody().available() == 0)
return null;
try {
String content = IOUtils.toString(exchange.getRequestBody(), StandardCharsets.ISO_8859_1);
JSONObject obj = new JSONObject(content);
return obj;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static boolean SendModifiedPage(int code, Page page, Function<Document, Document> modifyfunc,
HttpExchange exchange) throws IOException {
String content = GetPage(page, exchange);
if (content == null)
return false;
Document doc = Jsoup.parse(content);
doc = modifyfunc.apply(doc);
SendResponse(200, doc.html(), exchange);
return true;
}
public static void LoginUser(HttpExchange exchange, User user, DataProvider provider) {
provider.SetValues(() -> user.setSessionid(UUID.randomUUID()));
System.out.println("Logging in user: " + user);
ZonedDateTime expiretime = ZonedDateTime.now(ZoneId.of("GMT")).plus(Period.of(2, 0, 0));
exchange.getResponseHeaders().add("Set-Cookie",
"user_id=" + user.getId() + "; expires=" + expiretime.format(DateTimeFormatter.RFC_1123_DATE_TIME));
exchange.getResponseHeaders().add("Set-Cookie",
"session_id=" + user.getSessionid() + "; expires=" + expiretime);
}
public static void LogoutUser(HttpExchange exchange, User user) {
user.setSessionid(new UUID(0, 0));
SendLogoutHeaders(exchange);
}
private static void SendLogoutHeaders(HttpExchange exchange) {
String expiretime = "Sat, 19 Mar 2016 23:33:00 GMT";
exchange.getResponseHeaders().add("Set-Cookie", "user_id=del; expires=" + expiretime);
exchange.getResponseHeaders().add("Set-Cookie", "session_id=del; expires=" + expiretime);
}
public static void Redirect(String url, HttpExchange exchange) throws IOException {
exchange.getResponseHeaders().add("Location", url);
IOHelper.SendResponse(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange);
}
public static HashMap<String, String> GetCookies(HttpExchange exchange) {
if (!exchange.getRequestHeaders().containsKey("Cookie"))
return new HashMap<>();
HashMap<String, String> map = new HashMap<>();
for (String cheader : exchange.getRequestHeaders().get("Cookie")) {
String[] spl = cheader.split("\\;\\s*");
for (String s : spl) {
String[] kv = s.split("\\=");
if (kv.length < 2)
continue;
map.put(kv[0], kv[1]);
}
}
return map;
}
/**
* Get logged in user. It may also send logout headers if the cookies are
* invalid.
*
* @param exchange
* @return The logged in user or null if not logged in.
*/
public static User GetLoggedInUser(HttpExchange exchange) {
HashMap<String, String> cookies = GetCookies(exchange);
System.out.println("Cookies: " + cookies);
if (!cookies.containsKey("user_id") || !cookies.containsKey("session_id"))
return null;
System.out.println("Cookies found");
try (DataProvider provider = new DataProvider()) {
User user = provider.getUser(Long.parseLong(cookies.get("user_id")));
System.out.println("User: " + user);
System.out.println("session_id: " + cookies.get("session_id"));
if (user != null)
System.out.println("Equals: " + UUID.fromString(cookies.get("session_id")).equals(user.getSessionid()));
if (user != null && cookies.get("session_id") != null
&& UUID.fromString(cookies.get("session_id")).equals(user.getSessionid()))
return user;
else
SendLogoutHeaders(exchange);
}
return null;
}
public static void SendResponse(int code, Function<Document, Document> action, HttpExchange exchange)
throws IOException {
Document doc = new Document("");
doc = action.apply(doc);
SendResponse(200, doc.html(), exchange);
}
}

View file

@ -1,109 +1,109 @@
package io.github.norbipeti.chat.server;
import java.lang.reflect.Modifier;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import com.sun.net.httpserver.HttpServer;
import io.github.norbipeti.chat.server.db.*;
import io.github.norbipeti.chat.server.db.domain.*;
import io.github.norbipeti.chat.server.page.*;
public class Main {
// public static final HashMap<String, Page> Pages = new HashMap<String,
// Page>();
public static void main(String[] args) { // http://stackoverflow.com/questions/9266632/access-restriction-is-not-accessible-due-to-restriction-on-required-library/10642163#10642163
try { // rt.jar Javadoc:
// https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/
// https://docs.oracle.com/javase/8/docs/api/
System.out.println(System.getProperty("java.class.path")); // TODO:
// log4j
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.WARN);
ctx.updateLoggers(); // This causes all Loggers to refetch
// information from their LoggerConfig.
System.out.println("Loading database...");
try (DataProvider provider = new DataProvider()) {
User user = new User();
user.setName("asd");
user.setEmail("test@test.com");
User user2 = new User();
user2.setName("Teszt");
user2.setEmail("test2@test.com");
user2.getContacts().add(user);
provider.addUser(user);
List<User> users = provider.getUsers();
user = users.get(0);
user.getContacts().add(user2);
provider.addUser(user2);
users = provider.getUsers();
user2 = users.get(1);
System.out.println(users);
System.out.println("1st's contact: " + user.getContacts().get(0));
System.out.println("2nd's contact: " + user2.getContacts().get(0));
Conversation convo = new Conversation();
convo.getUsers().add(user);
convo.getUsers().add(user2);
Message msg = new Message();
msg.setSender(user);
msg.setTime(new Date());
msg.setMessage("Teszt 1");
convo.getMesssages().add(msg);
Message msg2 = new Message();
msg2.setSender(user2);
msg2.setTime(new Date());
msg2.setMessage("Teszt 2");
convo.getMesssages().add(msg2);
provider.addConversation(convo);
}
System.out.println("Starting webserver...");
HttpServer server = HttpServer.create(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 10);
Reflections rf = new Reflections(
new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(Page.class.getClassLoader()))
.addClassLoader(Page.class.getClassLoader()).addScanners(new SubTypesScanner())
.filterInputsBy((String pkg) -> pkg.contains("io.github.norbipeti.chat.server.page")));
Set<Class<? extends Page>> pages = rf.getSubTypesOf(Page.class);
for (Class<? extends Page> page : pages) {
try {
if (Modifier.isAbstract(page.getModifiers()))
continue;
Page p = page.newInstance();
addPage(server, p);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
server.start();
System.out.println("Ready... Press Enter to stop.");
System.in.read();
System.out.println("Stopping...");
server.stop(1);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Stopped");
}
private static void addPage(HttpServer server, Page page) {
server.createContext("/" + page.GetName(), page);
}
package io.github.norbipeti.chat.server;
import java.lang.reflect.Modifier;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import com.sun.net.httpserver.HttpServer;
import io.github.norbipeti.chat.server.db.*;
import io.github.norbipeti.chat.server.db.domain.*;
import io.github.norbipeti.chat.server.page.*;
public class Main {
// public static final HashMap<String, Page> Pages = new HashMap<String,
// Page>();
public static void main(String[] args) { // http://stackoverflow.com/questions/9266632/access-restriction-is-not-accessible-due-to-restriction-on-required-library/10642163#10642163
try { // rt.jar Javadoc:
// https://docs.oracle.com/javase/8/docs/jre/api/net/httpserver/spec/
// https://docs.oracle.com/javase/8/docs/api/
System.out.println(System.getProperty("java.class.path")); // TODO:
// log4j
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.WARN);
ctx.updateLoggers(); // This causes all Loggers to refetch
// information from their LoggerConfig.
System.out.println("Loading database...");
try (DataProvider provider = new DataProvider()) {
User user = new User();
user.setName("asd");
user.setEmail("test@test.com");
User user2 = new User();
user2.setName("Teszt");
user2.setEmail("test2@test.com");
user2.getContacts().add(user);
provider.addUser(user);
List<User> users = provider.getUsers();
user = users.get(0);
user.getContacts().add(user2);
provider.addUser(user2);
users = provider.getUsers();
user2 = users.get(1);
System.out.println(users);
System.out.println("1st's contact: " + user.getContacts().get(0));
System.out.println("2nd's contact: " + user2.getContacts().get(0));
Conversation convo = new Conversation();
convo.getUsers().add(user);
convo.getUsers().add(user2);
Message msg = new Message();
msg.setSender(user);
msg.setTime(new Date());
msg.setMessage("Teszt 1");
convo.getMesssages().add(msg);
Message msg2 = new Message();
msg2.setSender(user2);
msg2.setTime(new Date());
msg2.setMessage("Teszt 2");
convo.getMesssages().add(msg2);
provider.addConversation(convo);
}
System.out.println("Starting webserver...");
HttpServer server = HttpServer.create(new InetSocketAddress(InetAddress.getLocalHost(), 8080), 10);
Reflections rf = new Reflections(
new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(Page.class.getClassLoader()))
.addClassLoader(Page.class.getClassLoader()).addScanners(new SubTypesScanner())
.filterInputsBy((String pkg) -> pkg.contains("io.github.norbipeti.chat.server.page")));
Set<Class<? extends Page>> pages = rf.getSubTypesOf(Page.class);
for (Class<? extends Page> page : pages) {
try {
if (Modifier.isAbstract(page.getModifiers()))
continue;
Page p = page.newInstance();
addPage(server, p);
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
server.start();
System.out.println("Ready... Press Enter to stop.");
System.in.read();
System.out.println("Stopping...");
server.stop(1);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Stopped");
}
private static void addPage(HttpServer server, Page page) {
server.createContext("/" + page.GetName(), page);
}
}

View file

@ -1,87 +1,87 @@
package io.github.norbipeti.chat.server.db;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import io.github.norbipeti.chat.server.db.domain.*;
public class DataProvider implements AutoCloseable {
private EntityManagerFactory emf;
public DataProvider() {
emf = Persistence.createEntityManagerFactory("ChatServerPU");
}
public void addUser(User user) {
save(user);
}
public void addConversation(Conversation convo) {
save(convo);
}
private void save(Object object) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(object);
em.getTransaction().commit();
em.close();
}
public List<User> getUsers() {
return get(User.class);
}
public List<Message> getMessages() {
return get(Message.class);
}
public List<Conversation> getConversations() {
return get(Conversation.class);
}
private <T> List<T> get(Class<T> cl) {
EntityManager em = emf.createEntityManager();
TypedQuery<T> query = em.createQuery("SELECT x FROM " + cl.getSimpleName() + " x", cl);
List<T> results = query.getResultList();
em.close();
return results;
}
public void removeUser(User user) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
User managedUser = em.find(User.class, user.getId());
em.remove(managedUser);
em.getTransaction().commit();
em.close();
}
public User getUser(Long id) {
return get(User.class, id);
}
private <T> T get(Class<T> cl, Long id) {
EntityManager em = emf.createEntityManager();
T result = em.find(cl, id);
em.close();
return result;
}
public void SetValues(Runnable action) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
action.run();
em.getTransaction().commit();
em.close();
}
@Override
public void close() {
if (emf != null)
emf.close();
}
}
package io.github.norbipeti.chat.server.db;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.TypedQuery;
import io.github.norbipeti.chat.server.db.domain.*;
public class DataProvider implements AutoCloseable {
private EntityManagerFactory emf;
public DataProvider() {
emf = Persistence.createEntityManagerFactory("ChatServerPU");
}
public void addUser(User user) {
save(user);
}
public void addConversation(Conversation convo) {
save(convo);
}
private void save(Object object) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
em.persist(object);
em.getTransaction().commit();
em.close();
}
public List<User> getUsers() {
return get(User.class);
}
public List<Message> getMessages() {
return get(Message.class);
}
public List<Conversation> getConversations() {
return get(Conversation.class);
}
private <T> List<T> get(Class<T> cl) {
EntityManager em = emf.createEntityManager();
TypedQuery<T> query = em.createQuery("SELECT x FROM " + cl.getSimpleName() + " x", cl);
List<T> results = query.getResultList();
em.close();
return results;
}
public void removeUser(User user) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
User managedUser = em.find(User.class, user.getId());
em.remove(managedUser);
em.getTransaction().commit();
em.close();
}
public User getUser(Long id) {
return get(User.class, id);
}
private <T> T get(Class<T> cl, Long id) {
EntityManager em = emf.createEntityManager();
T result = em.find(cl, id);
em.close();
return result;
}
public void SetValues(Runnable action) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
action.run();
em.getTransaction().commit();
em.close();
}
@Override
public void close() {
if (emf != null)
emf.close();
}
}

View file

@ -1,51 +1,51 @@
package io.github.norbipeti.chat.server.db.domain;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;
@Entity
public class Conversation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
@ElementCollection(fetch=FetchType.EAGER)
@OneToMany(cascade = CascadeType.ALL)
private List<Message> messsages;
@ElementCollection(fetch = FetchType.EAGER)
@ManyToMany(cascade = CascadeType.ALL)
private List<User> users;
@Version
@GeneratedValue
private int Version;
public List<Message> getMesssages() {
if (messsages == null)
messsages = new ArrayList<>();
return messsages;
}
public void setMesssages(List<Message> messsages) {
this.messsages = messsages;
}
public List<User> getUsers() {
if (users == null)
users = new ArrayList<>();
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
package io.github.norbipeti.chat.server.db.domain;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.*;
@Entity
public class Conversation {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
@ElementCollection(fetch=FetchType.EAGER)
@OneToMany(cascade = CascadeType.ALL)
private List<Message> messsages;
@ElementCollection(fetch = FetchType.EAGER)
@ManyToMany(cascade = CascadeType.ALL)
private List<User> users;
@Version
@GeneratedValue
private int Version;
public List<Message> getMesssages() {
if (messsages == null)
messsages = new ArrayList<>();
return messsages;
}
public void setMesssages(List<Message> messsages) {
this.messsages = messsages;
}
public List<User> getUsers() {
if (users == null)
users = new ArrayList<>();
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}

View file

@ -1,62 +1,62 @@
package io.github.norbipeti.chat.server.db.domain;
import java.util.Date;
import javax.persistence.*;
@Entity
public class Message {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
@ManyToOne(cascade=CascadeType.ALL)
private User sender;
private Date time;
private String message;
@ManyToOne(cascade=CascadeType.ALL)
private Conversation conversation;
@Version
@GeneratedValue
private int Version;
public User getSender() {
return sender;
}
public void setSender(User sender) {
this.sender = sender;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Conversation getConversation() {
return conversation;
}
public void setConversation(Conversation conversation) {
this.conversation = conversation;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
package io.github.norbipeti.chat.server.db.domain;
import java.util.Date;
import javax.persistence.*;
@Entity
public class Message {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
@ManyToOne(cascade=CascadeType.ALL)
private User sender;
private Date time;
private String message;
@ManyToOne(cascade=CascadeType.ALL)
private Conversation conversation;
@Version
@GeneratedValue
private int Version;
public User getSender() {
return sender;
}
public void setSender(User sender) {
this.sender = sender;
}
public Date getTime() {
return time;
}
public void setTime(Date time) {
this.time = time;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Conversation getConversation() {
return conversation;
}
public void setConversation(Conversation conversation) {
this.conversation = conversation;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}

View file

@ -1,115 +1,115 @@
package io.github.norbipeti.chat.server.db.domain;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.persistence.*;
@Entity
@Table(name = "\"User\"")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
private String name;
private String email;
private String password;
@ElementCollection(fetch = FetchType.EAGER)
private List<User> contacts;
private String salt;
@Column(columnDefinition = "CHAR(16) FOR BIT DATA")
private UUID sessionid;
@Version
@GeneratedValue
private int Version;
@ElementCollection(fetch = FetchType.EAGER)
@ManyToMany(cascade = CascadeType.ALL)
public List<Conversation> conversations;
public List<User> getContacts() {
if (contacts == null)
contacts = new ArrayList<>();
return contacts;
}
public void setContacts(List<User> contacts) {
this.contacts = contacts;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
@Override
public String toString() {
List<String> c = null;
if (contacts != null) {
c = new ArrayList<>();
for (User u : contacts)
c.add(u.name);
}
return "User [id=" + id + ", name=" + name + ", email=" + email + ", password=" + password + ", contacts=" + c
+ ", sessionid=" + sessionid + "]"; // TODO: SessionID null
// after getting from db
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public UUID getSessionid() {
return sessionid;
}
public void setSessionid(UUID sessionid) {
this.sessionid = sessionid;
}
public List<Conversation> getConversations() {
if (conversations == null)
conversations = new ArrayList<>();
return conversations;
}
public void setConversations(List<Conversation> conversations) {
this.conversations = conversations;
}
public User() {
}
}
package io.github.norbipeti.chat.server.db.domain;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.persistence.*;
@Entity
@Table(name = "\"User\"")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", unique = true, nullable = false)
private Long id;
private String name;
private String email;
private String password;
@ElementCollection(fetch = FetchType.EAGER)
private List<User> contacts;
private String salt;
@Column(columnDefinition = "CHAR(16) FOR BIT DATA")
private UUID sessionid;
@Version
@GeneratedValue
private int Version;
@ElementCollection(fetch = FetchType.EAGER)
@ManyToMany(cascade = CascadeType.ALL)
public List<Conversation> conversations;
public List<User> getContacts() {
if (contacts == null)
contacts = new ArrayList<>();
return contacts;
}
public void setContacts(List<User> contacts) {
this.contacts = contacts;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
@Override
public String toString() {
List<String> c = null;
if (contacts != null) {
c = new ArrayList<>();
for (User u : contacts)
c.add(u.name);
}
return "User [id=" + id + ", name=" + name + ", email=" + email + ", password=" + password + ", contacts=" + c
+ ", sessionid=" + sessionid + "]"; // TODO: SessionID null
// after getting from db
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public UUID getSessionid() {
return sessionid;
}
public void setSessionid(UUID sessionid) {
this.sessionid = sessionid;
}
public List<Conversation> getConversations() {
if (conversations == null)
conversations = new ArrayList<>();
return conversations;
}
public void setConversations(List<Conversation> conversations) {
this.conversations = conversations;
}
public User() {
}
}

View file

@ -1,60 +1,60 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.jsoup.nodes.Element;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.ssl.internal.ssl.Provider;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.Conversation;
import io.github.norbipeti.chat.server.db.domain.Message;
import io.github.norbipeti.chat.server.db.domain.User;
public class IndexPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
// final User user = IOHelper.GetLoggedInUser(exchange); - TODO
final User user = new User();
user.setEmail("test@test.com");
user.setName("Norbi");
user.setId(3L);
if (user == null)
IOHelper.SendModifiedPage(200, this, (doc) -> {
doc.getElementById("userbox").remove();
doc.getElementById("usercontent").remove();
return doc;
}, exchange);
else
IOHelper.SendModifiedPage(200, this, (doc) -> {
doc.getElementById("loginbox").remove();
doc.getElementById("registerbox").remove();
Element userbox = doc.getElementById("userbox");
userbox.html(userbox.html().replace("<username />", user.getName()));
Element channelmessages = doc.getElementById("channelmessages");
try (DataProvider provider = new DataProvider()) {
Conversation convo = provider.getConversations().get(0); //TODO
for (Message message : convo.getMesssages()) {
Element msgelement = channelmessages.appendElement("div");
Element header = msgelement.appendElement("p");
header.text(message.getSender().getName() + " - " + message.getTime());
Element body = msgelement.appendElement("p");
body.text(message.getMessage());
}
}
return doc;
}, exchange);
} // TODO:
// Validation
// at
// registration
@Override
public String GetName() {
return "";
}
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.jsoup.nodes.Element;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.ssl.internal.ssl.Provider;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.Conversation;
import io.github.norbipeti.chat.server.db.domain.Message;
import io.github.norbipeti.chat.server.db.domain.User;
public class IndexPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
// final User user = IOHelper.GetLoggedInUser(exchange); - TODO
final User user = new User();
user.setEmail("test@test.com");
user.setName("Norbi");
user.setId(3L);
if (user == null)
IOHelper.SendModifiedPage(200, this, (doc) -> {
doc.getElementById("userbox").remove();
doc.getElementById("usercontent").remove();
return doc;
}, exchange);
else
IOHelper.SendModifiedPage(200, this, (doc) -> {
doc.getElementById("loginbox").remove();
doc.getElementById("registerbox").remove();
Element userbox = doc.getElementById("userbox");
userbox.html(userbox.html().replace("<username />", user.getName()));
Element channelmessages = doc.getElementById("channelmessages");
try (DataProvider provider = new DataProvider()) {
Conversation convo = provider.getConversations().get(0); //TODO
for (Message message : convo.getMesssages()) {
Element msgelement = channelmessages.appendElement("div");
Element header = msgelement.appendElement("p");
header.text(message.getSender().getName() + " - " + message.getTime());
Element body = msgelement.appendElement("p");
body.text(message.getMessage());
}
}
return doc;
}, exchange);
} // TODO:
// Validation
// at
// registration
@Override
public String GetName() {
return "";
}
}

View file

@ -1,49 +1,49 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.json.JSONObject;
import org.mindrot.jbcrypt.BCrypt;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
public class LoginPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
JSONObject post = IOHelper.GetPOSTJSON(exchange);
if (post == null || !post.has("email") || !post.has("pass")) {
IOHelper.Redirect("/", exchange);
return;
}
try (DataProvider provider = new DataProvider()) {
User loginuser = null;
for (User user : provider.getUsers()) {
if (user.getEmail().equals(post.get("email"))) {
loginuser = user;
break;
}
}
if (loginuser == null || !BCrypt.checkpw(post.getString("pass"), loginuser.getPassword())) {
IOHelper.SendResponse(200, (doc) -> {
doc.appendElement("p").text("The username or password is invalid.");
return doc;
}, exchange);
return;
}
IOHelper.LoginUser(exchange, loginuser, provider);
IOHelper.SendResponse(200, "Success", exchange);
} catch (Exception e) {
throw e;
}
}
@Override
public String GetName() {
return "login";
}
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.json.JSONObject;
import org.mindrot.jbcrypt.BCrypt;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
public class LoginPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
JSONObject post = IOHelper.GetPOSTJSON(exchange);
if (post == null || !post.has("email") || !post.has("pass")) {
IOHelper.Redirect("/", exchange);
return;
}
try (DataProvider provider = new DataProvider()) {
User loginuser = null;
for (User user : provider.getUsers()) {
if (user.getEmail().equals(post.get("email"))) {
loginuser = user;
break;
}
}
if (loginuser == null || !BCrypt.checkpw(post.getString("pass"), loginuser.getPassword())) {
IOHelper.SendResponse(200, (doc) -> {
doc.appendElement("p").text("The username or password is invalid.");
return doc;
}, exchange);
return;
}
IOHelper.LoginUser(exchange, loginuser, provider);
IOHelper.SendResponse(200, "Success", exchange);
} catch (Exception e) {
throw e;
}
}
@Override
public String GetName() {
return "login";
}
}

View file

@ -1,20 +1,20 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
public class MessageAjaxPage extends Page {
@Override
public String GetName() {
return "message";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
// TODO Auto-generated method stub
}
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
public class MessageAjaxPage extends Page {
@Override
public String GetName() {
return "message";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
// TODO Auto-generated method stub
}
}

View file

@ -1,28 +1,28 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class NotFoundPage extends Page {
@Override
public String GetName() {
return "notfound";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
IOHelper.SendPage(404, this, exchange);
}
public NotFoundPage() {
if (Instance != null)
throw new UnsupportedOperationException("There can only be one instance of a page.");
Instance = this;
}
public static NotFoundPage Instance;
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class NotFoundPage extends Page {
@Override
public String GetName() {
return "notfound";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
IOHelper.SendPage(404, this, exchange);
}
public NotFoundPage() {
if (Instance != null)
throw new UnsupportedOperationException("There can only be one instance of a page.");
Instance = this;
}
public static NotFoundPage Instance;
}

View file

@ -1,55 +1,55 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.output.ByteArrayOutputStream;
import com.sun.net.httpserver.*;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.Main;
/**
* Add to {@link Main}.Pages
*
*/
public abstract class Page implements HttpHandler {
public abstract String GetName();
public final String GetHTMLPath() {
if (GetName().length() == 0)
return "pages/index.html";
return new StringBuilder("pages/").append(GetName()).append(".html").toString();
}
@Override
public void handle(HttpExchange exchange) {
try {
if (!getDo404() || exchange.getRequestURI().getPath().equals("/" + GetName()))
handlePage(exchange);
else {
IOHelper.SendPage(404, NotFoundPage.Instance, exchange);
}
} catch (Exception e) {
e.printStackTrace();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream str = new PrintStream(baos);
str.print("<h1>500 Internal Server Error</h1><pre>");
e.printStackTrace(str);
str.print("</pre>");
IOHelper.SendResponse(500, baos.toString(StandardCharsets.ISO_8859_1), exchange);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public abstract void handlePage(HttpExchange exchange) throws IOException;
public boolean getDo404() {
return true;
}
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.output.ByteArrayOutputStream;
import com.sun.net.httpserver.*;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.Main;
/**
* Add to {@link Main}.Pages
*
*/
public abstract class Page implements HttpHandler {
public abstract String GetName();
public final String GetHTMLPath() {
if (GetName().length() == 0)
return "pages/index.html";
return new StringBuilder("pages/").append(GetName()).append(".html").toString();
}
@Override
public void handle(HttpExchange exchange) {
try {
if (!getDo404() || exchange.getRequestURI().getPath().equals("/" + GetName()))
handlePage(exchange);
else {
IOHelper.SendPage(404, NotFoundPage.Instance, exchange);
}
} catch (Exception e) {
e.printStackTrace();
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream str = new PrintStream(baos);
str.print("<h1>500 Internal Server Error</h1><pre>");
e.printStackTrace(str);
str.print("</pre>");
IOHelper.SendResponse(500, baos.toString(StandardCharsets.ISO_8859_1), exchange);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public abstract void handlePage(HttpExchange exchange) throws IOException;
public boolean getDo404() {
return true;
}
}

View file

@ -1,72 +1,72 @@
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.json.JSONObject;
import org.mindrot.jbcrypt.BCrypt;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
public class RegisterPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
JSONObject post = IOHelper.GetPOSTJSON(exchange);
if (post != null) {
String errormsg = CheckValues(post, "name", "email", "pass", "pass2");
if (errormsg.length() > 0) {
final String msg = errormsg;
IOHelper.SendResponse(200, (doc) -> doc.html(msg).ownerDocument(), exchange);
return; // TODO: Use JavaScript too, for error checks
}
try (DataProvider provider = new DataProvider()) {
for (User user : provider.getUsers()) {
if (post.get("email").equals(user.getEmail())) {
errormsg += "<p>An user with this name already exists</p>";
break;
}
}
if (!post.get("pass").equals(post.get("pass2")))
errormsg += "<p>The passwords don't match</p>";
if (errormsg.length() > 0) {
final String msg = errormsg;
IOHelper.SendResponse(200, (doc) -> doc.html(msg).ownerDocument(), exchange);
return;
}
User user = new User();
user.setName(post.getString("name"));
user.setEmail(post.getString("email"));
user.setSalt(BCrypt.gensalt()); // http://www.mindrot.org/projects/jBCrypt/
user.setPassword(BCrypt.hashpw(post.getString("pass"), user.getSalt()));
provider.addUser(user);
User managedUser = provider.getUser(user.getId());
IOHelper.LoginUser(exchange, managedUser, provider);
IOHelper.SendResponse(200, "Success", exchange);
} catch (Exception e) {
throw e;
}
return;
}
IOHelper.Redirect("/", exchange);
}
private String CheckValues(JSONObject post, String... values) {
String errormsg = "";
for (String value : values)
if (!CheckValue(post.getString(value)))
errormsg += "<p>" + value + " can't be empty</p>";
return errormsg;
}
private boolean CheckValue(String val) {
return val != null && val.length() > 0;
}
@Override
public String GetName() {
return "register";
}
}
package io.github.norbipeti.chat.server.page;
import java.io.IOException;
import org.json.JSONObject;
import org.mindrot.jbcrypt.BCrypt;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
import io.github.norbipeti.chat.server.db.DataProvider;
import io.github.norbipeti.chat.server.db.domain.User;
public class RegisterPage extends Page {
@Override
public void handlePage(HttpExchange exchange) throws IOException {
JSONObject post = IOHelper.GetPOSTJSON(exchange);
if (post != null) {
String errormsg = CheckValues(post, "name", "email", "pass", "pass2");
if (errormsg.length() > 0) {
final String msg = errormsg;
IOHelper.SendResponse(200, (doc) -> doc.html(msg).ownerDocument(), exchange);
return; // TODO: Use JavaScript too, for error checks
}
try (DataProvider provider = new DataProvider()) {
for (User user : provider.getUsers()) {
if (post.get("email").equals(user.getEmail())) {
errormsg += "<p>An user with this name already exists</p>";
break;
}
}
if (!post.get("pass").equals(post.get("pass2")))
errormsg += "<p>The passwords don't match</p>";
if (errormsg.length() > 0) {
final String msg = errormsg;
IOHelper.SendResponse(200, (doc) -> doc.html(msg).ownerDocument(), exchange);
return;
}
User user = new User();
user.setName(post.getString("name"));
user.setEmail(post.getString("email"));
user.setSalt(BCrypt.gensalt()); // http://www.mindrot.org/projects/jBCrypt/
user.setPassword(BCrypt.hashpw(post.getString("pass"), user.getSalt()));
provider.addUser(user);
User managedUser = provider.getUser(user.getId());
IOHelper.LoginUser(exchange, managedUser, provider);
IOHelper.SendResponse(200, "Success", exchange);
} catch (Exception e) {
throw e;
}
return;
}
IOHelper.Redirect("/", exchange);
}
private String CheckValues(JSONObject post, String... values) {
String errormsg = "";
for (String value : values)
if (!CheckValue(post.getString(value)))
errormsg += "<p>" + value + " can't be empty</p>";
return errormsg;
}
private boolean CheckValue(String val) {
return val != null && val.length() > 0;
}
@Override
public String GetName() {
return "register";
}
}

View file

@ -1,34 +1,34 @@
package io.github.norbipeti.chat.server.page;
import java.io.File;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class ScriptsPage extends Page {
@Override
public boolean getDo404() {
return false;
}
@Override
public String GetName() {
return "js/";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
if (exchange.getRequestURI().getPath().startsWith("/js/")) {
File jsfile = new File("pages", exchange.getRequestURI().getPath());
if (!jsfile.exists())
IOHelper.SendResponse(404, "<h1>JavaScript file not found</h1>", exchange);
else
IOHelper.SendResponse(200, IOHelper.ReadFile(jsfile), exchange);
}
else
System.out.println(exchange.getRequestURI().getPath());
}
}
package io.github.norbipeti.chat.server.page;
import java.io.File;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class ScriptsPage extends Page {
@Override
public boolean getDo404() {
return false;
}
@Override
public String GetName() {
return "js/";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
if (exchange.getRequestURI().getPath().startsWith("/js/")) {
File jsfile = new File("pages", exchange.getRequestURI().getPath());
if (!jsfile.exists())
IOHelper.SendResponse(404, "<h1>JavaScript file not found</h1>", exchange);
else
IOHelper.SendResponse(200, IOHelper.ReadFile(jsfile), exchange);
}
else
System.out.println(exchange.getRequestURI().getPath());
}
}

View file

@ -1,35 +1,35 @@
package io.github.norbipeti.chat.server.page;
import java.io.File;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class StylePage extends Page {
@Override
public boolean getDo404() {
return false;
}
@Override
public String GetName() {
return "css/";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
if (exchange.getRequestURI().getPath().startsWith("/css/")) {
File cssfile = new File("pages", exchange.getRequestURI().getPath());
if (!cssfile.exists())
IOHelper.SendResponse(404, "<h1>CSS file not found</h1>", exchange);
else {
exchange.getResponseHeaders().add("Content-Type", "text/css");
IOHelper.SendResponse(200, IOHelper.ReadFile(cssfile), exchange);
}
} else
System.out.println(exchange.getRequestURI().getPath());
}
}
package io.github.norbipeti.chat.server.page;
import java.io.File;
import java.io.IOException;
import com.sun.net.httpserver.HttpExchange;
import io.github.norbipeti.chat.server.IOHelper;
public class StylePage extends Page {
@Override
public boolean getDo404() {
return false;
}
@Override
public String GetName() {
return "css/";
}
@Override
public void handlePage(HttpExchange exchange) throws IOException {
if (exchange.getRequestURI().getPath().startsWith("/css/")) {
File cssfile = new File("pages", exchange.getRequestURI().getPath());
if (!cssfile.exists())
IOHelper.SendResponse(404, "<h1>CSS file not found</h1>", exchange);
else {
exchange.getResponseHeaders().add("Content-Type", "text/css");
IOHelper.SendResponse(200, IOHelper.ReadFile(cssfile), exchange);
}
} else
System.out.println(exchange.getRequestURI().getPath());
}
}