diff --git a/maxkey-authentications/build.gradle b/maxkey-authentications/build.gradle index db007659e..a3a0ad5c4 100644 --- a/maxkey-authentications/build.gradle +++ b/maxkey-authentications/build.gradle @@ -10,7 +10,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0") compile project(":maxkey-protocols:maxkey-protocol-saml-2.0") diff --git a/maxkey-client-sdk/.classpath b/maxkey-client-sdk/.classpath deleted file mode 100644 index 319c4a47c..000000000 --- a/maxkey-client-sdk/.classpath +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-client-sdk/.gitignore b/maxkey-client-sdk/.gitignore deleted file mode 100644 index 84c048a73..000000000 --- a/maxkey-client-sdk/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build/ diff --git a/maxkey-client-sdk/.project b/maxkey-client-sdk/.project deleted file mode 100644 index ef7f802bf..000000000 --- a/maxkey-client-sdk/.project +++ /dev/null @@ -1,40 +0,0 @@ - - - maxkey-client-sdk - maxkey-client-sdk - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - - diff --git a/maxkey-client-sdk/.settings/org.eclipse.buildship.core.prefs b/maxkey-client-sdk/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 216bf8377..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -build.commands=org.eclipse.jdt.core.javabuilder -connection.arguments= -connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) -connection.java.home=null -connection.jvm.arguments= -connection.project.dir=.. -containers=org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7/ -derived.resources=.gradle,build -eclipse.preferences.version=1 -natures=org.eclipse.jdt.core.javanature -project.path=\:maxkey-client-sdk diff --git a/maxkey-client-sdk/.settings/org.eclipse.core.resources.prefs b/maxkey-client-sdk/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-client-sdk/.settings/org.eclipse.jdt.core.prefs b/maxkey-client-sdk/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 4248c7fd6..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,113 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -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.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -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=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -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=warning -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.unlikelyCollectionMethodArgumentType=warning -org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled -org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info -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 -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/maxkey-client-sdk/.settings/org.eclipse.jdt.launching.prefs b/maxkey-client-sdk/.settings/org.eclipse.jdt.launching.prefs deleted file mode 100644 index d211d3263..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.jdt.launching.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/maxkey-client-sdk/.settings/org.eclipse.wst.common.component b/maxkey-client-sdk/.settings/org.eclipse.wst.common.component deleted file mode 100644 index ac100e060..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/maxkey-client-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-client-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index fd0227a68..000000000 --- a/maxkey-client-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/maxkey-client-sdk/.sts4-cache/classpath-data.json b/maxkey-client-sdk/.sts4-cache/classpath-data.json deleted file mode 100644 index 8d521ed76..000000000 --- a/maxkey-client-sdk/.sts4-cache/classpath-data.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"maxkey-client-sdk","classpathEntries":[{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\resources.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\rt.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\jsse.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\jce.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\charsets.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Program Files\\Java\\jre1.8.0_221\\lib\\jfr.jar","javadocContainerUrl":"https://docs.oracle.com/javase/1/docs/api/","isSystem":true,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-beanutils\\commons-beanutils\\1.9.3\\c845703de334ddc6b4b3cd26835458cb1cba1f3d\\commons-beanutils-1.9.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-codec\\commons-codec\\1.12\\47a28ef1ed31eb182b44e15d49300dee5fadcf6a\\commons-codec-1.12.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-collections\\commons-collections\\3.2.2\\8ad72fe39fa8c91eaaf12aadb21e0c3661fe26d5\\commons-collections-3.2.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-csv\\1.7\\cb5d05520f8fe1b409aaf29962e47dc5764f8f39\\commons-csv-1.7.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-dbcp2\\2.6.0\\78d0e99c4bc815a9f20cf6837761e91b7fc6eef4\\commons-dbcp2-2.6.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-dbutils\\commons-dbutils\\1.7\\a2d6e515aa87e5d38f6b3003e70b13c1b1f19ca0\\commons-dbutils-1.7.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-digester3\\3.2\\c3f68c5ff25ec5204470fd8fdf4cb8feff5e8a79\\commons-digester3-3.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-digester\\commons-digester\\2.1\\73a8001e7a54a255eef0f03521ec1805dc738ca0\\commons-digester-2.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-io\\commons-io\\2.6\\815893df5f31da2ece4040fe0a12fd44b577afaf\\commons-io-2.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-lang\\commons-lang\\2.6\\ce1edb914c94ebc388f086c6827e8bdeec71ac2\\commons-lang-2.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-lang3\\3.9\\122c7cee69b53ed4a7681c03d4ee4c0e2765da5\\commons-lang3-3.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\commons-logging\\commons-logging\\1.2\\commons-logging-1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-pool2\\2.6.2\\775a8072995b29eafe8fb0a828a190589f71cede\\commons-pool2-2.6.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-httpclient\\commons-httpclient\\3.1\\964cd74171f427720480efdec40a7c7f6e58426a\\commons-httpclient-3.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\commons-fileupload\\commons-fileupload\\1.4\\f95188e3d372e20e7328706c37ef366e5d7859b0\\commons-fileupload-1.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\commons-email\\1.5\\e8e677c6362eba14ff3c476ba63ccb83132dbd52\\commons-email-1.5.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.httpcomponents\\httpclient\\4.5.6\\1afe5621985efe90a92d0fbc9be86271efbe796f\\httpclient-4.5.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.httpcomponents\\fluent-hc\\4.5.6\\7f4b2ccd83078e3bb87c8ad280ec074c04c7e4a4\\fluent-hc-4.5.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.httpcomponents\\httpclient-cache\\4.5.6\\4238cd34156021eaadc7e4d2d5c47b835e1fed3c\\httpclient-cache-4.5.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.httpcomponents\\httpmime\\4.5.6\\164343da11db817e81e24e0d9869527e069850c9\\httpmime-4.5.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.httpcomponents\\httpcore\\4.4.10\\acc54d9b28bdffe4bbde89ed2e4a1e86b5285e2b\\httpcore-4.4.10.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.velocity\\velocity\\1.7\\2ceb567b8f3f21118ecdec129fe1271dbc09aa7a\\velocity-1.7.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\velocity\\velocity-dep\\1.4\\b1df5193d3dd66a310b32828c547cd9e163b98df\\velocity-dep-1.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.freemarker\\freemarker\\2.3.29\\46005eeee02e4458520c85d0bcf5001467b053c3\\freemarker-2.3.29.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.commons\\not-yet-commons-ssl\\0.3.9\\7548f1f49b8a0b808b8715ead7b3cb2d395b0909\\not-yet-commons-ssl-0.3.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-1.2-api\\2.12.0\\29474790d2292384eac2ecf1b3280f095b6ac3f1\\log4j-1.2-api-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-api\\2.12.0\\8b50b487ac0c0bff1af79d56c6454ea68f40c150\\log4j-api-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-core\\2.12.0\\1723837573e4c5dbc8840f9f6e8f79b245b94bb\\log4j-core-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-jcl\\2.12.0\\c6b6cc2594e6481d1a8cf5762ed67bcab004363e\\log4j-jcl-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-jul\\2.12.0\\d50c2eb436de7128393c1fa1b71596c12462eb88\\log4j-jul-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-slf4j-impl\\2.12.0\\7f44f5201f79d6f7010a1515699a5f6c40e49cb\\log4j-slf4j-impl-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.logging.log4j\\log4j-web\\2.12.0\\93c550519d057e56c75ba5074ea4a258d1732b8b\\log4j-web-2.12.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\org\\slf4j\\slf4j-api\\1.7.26\\slf4j-api-1.7.26.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.jboss.logging\\jboss-logging\\3.4.0.Final\\b225692a59f7dc3a789d2c85edc06041914e97e7\\jboss-logging-3.4.0.Final.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-aop\\5.2.2.RELEASE\\899739cf7f338f6297aa9eb25ea8b16338fe4e6d\\spring-aop-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-aspects\\5.2.2.RELEASE\\a7fc38ee5fcc7efff607cc93b5fa7259c0fbb4da\\spring-aspects-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-beans\\5.2.2.RELEASE\\81e4d9cc2e8fac88ab4eb7325c4521bd07c6389c\\spring-beans-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-core\\5.2.2.RELEASE\\bfcf2f6d0494d89db63ae170b8491223c93a88dc\\spring-core-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-context\\5.2.2.RELEASE\\a77a18fa425eba9c55447fa0711e2dbfbf71907b\\spring-context-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-context-indexer\\5.2.2.RELEASE\\f31f4b86f2a4c973834848917774f12c3d108b8a\\spring-context-indexer-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-context-support\\5.2.2.RELEASE\\f09e0177737a5be5c6b6315363bfff722e3524cb\\spring-context-support-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-expression\\5.2.2.RELEASE\\eb93bc4d4eb8e0bee60ea910e0fd615869336643\\spring-expression-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-instrument\\5.2.2.RELEASE\\73de68c900985304ef13ee3c4d313facf7fbf883\\spring-instrument-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-jcl\\5.2.2.RELEASE\\35efd564bf664c0bf53bd336b583391a7f872da7\\spring-jcl-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-jdbc\\5.2.2.RELEASE\\6f0070f04c60f77d0048dc5521f8aafd5a86e87e\\spring-jdbc-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-jms\\5.2.2.RELEASE\\a275151b739a85c3ef9003338231a3798a72a870\\spring-jms-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-messaging\\5.2.2.RELEASE\\93e22c86e57017e3093347e31bdb162b928999c9\\spring-messaging-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-orm\\5.2.2.RELEASE\\1b17c9e69d92e54439a092d6943e956f80392f43\\spring-orm-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-oxm\\5.2.2.RELEASE\\6bfabf762138bffaf1799f9d27d37f0ee7896722\\spring-oxm-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-test\\5.2.2.RELEASE\\444e2f91f667558df1853b15915ac28b2185404c\\spring-test-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-tx\\5.2.2.RELEASE\\2af860baa0b094e13786613e15e1804edb7a5977\\spring-tx-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-web\\5.2.2.RELEASE\\d9b0a8079b7d604f134e3054127a7aeba65949a5\\spring-web-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-webflux\\5.2.2.RELEASE\\610c4889b4e5087e2103fcfae32144af0321d06d\\spring-webflux-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-webmvc\\5.2.2.RELEASE\\a0e9e88a296c09850f92318872f4dee9f62c8c13\\spring-webmvc-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework\\spring-websocket\\5.2.2.RELEASE\\f751c66b60482096f97f28e196de25aaabc39668\\spring-websocket-5.2.2.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.security\\spring-security-core\\5.2.1.RELEASE\\f1265ecdd4636a2038768c2ab9da4b79961a3465\\spring-security-core-5.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.security\\spring-security-web\\5.2.1.RELEASE\\9e43c2d8d2dffc60bfba8ac95a106d30e9593106\\spring-security-web-5.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.security\\spring-security-crypto\\5.2.1.RELEASE\\77d7c803ab3f91231254509e37c51ee72651e0d7\\spring-security-crypto-5.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot\\2.2.1.RELEASE\\3acb07ca9d6b968209a91aec6a7751f35bf22764\\spring-boot-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter\\2.2.1.RELEASE\\5a4d687e6ffec805ce6320af7ca0b18798638200\\spring-boot-starter-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-actuator\\2.2.1.RELEASE\\6f91f2e1f75b06388b65da9d3ae54164ad427922\\spring-boot-actuator-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-autoconfigure\\2.2.1.RELEASE\\1e45b519cc3b1de0b1ecee6eed6397c19ede95a2\\spring-boot-autoconfigure-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter-freemarker\\2.2.1.RELEASE\\351b315a712c46a7680d944e63782b014920b3e5\\spring-boot-starter-freemarker-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter-log4j2\\2.2.1.RELEASE\\e4365822acf8b4300dae309206f75e6d12b9ac90\\spring-boot-starter-log4j2-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter-web\\2.2.1.RELEASE\\689213aca6e25e2aa9b377e61273aa3d31f30f60\\spring-boot-starter-web-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter-tomcat\\2.2.1.RELEASE\\da314ec9026c230906ea9d1a1330f99bbe2d0fa8\\spring-boot-starter-tomcat-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.opensaml\\opensaml\\2.6.4\\de2c742b770bd58328fd05ebd9d9efc85f79d88c\\opensaml-2.6.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.opensaml\\openws\\1.5.4\\942bd987e5956fcdf1eaa56cde87112ea871d0e8\\openws-1.5.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.opensaml\\xmltooling\\1.4.4\\8cf44998d4b9cca5f9eeb47cc95d95cea9f86714\\xmltooling-1.4.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\cn.hutool\\hutool-core\\5.1.2\\8952c0cb43272ba2873be46193971825d4b9f7d9\\hutool-core-5.1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\cn.hutool\\hutool-http\\5.1.2\\9f43596260cd0b8212a12f96051b1fa04ec0c5de\\hutool-http-5.1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.javassist\\javassist\\3.23.0-GA\\5c71cd6815cc207379639aca8c88478b7e959e35\\javassist-3.23.0-GA.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.owasp.esapi\\esapi\\2.2.0.0\\721cbbf80e2bf1cc3d87d4a791e4c7bc827fca95\\esapi-2.2.0.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.sun.mail\\javax.mail\\1.6.2\\935151eb71beff17a2ffac15dd80184a99a0514f\\javax.mail-1.6.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\taglibs\\standard\\1.1.2\\a17e8a4d9a1f7fcc5eed606721c9ed6b7f18acf7\\standard-1.1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.servlet.jsp.jstl\\jstl\\1.2\\7a93a178d5599db1321a9e5ff927b4ed015b68d8\\jstl-1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\javax\\activation\\activation\\1.1.1\\activation-1.1.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.annotation\\javax.annotation-api\\1.3.2\\934c04d3cfef185a8008e7bf34331b79730a9d43\\javax.annotation-api-1.3.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.transaction\\jta\\1.1\\2ca09f0b36ca7d71b762e14ea2ff09d5eac57558\\jta-1.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.transaction\\javax.transaction-api\\1.3\\e006adf5cf3cca2181d16bd640ecb80148ec0fce\\javax.transaction-api-1.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.validation\\validation-api\\2.0.1.Final\\cb855558e6271b1b32e716d24cb85c7f583ce09e\\validation-api-2.0.1.Final.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.xml\\jsr173\\1.0\\8b7a70786148944ef061fca58b5467d05dae07ba\\jsr173-1.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.xml.bind\\jaxb-api\\2.3.1\\8531ad5ac454cc2deb9d4d32c40c4d7451939b5d\\jaxb-api-2.3.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.sun.xml.bind\\jaxb-core\\2.3.0.1\\23574ca124d0a694721ce3ef13cd720095f18fdd\\jaxb-core-2.3.0.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.sun.xml.bind\\jaxb-impl\\2.3.2\\9d70d9b54cbc91b0e647d97af87395f39ea189f9\\jaxb-impl-2.3.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.sun.xml.bind\\jaxb-xjc\\2.3.2\\264a255681ebe9f9e955182c7922a34b5f7c4578\\jaxb-xjc-2.3.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.bouncycastle\\bcpkix-jdk15on\\1.60\\d0c46320fbc07be3a24eb13a56cee4e3d38e0c75\\bcpkix-jdk15on-1.60.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.bouncycastle\\bcprov-jdk15on\\1.60\\bd47ad3bd14b8e82595c7adaa143501e60842a84\\bcprov-jdk15on-1.60.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.bouncycastle\\bcprov-ext-jdk15on\\1.60\\faea4c950bbfa6e8882830f0266bc9185755d37\\bcprov-ext-jdk15on-1.60.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.google.crypto.tink\\tink\\1.2.2\\db27fd32f842b436ad07aecbe2934524473dc0ac\\tink-1.2.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.jhlabs\\filters\\2.0.235-1\\fff65ebe39d1097cee431087858b3caf957ecfb7\\filters-2.0.235-1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.github.penggle\\kaptcha\\2.3.2\\a3e13fd05bae905d67eafb40b712a1b624daef3b\\kaptcha-2.3.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.google.code.gson\\gson\\2.8.5\\f645ed69d595b24d4cf8b3fbb64cc505bede8829\\gson-2.8.5.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.codehaus.jackson\\jackson-all\\1.8.5\\a5549eaa90a63b20da244690f9ade851eaeb2d99\\jackson-all-1.8.5.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-databind\\2.9.9\\jackson-databind-2.9.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-core\\2.9.9\\jackson-core-2.9.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\com\\fasterxml\\jackson\\core\\jackson-annotations\\2.9.9\\jackson-annotations-2.9.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.fasterxml\\classmate\\1.5.0\\bc2d1d55f28e6dc0801d86cbd195debd81090d33\\classmate-1.5.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.alibaba\\fastjson\\1.2.62\\9243497a2f1f9d40d7d1d8d852f0abdc71955532\\fastjson-1.2.62.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.reactivestreams\\reactive-streams\\1.0.2\\323964c36556eb0e6209f65c1cef72b53b461ab8\\reactive-streams-1.0.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\io.projectreactor\\reactor-core\\3.2.10.RELEASE\\14b979abc580502c679d0b318814cef8b2066fce\\reactor-core-3.2.10.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\eu.tekul\\szxcvbn_2.9.2\\0.2\\cfac462aed38c7c0267a06993a3e3c2656807aae\\szxcvbn_2.9.2-0.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.quartz-scheduler\\quartz\\2.2.3\\d4d8ea088852beeb89f54d3040fe1cbaa8491dcd\\quartz-2.2.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\mysql\\mysql-connector-java\\5.1.48\\9140be77aafa5050bf4bb936d560cbacb5a6b5c1\\mysql-connector-java-5.1.48.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.alibaba\\druid\\1.1.21\\5b2a163e69c4afd223ca6f6f5ac440eec92c0249\\druid-1.1.21.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\redis.clients\\jedis\\3.0.1\\4e8f7e393f17e197b29f7b9481004ede8e154dcb\\jedis-3.0.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.ehcache\\ehcache\\3.5.3\\b81a3c3f1ba4feea2262d24f256fed501f2f4c48\\ehcache-3.5.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\org\\mybatis\\mybatis\\3.5.3\\mybatis-3.5.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.mybatis\\mybatis-spring\\2.0.3\\17472a85388c8d37c9ffefcc9ef0fc3edabcce02\\mybatis-spring-2.0.3.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.hibernate.validator\\hibernate-validator\\6.0.17.Final\\af73055fc4a103ab347c56e7da5a143d68a0170\\hibernate-validator-6.0.17.Final.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.hibernate.validator\\hibernate-validator-annotation-processor\\6.0.17.Final\\7e781852d08e29c11a7b35eea6fb534d7a453fd3\\hibernate-validator-annotation-processor-6.0.17.Final.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\net.jradius\\jradius-core\\1.1.5\\c216654b56044f331290628a2a3d40a0c5d50323\\jradius-core-1.1.5.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\net.jradius\\jradius-dictionary\\1.1.5\\a186921802d11779e3ee3adbe54636489dc1dfd3\\jradius-dictionary-1.1.5.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\joda-time\\joda-time\\2.10\\f66c8125d1057ffce6c4e29e624cac863e110e2b\\joda-time-2.10.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.yaml\\snakeyaml\\1.24\\13a9c0d6776483c3876e3ff9384f9bb55b17001b\\snakeyaml-1.24.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\net.sourceforge.nekohtml\\nekohtml\\1.9.22\\4f54af68ecb345f2453fb6884672ad08414154e3\\nekohtml-1.9.22.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.jdom\\jdom\\2.0.2\\d06c71e0df0ac4b94deb737718580ccce22d92e8\\jdom-2.0.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.google.zxing\\core\\3.4.0\\5264296c46634347890ec9250bc65f14b7362bf8\\core-3.4.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.google.guava\\guava\\27.1-jre\\e47b59c893079b87743cdcfb6f17ca95c08c592c\\guava-27.1-jre.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\ognl\\ognl\\3.2.9\\c582d2e2a7db6e57bfd169b6490cce64c7d245c0\\ognl-3.2.9.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\cglib\\cglib\\3.2.12\\16c0d1d8b5d50ea9ad38c1f6f9f1e35a42727bf0\\cglib-3.2.12.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.ow2.asm\\asm\\7.0\\d74d4ba0dee443f68fb2dcb7fcdb945a2cd89912\\asm-7.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.m2\\repository\\aopalliance\\aopalliance\\1.0\\aopalliance-1.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.aspectj\\aspectjtools\\1.9.4\\b907e51a8a6820926785b8933be3de4a021da90b\\aspectjtools-1.9.4.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\dom4j\\dom4j\\1.6.1\\5d3ccc056b6f056dbf0dddfdf43894b9065a8f94\\dom4j-1.6.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\xalan\\serializer\\2.7.2\\24247f3bb052ee068971393bdb83e04512bb1c3c\\serializer-2.7.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\xml-resolver\\xml-resolver\\1.2\\3d0f97750b3a03e0971831566067754ba4bfd68c\\xml-resolver-1.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.santuario\\xmlsec\\1.5.8\\d0b5e51f571069a86c9578ec15d6d7f9da8c0e76\\xmlsec-1.5.8.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.ogce\\xpp3\\1.1.6\\dc87e00ddb69341b46a3eb1c331c6fcebf6c8546\\xpp3-1.1.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.thoughtworks.xstream\\xstream\\1.4.10\\dfecae23647abc9d9fd0416629a4213a3882b101\\xstream-1.4.10.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\com.belerweb\\pinyin4j\\2.5.1\\ea23babfc45a078af5b73cd9f3401caad1f1b2a9\\pinyin4j-2.5.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.tomcat.embed\\tomcat-embed-core\\9.0.29\\207dc9ca4215853d96ed695862f9873001f02a4b\\tomcat-embed-core-9.0.29.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.apache.tomcat.embed\\tomcat-embed-logging-juli\\8.5.2\\eb8d86e9972274272133c73a976ea744d9086cf1\\tomcat-embed-logging-juli-8.5.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\junit\\junit\\4.11\\4e031bb61df09069aeb2bffb4019e7a5034a4ee0\\junit-4.11.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\javax.servlet\\javax.servlet-api\\3.0.1\\6bf0ebb7efd993e222fc1112377b5e92a13b38dd\\javax.servlet-api-3.0.1.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\me.zhyd.oauth\\JustAuth\\1.13.2\\27f2b1dbaf7ac21f6c3d448885d14696ef8d70be\\JustAuth-1.13.2.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.springframework.boot\\spring-boot-starter-test\\2.2.1.RELEASE\\fae935b40f7a6b7eac7f5daef51e83c2ca978211\\spring-boot-starter-test-2.2.1.RELEASE.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\xmlunit\\xmlunit\\1.6\\adcae0aff916681dacd2b490e193f1119cd964a9\\xmlunit-1.6.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"C:\\Users\\Administrator\\.gradle\\caches\\modules-2\\files-2.1\\org.mockito\\mockito-all\\1.10.19\\539df70269cc254a58cccc5d8e43286b4a73bf30\\mockito-all-1.10.19.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-lib\\mybatis-jpa-extra-1.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"binary","path":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-lib\\mybatis-jpa-extra-2.1-api-1.0.jar","isSystem":false,"isOwn":false,"isTest":false,"isJavaContent":false},{"kind":"source","path":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-client-sdk\\src\\main\\java","outputFolder":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-client-sdk\\bin\\main","isSystem":false,"isOwn":true,"isTest":false,"isJavaContent":true},{"kind":"source","path":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-client-sdk\\src\\test\\java","outputFolder":"D:\\JavaIDE\\Workspaces\\maxkey\\MaxKey\\maxkey-client-sdk\\bin\\test","isSystem":false,"isOwn":true,"isTest":true,"isJavaContent":true}]} \ No newline at end of file diff --git a/maxkey-client-sdk/build.gradle b/maxkey-client-sdk/build.gradle deleted file mode 100644 index 294a6fab2..000000000 --- a/maxkey-client-sdk/build.gradle +++ /dev/null @@ -1,12 +0,0 @@ -description = "maxkey-client-sdk" - -dependencies { - /*compile group: 'commons-io', name: 'commons-io', version: '2.6' - compile group: 'commons-logging', name: 'commons-logging', version: '1.2' - compile group: 'log4j', name: 'log4j', version: '1.2.17' - compile group: 'org.slf4j', name: 'slf4j-api', version: '1.5.11' - compile group: 'commons-codec', name: 'commons-codec', version: '1.14' - compile group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '8.10' - compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6' - */ -} \ No newline at end of file diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/Base64Utils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/Base64Utils.java deleted file mode 100644 index 50f64364f..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/Base64Utils.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.crypto; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; - -import org.apache.commons.codec.binary.Base64; - - -/** - * Base64 Utils - * - * @author Crystal.Sea - * - */ -public final class Base64Utils { - - - - public static String encodeBase64(byte[] simple){ - String cipher=BytesUtils.bytes2String(Base64.encodeBase64(simple)); - return cipher; - } - - public static byte[] decoderBase64(String cipher){ - byte[] simple=Base64.decodeBase64(cipher); - return simple; - } - - public static String encode(String simple){ - return encodeBase64(simple.getBytes()); - } - - public static String encoder(byte[] simple){ - return encodeBase64(simple); - } - - public static String decode(String cipher){ - return BytesUtils.bytes2String(decoderBase64(cipher)); - } - - public static byte[] decoder(String cipher){ - return decoderBase64(cipher); - } - - - /** - *encode file to base64 Code String - * @param fileName file path - * @return * - * @throws Exception - */ - - public static String fileToBase64(String fileName) throws Exception { - File file = new File(fileName);; - FileInputStream inputFile = new FileInputStream(file); - byte[] buffer = new byte[(int) file.length()]; - inputFile.read(buffer); - inputFile.close(); - return encodeBase64(buffer); - - } - - /** - * base64 Code decode String save to targetPath - * @param base64Code - * @param targetPath - * @throws Exception - */ - - public static void decodeBase64ToFile(String base64Code, String targetPath) - throws Exception { - byte[] buffer = decoderBase64(base64Code); - FileOutputStream out = new FileOutputStream(targetPath); - out.write(buffer); - out.close(); - - } - - /** - * base64 code save to file - * @param base64Code - * @param targetPath - * @throws Exception - */ - - public static void base64ToFile(String base64Code, String targetPath) - throws Exception { - byte[] buffer = base64Code.getBytes(); - FileOutputStream out = new FileOutputStream(targetPath); - out.write(buffer); - out.close(); - } - - public static String base64UrlEncode(byte[] simple) { - String s = new String(Base64.encodeBase64(simple)); // Regular base64 - // encoder - s = s.split("=")[0]; // Remove any trailing '='s - s = s.replace('+', '-'); // 62nd char of encoding - s = s.replace('/', '_'); // 63rd char of encoding - return s; - } - - public static byte[] base64UrlDecode(String cipher) { - String s = cipher; - s = s.replace('-', '+'); // 62nd char of encoding - s = s.replace('_', '/'); // 63rd char of encoding - switch (s.length() % 4) { // Pad with trailing '='s - case 0: - break; // No pad chars in this case - case 2: - s += "=="; - break; // Two pad chars - case 3: - s += "="; - break; // One pad char - default: - System.err.println("Illegal base64url String!"); - } - return Base64.decodeBase64(s); // Standard base64 decoder - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/BytesUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/BytesUtils.java deleted file mode 100644 index dec637e6b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/BytesUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.crypto; - -public final class BytesUtils { - - public static String bytes2String(byte[] bytesArray) { - String result = ""; - for (Byte bts : bytesArray) { - result += (char) bts.intValue(); - } - return result; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/HexUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/HexUtils.java deleted file mode 100644 index 02b8baf29..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/HexUtils.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -package org.maxkey.client.crypto; - -import java.io.UnsupportedEncodingException; - -/** - * @author Crystal.Sea - * - */ -public final class HexUtils { - - static final byte[] HEX_CHAR_TABLE = { - (byte) '0', (byte) '1',(byte) '2',(byte) '3', (byte) '4',(byte) '5', (byte) '6', (byte) '7', - (byte) '8', (byte) '9',(byte) 'a', (byte) 'b',(byte) 'c',(byte) 'd', (byte) 'e', (byte) 'f' - }; - - - public static String hex2String(byte[] b) { - String result = ""; - for (int i = 0; i < b.length; i++) { - result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1); - } - return result; - } - - public static String bytes2HexString(byte[] raw) { - byte[] hex = new byte[2 * raw.length]; - int index = 0; - - for (byte b : raw) { - int v = b & 0xFF; - hex[index++] = HEX_CHAR_TABLE[v >>> 4]; - hex[index++] = HEX_CHAR_TABLE[v & 0xF]; - } - String s = ""; - try { - s = new String(hex, "ASCII"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return s; - } - - public static byte[] hex2Bytes(char[] hex) { - int length = hex.length / 2; - byte[] raw = new byte[length]; - for (int i = 0; i < length; i++) { - int high = Character.digit(hex[i * 2], 16); - int low = Character.digit(hex[i * 2 + 1], 16); - int value = (high << 4) | low; - if (value > 127) - value -= 256; - raw[i] = (byte) value; - } - return raw; - } - - public static byte[] hex2Bytes(String hex) { - return hex2Bytes(hex.toCharArray()); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/ReciprocalUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/ReciprocalUtils.java deleted file mode 100644 index 666226124..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/crypto/ReciprocalUtils.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -package org.maxkey.client.crypto; - -import java.io.UnsupportedEncodingException; -import java.security.SecureRandom; -import java.security.Security; - -import javax.crypto.Cipher; -import javax.crypto.KeyGenerator; -import javax.crypto.SecretKey; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.logging.LogFactory; -import org.maxkey.client.utils.StringGenerator; - - -/** - * Reciprocal cipher or Symmetric-key algorithm - * - * algorithm Support DES,DESede,Blowfish and AES - * - * default key value use ReciprocalUtils.defaultKey - * - * generateKey is generate random key for algorithm - * - * @author Crystal.Sea - * - */ -public final class ReciprocalUtils { - - private static final String defaultKey= "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // - - public final class Algorithm { - public static final String DES = "DES"; - public static final String DESede = "DESede"; - public static final String Blowfish = "Blowfish"; - public static final String AES = "AES"; - } - - public static byte[] encode(byte[] simpleBytes, SecretKey secretKey,String algorithm) { - // Create the ciphers - Cipher ecipher; - byte[] byteFinal = null; - try { - ecipher = Cipher.getInstance(secretKey.getAlgorithm()); - // Encode the string into bytes using utf-8 - ecipher.init(Cipher.ENCRYPT_MODE, secretKey); - // Encrypt - byteFinal = ecipher.doFinal(simpleBytes); - return byteFinal; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * @param simple - * @param secretKey - * must length - * @return - * @throws Exception - */ - public static byte[] encode(String simple, String secretKey,String algorithm) { - if (keyLengthCheck(secretKey, algorithm)) { - SecretKey key = generatorKey(secretKey, algorithm); - try { - return encode(simple.getBytes("UTF-8"), key, algorithm); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - return null; - } - - public static byte[] decoder(byte[] ciphersBytes, SecretKey secretKey,String algorithm) { - Cipher cipher; - byte[] byteFinal = null; - try { - cipher = Cipher.getInstance(algorithm); - cipher.init(Cipher.DECRYPT_MODE, secretKey); - byteFinal = cipher.doFinal(ciphersBytes); - // String simple=new String(byteFinal, "UTF8" ); - // return simple; - return byteFinal; - } catch (Exception e) { - e.printStackTrace(); - } finally { - cipher = null; - } - return null; - } - - public static String decoder(byte[] ciphersBytes, String secretKey,String algorithm) { - if (keyLengthCheck(secretKey, algorithm)) { - SecretKey key = generatorKey(secretKey, algorithm); - try { - return new String(decoder(ciphersBytes, key, algorithm), "UTF8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - return null; - } - - private static SecretKey generatorDefaultKey(String algorithm) { - try { - Security.addProvider(new com.sun.crypto.provider.SunJCE()); - KeyGenerator _generator = KeyGenerator.getInstance(algorithm); - _generator.init(new SecureRandom(defaultKey.getBytes())); - SecretKey key = _generator.generateKey(); - _generator = null; - return key; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - private static SecretKey generatorKey(String secretKey, String algorithm) { - try { - SecretKey key = new SecretKeySpec(secretKey.getBytes(), algorithm); - return key; - } catch (Exception e) { - e.printStackTrace(); - } - return null; - } - - - - private static boolean keyLengthCheck(String secretKey,String algorithm){ - boolean lengthCheck=false; - if(algorithm.equals(Algorithm.DES)){ - if(secretKey.length()==8){ - lengthCheck=true; - }else{ - LogFactory.getLog(ReciprocalUtils.class).debug("key length is "+secretKey.getBytes().length+" ,must lequal 8"); - } - }else if(algorithm.equals(Algorithm.DESede)){ - if(secretKey.length()==24){ - lengthCheck=true; - }else{ - LogFactory.getLog(ReciprocalUtils.class).debug("key length is "+secretKey.getBytes().length+" ,must equal 24"); - } - }else if(algorithm.equals(Algorithm.AES)){ - if(secretKey.length()==16){ - lengthCheck=true; - }else{ - LogFactory.getLog(ReciprocalUtils.class).debug("key length is "+secretKey.getBytes().length+" ,must equal 16"); - } - }else if(algorithm.equals(Algorithm.Blowfish)){ - if(secretKey.length()<= 16){ - lengthCheck=true; - }else{ - LogFactory.getLog(ReciprocalUtils.class).debug("key length is "+secretKey.getBytes().length+" ,must be less then 16"); - } - } - return lengthCheck; - } - - public static byte[] encodeByDefaultKey(String simple, String algorithm) { - SecretKey key = generatorDefaultKey(algorithm); - return encode(simple.getBytes(), key, algorithm); - - } - - public static String encode2HexByDefaultKey(String simple, String algorithm) { - byte[] byteFinal = encodeByDefaultKey(simple, algorithm); - - String cipherHex = HexUtils.bytes2HexString(byteFinal); - return cipherHex; - } - - public static byte[] decoderByDefaultKey(byte[] byteCiphers,String algorithm) { - SecretKey key = generatorDefaultKey(algorithm); - return decoder(byteCiphers, key, algorithm); - - } - - public static String decoderHexByDefaultKey(String ciphers, String algorithm) { - byte[] byteSimple = HexUtils.hex2Bytes(ciphers); - byte[] byteFinal = decoderByDefaultKey(byteSimple, algorithm); - - String simple = null; - try { - simple = new String(byteFinal, "UTF-8"); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return simple; - - } - - /** - * encode by defaultKey with Algorithm.AES - * - * @param simple - * @return Hex - */ - public static String encode(String simple) { - return encode2HexByDefaultKey(simple, Algorithm.AES); - } - - /** - * decoder by defaultKey with Algorithm.AES - * - * @param ciphers is HEX - * - * @return - */ - public static String decoder(String ciphers) { - return decoderHexByDefaultKey(ciphers, Algorithm.AES); - } - - public static String generateKey(String algorithm){ - if(algorithm.equals(Algorithm.DES)){ - return (new StringGenerator(8)).randomGenerate(); - }else if(algorithm.equals(Algorithm.AES)){ - return (new StringGenerator(16)).randomGenerate(); - }else if(algorithm.equals(Algorithm.Blowfish)){ - return (new StringGenerator(16)).randomGenerate(); - }else if(algorithm.equals(Algorithm.DESede)){ - return (new StringGenerator(24)).randomGenerate(); - }else{ - return (new StringGenerator()).uniqueGenerate(); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ApacheHttpClient.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ApacheHttpClient.java deleted file mode 100644 index 75bfe9751..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ApacheHttpClient.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.maxkey.client.http; - -/* -public class ApacheHttpClient{ - - private final CloseableHttpAsyncClient client; - - public ApacheHttpClient() { - this(ApacheHttpClientConfig.defaultConfig()); - } - - public ApacheHttpClient(ApacheHttpClientConfig config) { - this(config.getHttpAsyncClientBuilder()); - } - - public ApacheHttpClient(HttpAsyncClientBuilder builder) { - this(builder.build()); - } - - public ApacheHttpClient(CloseableHttpAsyncClient client) { - this.client = client; - this.client.start(); - } - - @Override - public void close() throws IOException { - client.close(); - } - - @Override - public Future executeAsync(String userAgent, Map headers, Verb httpVerb, String completeUrl, - byte[] bodyContents, OAuthAsyncRequestCallback callback, OAuthRequest.ResponseConverter converter) { - final HttpEntity entity = bodyContents == null ? null : new ByteArrayEntity(bodyContents); - return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, entity, callback, converter); - } - - @Override - public Future executeAsync(String userAgent, Map headers, Verb httpVerb, String completeUrl, - MultipartPayload bodyContents, OAuthAsyncRequestCallback callback, - OAuthRequest.ResponseConverter converter) { - - throw new UnsupportedOperationException("ApacheHttpClient does not support MultipartPayload yet."); - } - - @Override - public Future executeAsync(String userAgent, Map headers, Verb httpVerb, String completeUrl, - String bodyContents, OAuthAsyncRequestCallback callback, OAuthRequest.ResponseConverter converter) { - final HttpEntity entity = bodyContents == null ? null : new StringEntity(bodyContents, StandardCharsets.UTF_8); - return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, entity, callback, converter); - } - - @Override - public Future executeAsync(String userAgent, Map headers, Verb httpVerb, String completeUrl, - File bodyContents, OAuthAsyncRequestCallback callback, OAuthRequest.ResponseConverter converter) { - final HttpEntity entity = bodyContents == null ? null : new FileEntity(bodyContents); - return doExecuteAsync(userAgent, headers, httpVerb, completeUrl, entity, callback, converter); - } - - private Future doExecuteAsync(String userAgent, Map headers, Verb httpVerb, - String completeUrl, HttpEntity entity, OAuthAsyncRequestCallback callback, - OAuthRequest.ResponseConverter converter) { - final RequestBuilder builder = getRequestBuilder(httpVerb); - builder.setUri(completeUrl); - - if (httpVerb.isPermitBody()) { - if (!headers.containsKey(CONTENT_TYPE)) { - builder.addHeader(CONTENT_TYPE, DEFAULT_CONTENT_TYPE); - } - builder.setEntity(entity); - } - - for (Map.Entry header : headers.entrySet()) { - builder.addHeader(header.getKey(), header.getValue()); - } - - if (userAgent != null) { - builder.setHeader(OAuthConstants.USER_AGENT_HEADER_NAME, userAgent); - } - final OAuthAsyncCompletionHandler handler = new OAuthAsyncCompletionHandler<>(callback, converter); - final Future future = client.execute(builder.build(), handler); - return new ApacheHttpFuture<>(future, handler); - } - - private static RequestBuilder getRequestBuilder(Verb httpVerb) { - switch (httpVerb) { - case GET: - return RequestBuilder.get(); - case PUT: - return RequestBuilder.put(); - case DELETE: - return RequestBuilder.delete(); - case HEAD: - return RequestBuilder.head(); - case POST: - return RequestBuilder.post(); - case PATCH: - return RequestBuilder.patch(); - case TRACE: - return RequestBuilder.trace(); - case OPTIONS: - return RequestBuilder.options(); - default: - throw new IllegalArgumentException("message build error: unknown verb type"); - } - } -}*/ \ No newline at end of file diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/AuthorizationHeader.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/AuthorizationHeader.java deleted file mode 100644 index c7c71dd0b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/AuthorizationHeader.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import org.maxkey.client.crypto.Base64Utils; - - -/** - * @author Crystal.Sea - * - */ -public class AuthorizationHeader { - - public static String AUTHORIZATION_HEADERNAME="Authorization"; - - public static String BASIC="Basic "; - - public static String BEARER="Bearer "; - - public static String createBasic( String username, String password ){ - String authUserPass = username + ":" + password; - String encodedAuthUserPass = Base64Utils.encode(authUserPass ); - return BASIC + encodedAuthUserPass; - } - - public static String [] resolveBasic( String basic ){ - if(isBasic(basic)){ - String[] userPass =basic.split(" "); - String decodeUserPass = Base64Utils.decode(userPass[1] ); - return decodeUserPass.split(":"); - }else{ - return null; - } - } - - public static boolean isBasic( String basic ){ - if(basic.startsWith(BASIC )){ - return true; - }else{ - return false; - } - } - - public static String resolveBearer( String bearer ){ - if(isBearer(bearer)){ - return bearer.split(" ")[1]; - }else{ - return null; - } - } - - - public static String createBearer(String bearer){ - return BEARER +bearer; - } - - - - public static boolean isBearer( String bearer ){ - if(bearer.startsWith(BEARER )){ - return true; - }else{ - return false; - } - } - - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/HttpVerb.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/HttpVerb.java deleted file mode 100644 index 741f66ccc..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/HttpVerb.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -/** - * An enumeration containing the most common HTTP Verbs. - */ -public enum HttpVerb { - - GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, PATCH -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Parameter.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Parameter.java deleted file mode 100644 index ec317840b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Parameter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import org.maxkey.client.utils.HttpEncoder; - -public class Parameter implements Comparable { - - private final String key; - private final String value; - - public Parameter(String key, String value) { - this.key = key; - this.value = value; - } - - public String asUrlEncodedPair() { - return HttpEncoder.encode(key).concat("=").concat(HttpEncoder.encode(value)); - } - - @Override - public boolean equals(Object other) { - if (other == null) { - return false; - } - if (other == this) { - return true; - } - if (!(other instanceof Parameter)) { - return false; - } - - final Parameter otherParam = (Parameter) other; - return otherParam.getKey().equals(key) && otherParam.getValue().equals(value); - } - - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - - @Override - public int hashCode() { - return key.hashCode() + value.hashCode(); - } - - @Override - public int compareTo(Parameter parameter) { - final int keyDiff = key.compareTo(parameter.getKey()); - - return keyDiff == 0 ? value.compareTo(parameter.getValue()) : keyDiff; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ParameterList.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ParameterList.java deleted file mode 100644 index 347890c3e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/ParameterList.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -public class ParameterList { - - private static final char QUERY_STRING_SEPARATOR = '?'; - private static final String PARAM_SEPARATOR = "&"; - private static final String PAIR_SEPARATOR = "="; - private static final String EMPTY_STRING = ""; - - private final List params; - - public ParameterList() { - params = new ArrayList<>(); - } - - ParameterList(List params) { - this.params = new ArrayList<>(params); - } - - public ParameterList(Map map) { - this(); - if (map != null && !map.isEmpty()) { - for (Map.Entry entry : map.entrySet()) { - params.add(new Parameter(entry.getKey(), entry.getValue())); - } - } - } - - public void add(String key, String value) { - params.add(new Parameter(key, value)); - } - - public String appendTo(String url) { - Preconditions.checkNotNull(url, "Cannot append to null URL"); - final String queryString = asFormUrlEncodedString(); - if (queryString.equals(EMPTY_STRING)) { - return url; - } else { - return url - + (url.indexOf(QUERY_STRING_SEPARATOR) == -1 ? QUERY_STRING_SEPARATOR : PARAM_SEPARATOR) - + queryString; - } - } - - public String asOauthBaseString() { - return HttpEncoder.encode(asFormUrlEncodedString()); - } - - public String asFormUrlEncodedString() { - if (params.isEmpty()) { - return EMPTY_STRING; - } - - final StringBuilder builder = new StringBuilder(); - for (Parameter p : params) { - builder.append(PARAM_SEPARATOR).append(p.asUrlEncodedPair()); - } - return builder.substring(1); - } - - public void addAll(ParameterList other) { - params.addAll(other.getParams()); - } - - public void addQuerystring(String queryString) { - if (queryString != null && !queryString.isEmpty()) { - for (String param : queryString.split(PARAM_SEPARATOR)) { - try{ - final String[] pair = param.split(PAIR_SEPARATOR); - final String key = HttpEncoder.decode(pair[0]); - final String value = pair.length > 1 ? HttpEncoder.decode(pair[1]) : EMPTY_STRING; - params.add(new Parameter(key, value)); - }catch(Exception e){ - - } - } - } - } - - public boolean contains(Parameter param) { - return params.contains(param); - } - - public int size() { - return params.size(); - } - - public List getParams() { - return params; - } - - public ParameterList sort() { - final ParameterList sorted = new ParameterList(params); - Collections.sort(sorted.getParams()); - return sorted; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Request.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Request.java deleted file mode 100644 index d084cb0f5..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Request.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import java.io.*; -import java.net.*; -import java.nio.charset.*; -import java.util.*; -import java.util.concurrent.*; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.utils.HttpsTrusts; -import org.maxkey.client.utils.JsonUtils; - -/** - * Represents an HTTP Request object - * - */ -public class Request -{ - private static Log _log = LogFactory.getLog(Request. class ); - public static final String DEFAULT_CONTENT_TYPE = "application/x-www-form-urlencoded"; - private static final String CONTENT_LENGTH = "Content-Length"; - private static final String CONTENT_TYPE = "Content-Type"; - private static RequestTuner NOOP = new RequestTuner() { - @Override public void tune(Request request){} - }; - - - private String url; - private HttpVerb verb; - private ParameterList querystringParams; - private ParameterList bodyParams; - private Map headers; - private String payload = null; - private HttpURLConnection connection; - private String charset; - private byte[] bytePayload = null; - private boolean connectionKeepAlive = false; - private boolean followRedirects = true; - private Long connectTimeout = null; - private Long readTimeout = null; - private String realm; - /** - * Creates a new Http Request - * - * @param verb Http Verb (GET, POST, etc) - * @param url url with optional querystring parameters. - */ - public Request(HttpVerb verb, String url) - { - this.verb = verb; - this.url = url; - this.querystringParams = new ParameterList(); - this.bodyParams = new ParameterList(); - this.headers = new HashMap(); - } - - /** - * Execute the request and return a {@link Response} - * - * @return Http Response - * @throws RuntimeException - * if the connection cannot be created. - */ - public Response send(RequestTuner tuner) - { - try - { - createConnection(); - return doSend(tuner); - } - catch (Exception e) - { - throw new OAuthConnectionException(e); - } - } - - public Response send() - { - return send(NOOP); - } - - private void createConnection() throws IOException - { - String completeUrl = getCompleteUrl(); - _log.debug("verb method : "+verb); - _log.debug("completeUrl : "+completeUrl); - - if (connection == null) - { - System.setProperty("http.keepAlive", connectionKeepAlive ? "true" : "false"); - connection = (HttpURLConnection) new URL(completeUrl).openConnection(); - if(completeUrl.trim().startsWith("https")){ - HttpsTrusts.beforeConnection(); - } - - connection.setInstanceFollowRedirects(followRedirects); - } - } - - /** - * Returns the complete url (host + resource + encoded querystring parameters). - * - * @return the complete url. - */ - public String getCompleteUrl() - { - return querystringParams.appendTo(url); - } - - Response doSend(RequestTuner tuner) throws IOException - { - connection.setRequestMethod(this.verb.name()); - if (connectTimeout != null) - { - connection.setConnectTimeout(connectTimeout.intValue()); - } - if (readTimeout != null) - { - connection.setReadTimeout(readTimeout.intValue()); - } - addHeaders(connection); - if (verb.equals(HttpVerb.PUT) || verb.equals(HttpVerb.POST)) - { - addBody(connection, getByteBodyContents()); - } - tuner.tune(this); - return new Response(connection); - } - - void addHeaders(HttpURLConnection conn) - { - for (String key : headers.keySet()) - conn.setRequestProperty(key, headers.get(key)); - } - - void addBody(HttpURLConnection conn, byte[] content) throws IOException - { - conn.setRequestProperty(CONTENT_LENGTH, String.valueOf(content.length)); - - // Set default content type if none is set. - if (conn.getRequestProperty(CONTENT_TYPE) == null) - { - conn.setRequestProperty(CONTENT_TYPE, DEFAULT_CONTENT_TYPE); - } - conn.setDoOutput(true); - conn.getOutputStream().write(content); - } - - /** - * Add an HTTP Header to the Request - * - * @param key the header name - * @param value the header value - */ - public void addHeader(String key, String value) - { - this.headers.put(key, value); - } - - /** - * Add a body Parameter (for POST/ PUT Requests) - * - * @param key the parameter name - * @param value the parameter value - */ - public void addBodyParameter(String key, String value) - { - this.bodyParams.add(key, value); - } - - /** - * Add a QueryString parameter - * - * @param key the parameter name - * @param value the parameter value - */ - public void addQuerystringParameter(String key, String value) - { - this.querystringParams.add(key, value); - } - - public void addParameter(String key, String value) { - if (hasBodyContent()) { - bodyParams.add(key, value); - } else { - querystringParams.add(key, value); - } - } - - protected boolean hasBodyContent() { - return verb == HttpVerb.PUT || verb == HttpVerb.POST; - } - /** - * Add body payload. - * - * This method is used when the HTTP body is not a form-url-encoded string, - * but another thing. Like for example XML. - * - * Note: The contents are not part of the OAuth signature - * - * @param payload the body of the request - */ - public void addPayload(String payload) - { - this.payload = payload; - } - - /** - * Overloaded version for byte arrays - * - * @param payload - */ - public void addPayload(byte[] payload) - { - this.bytePayload = payload.clone(); - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(String content) - { - this.payload = content; - } - - /** - * set REST Content - * - * @param content - */ - public void addRestObject(Object content) - { - try { - this.bytePayload = JsonUtils.gson2Json(content).getBytes("UTF-8"); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(byte[] content) - { - this.bytePayload = content.clone(); - } - - /** - * Get a {@link ParameterList} with the query string parameters. - * - * @return a {@link ParameterList} containing the query string parameters. - * @throws OAuthException if the request URL is not valid. - */ - public ParameterList getQueryStringParams() - { - try - { - ParameterList result = new ParameterList(); - String queryString = new URL(url).getQuery(); - result.addQuerystring(queryString); - result.addAll(querystringParams); - return result; - } - catch (MalformedURLException mue) - { - throw new OAuthException("Malformed URL", mue); - } - } - - /** - * Obtains a {@link ParameterList} of the body parameters. - * - * @return a {@link ParameterList}containing the body parameters. - */ - public ParameterList getBodyParams() - { - return bodyParams; - } - - /** - * Obtains the URL of the HTTP Request. - * - * @return the original URL of the HTTP Request - */ - public String getUrl() - { - return url; - } - - /** - * Returns the URL without the port and the query string part. - * - * @return the OAuth-sanitized URL - - public String getSanitizedUrl() - { - return url.replaceAll("\\?.*", "").replace("\\:\\d{4}", ""); - } - */ - /** - * Returns the URL without the port and the query string part. - * - * @return the OAuth-sanitized URL - */ - public String getSanitizedUrl() { - if (url.startsWith("http://") && (url.endsWith(":80") || url.contains(":80/"))) { - return url.replaceAll("\\?.*", "").replaceAll(":80", ""); - } else if (url.startsWith("https://") && (url.endsWith(":443") || url.contains(":443/"))) { - return url.replaceAll("\\?.*", "").replaceAll(":443", ""); - } else { - return url.replaceAll("\\?.*", ""); - } - } - /** - * Returns the body of the request - * - * @return form encoded string - * @throws OAuthException if the charset chosen is not supported - */ - public String getBodyContents() - { - try - { - return new String(getByteBodyContents(),getCharset()); - } - catch(UnsupportedEncodingException uee) - { - throw new OAuthException("Unsupported Charset: "+charset, uee); - } - } - - byte[] getByteBodyContents() - { - if (bytePayload != null) return bytePayload; - String body = (payload != null) ? payload : bodyParams.asFormUrlEncodedString(); - - _log.debug("getByteBodyContents : "+body); - try - { - return body.getBytes(getCharset()); - } - catch(UnsupportedEncodingException uee) - { - throw new OAuthException("Unsupported Charset: "+getCharset(), uee); - } - } - - - /** - * Returns the HTTP Verb - * - * @return the verb - */ - public HttpVerb getVerb() - { - return verb; - } - - public void setRealm(String realm) { - this.realm = realm; - } - - public String getRealm() { - return realm; - } - - /** - * Returns the connection headers as a {@link Map} - * - * @return map of headers - */ - public Map getHeaders() - { - return headers; - } - - /** - * Returns the connection charset. Defaults to {@link Charset} defaultCharset if not set - * - * @return charset - */ - public String getCharset() - { - return charset == null ? Charset.defaultCharset().name() : charset; - } - - /** - * Sets the connect timeout for the underlying {@link HttpURLConnection} - * - * @param duration duration of the timeout - * - * @param unit unit of time (milliseconds, seconds, etc) - */ - public void setConnectTimeout(int duration, TimeUnit unit) - { - this.connectTimeout = unit.toMillis(duration); - } - - /** - * Sets the read timeout for the underlying {@link HttpURLConnection} - * - * @param duration duration of the timeout - * - * @param unit unit of time (milliseconds, seconds, etc) - */ - public void setReadTimeout(int duration, TimeUnit unit) - { - this.readTimeout = unit.toMillis(duration); - } - - /** - * Set the charset of the body of the request - * - * @param charsetName name of the charset of the request - */ - public void setCharset(String charsetName) - { - this.charset = charsetName; - } - - /** - * Sets whether the underlying Http Connection is persistent or not. - * - * @see http://download.oracle.com/javase/1.5.0/docs/guide/net/http-keepalive.html - * @param connectionKeepAlive - */ - - @Deprecated - public void setConnectionKeepAlive(boolean connectionKeepAlive){ - this.connectionKeepAlive = connectionKeepAlive; - } - - /** - * - * @param connectionKeepAlive - * true or false - */ - public void setConnectionKeepAlive(String connectionKeepAlive){ - System.setProperty("http.keepAlive", connectionKeepAlive); - } - - /** - * Sets whether the underlying Http Connection follows redirects or not. - * - * Defaults to true (follow redirects) - * - * @see http://docs.oracle.com/javase/6/docs/api/java/net/HttpURLConnection.html#setInstanceFollowRedirects(boolean) - * @param followRedirects - */ - public void setFollowRedirects(boolean followRedirects) - { - this.followRedirects = followRedirects; - } - - /* - * We need this in order to stub the connection object for test cases - */ - void setConnection(HttpURLConnection connection) - { - this.connection = connection; - } - - @Override - public String toString() - { - return String.format("@Request(%s %s)", getVerb(), getUrl()); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RequestTuner.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RequestTuner.java deleted file mode 100644 index a95e3b884..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RequestTuner.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -public abstract class RequestTuner -{ - public abstract void tune(Request request); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Response.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Response.java deleted file mode 100644 index e43de9311..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/Response.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import java.io.*; -import java.net.*; -import java.util.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.utils.StreamUtils; - -/** - * Represents an HTTP Response. - * - * @author Pablo Fernandez - */ -public class Response { - - private int code; - private String message; - private String body; - private InputStream stream; - private Map headers; - - public Response(int code, String message, Map headers, String body, InputStream stream) { - this.code = code; - this.headers = headers; - this.body = body; - this.message = message; - this.stream = stream; - } - - Response(HttpURLConnection connection) throws IOException { - try { - connection.connect(); - code = connection.getResponseCode(); - message = connection.getResponseMessage(); - headers = parseHeaders(connection); - stream = isSuccessful() ? connection.getInputStream() : connection.getErrorStream(); - } catch (UnknownHostException e) { - throw new OAuthException("The IP address of a host could not be determined.", e); - } - } - - private String parseBodyContents() throws IOException { - if ("gzip".equals(getHeader("Content-Encoding"))) { - body = StreamUtils.getGzipStreamContents(getStream()); - } else { - body = StreamUtils.getStreamContents(getStream()); - } - return body; - } - - private Map parseHeaders(HttpURLConnection conn) { - final Map headers = new HashMap<>(); - for (String key : conn.getHeaderFields().keySet()) { - headers.put(key, conn.getHeaderFields().get(key).get(0)); - } - return headers; - } - - public final boolean isSuccessful() { - return getCode() >= 200 && getCode() < 400; - } - - public String getBody() { - try { - return body == null ? parseBodyContents() : body; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return ""; - } - - /** - * Obtains the meaningful stream of the HttpUrlConnection, either inputStream or errorInputStream, depending on the - * status code - * - * @return input stream / error stream - */ - public InputStream getStream() { - return stream; - } - - /** - * Obtains the HTTP status code - * - * @return the status code - */ - public final int getCode() { - return code; - } - - /** - * Obtains the HTTP status message. Returns null if the message can not be discerned from the response - * (not valid HTTP) - * - * @return the status message - */ - public String getMessage() { - return message; - } - - /** - * Obtains a {@link Map} containing the HTTP Response Headers - * - * @return headers - */ - public Map getHeaders() { - return headers; - } - - /** - * Obtains a single HTTP Header value, or null if undefined - * - * @param name the header name. - * - * @return header value or null. - */ - public String getHeader(String name) { - return headers.get(name); - } - - @Override - public String toString() { - return "Response{" + - "code=" + code + - ", message='" + message + '\'' + - ", body='" + body + '\'' + - ", headers=" + headers + - '}'; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RestClient.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RestClient.java deleted file mode 100644 index 1fdc638f0..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/RestClient.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.maxkey.client.http.AuthorizationHeader; -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Response; -import org.maxkey.client.utils.Preconditions; - - -public class RestClient { - - private static Log _log = LogFactory.getLog(RestClient. class ); - - //action method - private HttpVerb method = HttpVerb.GET; - - //request Service - private Request request; - - - public RestClient(String url) { - Preconditions.checkEmptyString(url, "Invalid request url"); - - request = new Request(method, url); - } - - - /** - * 鏋勯�犳柟娉� - * - * @param method 璇锋眰鏂规硶 - * @param url 璇锋眰url - */ - public RestClient(String url,HttpVerb method) { - Preconditions.checkEmptyString(url, "Invalid request url"); - if(method != null) { - this.method = method; - } - request = new Request(method, url); - } - - - /** - * 娣诲姞璇锋眰鍙傛暟 - * - * @param name 鍙傛暟鍚� - * @param value 鍙傛暟鍊� - */ - public void addParameter(String name,String value) { - Preconditions.checkEmptyString(name, "parameter name is null"); - Preconditions.checkNotNull(request, "RestClient is null"); - if(HttpVerb.GET == method) { - request.addQuerystringParameter(name, value); - } else if(HttpVerb.POST == method) { - request.addBodyParameter(name, value); - } - } - - /** - * 娣诲姞璇锋眰Header - * - * @param name 鍙傛暟鍚� - * @param value 鍙傛暟鍊� - */ - public void addHeader(String name,String value) { - Preconditions.checkEmptyString(name, "parameter name is null"); - Preconditions.checkNotNull(request, "OAuthRequest is null"); - request.addHeader(name, value); - } - - /** - * 鍙戦�佽姹傦紝鑾峰彇杩斿洖鐨勬暟鎹� - * - * @return Response 鏈嶅姟绔繑鍥炵殑鏁版嵁 - */ - public Response execute() { - return request.send(); - } - - - public void addBasicAuthorization(String username,String password) { - Preconditions.checkEmptyString(username, "parameter username is null"); - Preconditions.checkEmptyString(password, "parameter password is null"); - Preconditions.checkNotNull(request, "RestClient is null"); - request.addHeader(AuthorizationHeader.AUTHORIZATION_HEADERNAME, AuthorizationHeader.createBasic(username, password)); - } - - public void addBearerAuthorization(String bearer) { - Preconditions.checkEmptyString(bearer, "parameter bearer is null"); - Preconditions.checkNotNull(request, "RestClient is null"); - request.addHeader(AuthorizationHeader.AUTHORIZATION_HEADERNAME, AuthorizationHeader.createBearer(bearer)); - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(String content) - { - this.request.addRestContent(content) ; - } - - /** - * set REST Content - * - * @param content - */ - public void addRestObject(Object content) - { - this.request.addRestObject(content); - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(byte[] content) - { - this.request.addRestContent(content); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/SignatureType.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/SignatureType.java deleted file mode 100644 index d3ee2d076..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/SignatureType.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.http; - -public enum SignatureType -{ - Header, - QueryString -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/package-info.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/http/package-info.java deleted file mode 100644 index 5a7bb9b15..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/http/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -/** - * @author Administrator - * - */ -package org.maxkey.client.http; diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/ltpa/LtpaUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/ltpa/LtpaUtils.java deleted file mode 100644 index 29de0a78d..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/ltpa/LtpaUtils.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.ltpa; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.maxkey.client.crypto.Base64Utils; -import org.maxkey.client.crypto.ReciprocalUtils; -import org.maxkey.client.utils.JsonUtils; - -public class LtpaUtils { - - public static String readLtpa(HttpServletRequest request,String ltpaDomain,String ltpaName){ - Cookie[] cookies = request.getCookies(); - if(cookies!=null) { - for (int i = 0; i < cookies.length; i++) { - if(cookies[i].getName().equalsIgnoreCase(ltpaName)){ - return cookies[i].getValue(); - } - } - } - return null; - } - - public static String decode(String ltpaString,String algorithmKey, String algorithm){ - - String token=ReciprocalUtils.decoder(Base64Utils.base64UrlDecode(ltpaString), algorithmKey, algorithm); - - try { - token=new String(Hex.decodeHex(token.toCharArray()),"UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } catch (DecoderException e) { - e.printStackTrace(); - } - - return token; - } - - - @SuppressWarnings("unchecked") - public static HashMap parseLtpaJson(String token){ - HashMap tokenMap=new HashMap(); - - tokenMap=JsonUtils.gson2Object(token, tokenMap.getClass()); - - return tokenMap; - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - String token="ICHQ%2F1Tdzw214UNw9fKEjRNFbvOlGdXyxVjF9I7kwEo%3D"; - String tokenString=LtpaUtils.decode(token, "x8zPbCya", ReciprocalUtils.Algorithm.DES); - System.out.println(tokenString); - - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/OAuthClient.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/OAuthClient.java deleted file mode 100644 index 775cfd64f..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/OAuthClient.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.maxkey.client.http.AuthorizationHeader; -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Response; -import org.maxkey.client.oauth.domain.OIDCUserInfo; -import org.maxkey.client.oauth.domain.UserInfo; -import org.maxkey.client.oauth.model.OAuthConstants; -import org.maxkey.client.oauth.model.OAuthRequest; -import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.utils.JsonUtils; -import org.maxkey.client.utils.Preconditions; - - -public class OAuthClient { - - private static Log log = LogFactory.getLog(OAuthClient. class ); - private static final String DEFAULT_WEB_URL = "http://sso.maxkey.org/maxkey"; - - public static String OAUTH_V20_USERINFO_URI=DEFAULT_WEB_URL+"/api/oauth/v20/me"; - - public static String OAUTH_V10A_USERINFO_URI=DEFAULT_WEB_URL+"/api/oauth/v10a/me"; - - public static String OPENID_CONNECT_V10A_USERINFO_URI=DEFAULT_WEB_URL+"/api/connect/v10/userinfo"; - - //action method - private HttpVerb method = HttpVerb.GET; - //request Service - private OAuthRequest request; - - - public OAuthClient(String url) { - Preconditions.checkEmptyString(url, "Invalid request url"); - - request = new OAuthRequest(method, url); - } - - public OAuthClient(String url,String accessToken) { - - Preconditions.checkEmptyString(url, "Invalid request url"); - - request = new OAuthRequest(method, url); - - addParameter(OAuthConstants.ACCESS_TOKEN, accessToken); - } - - - /** - * 鏋勯�犳柟娉� - * - * @param method 璇锋眰鏂规硶 - * @param url 璇锋眰url - */ - public OAuthClient(String url,HttpVerb method) { - Preconditions.checkEmptyString(url, "Invalid request url"); - if(method != null) { - this.method = method; - } - request = new OAuthRequest(method, url); - } - - /** - * 灏哸ccess token闄勫姞鍒拌姹傚弬鏁颁腑 - * - * @param accessToken - */ - public void signAccessToken(Token accessToken) { - Preconditions.checkNotNull(request, "OAuthRequest is null"); - addParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken()); - } - - /** - * 娣诲姞璇锋眰鍙傛暟 - * - * @param name 鍙傛暟鍚� - * @param value 鍙傛暟鍊� - */ - public void addParameter(String name,String value) { - Preconditions.checkEmptyString(name, "parameter name is null"); - Preconditions.checkNotNull(request, "OAuthRequest is null"); - if(HttpVerb.GET == method) { - request.addQuerystringParameter(name, value); - } else if(HttpVerb.POST == method) { - request.addBodyParameter(name, value); - } - } - - /** - * 娣诲姞璇锋眰Header - * - * @param name 鍙傛暟鍚� - * @param value 鍙傛暟鍊� - */ - public void addHeader(String name,String value) { - Preconditions.checkEmptyString(name, "parameter name is null"); - Preconditions.checkNotNull(request, "OAuthRequest is null"); - request.addHeader(name, value); - } - - /** - * 鍙戦�佽姹傦紝鑾峰彇杩斿洖鐨勬暟鎹� - * - * @return Response 鏈嶅姟绔繑鍥炵殑鏁版嵁 - */ - public Response execute() { - return request.send(); - } - - public Token requestAccessToken(){ - String tokenString=execute().getBody(); - Token token =JsonUtils.gson2Object(tokenString, Token.class); - log.debug("Request token : "+token); - return token; - } - - public void addBasicAuthorization(String username,String password) { - Preconditions.checkEmptyString(username, "parameter username is null"); - Preconditions.checkEmptyString(password, "parameter password is null"); - Preconditions.checkNotNull(request, "OAuthRequest is null"); - request.addHeader(AuthorizationHeader.AUTHORIZATION_HEADERNAME, AuthorizationHeader.createBasic(username, password)); - } - - public void addBearerAuthorization(String bearer) { - Preconditions.checkEmptyString(bearer, "parameter bearer is null"); - Preconditions.checkNotNull(request, "OAuthRequest is null"); - request.addHeader(AuthorizationHeader.AUTHORIZATION_HEADERNAME, AuthorizationHeader.createBearer(bearer)); - } - - public UserInfo getUserInfo(String accessToken){ - - addParameter(OAuthConstants.ACCESS_TOKEN, accessToken); - - Response response = execute(); - - log.debug("Request UserInfo : "+response.getBody()); - - UserInfo userInfo = (UserInfo) JsonUtils.gson2Object(response.getBody(), UserInfo.class); - - userInfo.setResponseString(response.getBody()); - - if(userInfo.getError() != null && !"".equals(userInfo.getError().trim())) { - } - - log.debug("UserInfo : "+userInfo); - return userInfo; - } - - public OIDCUserInfo getOIDCUserInfo(String accessToken){ - - addHeader("Authorization", accessToken); - - Response response = execute(); - - log.debug("Request OIDCUserInfo : "+response.getBody()); - - OIDCUserInfo userInfo = (OIDCUserInfo) JsonUtils.gson2Object(response.getBody(), OIDCUserInfo.class); - - userInfo.setResponseString(response.getBody()); - - if(userInfo.getError() != null && !"".equals(userInfo.getError().trim())) { - } - - log.debug("UserInfo : "+userInfo); - return userInfo; - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(String content) - { - this.request.addRestContent(content) ; - } - - /** - * set REST Content - * - * @param content - */ - public void addRestObject(Object content) - { - this.request.addRestObject(content); - } - - /** - * set REST Content - * - * @param content - */ - public void addRestContent(byte[] content) - { - this.request.addRestContent(content); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/ServiceBuilder.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/ServiceBuilder.java deleted file mode 100644 index 66f2d73fd..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/ServiceBuilder.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder; - -import java.io.*; - -import org.maxkey.client.http.SignatureType; -import org.maxkey.client.oauth.builder.api.*; -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.oauth.oauth.*; -import org.maxkey.client.utils.Preconditions; - -/** - * Implementation of the Builder pattern, with a fluent interface that creates a - * {@link OAuthService} - * - * @author Pablo Fernandez - * - */ -public class ServiceBuilder -{ - private String apiKey; - private String apiSecret; - private String callback; - private Api api; - private String scope; - private SignatureType signatureType; - private OutputStream debugStream; - - /** - * Default constructor - */ - public ServiceBuilder() - { - this.callback = OAuthConstants.OUT_OF_BAND; - this.signatureType = SignatureType.Header; - this.debugStream = null; - } - - /** - * Configures the {@link Api} - * - * @param apiClass the class of one of the existent {@link Api}s on org.scribe.api package - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder provider(Class apiClass) - { - this.api = createApi(apiClass); - return this; - } - - private Api createApi(Class apiClass) - { - Preconditions.checkNotNull(apiClass, "Api class cannot be null"); - Api api; - try - { - api = apiClass.newInstance(); - } - catch(Exception e) - { - throw new OAuthException("Error while creating the Api object", e); - } - return api; - } - - /** - * Configures the {@link Api} - * - * Overloaded version. Let's you use an instance instead of a class. - * - * @param api instance of {@link Api}s - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder provider(Api api) - { - Preconditions.checkNotNull(api, "Api cannot be null"); - this.api = api; - return this; - } - - /** - * Adds an OAuth callback url - * - * @param callback callback url. Must be a valid url or 'oob' for out of band OAuth - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder callback(String callback) - { - Preconditions.checkNotNull(callback, "Callback can't be null"); - this.callback = callback; - return this; - } - - /** - * Configures the api key - * - * @param apiKey The api key for your application - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder apiKey(String apiKey) - { - Preconditions.checkEmptyString(apiKey, "Invalid Api key"); - this.apiKey = apiKey; - return this; - } - - /** - * Configures the api secret - * - * @param apiSecret The api secret for your application - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder apiSecret(String apiSecret) - { - Preconditions.checkEmptyString(apiSecret, "Invalid Api secret"); - this.apiSecret = apiSecret; - return this; - } - - /** - * Configures the OAuth scope. This is only necessary in some APIs (like Google's). - * - * @param scope The OAuth scope - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder scope(String scope) - { - Preconditions.checkEmptyString(scope, "Invalid OAuth scope"); - this.scope = scope; - return this; - } - - /** - * Configures the signature type, choose between header, querystring, etc. Defaults to Header - * - * @param scope The OAuth scope - * @return the {@link ServiceBuilder} instance for method chaining - */ - public ServiceBuilder signatureType(SignatureType type) - { - Preconditions.checkNotNull(type, "Signature type can't be null"); - this.signatureType = type; - return this; - } - - public ServiceBuilder debugStream(OutputStream stream) - { - Preconditions.checkNotNull(stream, "debug stream can't be null"); - this.debugStream = stream; - return this; - } - - public ServiceBuilder debug() - { - this.debugStream(System.out); - return this; - } - - /** - * Returns the fully configured {@link OAuthService} - * - * @return fully configured {@link OAuthService} - */ - public OAuthService build() - { - Preconditions.checkNotNull(api, "You must specify a valid api through the provider() method"); - Preconditions.checkEmptyString(apiKey, "You must provide an api key"); - Preconditions.checkEmptyString(apiSecret, "You must provide an api secret"); - return api.createService(new OAuthConfig(apiKey, apiSecret, callback, signatureType, scope, debugStream)); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/Api.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/Api.java deleted file mode 100644 index a2284f87e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/Api.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder.api; - - -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.oauth.oauth.*; - -/** - * Contains all the configuration needed to instantiate a valid {@link OAuthService} - * - * @author Pablo Fernandez - * - */ -public interface Api -{ - /** - * Creates an {@link OAuthService} - * - * @param apiKey your application api key - * @param apiSecret your application api secret - * @param callback the callback url (or 'oob' for out of band OAuth) - * @param scope the OAuth scope - * - * @return fully configured {@link OAuthService} - */ - OAuthService createService(OAuthConfig config); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/DefaultApi20.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/DefaultApi20.java deleted file mode 100644 index fb5e4209c..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/DefaultApi20.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder.api; - - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.oauth.extractors.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.oauth.oauth.*; - -/** - * Default implementation of the OAuth protocol, version 2.0 (draft 11) - * - * This class is meant to be extended by concrete implementations of the API, - * providing the endpoints and endpoint-http-verbs. - * - * If your Api adheres to the 2.0 (draft 11) protocol correctly, you just need to extend - * this class and define the getters for your endpoints. - * - * If your Api does something a bit different, you can override the different - * extractors or services, in order to fine-tune the process. Please read the - * javadocs of the interfaces to get an idea of what to do. - * - * @author Diego Silveira - * - */ -public abstract class DefaultApi20 implements Api -{ - - /** - * Returns the access token extractor. - * - * @return access token extractor - */ - public AccessTokenExtractor getAccessTokenExtractor() - { - return new TokenExtractor20Impl(); - } - - /** - * Returns the verb for the access token endpoint (defaults to GET) - * - * @return access token endpoint verb - */ - public HttpVerb getAccessTokenVerb() - { - return HttpVerb.GET; - } - - /** - * Returns the URL that receives the access token requests. - * - * @return access token URL - */ - public abstract String getAccessTokenEndpoint(); - - - public abstract String getGrantType() ; - /** - * Returns the URL where you should redirect your users to authenticate - * your application. - * - * @param config OAuth 2.0 configuration param object - * @return the URL where you should redirect your users - */ - public abstract String getAuthorizationUrl(OAuthConfig config); - - /** - * {@inheritDoc} - */ - public OAuthService createService(OAuthConfig config) - { - return new OAuth20ServiceImpl(this, config); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyApi20.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyApi20.java deleted file mode 100644 index 7795a1f0b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyApi20.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder.api; - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.oauth.extractors.AccessTokenExtractor; -import org.maxkey.client.oauth.extractors.GsonJsonTokenExtractor; -import org.maxkey.client.oauth.model.OAuthConfig; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -public class MaxkeyApi20 extends DefaultApi20 { - //approval_prompt:force or auto - private static final String DEFAULT_WEB_URL = "https://sso.maxkey.top/maxkey"; - - private static final String AUTHORIZATION_URL = "%s/oauth/v20/authorize?client_id=%s&response_type=code&redirect_uri=%s&approval_prompt=auto"; - - private static final String SCOPED_AUTHORIZE_URL = String.format("%s&scope=%%s", AUTHORIZATION_URL); - - public MaxkeyApi20() { - - } - - - @Override - public String getAccessTokenEndpoint() { - return getWebUrl() + "/oauth/v20/token?grant_type=authorization_code"; - } - - - @Override - public String getAuthorizationUrl(OAuthConfig config) { - Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback. Secure does not support OOB"); - if(config.hasScope()) { - return String.format(SCOPED_AUTHORIZE_URL, getWebUrl(),config.getApiKey(), HttpEncoder.encode(config.getCallback()), HttpEncoder.encode(config.getScope())); - } else { - return String.format(AUTHORIZATION_URL, getWebUrl(),config.getApiKey(), HttpEncoder.encode(config.getCallback())); - } - } - - - - @Override - public HttpVerb getAccessTokenVerb() { - return HttpVerb.POST; - } - - - @Override - public AccessTokenExtractor getAccessTokenExtractor() { - return new GsonJsonTokenExtractor(); - } - - private String getWebUrl() { - String webUrl = null; - if(webUrl == null || "".equals(webUrl)) { - webUrl = DEFAULT_WEB_URL; - } - return webUrl; - } - - - @Override - public String getGrantType() { - // TODO Auto-generated method stub - return "authorization_code"; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyPasswordApi20.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyPasswordApi20.java deleted file mode 100644 index 1507e6d5e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/MaxkeyPasswordApi20.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder.api; - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.oauth.extractors.AccessTokenExtractor; -import org.maxkey.client.oauth.extractors.GsonJsonTokenExtractor; -import org.maxkey.client.oauth.model.OAuthConfig; - - - -/** - * OAuth 2.0 api. - */ -public class MaxkeyPasswordApi20 extends DefaultApi20 { - - private String accessTokenUrl; - private String grantType = "password"; - private String scope = "&scope=%s"; - private String accessTokenMethod = "POST"; - - private static final String AUTHORIZE_PARAM = "&client_id=%s&client_secret=%s&username=%s&password=%s"; - - public MaxkeyPasswordApi20(String accessTokenUrl) { - super(); - this.accessTokenUrl = accessTokenUrl; - } - - @Override - public HttpVerb getAccessTokenVerb() { - if (accessTokenMethod != null - && accessTokenMethod.toUpperCase().equals("POST")) { - return HttpVerb.POST; - } else { - return HttpVerb.GET; - } - } - - @Override - public AccessTokenExtractor getAccessTokenExtractor() { - return new GsonJsonTokenExtractor(); - } - - @Override - public String getAccessTokenEndpoint() { - if (accessTokenUrl.indexOf("?") > 0) { - return accessTokenUrl + "&grant_type=" + grantType+ AUTHORIZE_PARAM; - } else { - return accessTokenUrl + "?grant_type=" + grantType+ AUTHORIZE_PARAM; - } - } - - public String getAuthorizationUrl(OAuthConfig config,String username,String password) { - return String.format(getAccessTokenEndpoint(), - config.getApiKey(), - config.getApiSecret(), - username, - password); - } - - public String getAccessTokenUrl() { - return accessTokenUrl; - } - - public void setAccessTokenUrl(String accessTokenUrl) { - this.accessTokenUrl = accessTokenUrl; - } - - @Override - public String toString() { - return "OAuthApi20 [accessTokenUrl=" + accessTokenUrl + ", grantType=" - + grantType + ", scope=" + scope + "]"; - } - - @Override - public String getAuthorizationUrl(OAuthConfig config) { - return ""; - } - - @Override - public String getGrantType() { - // TODO Auto-generated method stub - return "authorization_code"; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/OAuthApi20.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/OAuthApi20.java deleted file mode 100644 index 3a0a81509..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/builder/api/OAuthApi20.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.builder.api; - - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.oauth.extractors.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.HttpEncoder; - -/** - * OAuth 2.0 api. - */ -public class OAuthApi20 extends DefaultApi20 -{ - //private static final String AUTHORIZE_URL = "https://api.weibo.com/oauth2/authorize?client_id=%s&redirect_uri=%s&response_type=code"; - //private static final String SCOPED_AUTHORIZE_URL = AUTHORIZE_URL + "&scope=%s"; - private String authorizeUrl; - private String accessTokenUrl; - private String grantType="authorization_code"; - private String scope="&scope=%s"; - private String accessTokenMethod="POST"; - - - public OAuthApi20(String authorizeUrl, String accessTokenUrl) { - super(); - this.authorizeUrl = authorizeUrl; - this.accessTokenUrl = accessTokenUrl; - } - - public OAuthApi20(String authorizeUrl, String accessTokenUrl,String accessTokenMethod) { - super(); - this.authorizeUrl = authorizeUrl; - this.accessTokenUrl = accessTokenUrl; - this.accessTokenMethod=accessTokenMethod; - } - - public OAuthApi20(String authorizeUrl, String accessTokenUrl,String grantType,String accessTokenMethod) { - super(); - this.authorizeUrl = authorizeUrl; - this.accessTokenUrl = accessTokenUrl; - this.grantType = grantType; - this.accessTokenMethod=accessTokenMethod; - } - - - public OAuthApi20(String authorizeUrl, String accessTokenUrl,String grantType, String accessTokenMethod,String scope) { - super(); - this.authorizeUrl = authorizeUrl; - this.accessTokenUrl = accessTokenUrl; - this.grantType = grantType; - this.accessTokenMethod=accessTokenMethod; - this.scope = scope; - } - - - @Override - public HttpVerb getAccessTokenVerb(){ - if(accessTokenMethod!= null &&accessTokenMethod.toUpperCase().equals("POST")){ - return HttpVerb.POST; - }else{ - return HttpVerb.GET; - } - } - - @Override - public AccessTokenExtractor getAccessTokenExtractor(){ - if(accessTokenUrl.indexOf("qq")>-1){ - return new QQTokenExtractor(); - } - return new GsonJsonTokenExtractor(); - } - - @Override - public String getAccessTokenEndpoint(){ - if(accessTokenUrl.indexOf("?")>0){ - return accessTokenUrl+"&grant_type="+grantType; - }else{ - return accessTokenUrl+"?grant_type="+grantType; - } - } - - @Override - public String getAuthorizationUrl(OAuthConfig config){ - // Append scope if present - //dingtalk - if(authorizeUrl.indexOf("oapi.dingtalk.com")>-1) { - if (config.hasScope()){ - return String.format(authorizeUrl+scope, config.getApiKey(), config.getCallback(), HttpEncoder.encode(config.getScope())); - } - else{ - return String.format(authorizeUrl, config.getApiKey(), config.getCallback()); - } - }else { - if (config.hasScope()){ - return String.format(authorizeUrl+scope, config.getApiKey(), HttpEncoder.encode(config.getCallback()), HttpEncoder.encode(config.getScope())); - } - else{ - return String.format(authorizeUrl, config.getApiKey(), HttpEncoder.encode(config.getCallback())); - } - } - } - - public String getAuthorizeUrl() { - return authorizeUrl; - } - - public void setAuthorizeUrl(String authorizeUrl) { - this.authorizeUrl = authorizeUrl; - } - - public String getAccessTokenUrl() { - return accessTokenUrl; - } - - public void setAccessTokenUrl(String accessTokenUrl) { - this.accessTokenUrl = accessTokenUrl; - } - - public String getGrantType() { - return grantType; - } - - public void setGrantType(String grantType) { - this.grantType = grantType; - } - - - @Override - public String toString() { - return "OAuthApi20 [authorizeUrl=" + authorizeUrl + ", accessTokenUrl=" - + accessTokenUrl + ", grantType=" + grantType + ", scope=" - + scope + "]"; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseDomain.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseDomain.java deleted file mode 100644 index 01aa6f168..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseDomain.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.domain; - -import java.io.Serializable; -import java.util.Date; -import java.util.UUID; - -import org.apache.log4j.Logger; - -/** - * BaseDomain for connsec's domain - * - * @author Crystal.sea - * - */ -public class BaseDomain implements Serializable{ - /** - * - */ - private static final long serialVersionUID = -6290127045507211154L; - - - protected final static Logger logger = Logger.getLogger(BaseDomain.class); - - /** - * Domain id - */ - protected String id; - - - - protected String tid; - - protected String tname; - /** - * description - */ - protected String description; - - protected int status; - - protected int sortOrder; - - protected String createdBy; - - protected Date createdDate; - - protected String modifiedBy; - - protected Date modifiedDate; - - - protected String startDate; - protected String endDate; - - protected String error; - protected String error_description; - - protected String responseString; - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getError_description() { - return error_description; - } - - public void setError_description(String error_description) { - this.error_description = error_description; - } - - public BaseDomain() { - - } - - /** - * @return the id - */ - public String getId() { - return id; - } - - - - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - - - - - /** - * @return the status - */ - public int getStatus() { - return status; - } - - - - - /** - * @param status the status to set - */ - public void setStatus(int status) { - this.status = status; - } - - - - /** - * @return the tid - */ - public String getTid() { - return tid; - } - - /** - * @param tid the tid to set - */ - public void setTid(String tid) { - this.tid = tid; - } - - /** - * @return the tname - */ - public String getTname() { - return tname; - } - - /** - * @param tname the tname to set - */ - public void setTname(String tname) { - this.tname = tname; - } - - /** - * @return the sortOrder - */ - public int getSortOrder() { - return sortOrder; - } - - - - - /** - * @param sortOrder the sortOrder to set - */ - public void setSortOrder(int sortOrder) { - this.sortOrder = sortOrder; - } - - - - - /** - * @return the createdBy - */ - public String getCreatedBy() { - return createdBy; - } - - - - - /** - * @param createdBy the createdBy to set - */ - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - - - - /** - * @return the createdDate - */ - public Date getCreatedDate() { - return createdDate; - } - - - - - /** - * @param createdDate the createdDate to set - */ - public void setCreatedDate(Date createdDate) { - this.createdDate = createdDate; - } - - - - - /** - * @return the modifiedBy - */ - public String getModifiedBy() { - return modifiedBy; - } - - - - - /** - * @param modifiedBy the modifiedBy to set - */ - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - - - - /** - * @return the modifiedDate - */ - public Date getModifiedDate() { - return modifiedDate; - } - - - - - /** - * @param modifiedDate the modifiedDate to set - */ - public void setModifiedDate(Date modifiedDate) { - this.modifiedDate = modifiedDate; - } - - - - - /** - * @return the description - */ - public String getDescription() { - return description; - } - - - - - /** - * @param description the description to set - */ - public void setDescription(String description) { - this.description = description; - } - - - - - /** - * @return the startDate - */ - public String getStartDate() { - return startDate; - } - - - - - /** - * @param startDate the startDate to set - */ - public void setStartDate(String startDate) { - this.startDate = startDate; - } - - - - - /** - * @return the endDate - */ - public String getEndDate() { - return endDate; - } - - /** - * @param endDate the endDate to set - */ - public void setEndDate(String endDate) { - this.endDate = endDate; - } - - public void genId() { - this.id=UUID.randomUUID().toString().toLowerCase(); - } - - public String getResponseString() { - return responseString; - } - - public void setResponseString(String responseString) { - this.responseString = responseString; - } - - @Override - public String toString() { - return "BaseDomain [id=" + id + ", tid=" + tid + ", tname=" + tname - + ", status=" + status + ", sortOrder=" + sortOrder - + ", createdBy=" + createdBy + ", createdDate=" + createdDate - + ", modifiedBy=" + modifiedBy + ", modifiedDate=" - + modifiedDate + ", description=" + description - + ", startDate=" + startDate + ", endDate=" + endDate + "]"; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseEntity.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseEntity.java deleted file mode 100644 index 63ec3433a..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/BaseEntity.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.domain; - -public class BaseEntity { - - private String error; - private String error_description; - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getError_description() { - return error_description; - } - - public void setError_description(String error_description) { - this.error_description = error_description; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCAddress.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCAddress.java deleted file mode 100644 index 0cc99f48d..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCAddress.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.domain; - -public class OIDCAddress { - - public String country; - public String region; - public String locality; - public String street_address; - public String formatted; - public String postal_code; - /** - * - */ - public OIDCAddress() { - // TODO Auto-generated constructor stub - } - public String getCountry() { - return country; - } - public void setCountry(String country) { - this.country = country; - } - public String getRegion() { - return region; - } - public void setRegion(String region) { - this.region = region; - } - public String getLocality() { - return locality; - } - public void setLocality(String locality) { - this.locality = locality; - } - public String getStreet_address() { - return street_address; - } - public void setStreet_address(String street_address) { - this.street_address = street_address; - } - public String getFormatted() { - return formatted; - } - public void setFormatted(String formatted) { - this.formatted = formatted; - } - public String getPostal_code() { - return postal_code; - } - public void setPostal_code(String postal_code) { - this.postal_code = postal_code; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCUserInfo.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCUserInfo.java deleted file mode 100644 index 965e44d6a..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/OIDCUserInfo.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -package org.maxkey.client.oauth.domain; - -/** - * @author Administrator - * - */ -public class OIDCUserInfo { - - private String sub; - private String name; - private String preferred_username; - private String given_name; - private String family_name; - private String middle_name; - private String nickname; - private String profile; - private String picture; - private String website; - private String gender; - private String zoneinfo; - private String locale; - private String updated_time; - private String birthdate; - - - private String email; - private boolean email_verified; - - private String phone_number; - private boolean phone_number_verified; - private OIDCAddress address; - - - protected String error; - protected String error_description; - - protected String responseString; - - - /** - * - */ - public OIDCUserInfo() { - // TODO Auto-generated constructor stub - } - - public String getSub() { - return sub; - } - - public void setSub(String sub) { - this.sub = sub; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPreferred_username() { - return preferred_username; - } - - public void setPreferred_username(String preferred_username) { - this.preferred_username = preferred_username; - } - - public String getGiven_name() { - return given_name; - } - - public void setGiven_name(String given_name) { - this.given_name = given_name; - } - - public String getFamily_name() { - return family_name; - } - - public void setFamily_name(String family_name) { - this.family_name = family_name; - } - - public String getMiddle_name() { - return middle_name; - } - - public void setMiddle_name(String middle_name) { - this.middle_name = middle_name; - } - - public String getNickname() { - return nickname; - } - - public void setNickname(String nickname) { - this.nickname = nickname; - } - - public String getProfile() { - return profile; - } - - public void setProfile(String profile) { - this.profile = profile; - } - - public String getPicture() { - return picture; - } - - public void setPicture(String picture) { - this.picture = picture; - } - - public String getWebsite() { - return website; - } - - public void setWebsite(String website) { - this.website = website; - } - - public String getGender() { - return gender; - } - - public void setGender(String gender) { - this.gender = gender; - } - - public String getZoneinfo() { - return zoneinfo; - } - - public void setZoneinfo(String zoneinfo) { - this.zoneinfo = zoneinfo; - } - - public String getLocale() { - return locale; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public String getUpdated_time() { - return updated_time; - } - - public void setUpdated_time(String updated_time) { - this.updated_time = updated_time; - } - - public String getBirthdate() { - return birthdate; - } - - public void setBirthdate(String birthdate) { - this.birthdate = birthdate; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public boolean isEmail_verified() { - return email_verified; - } - - public void setEmail_verified(boolean email_verified) { - this.email_verified = email_verified; - } - - public String getPhone_number() { - return phone_number; - } - - public void setPhone_number(String phone_number) { - this.phone_number = phone_number; - } - - public boolean isPhone_number_verified() { - return phone_number_verified; - } - - public void setPhone_number_verified(boolean phone_number_verified) { - this.phone_number_verified = phone_number_verified; - } - - public OIDCAddress getAddress() { - return address; - } - - public void setAddress(OIDCAddress address) { - this.address = address; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getError_description() { - return error_description; - } - - public void setError_description(String error_description) { - this.error_description = error_description; - } - - public String getResponseString() { - return responseString; - } - - public void setResponseString(String responseString) { - this.responseString = responseString; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/UserInfo.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/UserInfo.java deleted file mode 100644 index 0a60c9d6e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/domain/UserInfo.java +++ /dev/null @@ -1,792 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.domain; - -import java.util.Arrays; - - -/** - * @author Crystal.Sea - * - */ -public class UserInfo extends BaseDomain { - - /** - * - */ - private static final long serialVersionUID = 6402443942083382236L; - // - - protected String username; - - /** - * "Employee", "Supplier","Dealer","Contractor",Partner,Customer "Intern", - * "Temp", "External", and "Unknown" - */ - protected String userType; - protected String windowsAccount; - - // for user name - protected String displayName; - protected String nickName; - protected String nameZHSpell; - protected String nameZHShortSpell; - protected String givenName; - protected String middleName; - protected String familyName; - protected String honorificPrefix; - protected String honorificSuffix; - protected String formattedName; - - protected int married; - protected int gender; - protected String birthDate; - protected byte[] picture; - protected int idType; - protected String idCardNo; - protected String webSite; - protected String startWorkDate; - - // for security - protected int authnType; - protected String email; - protected String mobile; - protected int mobileVerified; - - protected String lastLoginTime; - protected String lastLoginIp; - protected String lastLogoffTime; - protected int passwordSetType; - protected Integer loginCount; - - protected String locale; - protected String timeZone; - protected String preferredLanguage; - - // for work - protected String workCountry; - protected String workRegion;// province; - protected String workLocality;// city; - protected String workStreetAddress; - protected String workAddressFormatted; - protected String workEmail; - protected String workPhoneNumber; - protected String workPostalCode; - protected String workFax; - // for home - protected String homeCountry; - protected String homeRegion;// province; - protected String homeLocality;// city; - protected String homeStreetAddress; - protected String homeAddressFormatted; - protected String homeEmail; - protected String homePhoneNumber; - protected String homePostalCode; - protected String homeFax; - // for company - protected String employeeNumber; - protected String costCenter; - protected String organization; - protected String division; - protected String departmentId; - protected String department; - protected String jobTitle; - protected String jobLevel; - protected String managerId; - protected String manager; - protected String assistantId; - protected String assistant; - protected String entryDate; - protected String quitDate; - - // for social contact - /** - * QQ WeiXin SinaWeibo Gtalk YiXin IMessage Skype Yahoo MSN Aim ICQ Xmpp - */ - protected String ims; - /* - * for extended Attribute from userType extraAttribute for database - * extraAttributeName & extraAttributeValue for page submit - */ - protected String extraAttribute; - - protected int online; - - public static class ONLINE { - // 在线 - public static int ONLINE = 0; - // 下线 - public static int OFFLINE = 1; - } - - public static class MARRIED { - // 未知 - public static int UNKNOWN = 0; - // 单身 - public static int SINGLE = 1; - // 结婚 - public static int MARRIED = 2; - // 离异 - public static int DIVORCE = 3; - // 丧偶 - public static int WIDOWED = 4; - - } - - public static class GENDER { - // 未知 - public static int UNKNOWN = 0; - // 女性 - public static int FEMALE = 1; - // 男性 - public static int MALE = 2; - } - - public static class IDTYPE { - // 未知 - public static int UNKNOWN = 0; - // 身份证 - public static int IDCARD = 1; - // 护照 - public static int PASSPORT = 2; - // 学生证 - public static int STUDENTCARD = 3; - // 军人证 - public static int MILITARYCARD = 4; - } - - public static class AUTHNTYPE { - // 用户名密码 - public static int NORMAL = 1; - // 手机 - public static int MOBILE = 2; - // 短信 - public static int SMS = 3; - // 邮箱 - public static int EMAIL = 4; - - public static int TIMEBASED_OPT = 5; - - public static int COUNTERBASED_OPT = 6; - - public static int HOTP_OPT = 7; - - public static int RSA_OPT = 8; - // 证书 - public static int CERTIFICATE = 9; - // usb证书 - public static int USBKEY = 10; - - } - - /** - * - */ - public UserInfo() { - super(); - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getUserType() { - return userType; - } - - public void setUserType(String userType) { - this.userType = userType; - } - - public String getWindowsAccount() { - return windowsAccount; - } - - public void setWindowsAccount(String windowsAccount) { - this.windowsAccount = windowsAccount; - } - - public String getDisplayName() { - return displayName; - } - - public void setDisplayName(String displayName) { - this.displayName = displayName; - } - - public String getNickName() { - return nickName; - } - - public void setNickName(String nickName) { - this.nickName = nickName; - } - - public String getNameZHSpell() { - return nameZHSpell; - } - - public void setNameZHSpell(String nameZHSpell) { - this.nameZHSpell = nameZHSpell; - } - - public String getNameZHShortSpell() { - return nameZHShortSpell; - } - - public void setNameZHShortSpell(String nameZHShortSpell) { - this.nameZHShortSpell = nameZHShortSpell; - } - - public String getGivenName() { - return givenName; - } - - public void setGivenName(String givenName) { - this.givenName = givenName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getFamilyName() { - return familyName; - } - - public void setFamilyName(String familyName) { - this.familyName = familyName; - } - - public String getHonorificPrefix() { - return honorificPrefix; - } - - public void setHonorificPrefix(String honorificPrefix) { - this.honorificPrefix = honorificPrefix; - } - - public String getHonorificSuffix() { - return honorificSuffix; - } - - public void setHonorificSuffix(String honorificSuffix) { - this.honorificSuffix = honorificSuffix; - } - - public String getFormattedName() { - return formattedName; - } - - public void setFormattedName(String formattedName) { - this.formattedName = formattedName; - } - - public int getMarried() { - return married; - } - - public void setMarried(int married) { - this.married = married; - } - - public int getGender() { - return gender; - } - - public void setGender(int gender) { - this.gender = gender; - } - - public String getBirthDate() { - return birthDate; - } - - public void setBirthDate(String birthDate) { - this.birthDate = birthDate; - } - - public byte[] getPicture() { - return picture; - } - - public void setPicture(byte[] picture) { - this.picture = picture; - } - - public int getIdType() { - return idType; - } - - public void setIdType(int idType) { - this.idType = idType; - } - - public String getIdCardNo() { - return idCardNo; - } - - public void setIdCardNo(String idCardNo) { - this.idCardNo = idCardNo; - } - - public String getWebSite() { - return webSite; - } - - public void setWebSite(String webSite) { - this.webSite = webSite; - } - - public String getStartWorkDate() { - return startWorkDate; - } - - public void setStartWorkDate(String startWorkDate) { - this.startWorkDate = startWorkDate; - } - - public int getAuthnType() { - return authnType; - } - - public void setAuthnType(int authnType) { - this.authnType = authnType; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getMobile() { - return mobile; - } - - public void setMobile(String mobile) { - this.mobile = mobile; - } - - public int getMobileVerified() { - return mobileVerified; - } - - public void setMobileVerified(int mobileVerified) { - this.mobileVerified = mobileVerified; - } - - public String getLastLoginTime() { - return lastLoginTime; - } - - public void setLastLoginTime(String lastLoginTime) { - this.lastLoginTime = lastLoginTime; - } - - public String getLastLoginIp() { - return lastLoginIp; - } - - public void setLastLoginIp(String lastLoginIp) { - this.lastLoginIp = lastLoginIp; - } - - public String getLastLogoffTime() { - return lastLogoffTime; - } - - public void setLastLogoffTime(String lastLogoffTime) { - this.lastLogoffTime = lastLogoffTime; - } - - public int getPasswordSetType() { - return passwordSetType; - } - - public void setPasswordSetType(int passwordSetType) { - this.passwordSetType = passwordSetType; - } - - public Integer getLoginCount() { - return loginCount; - } - - public void setLoginCount(Integer loginCount) { - this.loginCount = loginCount; - } - - public String getLocale() { - return locale; - } - - public void setLocale(String locale) { - this.locale = locale; - } - - public String getTimeZone() { - return timeZone; - } - - public void setTimeZone(String timeZone) { - this.timeZone = timeZone; - } - - public String getPreferredLanguage() { - return preferredLanguage; - } - - public void setPreferredLanguage(String preferredLanguage) { - this.preferredLanguage = preferredLanguage; - } - - public String getWorkCountry() { - return workCountry; - } - - public void setWorkCountry(String workCountry) { - this.workCountry = workCountry; - } - - public String getWorkRegion() { - return workRegion; - } - - public void setWorkRegion(String workRegion) { - this.workRegion = workRegion; - } - - public String getWorkLocality() { - return workLocality; - } - - public void setWorkLocality(String workLocality) { - this.workLocality = workLocality; - } - - public String getWorkStreetAddress() { - return workStreetAddress; - } - - public void setWorkStreetAddress(String workStreetAddress) { - this.workStreetAddress = workStreetAddress; - } - - public String getWorkAddressFormatted() { - return workAddressFormatted; - } - - public void setWorkAddressFormatted(String workAddressFormatted) { - this.workAddressFormatted = workAddressFormatted; - } - - public String getWorkEmail() { - return workEmail; - } - - public void setWorkEmail(String workEmail) { - this.workEmail = workEmail; - } - - public String getWorkPhoneNumber() { - return workPhoneNumber; - } - - public void setWorkPhoneNumber(String workPhoneNumber) { - this.workPhoneNumber = workPhoneNumber; - } - - public String getWorkPostalCode() { - return workPostalCode; - } - - public void setWorkPostalCode(String workPostalCode) { - this.workPostalCode = workPostalCode; - } - - public String getWorkFax() { - return workFax; - } - - public void setWorkFax(String workFax) { - this.workFax = workFax; - } - - public String getHomeCountry() { - return homeCountry; - } - - public void setHomeCountry(String homeCountry) { - this.homeCountry = homeCountry; - } - - public String getHomeRegion() { - return homeRegion; - } - - public void setHomeRegion(String homeRegion) { - this.homeRegion = homeRegion; - } - - public String getHomeLocality() { - return homeLocality; - } - - public void setHomeLocality(String homeLocality) { - this.homeLocality = homeLocality; - } - - public String getHomeStreetAddress() { - return homeStreetAddress; - } - - public void setHomeStreetAddress(String homeStreetAddress) { - this.homeStreetAddress = homeStreetAddress; - } - - public String getHomeAddressFormatted() { - return homeAddressFormatted; - } - - public void setHomeAddressFormatted(String homeAddressFormatted) { - this.homeAddressFormatted = homeAddressFormatted; - } - - public String getHomeEmail() { - return homeEmail; - } - - public void setHomeEmail(String homeEmail) { - this.homeEmail = homeEmail; - } - - public String getHomePhoneNumber() { - return homePhoneNumber; - } - - public void setHomePhoneNumber(String homePhoneNumber) { - this.homePhoneNumber = homePhoneNumber; - } - - public String getHomePostalCode() { - return homePostalCode; - } - - public void setHomePostalCode(String homePostalCode) { - this.homePostalCode = homePostalCode; - } - - public String getHomeFax() { - return homeFax; - } - - public void setHomeFax(String homeFax) { - this.homeFax = homeFax; - } - - public String getEmployeeNumber() { - return employeeNumber; - } - - public void setEmployeeNumber(String employeeNumber) { - this.employeeNumber = employeeNumber; - } - - public String getCostCenter() { - return costCenter; - } - - public void setCostCenter(String costCenter) { - this.costCenter = costCenter; - } - - public String getOrganization() { - return organization; - } - - public void setOrganization(String organization) { - this.organization = organization; - } - - public String getDivision() { - return division; - } - - public void setDivision(String division) { - this.division = division; - } - - public String getDepartmentId() { - return departmentId; - } - - public void setDepartmentId(String departmentId) { - this.departmentId = departmentId; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getJobTitle() { - return jobTitle; - } - - public void setJobTitle(String jobTitle) { - this.jobTitle = jobTitle; - } - - public String getJobLevel() { - return jobLevel; - } - - public void setJobLevel(String jobLevel) { - this.jobLevel = jobLevel; - } - - public String getManagerId() { - return managerId; - } - - public void setManagerId(String managerId) { - this.managerId = managerId; - } - - public String getManager() { - return manager; - } - - public void setManager(String manager) { - this.manager = manager; - } - - public String getAssistantId() { - return assistantId; - } - - public void setAssistantId(String assistantId) { - this.assistantId = assistantId; - } - - public String getAssistant() { - return assistant; - } - - public void setAssistant(String assistant) { - this.assistant = assistant; - } - - public String getEntryDate() { - return entryDate; - } - - public void setEntryDate(String entryDate) { - this.entryDate = entryDate; - } - - public String getQuitDate() { - return quitDate; - } - - public void setQuitDate(String quitDate) { - this.quitDate = quitDate; - } - - public String getIms() { - return ims; - } - - public void setIms(String ims) { - this.ims = ims; - } - - public String getExtraAttribute() { - return extraAttribute; - } - - public void setExtraAttribute(String extraAttribute) { - this.extraAttribute = extraAttribute; - } - - public int getOnline() { - return online; - } - - public void setOnline(int online) { - this.online = online; - } - - @Override - public String toString() { - return "UserInfo [username=" + username + ", userType=" + userType - + ", windowsAccount=" + windowsAccount + ", displayName=" - + displayName + ", nickName=" + nickName + ", nameZHSpell=" - + nameZHSpell + ", nameZHShortSpell=" + nameZHShortSpell - + ", givenName=" + givenName + ", middleName=" + middleName - + ", familyName=" + familyName + ", honorificPrefix=" - + honorificPrefix + ", honorificSuffix=" + honorificSuffix - + ", formattedName=" + formattedName + ", married=" + married - + ", gender=" + gender + ", birthDate=" + birthDate - + ", picture=" + Arrays.toString(picture) + ", idType=" - + idType + ", idCardNo=" + idCardNo + ", webSite=" + webSite - + ", startWorkDate=" + startWorkDate + ", authnType=" - + authnType + ", email=" + email + ", mobile=" + mobile - + ", mobileVerified=" + mobileVerified + ", lastLoginTime=" - + lastLoginTime + ", lastLoginIp=" + lastLoginIp - + ", lastLogoffTime=" + lastLogoffTime + ", passwordSetType=" - + passwordSetType + ", loginCount=" + loginCount + ", locale=" - + locale + ", timeZone=" + timeZone + ", preferredLanguage=" - + preferredLanguage + ", workCountry=" + workCountry - + ", workRegion=" + workRegion + ", workLocality=" - + workLocality + ", workStreetAddress=" + workStreetAddress - + ", workAddressFormatted=" + workAddressFormatted - + ", workEmail=" + workEmail + ", workPhoneNumber=" - + workPhoneNumber + ", workPostalCode=" + workPostalCode - + ", workFax=" + workFax + ", homeCountry=" + homeCountry - + ", homeRegion=" + homeRegion + ", homeLocality=" - + homeLocality + ", homeStreetAddress=" + homeStreetAddress - + ", homeAddressFormatted=" + homeAddressFormatted - + ", homeEmail=" + homeEmail + ", homePhoneNumber=" - + homePhoneNumber + ", homePostalCode=" + homePostalCode - + ", homeFax=" + homeFax + ", employeeNumber=" + employeeNumber - + ", costCenter=" + costCenter + ", organization=" - + organization + ", division=" + division + ", departmentId=" - + departmentId + ", department=" + department + ", jobTitle=" - + jobTitle + ", jobLevel=" + jobLevel + ", managerId=" - + managerId + ", manager=" + manager + ", assistantId=" - + assistantId + ", assistant=" + assistant + ", entryDate=" - + entryDate + ", quitDate=" + quitDate + ", ims=" + ims - + ", extraAttribute=" + extraAttribute + ", online=" + online - + "]"; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthConnectionException.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthConnectionException.java deleted file mode 100644 index b793390c5..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthConnectionException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.exceptions; - -/** - * @author: Pablo Fernandez - */ -public class OAuthConnectionException extends OAuthException -{ - private static final String MSG = "There was a problem while creating a connection to the remote service."; - - public OAuthConnectionException(Exception e) - { - super(MSG, e); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthException.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthException.java deleted file mode 100644 index 3df1e3452..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthException.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.exceptions; - -/** - * Default scribe exception. - * Represents a problem in the OAuth signing process - * - * @author Pablo Fernandez - */ -public class OAuthException extends RuntimeException -{ - - /** - * Default constructor - * @param message message explaining what went wrong - * @param e original exception - */ - public OAuthException(String message, Exception e) - { - super(message, e); - } - - /** - * No-exception constructor. Used when there is no original exception - * - * @param message message explaining what went wrong - */ - public OAuthException(String message) - { - super(message, null); - } - - private static final long serialVersionUID = 1L; -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthParametersMissingException.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthParametersMissingException.java deleted file mode 100644 index 381357058..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthParametersMissingException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.exceptions; - -import org.maxkey.client.oauth.model.*; - -/** - * Specialized exception that represents a missing OAuth parameter. - * - * @author Pablo Fernandez - */ -public class OAuthParametersMissingException extends OAuthException -{ - - private static final long serialVersionUID = 1745308760111976671L; - private static final String MSG = "Could not find oauth parameters in request: %s. " - + "OAuth parameters must be specified with the addOAuthParameter() method"; - - /** - * Default constructor. - * - * @param request OAuthRequest that caused the error - */ - public OAuthParametersMissingException(OAuthRequest request) - { - super(String.format(MSG, request)); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthSignatureException.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthSignatureException.java deleted file mode 100644 index fe76cc2ec..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/exceptions/OAuthSignatureException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.exceptions; - -/** - * Specialized exception that represents a problem in the signature - * - * @author Pablo Fernandez - */ -public class OAuthSignatureException extends OAuthException -{ - private static final long serialVersionUID = 1L; - private static final String MSG = "Error while signing string: %s"; - - /** - * Default constructor - * - * @param stringToSign plain string that gets signed (HMAC-SHA, etc) - * @param e original exception - */ - public OAuthSignatureException(String stringToSign, Exception e) - { - super(String.format(MSG, stringToSign), e); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/AccessTokenExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/AccessTokenExtractor.java deleted file mode 100644 index 54d7c4a0b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/AccessTokenExtractor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import org.maxkey.client.oauth.model.*; - -/** - * Simple command object that extracts a {@link Token} from a String - * - * @author Pablo Fernandez - */ -public interface AccessTokenExtractor -{ - /** - * Extracts the access token from the contents of an Http Response - * - * @param response the contents of the response - * @return OAuth access token - */ - public Token extract(String response); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractor.java deleted file mode 100644 index 5b992f031..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractor.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import org.maxkey.client.oauth.model.*; - -/** - * Simple command object that extracts a base string from a {@link OAuthRequest} - * - * @author Pablo Fernandez - */ -public interface BaseStringExtractor -{ - /** - * Extracts an url-encoded base string from the {@link OAuthRequest}. - * - * See the oauth spec for more info on this. - * - * @param request the OAuthRequest - * @return the url-encoded base string - */ - String extract(OAuthRequest request); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractorImpl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractorImpl.java deleted file mode 100644 index 8c87c1dad..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/BaseStringExtractorImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - - -import org.maxkey.client.http.ParameterList; -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * Default implementation of {@link BaseStringExtractor}. Conforms to OAuth 1.0a - * - * @author Pablo Fernandez - * - */ -public class BaseStringExtractorImpl implements BaseStringExtractor -{ - - private static final String AMPERSAND_SEPARATED_STRING = "%s&%s&%s"; - - /** - * {@inheritDoc} - */ - public String extract(OAuthRequest request) - { - checkPreconditions(request); - String verb = HttpEncoder.encode(request.getVerb().name()); - String url = HttpEncoder.encode(request.getSanitizedUrl()); - String params = getSortedAndEncodedParams(request); - return String.format(AMPERSAND_SEPARATED_STRING, verb, url, params); - } - - private String getSortedAndEncodedParams(OAuthRequest request) - { - ParameterList params = new ParameterList(); - params.addAll(request.getQueryStringParams()); - params.addAll(request.getBodyParams()); - params.addAll(new ParameterList(request.getOauthParameters())); - return params.sort().asOauthBaseString(); - } - - private void checkPreconditions(OAuthRequest request) - { - Preconditions.checkNotNull(request, "Cannot extract base string from null object"); - - if (request.getOauthParameters() == null || request.getOauthParameters().size() <= 0) - { - throw new OAuthParametersMissingException(request); - } - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/GsonJsonTokenExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/GsonJsonTokenExtractor.java deleted file mode 100644 index d851068c2..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/GsonJsonTokenExtractor.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.JsonUtils; -import org.maxkey.client.utils.Preconditions; - -public class GsonJsonTokenExtractor implements AccessTokenExtractor { - - public Token extract(String response) { - System.out.println("extract a token from : " + response); - Preconditions.checkEmptyString(response,"Cannot extract a token from a null or empty String"); - try { - Token token; - try { - token = JsonUtils.gson2Object(response, Token.class); - } catch (Exception e) { - token = JsonUtils.gson2Object("{\""+ response.replace("&", "\",\"").replace("=","\":\"") + "\"}", Token.class); - } - - if (token != null) { - token.setRawResponse(response); - token.setToken(token.getAccess_token()); - } - - return token; - } catch (Exception e) { - throw new OAuthException("Cannot extract an acces token. Response was: " + response); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractor.java deleted file mode 100644 index e4d5271ee..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import org.maxkey.client.oauth.model.*; - -/** - * Simple command object that generates an OAuth Authorization header to include in the request. - * - * @author Pablo Fernandez - */ -public interface HeaderExtractor -{ - /** - * Generates an OAuth 'Authorization' Http header to include in requests as the signature. - * - * @param request the OAuthRequest to inspect and generate the header - * @return the Http header value - */ - String extract(OAuthRequest request); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractorImpl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractorImpl.java deleted file mode 100644 index f3fca611c..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/HeaderExtractorImpl.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import java.util.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * Default implementation of {@link HeaderExtractor}. Conforms to OAuth 1.0a - * - * @author Pablo Fernandez - * - */ -public class HeaderExtractorImpl implements HeaderExtractor -{ - private static final String PARAM_SEPARATOR = ", "; - private static final String PREAMBLE = "OAuth "; - public static final int ESTIMATED_PARAM_LENGTH = 20; - - /** - * {@inheritDoc} - */ - public String extract(OAuthRequest request) - { - checkPreconditions(request); - Map parameters = request.getOauthParameters(); - StringBuilder header = new StringBuilder(parameters.size() * ESTIMATED_PARAM_LENGTH); - header.append(PREAMBLE); - for (Map.Entry entry : parameters.entrySet()) - { - if(header.length() > PREAMBLE.length()) - { - header.append(PARAM_SEPARATOR); - } - header.append(String.format("%s=\"%s\"", entry.getKey(), HttpEncoder.encode(entry.getValue()))); - } - return header.toString(); - } - - private void checkPreconditions(OAuthRequest request) - { - Preconditions.checkNotNull(request, "Cannot extract a header from a null object"); - - if (request.getOauthParameters() == null || request.getOauthParameters().size() <= 0) - { - throw new OAuthParametersMissingException(request); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/JsonTokenExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/JsonTokenExtractor.java deleted file mode 100644 index 70c197fc6..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/JsonTokenExtractor.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import java.util.regex.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.Preconditions; - -public class JsonTokenExtractor implements AccessTokenExtractor -{ - private Pattern accessTokenPattern = Pattern.compile("\"access_token\":\\s*\"(\\S*?)\""); - - public Token extract(String response) - { - Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String"); - Matcher matcher = accessTokenPattern.matcher(response); - if(matcher.find()) - { - return new Token(matcher.group(1), "", response); - } - else - { - throw new OAuthException("Cannot extract an acces token. Response was: " + response); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/QQTokenExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/QQTokenExtractor.java deleted file mode 100644 index 02f05a23d..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/QQTokenExtractor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import java.util.HashMap; - -import org.apache.log4j.Logger; -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.Preconditions; - -public class QQTokenExtractor implements AccessTokenExtractor -{ - final static Logger log = Logger.getLogger(QQTokenExtractor.class); - public Token extract(String response){ - - log.debug("extract a token from : "+response); - Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String"); - try{ - - String [] fields=response.split("&"); - HashMap tokenMap=new HashMap(); - for(String field : fields){ - String [] sfield=field.split("="); - if(sfield.length==2){ - tokenMap.put(sfield[0], sfield[1]); - } - } - log.debug("token map : "+tokenMap); - Token token =new Token(tokenMap.get("access_token").toString(),"",response,tokenMap); - return token; - } - catch(Exception e){ - throw new OAuthException("Cannot extract an acces token. Response was: " + response); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/RequestTokenExtractor.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/RequestTokenExtractor.java deleted file mode 100644 index d5ffd5ef8..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/RequestTokenExtractor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import org.maxkey.client.oauth.model.*; - -/** - * Simple command object that extracts a {@link Token} from a String - * - * @author Pablo Fernandez - */ -public interface RequestTokenExtractor -{ - /** - * Extracts the request token from the contents of an Http Response - * - * @param response the contents of the response - * @return OAuth access token - */ - public Token extract(String response); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractor20Impl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractor20Impl.java deleted file mode 100644 index a6509802f..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractor20Impl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import java.io.UnsupportedEncodingException; -import java.util.regex.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * Default implementation of {@AccessTokenExtractor}. Conforms to OAuth 2.0 - * - */ -public class TokenExtractor20Impl implements AccessTokenExtractor -{ - private static final String TOKEN_REGEX = "access_token=([^&]+)"; - private static final String EMPTY_SECRET = ""; - - /** - * {@inheritDoc} - */ - public Token extract(String response) - { - Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string"); - - Matcher matcher = Pattern.compile(TOKEN_REGEX).matcher(response); - if (matcher.find()) - { - String token; - try { - token = HttpEncoder.decode(matcher.group(1)); - return new Token(token, EMPTY_SECRET, response); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - } - else - { - throw new OAuthException("Response body is incorrect. Can't extract a token from this: '" + response + "'", null); - } - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractorImpl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractorImpl.java deleted file mode 100644 index 3f2331926..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/extractors/TokenExtractorImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.extractors; - -import java.io.UnsupportedEncodingException; -import java.util.regex.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.oauth.model.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * Default implementation of {@RequestTokenExtractor} and {@AccessTokenExtractor}. Conforms to OAuth 1.0a - * - * The process for extracting access and request tokens is similar so this class can do both things. - * - * @author Pablo Fernandez - */ -public class TokenExtractorImpl implements RequestTokenExtractor, AccessTokenExtractor -{ - private static final Pattern TOKEN_REGEX = Pattern.compile("oauth_token=([^&]+)"); - private static final Pattern SECRET_REGEX = Pattern.compile("oauth_token_secret=([^&]*)"); - - /** - * {@inheritDoc} - */ - public Token extract(String response){ - Preconditions.checkEmptyString(response, "Response body is incorrect. Can't extract a token from an empty string"); - String token = extract(response, TOKEN_REGEX); - String secret = extract(response, SECRET_REGEX); - return new Token(token, secret, response); - } - - private String extract(String response, Pattern p){ - Matcher matcher = p.matcher(response); - if (matcher.find() && matcher.groupCount() >= 1){ - try { - return HttpEncoder.decode(matcher.group(1)); - } catch (UnsupportedEncodingException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return null; - }else{ - throw new OAuthException("Response body is incorrect. Can't extract token and secret from this: '" + response + "'", null); - } - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConfig.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConfig.java deleted file mode 100644 index c00ecd537..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConfig.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.model; - -import java.io.*; - -import org.maxkey.client.http.SignatureType; - -/** - * Parameter object that groups OAuth config values - * - * @author Pablo Fernandez - */ -public class OAuthConfig { - private final String apiKey; - private final String apiSecret; - private final String callback; - private final SignatureType signatureType; - private final String scope; - private String approvalPrompt; // 授权方式:force or auto - private String responseType; // 返回类型:code、passwrod、token - private final OutputStream debugStream; - - public OAuthConfig(String key, String secret) { - this(key, secret, null, null, null, null); - } - - public OAuthConfig(String key, String secret, String callback) { - this(key, secret, callback, null, null, null); - } - - public OAuthConfig(String key, String secret, String callback, - SignatureType type, String scope, OutputStream stream) { - this.apiKey = key; - this.apiSecret = secret; - this.callback = callback; - this.signatureType = type; - this.scope = scope; - this.debugStream = stream; - } - - public String getApiKey() { - return apiKey; - } - - public String getApiSecret() { - return apiSecret; - } - - public String getCallback() { - return callback; - } - - public SignatureType getSignatureType() { - return signatureType; - } - - public String getScope() { - return scope; - } - - public boolean hasScope() { - return scope != null; - } - - public String getApprovalPrompt() { - return approvalPrompt; - } - - public void setApprovalPrompt(String approvalPrompt) { - this.approvalPrompt = approvalPrompt; - } - - public String getResponseType() { - return responseType; - } - - public void setResponseType(String responseType) { - this.responseType = responseType; - } - - public void log(String message) { - if (debugStream != null) { - message = message + "\n"; - try { - debugStream.write(message.getBytes("UTF8")); - } catch (Exception e) { - throw new RuntimeException( - "there were problems while writting to the debug stream", - e); - } - } - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConstants.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConstants.java deleted file mode 100644 index 5825c6655..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthConstants.java +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2010 Pablo Fernandez - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - */ -package org.maxkey.client.oauth.model; - - -/** - * This class contains OAuth constants, used project-wide - */ -public interface OAuthConstants { - - String TIMESTAMP = "oauth_timestamp"; - String SIGN_METHOD = "oauth_signature_method"; - String SIGNATURE = "oauth_signature"; - String CONSUMER_SECRET = "oauth_consumer_secret"; - String CONSUMER_KEY = "oauth_consumer_key"; - String CALLBACK = "oauth_callback"; - String VERSION = "oauth_version"; - String NONCE = "oauth_nonce"; - String REALM = "realm"; - String PARAM_PREFIX = "oauth_"; - String TOKEN = "oauth_token"; - String TOKEN_SECRET = "oauth_token_secret"; - String OUT_OF_BAND = "oob"; - String VERIFIER = "oauth_verifier"; - String HEADER = "Authorization"; - String SCOPE = "scope"; - String BASIC = "Basic"; - - // OAuth 2.0 - String ACCESS_TOKEN = "access_token"; - String CLIENT_ID = "client_id"; - String CLIENT_SECRET = "client_secret"; - String REDIRECT_URI = "redirect_uri"; - String CODE = "code"; - String REFRESH_TOKEN = "refresh_token"; - String GRANT_TYPE = "grant_type"; - String AUTHORIZATION_CODE = "authorization_code"; - String STATE = "state"; - String USERNAME = "username"; - String PASSWORD = "password"; - String RESPONSE_TYPE = "response_type"; - String RESPONSE_TYPE_CODE = "code"; - - //not OAuth specific - String USER_AGENT_HEADER_NAME = "User-Agent"; - - public static final Token EMPTY_TOKEN = new Token("", ""); -} - - diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthRequest.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthRequest.java deleted file mode 100644 index a05d01460..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/OAuthRequest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.model; - -import java.util.*; - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Request; - -/** - * The representation of an OAuth HttpRequest. - * - * Adds OAuth-related functionality to the {@link Request} - * - * @author Pablo Fernandez - */ -public class OAuthRequest extends Request -{ - private static final String OAUTH_PREFIX = "oauth_"; - private Map oauthParameters; - - /** - * Default constructor. - * - * @param verb Http verb/method - * @param url resource URL - */ - public OAuthRequest(HttpVerb verb, String url) - { - super(verb, url); - this.oauthParameters = new HashMap(); - } - - /** - * Adds an OAuth parameter. - * - * @param key name of the parameter - * @param value value of the parameter - * - * @throws IllegalArgumentException if the parameter is not an OAuth parameter - */ - public void addOAuthParameter(String key, String value) - { - oauthParameters.put(checkKey(key), value); - } - - public void addParameter(String key, String value) - { - oauthParameters.put(key, value); - } - - private String checkKey(String key) - { - if (key.startsWith(OAUTH_PREFIX) || key.equals(OAuthConstants.SCOPE)) - { - return key; - } - else - { - throw new IllegalArgumentException(String.format("OAuth parameters must either be '%s' or start with '%s'", OAuthConstants.SCOPE, OAUTH_PREFIX)); - } - } - - /** - * Returns the {@link Map} containing the key-value pair of parameters. - * - * @return parameters as map - */ - public Map getOauthParameters() - { - return oauthParameters; - } - - @Override - public String toString() - { - return String.format("@OAuthRequest(%s, %s)", getVerb(), getUrl()); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Token.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Token.java deleted file mode 100644 index b30b759dc..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Token.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.model; - -import java.io.*; -import java.util.Map; - -import org.maxkey.client.utils.Preconditions; - -/** - * Represents an OAuth 2 Access token. - *

- * http://tools.ietf.org/html/rfc6749#section-5.1 - * - * @see OAuth 2 Access Token Specification

- */ -public class Token implements Serializable { - private static final long serialVersionUID = 715000866082812683L; - - /* - * for return from Provider - */ - private String rawResponse; - private Map responseObject; - - /* - * for OAuth 1.0a & OAuth 2.0 - */ - /** - * access_token - *

- * REQUIRED. The access token issued by the authorization server.

- */ - private String access_token; - - private String token; - private String secret; - /** - * refresh_token - *

- * OPTIONAL. The refresh token, which can be used to obtain new access tokens using the same authorization grant as - * described in http://tools.ietf.org/html/rfc6749#section-6

- */ - private String refresh_token; - /** - * expires_in - *

- * RECOMMENDED. The lifetime in seconds of the access token. For example, the value "3600" denotes that the access - * token will expire in one hour from the time the response was generated. If omitted, the authorization server - * SHOULD provide the expiration time via other means or document the default value.

- */ - private String expires_in; - - /** - * scope - *

- * OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED. The scope of the access token - * as described by http://tools.ietf.org/html/rfc6749#section-3.3

- */ - private String scope; - - private String signature; - /* - * for OpenID Connect - */ - /** - * token_type - *

- * REQUIRED. The type of the token issued as described in http://tools.ietf.org/html/rfc6749#section-7.1 Value is - * case insensitive.

- */ - private String token_type; - - private String id_token; - - /** - * https://self-issued.me - */ - private String sub_jwk; - /* - * for error - */ - private String error; - private String error_description; - - - /** - * - */ - public Token() { - rawResponse = null; - } - - /** - * Default constructor - * - * @param token - * token value. Can't be null. - * @param secret - * token secret. Can't be null. - */ - public Token(String token, String secret) { - this(token, secret, null); - } - - public Token(String token, String secret, String rawResponse) { - Preconditions.checkNotNull(token, "Token can't be null"); - Preconditions.checkNotNull(secret, "Secret can't be null"); - - this.token = token; - this.secret = secret; - this.rawResponse = rawResponse; - this.responseObject = null; - } - - public Token(String token, String secret, String rawResponse, - Map responseObject) { - this.token = token; - this.secret = secret; - this.rawResponse = rawResponse; - this.responseObject = responseObject; - } - - public String getAccess_token() { - if(access_token==null||access_token.equals("")){ - access_token=this.token; - } - - return access_token; - } - - public void setAccess_token(String access_token) { - this.access_token = access_token; - } - - public Map getResponseObject() { - return responseObject; - } - - public void setResponseObject(Map responseObject) { - this.responseObject = responseObject; - } - - public String getToken() { - if(token==null){ - token=this.access_token; - } - return token; - } - - public void setToken(String token) { - this.token = token; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getRefresh_token() { - return refresh_token; - } - - public void setRefresh_token(String refresh_token) { - this.refresh_token = refresh_token; - } - - public String getExpires_in() { - return expires_in; - } - - public void setExpires_in(String expires_in) { - this.expires_in = expires_in; - } - - public String getSignature() { - return signature; - } - - public void setSignature(String signature) { - this.signature = signature; - } - - public String getToken_type() { - return token_type; - } - - public void setToken_type(String token_type) { - this.token_type = token_type; - } - - public String getId_token() { - return id_token; - } - - public void setId_token(String id_token) { - this.id_token = id_token; - } - - public String getSub_jwk() { - return sub_jwk; - } - - public void setSub_jwk(String sub_jwk) { - this.sub_jwk = sub_jwk; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getError_description() { - return error_description; - } - - public void setError_description(String error_description) { - this.error_description = error_description; - } - - public void setRawResponse(String rawResponse) { - this.rawResponse = rawResponse; - } - - public String getScope() { - return scope; - } - - public void setScope(String scope) { - this.scope = scope; - } - - public String getRawResponse() { - if (rawResponse == null) { - throw new IllegalStateException( - "This token object was not constructed by scribe and does not have a rawResponse"); - } - return rawResponse; - } - - @Override - public String toString() { - return "Token [rawResponse=" + rawResponse + ", responseObject=" - + responseObject + ", access_token=" + access_token - + ", token=" + token + ", secret=" + secret - + ", refresh_token=" + refresh_token + ", expires_in=" - + expires_in + ", signature=" + signature + ", token_type=" - + token_type + ", id_token=" + id_token + ", sub_jwk=" - + sub_jwk + ", error=" + error + ", error_description=" - + error_description + "]"; - } - - /** - * Returns true if the token is empty (token = "", secret = "") - */ - public boolean isEmpty() { - return "".equals(this.token) && "".equals(this.secret); - } - - /** - * Factory method that returns an empty token (token = "", secret = ""). - * - * Useful for two legged OAuth. - */ - public static Token empty() { - return new Token("", ""); - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - Token that = (Token) o; - return token.equals(that.token) && secret.equals(that.secret); - } - - @Override - public int hashCode() { - return 31 * token.hashCode() + secret.hashCode(); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Verifier.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Verifier.java deleted file mode 100644 index 92cdb719e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/model/Verifier.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.model; - -import org.maxkey.client.utils.Preconditions; - -/** - * Represents an OAuth verifier code. - * - * @author Pablo Fernandez - */ -public class Verifier -{ - - private final String value; - - /** - * Default constructor. - * - * @param value verifier value - */ - public Verifier(String value) - { - Preconditions.checkNotNull(value, "Must provide a valid string as verifier"); - this.value = value; - } - - public String getValue() - { - return value; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuth20ServiceImpl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuth20ServiceImpl.java deleted file mode 100644 index 422e9ae05..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuth20ServiceImpl.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.oauth; - - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Response; -import org.maxkey.client.oauth.builder.api.*; -import org.maxkey.client.oauth.model.*; - -public class OAuth20ServiceImpl implements OAuthService -{ - private static final String VERSION = "2.0"; - - private final DefaultApi20 api; - private final OAuthConfig config; - - /** - * Default constructor - * - * @param api OAuth2.0 api information - * @param config OAuth 2.0 configuration param object - */ - public OAuth20ServiceImpl(DefaultApi20 api, OAuthConfig config) - { - this.api = api; - this.config = config; - } - - - /** - * Default constructor - * - * @param clientId - * @param clientSecret - * @param redirectUri - */ - public OAuth20ServiceImpl(String clientId, String clientSecret,String redirectUri) - { - this.api=new MaxkeyApi20(); - this.config =new OAuthConfig(clientId,clientSecret,redirectUri); - - } - - /** - * {@inheritDoc} - */ - public Token getAccessToken(Token requestToken, Verifier verifier) - { - OAuthRequest request = new OAuthRequest(api.getAccessTokenVerb(), api.getAccessTokenEndpoint()); - if(api.getAccessTokenVerb().equals(HttpVerb.GET)){ - request.addQuerystringParameter(OAuthConstants.CLIENT_ID, config.getApiKey()); - request.addQuerystringParameter(OAuthConstants.CLIENT_SECRET, config.getApiSecret()); - request.addQuerystringParameter(OAuthConstants.CODE, verifier.getValue()); - request.addQuerystringParameter(OAuthConstants.REDIRECT_URI, config.getCallback()); - if(config.hasScope()) request.addQuerystringParameter(OAuthConstants.SCOPE, config.getScope()); - }else{ - request.getBodyParams().add(OAuthConstants.CLIENT_ID, config.getApiKey()); - request.getBodyParams().add(OAuthConstants.CLIENT_SECRET, config.getApiSecret()); - request.getBodyParams().add(OAuthConstants.CODE, verifier.getValue()); - request.getBodyParams().add(OAuthConstants.REDIRECT_URI, config.getCallback()); - request.getBodyParams().add(OAuthConstants.GRANT_TYPE, api.getGrantType()); - if(config.hasScope())request.getBodyParams().add(OAuthConstants.SCOPE, config.getScope()); - } - - Response response = request.send(); - return api.getAccessTokenExtractor().extract(response.getBody()); - } - - /** - * {@inheritDoc} - */ - public Token getRequestToken() - { - throw new UnsupportedOperationException("Unsupported operation, please use 'getAuthorizationUrl' and redirect your users there"); - } - - /** - * {@inheritDoc} - */ - public String getVersion() - { - return VERSION; - } - - /** - * {@inheritDoc} - */ - public void signRequest(Token accessToken, OAuthRequest request) - { - request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken()); - } - - /** - * {@inheritDoc} - */ - public String getAuthorizationUrl(Token requestToken) - { - return api.getAuthorizationUrl(config); - } - @Override - public void signAccessTokenRequest(Token accessToken, OAuthRequest request) { - // TODO Auto-generated method stub - request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, accessToken.getToken()); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthPasswordService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthPasswordService.java deleted file mode 100644 index 2313babd3..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthPasswordService.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.oauth; - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Response; -import org.maxkey.client.oauth.builder.ServiceBuilder; -import org.maxkey.client.oauth.builder.api.MaxkeyPasswordApi20; -import org.maxkey.client.oauth.model.OAuthConfig; -import org.maxkey.client.oauth.model.OAuthRequest; -import org.maxkey.client.oauth.model.Token; - - -/** - * OAuth 2.0 api. - */ -public class OAuthPasswordService { - - private OAuthConfig config; - - private MaxkeyPasswordApi20 passwordApi20; - - public OAuthPasswordService() { - super(); - } - - public OAuthPasswordService(OAuthConfig config,MaxkeyPasswordApi20 passwordApi20) { - super(); - this.passwordApi20=passwordApi20; - this.config = config; - } - - public Token getAccessToken(String username, String password) { - try { - String accessTokenUrl=passwordApi20.getAuthorizationUrl(config, username, password); - System.out.println(accessTokenUrl); - OAuthRequest oauthRequest = new OAuthRequest(HttpVerb.GET,accessTokenUrl); - Response response = oauthRequest.send(); - return passwordApi20.getAccessTokenExtractor().extract(response.getBody()); - } catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - public Response sendRequest(Token accessToken,HttpVerb requestMethod,String requestUrl) { - OAuthRequest oauthRequest = new OAuthRequest(requestMethod, requestUrl); - ServiceBuilder builder = new ServiceBuilder().provider(passwordApi20) - .apiKey(config.getApiKey()) - .apiSecret(config.getApiSecret()) - .callback(config.getCallback()); - OAuthService oAuthService=builder.build(); - oAuthService.signRequest(accessToken, oauthRequest); - return oauthRequest.send(); - } - public OAuthConfig getConfig() { - return config; - } - - public void setConfig(OAuthConfig config) { - this.config = config; - } - - public MaxkeyPasswordApi20 getPasswordApi20() { - return passwordApi20; - } - - public void setPasswordApi20(MaxkeyPasswordApi20 passwordApi20) { - this.passwordApi20 = passwordApi20; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthService.java deleted file mode 100644 index 4e8cc7566..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/oauth/OAuthService.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.oauth; - -import org.maxkey.client.oauth.model.*; - -/** - * The main Scribe object. - * - * A facade responsible for the retrieval of request and access tokens and for the signing of HTTP requests. - * - * @author Pablo Fernandez - */ -public interface OAuthService -{ - /** - * Retrieve the request token. - * - * @return request token - */ - public Token getRequestToken(); - - /** - * Retrieve the access token - * - * @param requestToken request token (obtained previously) - * @param verifier verifier code - * @return access token - */ - public Token getAccessToken(Token requestToken, Verifier verifier); - - /** - * Signs am OAuth request - * - * @param accessToken access token (obtained previously) - * @param request request to sign - */ - public void signRequest(Token accessToken, OAuthRequest request); - - - public void signAccessTokenRequest(Token accessToken, OAuthRequest request); - - /** - * Returns the OAuth version of the service. - * - * @return oauth version as string - */ - public String getVersion(); - - /** - * Returns the URL where you should redirect your users to authenticate - * your application. - * - * @param requestToken the request token you need to authorize - * @return the URL where you should redirect your users - */ - public String getAuthorizationUrl(Token requestToken); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/Base64Encoder.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/Base64Encoder.java deleted file mode 100644 index 3f4996be9..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/Base64Encoder.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -public abstract class Base64Encoder -{ - private static Base64Encoder instance; - - public static synchronized Base64Encoder getInstance() - { - if (instance == null) - { - instance = createEncoderInstance(); - } - return instance; - } - - private static Base64Encoder createEncoderInstance() - { - if (CommonsEncoder.isPresent()) - { - return new CommonsEncoder(); - } - else - { - return new DatatypeConverterEncoder(); - } - } - - public static String type() - { - return getInstance().getType(); - } - - public abstract String encode(byte[] bytes); - - public abstract String getType(); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/CommonsEncoder.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/CommonsEncoder.java deleted file mode 100644 index cdc9ddc43..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/CommonsEncoder.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -import org.apache.commons.codec.binary.*; -import org.maxkey.client.oauth.exceptions.*; - -import java.io.UnsupportedEncodingException; - -public class CommonsEncoder extends Base64Encoder -{ - - @Override - public String encode(byte[] bytes) - { - try - { - return new String(Base64.encodeBase64(bytes), "UTF-8"); - } - catch (UnsupportedEncodingException e) - { - throw new OAuthSignatureException("Can't perform base64 encoding", e); - } - } - - @Override - public String getType() - { - return "CommonsCodec"; - } - - public static boolean isPresent() - { - try - { - Class.forName("org.apache.commons.codec.binary.Base64"); - return true; - } - catch (ClassNotFoundException e) - { - return false; - } - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/DatatypeConverterEncoder.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/DatatypeConverterEncoder.java deleted file mode 100644 index 62fa5b352..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/DatatypeConverterEncoder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -import javax.xml.bind.*; - -public class DatatypeConverterEncoder extends Base64Encoder -{ - @Override - public String encode(byte[] bytes) - { - return DatatypeConverter.printBase64Binary(bytes); - } - - @Override - public String getType() - { - return "DatatypeConverter"; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/HMACSha1SignatureService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/HMACSha1SignatureService.java deleted file mode 100644 index b4a425fbb..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/HMACSha1SignatureService.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -import javax.crypto.*; -import javax.crypto.spec.*; - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * HMAC-SHA1 implementation of {@SignatureService} - * - * @author Pablo Fernandez - * - */ -public class HMACSha1SignatureService implements SignatureService -{ - private static final String EMPTY_STRING = ""; - private static final String CARRIAGE_RETURN = "\r\n"; - private static final String UTF8 = "UTF-8"; - private static final String HMAC_SHA1 = "HmacSHA1"; - private static final String METHOD = "HMAC-SHA1"; - - /** - * {@inheritDoc} - */ - public String getSignature(String baseString, String apiSecret, String tokenSecret) - { - try - { - Preconditions.checkEmptyString(baseString, "Base string cant be null or empty string"); - Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); - return doSign(baseString, HttpEncoder.encode(apiSecret) + '&' + HttpEncoder.encode(tokenSecret)); - } - catch (Exception e) - { - throw new OAuthSignatureException(baseString, e); - } - } - - private String doSign(String toSign, String keyString) throws Exception - { - SecretKeySpec key = new SecretKeySpec((keyString).getBytes(UTF8), HMAC_SHA1); - Mac mac = Mac.getInstance(HMAC_SHA1); - mac.init(key); - byte[] bytes = mac.doFinal(toSign.getBytes(UTF8)); - return bytesToBase64String(bytes).replace(CARRIAGE_RETURN, EMPTY_STRING); - } - - private String bytesToBase64String(byte[] bytes) - { - return Base64Encoder.getInstance().encode(bytes); - } - - /** - * {@inheritDoc} - */ - public String getSignatureMethod() - { - return METHOD; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/PlaintextSignatureService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/PlaintextSignatureService.java deleted file mode 100644 index a8aaeacb0..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/PlaintextSignatureService.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - - -import org.maxkey.client.oauth.exceptions.*; -import org.maxkey.client.utils.HttpEncoder; -import org.maxkey.client.utils.Preconditions; - -/** - * plaintext implementation of {@SignatureService} - * - * @author Pablo Fernandez - * - */ -public class PlaintextSignatureService implements SignatureService -{ - private static final String METHOD = "PLAINTEXT"; - - /** - * {@inheritDoc} - */ - public String getSignature(String baseString, String apiSecret, String tokenSecret) - { - try - { - Preconditions.checkEmptyString(apiSecret, "Api secret cant be null or empty string"); - return HttpEncoder.encode(apiSecret) + '&' + HttpEncoder.encode(tokenSecret); - } - catch (Exception e) - { - throw new OAuthSignatureException(baseString, e); - } - } - - /** - * {@inheritDoc} - */ - public String getSignatureMethod() - { - return METHOD; - } -} - diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/RSASha1SignatureService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/RSASha1SignatureService.java deleted file mode 100644 index 7cbd95c0e..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/RSASha1SignatureService.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -import java.security.*; - -import org.maxkey.client.oauth.exceptions.*; - -/** - * A signature service that uses the RSA-SHA1 algorithm. - */ -public class RSASha1SignatureService implements SignatureService -{ - private static final String METHOD = "RSA-SHA1"; - private static final String RSA_SHA1 = "SHA1withRSA"; - private static final String UTF8 = "UTF-8"; - - private PrivateKey privateKey; - - public RSASha1SignatureService(PrivateKey privateKey) - { - this.privateKey = privateKey; - } - - /** - * {@inheritDoc} - */ - public String getSignature(String baseString, String apiSecret, String tokenSecret) - { - try - { - Signature signature = Signature.getInstance(RSA_SHA1); - signature.initSign(privateKey); - signature.update(baseString.getBytes(UTF8)); - return bytesToBase64String(signature); - } - catch (Exception e) - { - throw new OAuthSignatureException(baseString, e); - } - } - - private String bytesToBase64String(Signature signature) throws SignatureException - { - return Base64Encoder.getInstance().encode(signature.sign()); - } - - /** - * {@inheritDoc} - */ - public String getSignatureMethod() - { - return METHOD; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/SignatureService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/SignatureService.java deleted file mode 100644 index f457dacd5..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/SignatureService.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -/** - * Signs a base string, returning the OAuth signature - * - * @author Pablo Fernandez - * - */ -public interface SignatureService -{ - /** - * Returns the signature - * - * @param baseString url-encoded string to sign - * @param apiSecret api secret for your app - * @param tokenSecret token secret (empty string for the request token step) - * - * @return signature - */ - public String getSignature(String baseString, String apiSecret, String tokenSecret); - - /** - * Returns the signature method/algorithm - * - * @return - */ - public String getSignatureMethod(); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampService.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampService.java deleted file mode 100644 index 201c6b765..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampService.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -/** - * Unix epoch timestamp generator. - * - * This class is useful for stubbing in tests. - * - * @author Pablo Fernandez - */ -public interface TimestampService -{ - /** - * Returns the unix epoch timestamp in seconds - * - * @return timestamp - */ - public String getTimestampInSeconds(); - - /** - * Returns a nonce (unique value for each request) - * - * @return nonce - */ - public String getNonce(); -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampServiceImpl.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampServiceImpl.java deleted file mode 100644 index 46125a5a2..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/oauth/services/TimestampServiceImpl.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.services; - -import java.util.*; - -/** - * Implementation of {@link TimestampService} using plain java classes. - * - * @author Pablo Fernandez - */ -public class TimestampServiceImpl implements TimestampService -{ - private Timer timer; - - /** - * Default constructor. - */ - public TimestampServiceImpl() - { - timer = new Timer(); - } - - /** - * {@inheritDoc} - */ - public String getNonce() - { - Long ts = getTs(); - return String.valueOf(ts + timer.getRandomInteger()); - } - - /** - * {@inheritDoc} - */ - public String getTimestampInSeconds() - { - return String.valueOf(getTs()); - } - - private Long getTs() - { - return timer.getMilis() / 1000; - } - - void setTimer(Timer timer) - { - this.timer = timer; - } - - /** - * Inner class that uses {@link System} for generating the timestamps. - * - * @author Pablo Fernandez - */ - static class Timer - { - private final Random rand = new Random(); - Long getMilis() - { - return System.currentTimeMillis(); - } - - Integer getRandomInteger() - { - return rand.nextInt(); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/package-info.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/package-info.java deleted file mode 100644 index 47a977082..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -/** - * @author Administrator - * - */ -package org.maxkey.client; diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/tokenbase/TokenUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/tokenbase/TokenUtils.java deleted file mode 100644 index 41ee5c186..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/tokenbase/TokenUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.tokenbase; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; - -import org.apache.commons.codec.DecoderException; -import org.apache.commons.codec.binary.Hex; -import org.maxkey.client.crypto.Base64Utils; -import org.maxkey.client.crypto.ReciprocalUtils; -import org.maxkey.client.utils.JsonUtils; - -public class TokenUtils { - - public static String decode(String tokenString,String algorithmKey, String algorithm){ - String token=ReciprocalUtils.decoder(Base64Utils.base64UrlDecode(tokenString), algorithmKey, algorithm); - - - try { - token=new String(Hex.decodeHex(token.toCharArray()),"UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } catch (DecoderException e) { - e.printStackTrace(); - } - - return token; - } - - public static String [] parseSimpleBasedToken(String token){ - return new String[] {token.substring(0, token.indexOf("@@")), - token.substring(token.indexOf("@@")+2)}; - } - - @SuppressWarnings("unchecked") - public static HashMap parseJsonBasedToken(String token){ - HashMap tokenMap=new HashMap(); - - tokenMap=JsonUtils.gson2Object(token, tokenMap.getClass()); - - return tokenMap; - } - - public static void main(String[] args) { - // TODO Auto-generated method stub - String token="634d23bf64c20ae937eb9b81dbe9c30969d2d569c8c6c3b9d8089bff8c910c07722ca1f4137132fefb380fb8dd011e71e5b1df84b73088629b85f07a3559c7d9"; - // ZpqjxUOX3QuE8rwl6etstU0z2WO%2Flpo5 - String tokenString=TokenUtils.decode(token, "x8zPbCya", ReciprocalUtils.Algorithm.DES); - System.out.println(tokenString); - - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/JsonUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/JsonUtils.java deleted file mode 100644 index c1ffc8f36..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/JsonUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public class JsonUtils { - - - /** - * Transform json string to java bean object use Gson - * @param - * @param json - * @param Class - * @return Object - */ - - public static T gson2Object(String json,Class cls){ - T newBean = (new Gson()).fromJson(json, cls); - return newBean; - } - - - /** - * Transform java bean object to json string use Gson - * @param bean - * @return string - */ - public static String gson2Json(Object bean){ - String json=""; - // convert java object to JSON format, - // and returned as JSON formatted string - json = (new Gson()).toJson(bean); - - return json; - } - - /** - * prettyJson use Gson - * @param bean - * @return String - */ - public static String gsonPretty(Object bean){ - Gson gson = new GsonBuilder().setPrettyPrinting().create(); - String json = gson.toJson(bean); - return json; - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/MapUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/MapUtils.java deleted file mode 100644 index f9370feee..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/MapUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.util.Map; - -public abstract class MapUtils { - - public static String toString(Map map) { - if (map == null) { - return ""; - } - if (map.isEmpty()) { - return "{}"; - } - - final StringBuilder result = new StringBuilder(); - for (Map.Entry entry : map.entrySet()) { - result.append(", ") - .append(entry.getKey().toString()) - .append(" -> ") - .append(entry.getValue().toString()) - .append(' '); - } - return "{" + result.append('}').substring(1); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/PathUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/PathUtils.java deleted file mode 100644 index 7db2b1b7a..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/PathUtils.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.io.UnsupportedEncodingException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public class PathUtils { - private final Log log = LogFactory.getLog(getClass()); - private static PathUtils instance = null; - private String classPath; - - public static synchronized PathUtils getInstance() { - if (instance == null) { - instance = new PathUtils(); - instance.log.debug("getInstance()" +" new ConfigFile instance"); - } - return instance; - } - - public PathUtils() { - try { - classPath = java.net.URLDecoder.decode(PathUtils.class.getResource("PathUtilsFile.properties").getFile(),"UTF-8"); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - String fileProtocol=PathUtils.class.getResource("PathUtilsFile.properties").getProtocol(); - log.info("getWebRoot getProtocol:"+PathUtils.class.getResource("PathUtilsFile.properties").getProtocol()); - if(fileProtocol.equalsIgnoreCase("file")){ - // /D:/SoftWare/apache-tomcat-5.5.30/webapps/app - if(classPath.indexOf("file:")==0){ - classPath=classPath.substring(5, classPath.length()); - } - }else if(fileProtocol.equalsIgnoreCase("jar")){ - // file:/D:/SoftWare/apache-tomcat-5.5.30/webapps/app - if(classPath.indexOf("file:")==0){ - classPath=classPath.substring(5, classPath.length()); - } - }else if(fileProtocol.equalsIgnoreCase("wsjar")){ - if(classPath.indexOf("file:")==0){ - classPath=classPath.substring(5, classPath.length()); - } - }else if(classPath.equalsIgnoreCase("file:")){ - classPath=classPath.substring(5, classPath.length()); - } - - /// /WEB-INF/ - if(classPath.indexOf("/WEB-INF/")!=-1){ - classPath=classPath.substring(0, classPath.indexOf("/WEB-INF/")); - } - - log.info("getWebRoot() webApp root Path : "+classPath); - } - - public String getWebInf(){ - return classPath+"/WEB-INF/"; - } - - - public String getClassPath(){ - return classPath+"/WEB-INF/classes/"; - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/Preconditions.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/Preconditions.java deleted file mode 100644 index 3ed0f5c4b..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/Preconditions.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.util.Locale; -import java.util.regex.Pattern; - -import org.maxkey.client.oauth.model.OAuthConstants; - -/** - * Utils for checking preconditions and invariants - */ -public abstract class Preconditions { - - private static final String DEFAULT_MESSAGE = "Received an invalid parameter"; - - // scheme = alpha *( alpha | digit | "+" | "-" | "." ) - private static final String URL_REGEXP = "^[a-zA-Z][a-zA-Z0-9+.-]*://\\S+"; - - /** - * Checks that an object is not null. - * - * @param object any object - * @param errorMsg error message - * - * @throws IllegalArgumentException if the object is null - */ - public static void checkNotNull(Object object, String errorMsg) { - check(object != null, errorMsg); - } - - /** - * Checks that a string is not null or empty - * - * @param string any string - * @param errorMsg error message - * - * @throws IllegalArgumentException if the string is null or empty - */ - public static void checkEmptyString(String string, String errorMsg) { - check(string != null && !string.trim().isEmpty(), errorMsg); - } - - /** - * Checks that a URL is valid - * - * @param url any string - * @param errorMsg error message - */ - public static void checkValidUrl(String url, String errorMsg) { - checkEmptyString(url, errorMsg); - check(isUrl(url), errorMsg); - } - - /** - * Checks that a URL is a valid OAuth callback - * - * @param url any string - * @param errorMsg error message - */ - public static void checkValidOAuthCallback(String url, String errorMsg) { - checkEmptyString(url, errorMsg); - if (url.toLowerCase(Locale.getDefault()).compareToIgnoreCase(OAuthConstants.OUT_OF_BAND) != 0) { - check(isUrl(url), errorMsg); - } - } - - private static boolean isUrl(String url) { - return Pattern.compile(URL_REGEXP).matcher(url).matches(); - } - - private static void check(boolean requirements, String error) { - if (!requirements) { - throw new IllegalArgumentException(error == null || error.trim().length() <= 0 ? DEFAULT_MESSAGE : error); - } - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StreamUtils.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StreamUtils.java deleted file mode 100644 index 9a8d67c09..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StreamUtils.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.zip.GZIPInputStream; - -/** - * Utils to deal with Streams. - */ -public abstract class StreamUtils { - - /** - * Returns the stream contents as an UTF-8 encoded string - * - * @param is input stream - * @return string contents - * @throws java.io.IOException in any. SocketTimeout in example - */ - public static String getStreamContents(InputStream is) throws IOException { - Preconditions.checkNotNull(is, "Cannot get String from a null object"); - final char[] buffer = new char[0x10000]; - final StringBuilder out = new StringBuilder(); - try (Reader in = new InputStreamReader(is, "UTF-8")) { - int read; - do { - read = in.read(buffer, 0, buffer.length); - if (read > 0) { - out.append(buffer, 0, read); - } - } while (read >= 0); - } - return out.toString(); - } - - /** - * Return String content from a gzip stream - * - * @param is input stream - * @return string contents - * @throws java.io.IOException in any. SocketTimeout in example - */ - public static String getGzipStreamContents(InputStream is) throws IOException { - Preconditions.checkNotNull(is, "Cannot get String from a null object"); - final GZIPInputStream gis = new GZIPInputStream(is); - return getStreamContents(gis); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StringGenerator.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StringGenerator.java deleted file mode 100644 index b564b74c8..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/StringGenerator.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.lang.management.ManagementFactory; -import java.security.SecureRandom; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Random; -import java.util.UUID; - -import org.maxkey.client.crypto.Base64Utils; - -public class StringGenerator { - - private static final int MAX_PID = 65536; - - private char[] DEFAULT_CODEC = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray(); - - public static final char[] DEFAULT_CODE_NUMBER = "1234567890".toCharArray(); - - public static final char[] DEFAULT_CODE_LOWERCASE = "abcdefghijklmnopqrstuvwxyz".toCharArray(); - - public static final char[] DEFAULT_CODE_UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); - - public static final char[] DEFAULT_CODE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray(); - - public static final char[] DEFAULT_CODE_NUMBER_LETTERS = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray(); - - public static int processId; - - private static final String uuidRegex = "^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"; - - - private Random random = new SecureRandom(); - - private int length; - - static { - final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); - int index = jvmName.indexOf('@'); - if (index < 1) - throw new RuntimeException("Could not get PID"); - - try { - processId= Integer.parseInt(jvmName.substring(0, index)) % MAX_PID; - } catch (NumberFormatException e) { - throw new RuntimeException("Could not get PID"); - } - } - - /** - * Create a generator with the default length (6). - */ - public StringGenerator() { - this(6); - } - - /** - * Create a generator of random strings of the length provided - * - * @param length the length of the strings generated - */ - public StringGenerator(int length) { - this.length = length; - } - - public StringGenerator(char[] defaultCode,int length) { - this.DEFAULT_CODEC=defaultCode; - this.length = length; - } - - public String randomGenerate() { - byte[] verifierBytes = new byte[length]; - random.nextBytes(verifierBytes); - return getString(verifierBytes); - } - - public String uuidGenerate() { - return UUID.randomUUID().toString().toLowerCase(); - } - - public String uniqueGenerate() { - StringBuffer uniqueString=new StringBuffer(""); - - this.length=9; - String randomString =randomGenerate(); - uniqueString.append(randomString.subSequence(0, 4)); - - Date currentDate=new Date(); - DateFormat dateFormat = new SimpleDateFormat("ddMMyyyyHHmmssSSS"); - String dateString=Base64Utils.encodeBase64(dateFormat.format(currentDate).getBytes()); - dateString=dateString.substring(0, dateString.length()-1); - uniqueString.append(dateString); - - uniqueString.append(randomString.subSequence(5, 8)); - - return uniqueString.toString(); - } - - /** - * Convert these random bytes to a verifier string. The length of the byte array can be - * {@link #setLength(int) configured}. The default implementation mods the bytes to fit into the - * ASCII letters 1-9, A-Z, a-z . - * - * @param verifierBytes The bytes. - * @return The string. - */ - protected String getString(byte[] verifierBytes) { - char[] chars = new char[verifierBytes.length]; - for (int i = 0; i < verifierBytes.length; i++) { - chars[i] = DEFAULT_CODEC[((verifierBytes[i] & 0xFF) % DEFAULT_CODEC.length)]; - } - return new String(chars); - } - - /** - * The random value generator used to create token secrets. - * - * @param random The random value generator used to create token secrets. - */ - public void setRandom(Random random) { - this.random = random; - } - - /** - * The length of string to generate. - * - * @param length the length to set - */ - public void setLength(int length) { - this.length = length; - } - - - public static boolean uuidMatches(String uuidString) { - return uuidString.matches(uuidRegex); - } - -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/AuthenticationFilter.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/AuthenticationFilter.java deleted file mode 100644 index a8fc21795..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/AuthenticationFilter.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.web.authn; - -import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.maxkey.client.oauth.OAuthClient; -import org.maxkey.client.oauth.builder.ServiceBuilder; -import org.maxkey.client.oauth.builder.api.MaxkeyApi20; -import org.maxkey.client.oauth.domain.UserInfo; -import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.oauth.model.Verifier; -import org.maxkey.client.oauth.oauth.OAuthService; - - - -/** - * - * @author Crystal.Sea - */ -public class AuthenticationFilter implements Filter { - - private static Log log = LogFactory.getLog(AuthenticationFilter. class ); - - private static final String UUID_REGEX = "^[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$"; - - public static final String CONST_MAXKEY_USERINFO="CONST_MAXKEY_USERINFO"; - - private String clientId; - private String clientSecret; - private String callBackUri; - private boolean enable; - private OAuthService service ; - - public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException { - - HttpServletRequest httpServletRequest = (HttpServletRequest) request; - HttpServletResponse httpServletResponse = (HttpServletResponse) response; - HttpSession session = httpServletRequest.getSession(); - - if(enable){ - Token EMPTY_TOKEN = null; - String code=request.getParameter("code"); - - if(code!=null&&uuidMatches(code)){ - Verifier verifier = new Verifier(code); - Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier); - log.debug(" access token is "+accessToken); - - OAuthClient restClient=new OAuthClient(OAuthClient.OAUTH_V20_USERINFO_URI); - - UserInfo userInfo=restClient.getUserInfo(accessToken.getToken()); - - session.setAttribute(CONST_MAXKEY_USERINFO, userInfo); - - }else if(session.getAttribute(CONST_MAXKEY_USERINFO)==null){ - String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN); - log.debug("Redirect to authorization Url : "+authorizationUrl); - httpServletResponse.sendRedirect(authorizationUrl); - } - } - - chain.doFilter(request, response); - } - - public void destroy() { - this.destroy(); - } - - public void init(FilterConfig config) throws ServletException { - this.clientId=config.getInitParameter("clientId"); - this.clientSecret=config.getInitParameter("clientSecret"); - this.callBackUri=config.getInitParameter("callBackUri"); - this.enable=config.getInitParameter("enable").equalsIgnoreCase("true"); - - log.debug("client_id : "+clientId); - log.debug("client_secret : "+clientSecret); - log.debug("callBack Uri : "+callBackUri); - log.debug("enable : "+enable); - - service = new ServiceBuilder() - .provider(MaxkeyApi20.class) - .apiKey(this.clientId) - .apiSecret(this.clientSecret) - .callback(this.callBackUri) - .build(); - log.debug(" init."); - } - - public static boolean uuidMatches(String uuidString) { - return uuidString.matches(UUID_REGEX); - } -} diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/SingleSignOutFilter.java b/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/SingleSignOutFilter.java deleted file mode 100644 index 144d5919d..000000000 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/web/authn/SingleSignOutFilter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.web.authn; - -import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * - * @author Crystal.Sea - */ -public class SingleSignOutFilter implements Filter { - private static final Logger log = LoggerFactory.getLogger(SingleSignOutFilter.class); - private String singleSignOutEndpoint; - - public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException { - - HttpServletRequest httpServletRequest = (HttpServletRequest) request; - HttpServletResponse httpServletResponse = (HttpServletResponse) response; - - HttpSession session = httpServletRequest.getSession(); - session.removeAttribute(AuthenticationFilter.CONST_MAXKEY_USERINFO); - session.invalidate(); - - httpServletResponse.sendRedirect(singleSignOutEndpoint); - - chain.doFilter(request, response); - } - - public void destroy() { - this.destroy(); - } - - public void init(FilterConfig config) throws ServletException { - this.singleSignOutEndpoint=config.getInitParameter("singleSignOutEndpoint"); - log.debug(" init."); - } -} diff --git a/maxkey-client-sdk/src/main/resources/log4j.properties b/maxkey-client-sdk/src/main/resources/log4j.properties deleted file mode 100644 index d924d5179..000000000 --- a/maxkey-client-sdk/src/main/resources/log4j.properties +++ /dev/null @@ -1,40 +0,0 @@ -# General Log Settings -#log4j.rootLogger=INFO,LOGFILE,stdout -log4j.rootLogger=INFO,LOGFILE,stdout - -#appender config:stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%c:%p %X %L] %m%n -#log4j.appender.stdout.layout.ConversionPattern=%-d{HH:mm:ss.SSS} [%c:%p %X{$UserName$} %L] %m%n - -#appender config:LOGFILE -# log file arrcoss file size -log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender -#log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender -#log4j.appender.LOGFILE.DatePattern=.yyyy-MM-dd -log4j.appender.LOGFILE.File=${catalina.home}/logs/maxkey_client_out.log -log4j.appender.LOGFILE.maxFileSize=2048KB -log4j.appender.LOGFILE.MaxBackupIndex = 5 - -log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout -log4j.appender.LOGFILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%c:%p] %m%n - -log4j.appender.DEBUG=org.apache.log4j.RollingFileAppender -log4j.appender.DEBUG.File=${catalina.home}/logs/maxkey_client_debug.log -log4j.appender.DEBUG.maxFileSize=2048KB -log4j.appender.DEBUG.MaxBackupIndex = 5 -log4j.appender.DEBUG.DatePattern=.yyyy-MM-dd -log4j.appender.DEBUG.layout=org.apache.log4j.PatternLayout -log4j.appender.DEBUG.layout.ConversionPattern=[%c:%p %X %L] %m%n - -#log4j.appender.ERROR=org.apache.log4j.DailyRollingFileAppender -#log4j.appender.ERROR.DatePattern=.yyyy-MM-dd -log4j.appender.ERROR=org.apache.log4j.RollingFileAppender -log4j.appender.ERROR.File=${catalina.home}/logs/maxkey_client_error.log - -log4j.appender.ERROR.maxFileSize=2048KB -log4j.appender.ERROR.MaxBackupIndex = 5 - -log4j.appender.ERROR.layout=org.apache.log4j.PatternLayout -log4j.appender.ERROR.layout.ConversionPattern=[%c:%p %X %L] %m%n diff --git a/maxkey-client-sdk/src/main/resources/org/maxkey/client/utils/PathUtilsFile.properties b/maxkey-client-sdk/src/main/resources/org/maxkey/client/utils/PathUtilsFile.properties deleted file mode 100644 index 6a2b0ac42..000000000 --- a/maxkey-client-sdk/src/main/resources/org/maxkey/client/utils/PathUtilsFile.properties +++ /dev/null @@ -1 +0,0 @@ -v1.0.1 \ No newline at end of file diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxKey20Example.java b/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxKey20Example.java deleted file mode 100644 index f9bf63083..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxKey20Example.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.test; - -import java.util.*; - -import org.maxkey.client.http.HttpVerb; -import org.maxkey.client.http.Response; -import org.maxkey.client.oauth.builder.ServiceBuilder; -import org.maxkey.client.oauth.builder.api.MaxkeyApi20; -import org.maxkey.client.oauth.model.OAuthRequest; -import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.oauth.model.Verifier; -import org.maxkey.client.oauth.oauth.OAuthService; - -public class MaxKey20Example -{ - private static final String NETWORK_NAME = "SinaWeibo"; - private static final String PROTECTED_RESOURCE_URL = "https://api.weibo.com/2/account/get_uid.json"; - private static final Token EMPTY_TOKEN = null; - - public static void main(String[] args) - { - // Replace these with your own api key and secret - String apiKey = "your_api_key"; - String apiSecret = "your_api_secret"; - OAuthService service = new ServiceBuilder() - .provider(MaxkeyApi20.class) - .apiKey(apiKey) - .apiSecret(apiSecret) - .callback("http://www.dajie.com/oauth/sina") - .build(); - Scanner in = new Scanner(System.in); - - System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ==="); - System.out.println(); - - // Obtain the Authorization URL - System.out.println("Fetching the Authorization URL..."); - String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN); - System.out.println("Got the Authorization URL!"); - System.out.println("Now go and authorize Scribe here:"); - System.out.println(authorizationUrl); - System.out.println("And paste the authorization code here"); - System.out.print(">>"); - Verifier verifier = new Verifier(in.nextLine()); - System.out.println(); - - // Trade the Request Token and Verifier for the Access Token - System.out.println("Trading the Request Token for an Access Token..."); - Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier); - System.out.println("Got the Access Token!"); - System.out.println("(if your curious it looks like this: " + accessToken + " )"); - System.out.println(); - - // Now let's go and ask for a protected resource! - System.out.println("Now we're going to access a protected resource..."); - OAuthRequest request = new OAuthRequest(HttpVerb.GET, PROTECTED_RESOURCE_URL); - service.signRequest(accessToken, request); - Response response = request.send(); - System.out.println("Got it! Lets see what we found..."); - System.out.println(); - System.out.println(response.getCode()); - System.out.println(response.getBody()); - - System.out.println(); - System.out.println("Thats it man! Go and build something awesome with Scribe! :)"); - - } -} diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxkeyPasswordDemo.java b/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxkeyPasswordDemo.java deleted file mode 100644 index 1ca8a94f6..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/MaxkeyPasswordDemo.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.oauth.test; - -import org.maxkey.client.http.Response; -import org.maxkey.client.oauth.builder.api.MaxkeyPasswordApi20; -import org.maxkey.client.oauth.model.OAuthConfig; -import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.oauth.oauth.OAuthPasswordService; - -public class MaxkeyPasswordDemo { - - /** - * @param args - */ - public static void main(String[] args) { - // TODO Auto-generated method stub - - String accessTokenUrl="http://localhost:8080/opensec/oauth/v20/token"; - String clientId = "e6bfadbfc1d64d0e9140a716548c35db"; - String clientSerect = "e6bfadbfc1d64d0e9140a716548c35db"; - - String callback = "http://localhost:8080/oauth1demo/oauth20callback.jsp"; - String responseType ="token"; - String approvalprompt = "auto"; - OAuthConfig oauthServiceConfig=new OAuthConfig(clientId,clientSerect,callback); - - MaxkeyPasswordApi20 ConnsecPasswordApi20=new MaxkeyPasswordApi20(accessTokenUrl); - - OAuthPasswordService oAuthPasswordService=new OAuthPasswordService(oauthServiceConfig,ConnsecPasswordApi20); - Token accessToken = null; - Response response = null; - accessToken = oAuthPasswordService.getAccessToken("6ac07a3d-b935-43f2-a693-9ce49b6695b7", "1qaz2wsx"); - - } - - -} diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/package-info.java b/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/package-info.java deleted file mode 100644 index dd633e524..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/client/oauth/test/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -/** - * @author Administrator - * - */ -package org.maxkey.client.oauth.test; diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/URLTest.java b/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/URLTest.java deleted file mode 100644 index 42cc41532..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/URLTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.client.utils; - -import java.io.UnsupportedEncodingException; -import java.net.URLDecoder; -import java.net.URLEncoder; - -public class URLTest { - - /** - * @param args - * @throws UnsupportedEncodingException - */ - public static void main(String[] args) throws UnsupportedEncodingException { - // TODO Auto-generated method stub - //String encoderString="/bi/QvAJAXZfc/opendoc.htm?document=康缘药业经营决策分析 .qvw&host=QVS@bi-server51"; - - String encoderString="康缘药业经营决策分析 .qvw"; - encoderString=URLEncoder.encode(encoderString,"UTF-8"); - System.out.println(encoderString); - - String decoderString="/bi/QvAJAXZfc/opendoc.htm?document=%E5%BA%B7%E7%BC%98%E8%8D%AF%E4%B8%9A%E7%BB%8F%E8%90%A5%E5%86%B3%E7%AD%96%E5%88%86%E6%9E%90.qvw&host=QVS%40bi-server51"; - decoderString=URLDecoder.decode(decoderString,"UTF-8"); - System.out.println(decoderString); - - } - -} diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/package-info.java b/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/package-info.java deleted file mode 100644 index d7d379089..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/client/utils/package-info.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * - */ -/** - * @author Administrator - * - */ -package org.maxkey.client.utils; diff --git a/maxkey-client-sdk/src/test/java/org/maxkey/rest/RestClientTest.java b/maxkey-client-sdk/src/test/java/org/maxkey/rest/RestClientTest.java deleted file mode 100644 index d81188335..000000000 --- a/maxkey-client-sdk/src/test/java/org/maxkey/rest/RestClientTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.rest; - -import java.util.HashMap; - -import org.junit.Test; -import org.maxkey.client.oauth.OAuthClient; -import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.utils.JsonUtils; - - -public class RestClientTest { - - //@Test - public void main() { - - - OAuthClient tokenRestClient=new OAuthClient("https://exmail.qq.com/cgi-bin/token"); - tokenRestClient.addParameter("grant_type", "client_credentials"); - tokenRestClient.addBasicAuthorization("maxkey", "66199e4c36b6dfcfb6f1ebceda789432"); - Token token =tokenRestClient.requestAccessToken(); - System.out.println(token); - - OAuthClient authkeyRestClient=new OAuthClient("http://openapi.exmail.qq.com:12211/openapi/mail/authkey"); - authkeyRestClient.addBearerAuthorization(token.getAccess_token()); - authkeyRestClient.addParameter("Alias", "test@maxkey.org"); - - - HashMap authKey=JsonUtils.gson2Object(authkeyRestClient.execute().getBody(), HashMap.class); - - String login_url="https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=%s&user=%s&ticket=%s"; - System.out.println(String.format(login_url, "connsec","test@maxkey.org",authKey.get("auth_key"))); - //https://exmail.qq.com/cgi-bin/login?fun=bizopenssologin&method=bizauth&agent=connsec&user=test@connsec.com&ticket=25640C491CA4A056BD1A936C6AA4ABBCAB13AE76EB80E6C3A9259F5E8BFD91D7EA05D10DA3FB18F9BFB445D104CB58A0B4CDE97D9F219F3C - } -} diff --git a/maxkey-connectors/.classpath b/maxkey-connectors/.classpath deleted file mode 100644 index eb19361b5..000000000 --- a/maxkey-connectors/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/.project b/maxkey-connectors/.project deleted file mode 100644 index a5cb9f4f0..000000000 --- a/maxkey-connectors/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - maxkey-connectors - Project maxkey-connectors created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.classpath b/maxkey-connectors/maxkey-connector-activedirectory/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.project b/maxkey-connectors/maxkey-connector-activedirectory/.project deleted file mode 100644 index 4e5ff56cb..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-activedirectory - Project maxkey-connectors-activedirectory created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.core.prefs b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8f838df8f..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.launching.prefs b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.launching.prefs deleted file mode 100644 index f8a131b56..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.jdt.launching.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning -org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 2972a0e7e..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-activedirectory/build.gradle b/maxkey-connectors/maxkey-connector-activedirectory/build.gradle deleted file mode 100644 index 3c87c5618..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-activedirectory" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/ActivedirectoryConsumerApplication.java b/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/ActivedirectoryConsumerApplication.java deleted file mode 100644 index f6468414b..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/ActivedirectoryConsumerApplication.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.ActiveDirectoryUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.activedirectory" - }) -public class ActivedirectoryConsumerApplication { - - public static void main(String[] args) { - ConfigurableApplicationContext context = SpringApplication.run(ActivedirectoryConsumerApplication.class, args); - - } - - //@Bean(name = "activeDirectoryUtils") - public ActiveDirectoryUtils getLdapConnection( - @Value("${config.connector.activedirectory.providerUrl}") String providerUrl, - @Value("${config.connector.activedirectory.principal}") String principal, - @Value("${config.connector.activedirectory.credentials}") String credentials, - @Value("${config.connector.activedirectory.baseDN}") String baseDn, - @Value("${config.connector.activedirectory.domain}") String domain, - @Value("${config.connector.activedirectory.trustStore}") String trustStore, - @Value("${config.connector.activedirectory.trustStore.password}") String trustStorePassword - )throws Exception{ - ActiveDirectoryUtils ldapUtils=new ActiveDirectoryUtils( - providerUrl, - principal, - credentials, - baseDn, - domain); - - ldapUtils.setTrustStore(trustStore); - ldapUtils.setTrustStorePassword(trustStorePassword); - ldapUtils.setSsl(true); - - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - -} diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Group2Activedirectory.java b/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Group2Activedirectory.java deleted file mode 100644 index 56ca7bf03..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Group2Activedirectory.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.activedirectory; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.ActiveDirectoryUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Activedirectory extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Activedirectory.class); - - ActiveDirectoryUtils ldapUtils; - - public Group2Activedirectory() { - // TODO Auto-generated constructor stub - } - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - Attribute objectClass = new BasicAttribute("objectClass"); - objectClass.add("top"); - objectClass.add("group"); - attributes.put(objectClass); - - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("member","CN=dummy,"+ldapUtils.getBaseDN())); - - String dn="cn="+group.getName()+",cn=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",cn=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - return create(group); - } - - - String uniqueMember=""; - SearchControls memberSearchControls = new SearchControls(); - logger.debug("user Search : "+"(sAMAccountName="+groupMember.getMemberName()+")"); - memberSearchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration memberResults = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+groupMember.getMemberName()+")", memberSearchControls); - if (memberResults == null || !memberResults.hasMore()) { - - }else{ - SearchResult memberSr = (SearchResult) memberResults.next(); - uniqueMember =memberSr.getNameInNamespace(); - logger.debug("uniqueMember : "+uniqueMember); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("member",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",cn=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - } - - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember=""; - SearchControls memberSearchControls = new SearchControls(); - memberSearchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration memberResults = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+groupMember.getMemberName()+")", memberSearchControls); - if (memberResults == null || !memberResults.hasMore()) { - - }else{ - SearchResult memberSr = (SearchResult) memberResults.next(); - uniqueMember =memberSr.getNameInNamespace(); - logger.debug("uniqueMember : "+uniqueMember); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("member",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",cn=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - -} diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Organization2Activedirectory.java b/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Organization2Activedirectory.java deleted file mode 100644 index 24ed0ef91..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Organization2Activedirectory.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.activedirectory; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.ActiveDirectoryUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Activedirectory extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Activedirectory.class); - - ActiveDirectoryUtils ldapUtils; - - public Organization2Activedirectory() { - // TODO Auto-generated constructor stub - } - - @Override - public boolean create(Organizations organization) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - } catch (NamingException e) { - e.printStackTrace(); - } - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - - //ModificationItem[] modificationItems = new ModificationItem[1]; - //modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Password2Activedirectory.java b/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Password2Activedirectory.java deleted file mode 100644 index 02c69ba62..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/Password2Activedirectory.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.activedirectory; - -import java.io.UnsupportedEncodingException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.ActiveDirectoryUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "passwordConnector") -public class Password2Activedirectory extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Activedirectory.class); - ActiveDirectoryUtils ldapUtils; - /** - * userAccountControl鍊煎緱璇存槑 - * http://support.microsoft.com/zh-cn/kb/305144 - * 灞炴�ф爣蹇� 鍗佸叚杩涘埗鍊� 鍗佽繘鍒跺�� - SCRIPT 0x0001 1 - ACCOUNTDISABLE 0x0002 2 - HOMEDIR_REQUIRED 0x0008 8 - LOCKOUT 0x0010 16 - PASSWD_NOTREQD 0x0020 32 - PASSWD_CANT_CHANGE 0x0040 64 - ENCRYPTED_TEXT_PWD_ALLOWED 0x0080 128 - TEMP_DUPLICATE_ACCOUNT 0x0100 256 - NORMAL_ACCOUNT 0x0200 512 - INTERDOMAIN_TRUST_ACCOUNT 0x0800 2048 - WORKSTATION_TRUST_ACCOUNT 0x1000 4096 - SERVER_TRUST_ACCOUNT 0x2000 8192 - DONT_EXPIRE_PASSWORD 0x10000 65536 - MNS_LOGON_ACCOUNT 0x20000 131072 - SMARTCARD_REQUIRED 0x40000 262144 - TRUSTED_FOR_DELEGATION 0x80000 524288 - NOT_DELEGATED 0x100000 1048576 - USE_DES_KEY_ONLY 0x200000 2097152 - DONT_REQ_PREAUTH 0x400000 4194304 - PASSWORD_EXPIRED 0x800000 8388608 - TRUSTED_TO_AUTH_FOR_DELEGATION 0x1000000 16777216 - */ - public Password2Activedirectory() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - try { - String dn=null; - SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+userInfo.getUsername()+")", searchControls); - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ModificationItem[] modificationItems = new ModificationItem[1]; - logger.info("decipherable : "+userInfo.getDecipherable()); - String password=ReciprocalUtils.decoder(userInfo.getDecipherable()); - //modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",password)); - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("unicodePwd",("\"" + password + "\"").getBytes("UTF-16LE"))); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/UserInfo2Activedirectory.java b/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/UserInfo2Activedirectory.java deleted file mode 100644 index eb45d4548..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/java/org/maxkey/connector/activedirectory/UserInfo2Activedirectory.java +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.activedirectory; - -import java.io.UnsupportedEncodingException; -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.ActiveDirectoryUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "userInfoConnector") -public class UserInfo2Activedirectory extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Activedirectory.class); - ActiveDirectoryUtils ldapUtils; - /** - * userAccountControl值得说明 - * http://support.microsoft.com/zh-cn/kb/305144 - * 属�?�标�? 十六进制�? 十进制�?? - SCRIPT 0x0001 1 - ACCOUNTDISABLE 0x0002 2 - HOMEDIR_REQUIRED 0x0008 8 - LOCKOUT 0x0010 16 - PASSWD_NOTREQD 0x0020 32 - PASSWD_CANT_CHANGE 0x0040 64 - ENCRYPTED_TEXT_PWD_ALLOWED 0x0080 128 - TEMP_DUPLICATE_ACCOUNT 0x0100 256 - NORMAL_ACCOUNT 0x0200 512 - INTERDOMAIN_TRUST_ACCOUNT 0x0800 2048 - WORKSTATION_TRUST_ACCOUNT 0x1000 4096 - SERVER_TRUST_ACCOUNT 0x2000 8192 - DONT_EXPIRE_PASSWORD 0x10000 65536 - MNS_LOGON_ACCOUNT 0x20000 131072 - SMARTCARD_REQUIRED 0x40000 262144 - TRUSTED_FOR_DELEGATION 0x80000 524288 - NOT_DELEGATED 0x100000 1048576 - USE_DES_KEY_ONLY 0x200000 2097152 - DONT_REQ_PREAUTH 0x400000 4194304 - PASSWORD_EXPIRED 0x800000 8388608 - TRUSTED_TO_AUTH_FOR_DELEGATION 0x1000000 16777216 - */ - public UserInfo2Activedirectory() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - try { - Attributes attributes = new BasicAttributes(); - Attribute objectClass = new BasicAttribute("objectClass"); - objectClass.add("top"); - objectClass.add("person"); - objectClass.add("organizationalPerson"); - objectClass.add("user"); - attributes.put(objectClass); - attributes.put(new BasicAttribute("sAMAccountName",userInfo.getUsername())); - logger.debug("decipherable : "+userInfo.getDecipherable()); - String password=ReciprocalUtils.decoder(userInfo.getDecipherable()); - - attributes.put(new BasicAttribute("unicodePwd",("\"" + password + "\"").getBytes("UTF-16LE"))); - //attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getUsername())); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"00000000000":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"email@default.com":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"0":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"default":userInfo.getDepartment())); - String managerDn="CN=dummy,"+ldapUtils.getBaseDN(); - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - logger.debug("manager is null."); - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - SearchControls managerSearchControls = new SearchControls(); - managerSearchControls.setSearchScope(ldapUtils.getSearchScope()); - logger.debug("managerResults : "+ldapUtils.getBaseDN()); - logger.debug("filter : "+"(sAMAccountName="+manager.getUsername()+")"); - logger.debug("managerSearchControls : "+managerSearchControls); - NamingEnumeration managerResults = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+manager.getUsername()+")", managerSearchControls); - if (managerResults == null || !managerResults.hasMore()) { - - }else{ - SearchResult managerSr = (SearchResult) managerResults.next(); - managerDn =managerSr.getNameInNamespace(); - } - } - - attributes.put(new BasicAttribute("manager",managerDn)); - - attributes.put(new BasicAttribute("department",userInfo.getDepartment()==null?"default":userInfo.getDepartment())); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"default":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"default":userInfo.getJobTitle())); - - //for kerberos login - attributes.put(new BasicAttribute("servicePrincipalName",this.properties.getProperty("servicePrincipalName"))); - attributes.put(new BasicAttribute("userPrincipalName",userInfo.getUsername()+"@"+this.properties.getProperty("domain"))); - - attributes.put(new BasicAttribute("userAccountControl",Integer.toString(66048))); - String rdn=""; - if(userInfo.getDepartmentId()!=null&& - !userInfo.getDepartmentId().equals("")){ - //get organization dn - SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope(ldapUtils.getSearchScope()); - logger.debug("managerResults : "+ldapUtils.getBaseDN()); - logger.debug("filter : "+"(&(objectClass=organizationalUnit)(description="+userInfo.getDepartmentId()+"))"); - logger.debug("searchControls : "+searchControls); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+userInfo.getDepartmentId()+"))", searchControls); - - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - }else{ - rdn=ldapUtils.getBaseDN(); - } - - //String dn="CN="+userInfo.getDisplayName()+","+rdn; - String dn="CN="+userInfo.getUsername()+","+rdn; - - logger.debug("dn : "+dn); - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - try { - String dn=null; - SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+userInfo.getUsername()+")", searchControls); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - - ModificationItem[] modificationItems = new ModificationItem[8]; - //modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"00000000000":userInfo.getWorkPhoneNumber())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"email@default.com":userInfo.getWorkEmail())); - - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"default":userInfo.getEmployeeNumber())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"default":userInfo.getDepartment())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("department",userInfo.getDepartmentId()==null?"default":userInfo.getDepartment())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"default":userInfo.getDepartmentId())); - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"default":userInfo.getJobTitle())); - - String managerDn="CN=dummy,"+ldapUtils.getBaseDN(); - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - SearchControls managerSearchControls = new SearchControls(); - managerSearchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration managerResults = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+manager.getUsername()+")", managerSearchControls); - if (managerResults == null || !managerResults.hasMore()) { - - }else{ - SearchResult managerSr = (SearchResult) managerResults.next(); - managerDn =managerSr.getNameInNamespace(); - } - } - - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - - if(userInfo.getDepartmentId()!=null&& - !userInfo.getDepartmentId().equals("")){ - //get organization dn - SearchControls orgSearchControls = new SearchControls(); - orgSearchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration orgResults = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+userInfo.getDepartmentId()+"))", orgSearchControls); - String orgRdn=""; - if (orgResults == null || !orgResults.hasMore()) { - orgRdn=ldapUtils.getBaseDN(); - }else{ - SearchResult orgSearchResult = (SearchResult) orgResults.next(); - orgRdn =orgSearchResult.getNameInNamespace(); - } - - //String newDn="CN="+userInfo.getDisplayName()+","+orgRdn; - String newDn="CN="+userInfo.getUsername()+","+orgRdn; - - if(!dn.equals(newDn)){ - logger.debug("oldDn : "+dn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(dn, newDn); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - try { - String dn=null; - SearchControls searchControls = new SearchControls(); - searchControls.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(sAMAccountName="+userInfo.getUsername()+")", searchControls); - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - logger.debug("delete dn : "+dn); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-activedirectory/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-activedirectory/src/main/resources/application.properties deleted file mode 100644 index 35fac8d5c..000000000 --- a/maxkey-connectors/maxkey-connector-activedirectory/src/main/resources/application.properties +++ /dev/null @@ -1,48 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-ActiveDirectory -application.name=MaxKey-Connector-ActiveDirectory -application.formatted-version=v2.0.0 GA -#server port -server.port=9602 -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=ActiveDirectoryConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.activedirectory.providerUrl=ldap:// -config.connector.activedirectory.principal=maxkey -config.connector.activedirectory.credentials=maxkey -config.connector.activedirectory.baseDN=dc=maxkey,dc=top -config.connector.activedirectory.domain=MAXKEY -config.connector.activedirectory.trustStore=maxkey -config.connector.activedirectory.trustStore.password=maxkey \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-base/.classpath b/maxkey-connectors/maxkey-connector-base/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-base/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-base/.project b/maxkey-connectors/maxkey-connector-base/.project deleted file mode 100644 index 17871f197..000000000 --- a/maxkey-connectors/maxkey-connector-base/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-base - Project maxkey-connectors-base created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.core.prefs b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8f838df8f..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.launching.prefs b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.launching.prefs deleted file mode 100644 index f8a131b56..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.jdt.launching.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning -org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 9a5f7e0a8..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-base/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-base/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-base/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-base/build.gradle b/maxkey-connectors/maxkey-connector-base/build.gradle deleted file mode 100644 index d727ab605..000000000 --- a/maxkey-connectors/maxkey-connector-base/build.gradle +++ /dev/null @@ -1,16 +0,0 @@ -description = "maxkey-connector-base" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/AbstractConnector.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/AbstractConnector.java deleted file mode 100644 index b98d2ed2a..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/AbstractConnector.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import java.util.Properties; - -import org.springframework.jdbc.core.JdbcTemplate; - - -public abstract class AbstractConnector{ - - - public static class CONNECTOR_TYPE{ - public static int USERINFO_TYPE=1; - public static int ORG_TYPE=2; - public static int GROUP_TYPE=3; - public static int PASSWORD_TYPE=4; - } - - protected Properties properties; - - protected JdbcTemplate jdbcTemplate; - - public boolean create(T entity) throws Exception{ - return true; - } - - public boolean update(T entity) throws Exception{ - return true; - } - - public boolean delete(T entity) throws Exception{ - return true; - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } - - public JdbcTemplate getJdbcTemplate() { - return jdbcTemplate; - } - - public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { - this.jdbcTemplate = jdbcTemplate; - } - - - - -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/GroupConnector.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/GroupConnector.java deleted file mode 100644 index 750fd60e5..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/GroupConnector.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; - -public abstract class GroupConnector extends AbstractConnector { - - @Override - public boolean create(Groups group) throws Exception{ - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - return true; - } - - @Override - public boolean delete(Groups group) throws Exception{ - return true; - } - - - public boolean addMember(GroupMember groupMember) throws Exception{ - return true; - } - - - public boolean deleteMember(GroupMember groupMember) throws Exception{ - return true; - } - -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/OrganizationConnector.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/OrganizationConnector.java deleted file mode 100644 index dae99e550..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/OrganizationConnector.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.domain.Organizations; - -public abstract class OrganizationConnector extends AbstractConnector { - - @Override - public boolean create(Organizations organization) throws Exception{ - return true; - } - - @Override - public boolean update(Organizations organization) throws Exception{ - return true; - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - return true; - } - -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/PasswordConnector.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/PasswordConnector.java deleted file mode 100644 index 11567f319..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/PasswordConnector.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.domain.UserInfo; - -public abstract class PasswordConnector extends AbstractConnector { - - public boolean sync(UserInfo userInfo) throws Exception{ - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/UserInfoConnector.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/UserInfoConnector.java deleted file mode 100644 index 3da3c7323..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/UserInfoConnector.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.domain.UserInfo; - -public abstract class UserInfoConnector extends AbstractConnector { - - @Override - public boolean create(UserInfo userInfo) throws Exception { - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - return true; - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaGroupsTopicReceiver.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaGroupsTopicReceiver.java deleted file mode 100644 index aeffbb2fc..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaGroupsTopicReceiver.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.receiver; - -import java.util.Optional; - -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.Groups; -import org.maxkey.identity.kafka.KafkaIdentityAction; -import org.maxkey.identity.kafka.KafkaIdentityTopic; -import org.maxkey.identity.kafka.KafkaMessage; -import org.maxkey.util.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.stereotype.Component; - -@Component -public class KafkaGroupsTopicReceiver { - private static final Logger _logger = LoggerFactory.getLogger(KafkaGroupsTopicReceiver.class); - - @Autowired - GroupConnector groupConnector; - - @KafkaListener(topics = {KafkaIdentityTopic.GROUP_TOPIC}) - public void listen(ConsumerRecord record) { - try { - Optional kafkaMessage = Optional.ofNullable(record.value()); - - if (kafkaMessage.isPresent()) { - - Object message = kafkaMessage.get(); - - _logger.debug("----------------- record =" + record); - _logger.debug("------------------ message =" + message); - - KafkaMessage receiverMessage = JsonUtils.gson2Object(message.toString(), KafkaMessage.class); - Groups group = JsonUtils.gson2Object(receiverMessage.getContent().toString(),Groups.class); - - if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.CREATE_ACTION)) { - groupConnector.create(group); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.UPDATE_ACTION)) { - groupConnector.update(group); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.DELETE_ACTION)) { - groupConnector.delete(group); - }else{ - _logger.info("Other Action "); - } - } - }catch(Exception e) { - - } - - } -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaOrgsTopicReceiver.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaOrgsTopicReceiver.java deleted file mode 100644 index 596fc082e..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaOrgsTopicReceiver.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.receiver; - -import java.util.Optional; - -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.identity.kafka.KafkaIdentityAction; -import org.maxkey.identity.kafka.KafkaIdentityTopic; -import org.maxkey.identity.kafka.KafkaMessage; -import org.maxkey.util.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.stereotype.Component; - -@Component -public class KafkaOrgsTopicReceiver { - private static final Logger _logger = LoggerFactory.getLogger(KafkaOrgsTopicReceiver.class); - - @Autowired - OrganizationConnector organizationConnector; - - @KafkaListener(topics = {KafkaIdentityTopic.ORG_TOPIC}) - public void listen(ConsumerRecord record) { - try { - Optional kafkaMessage = Optional.ofNullable(record.value()); - - if (kafkaMessage.isPresent()) { - - Object message = kafkaMessage.get(); - - _logger.debug("----------------- record =" + record); - _logger.debug("------------------ message =" + message); - - KafkaMessage receiverMessage = JsonUtils.gson2Object(message.toString(), KafkaMessage.class); - Organizations org = JsonUtils.gson2Object(receiverMessage.getContent().toString(),Organizations.class); - - if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.CREATE_ACTION)) { - organizationConnector.create(org); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.UPDATE_ACTION)) { - organizationConnector.update(org); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.DELETE_ACTION)) { - organizationConnector.delete(org); - }else{ - _logger.info("Other Action "); - } - } - }catch(Exception e) { - - } - - } -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaPasswordTopicReceiver.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaPasswordTopicReceiver.java deleted file mode 100644 index 0491044ef..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaPasswordTopicReceiver.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.receiver; - -import java.util.Optional; - -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.maxkey.connector.PasswordConnector; -import org.maxkey.domain.UserInfo; -import org.maxkey.identity.kafka.KafkaIdentityAction; -import org.maxkey.identity.kafka.KafkaIdentityTopic; -import org.maxkey.identity.kafka.KafkaMessage; -import org.maxkey.util.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.stereotype.Component; - -@Component -public class KafkaPasswordTopicReceiver { - private static final Logger _logger = LoggerFactory.getLogger(KafkaPasswordTopicReceiver.class); - - @Autowired - PasswordConnector passwordConnector; - - @KafkaListener(topics = {KafkaIdentityTopic.PASSWORD_TOPIC}) - public void listen(ConsumerRecord record) { - try { - Optional kafkaMessage = Optional.ofNullable(record.value()); - - if (kafkaMessage.isPresent()) { - - Object message = kafkaMessage.get(); - - _logger.debug("----------------- record =" + record); - _logger.debug("------------------ message =" + message); - - KafkaMessage receiverMessage = JsonUtils.gson2Object(message.toString(), KafkaMessage.class); - UserInfo userInfo = JsonUtils.gson2Object(receiverMessage.getContent().toString(),UserInfo.class); - - if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.PASSWORD_ACTION)) { - passwordConnector.update(userInfo); - }else{ - _logger.info("Other Action "); - } - } - }catch(Exception e) { - - } - } -} diff --git a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaUserInfoTopicReceiver.java b/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaUserInfoTopicReceiver.java deleted file mode 100644 index 733cd0d55..000000000 --- a/maxkey-connectors/maxkey-connector-base/src/main/java/org/maxkey/connector/receiver/KafkaUserInfoTopicReceiver.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.receiver; - -import java.util.Optional; - -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.domain.UserInfo; -import org.maxkey.identity.kafka.KafkaIdentityAction; -import org.maxkey.identity.kafka.KafkaIdentityTopic; -import org.maxkey.identity.kafka.KafkaMessage; -import org.maxkey.util.JsonUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.stereotype.Component; - -@Component -public class KafkaUserInfoTopicReceiver { - private static final Logger _logger = LoggerFactory.getLogger(KafkaUserInfoTopicReceiver.class); - - @Autowired - UserInfoConnector userInfoConnector; - - @KafkaListener(topics = {KafkaIdentityTopic.USERINFO_TOPIC}) - public void listen(ConsumerRecord record) { - try { - Optional kafkaMessage = Optional.ofNullable(record.value()); - - if (kafkaMessage.isPresent()) { - - Object message = kafkaMessage.get(); - - _logger.debug("----------------- record =" + record); - _logger.debug("------------------ message =" + message); - - KafkaMessage receiverMessage = JsonUtils.gson2Object(message.toString(), KafkaMessage.class); - UserInfo userInfo = JsonUtils.gson2Object(receiverMessage.getContent().toString(),UserInfo.class); - - if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.CREATE_ACTION)) { - userInfoConnector.create(userInfo); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.UPDATE_ACTION)) { - userInfoConnector.update(userInfo); - }else if(receiverMessage.getActionType().equalsIgnoreCase(KafkaIdentityAction.DELETE_ACTION)) { - userInfoConnector.delete(userInfo); - }else{ - _logger.info("Other Action "); - } - } - }catch(Exception e) { - - } - - } -} diff --git a/maxkey-connectors/maxkey-connector-dingding/.classpath b/maxkey-connectors/maxkey-connector-dingding/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-dingding/.project b/maxkey-connectors/maxkey-connector-dingding/.project deleted file mode 100644 index 18d33e7b1..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-dingding - Project maxkey-connector-dingding created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 538fc0077..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-dingding/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-dingding/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-dingding/build.gradle b/maxkey-connectors/maxkey-connector-dingding/build.gradle deleted file mode 100644 index ea3de9070..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-dingding" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/DingdingConsumerApplication.java b/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/DingdingConsumerApplication.java deleted file mode 100644 index ed8512c9c..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/DingdingConsumerApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.LdapUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.dingding" - }) -public class DingdingConsumerApplication { - - public static void main(String[] args) { - // TODO Auto-generated method stub - ConfigurableApplicationContext context = SpringApplication.run(DingdingConsumerApplication.class, args); - - } - - //@Bean(name = "ldapUtils") - public LdapUtils getLdapConnection( - @Value("${config.connector.ldap.providerUrl}") String providerUrl, - @Value("${config.connector.ldap.principal}") String principal, - @Value("${config.connector.ldap.credentials}") String credentials, - @Value("${config.connector.ldap.baseDN}") String baseDn - )throws Exception{ - - LdapUtils ldapUtils=new LdapUtils( - providerUrl, - principal, - credentials, - baseDn); - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - - - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(DingdingConsumerApplication.class); - } - -} diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Group2Dingding.java b/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Group2Dingding.java deleted file mode 100644 index e9406b2b2..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Group2Dingding.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.dingding; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Dingding extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Dingding.class); - - LdapUtils ldapUtils; - public Group2Dingding() { - - } - - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","groupOfUniqueNames")); - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("uniqueMember","uid=dummy")); - - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - create(group); - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Organization2Dingding.java b/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Organization2Dingding.java deleted file mode 100644 index c4308de0f..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Organization2Dingding.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.dingding; - -import javax.naming.NamingEnumeration; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Dingding extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Dingding.class); - - LdapUtils ldapUtils; - public Organization2Dingding() { - - } - - @Override - public boolean create(Organizations organization) throws Exception { - logger.info("create"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - logger.info("update"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("id",organization.getId())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgname",organization.getpName())); - //modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgid",organization.getpId())); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - logger.info("delete"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Password2Dingding.java b/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Password2Dingding.java deleted file mode 100644 index 4d1500efd..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/Password2Dingding.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.dingding; - -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component(value = "passwordConnector") -public class Password2Dingding extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Dingding.class); - - LdapUtils ldapUtils; - - public Password2Dingding() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - logger.info("changePassword"); - try { - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/UserInfo2Dingding.java b/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/UserInfo2Dingding.java deleted file mode 100644 index 1f0a68d33..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/java/org/maxkey/connector/dingding/UserInfo2Dingding.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.dingding; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -@Component(value = "userInfoConnector") -public class UserInfo2Dingding extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Dingding.class); - - LdapUtils ldapUtils; - - public UserInfo2Dingding() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","inetOrgPerson")); - attributes.put(new BasicAttribute("uid",userInfo.getUsername())); - attributes.put(new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - attributes.put(new BasicAttribute("manager",managerDn)); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=inetOrgPerson)(uid="+userInfo.getUsername()+"))", constraints); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - ModificationItem[] modificationItems = new ModificationItem[10]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - modificationItems[8]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - logger.info("delete"); - try { - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } -} diff --git a/maxkey-connectors/maxkey-connector-dingding/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-dingding/src/main/resources/application.properties deleted file mode 100644 index 063611c9a..000000000 --- a/maxkey-connectors/maxkey-connector-dingding/src/main/resources/application.properties +++ /dev/null @@ -1,47 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-LDAP -application.name=MaxKey-Connector-LDAP -application.formatted-version=v2.0.0 GA - -#server port -server.port=9601 - -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=LdapConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.ldap.providerUrl=ldap:// -config.connector.ldap.principal=maxkey -config.connector.ldap.credentials=maxkey -config.connector.ldap.baseDN=dc=maxkey,dc=top \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-feishu/.classpath b/maxkey-connectors/maxkey-connector-feishu/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-feishu/.project b/maxkey-connectors/maxkey-connector-feishu/.project deleted file mode 100644 index c6c026363..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-feishu - Project maxkey-connector-feishu created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 2fe9998c7..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-feishu/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-feishu/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-feishu/build.gradle b/maxkey-connectors/maxkey-connector-feishu/build.gradle deleted file mode 100644 index 280b117ab..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-feishu" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/FeishuConsumerApplication.java b/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/FeishuConsumerApplication.java deleted file mode 100644 index 3a761748e..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/FeishuConsumerApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.LdapUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.feishu" - }) -public class FeishuConsumerApplication { - - public static void main(String[] args) { - // TODO Auto-generated method stub - ConfigurableApplicationContext context = SpringApplication.run(FeishuConsumerApplication.class, args); - - } - - //@Bean(name = "ldapUtils") - public LdapUtils getLdapConnection( - @Value("${config.connector.ldap.providerUrl}") String providerUrl, - @Value("${config.connector.ldap.principal}") String principal, - @Value("${config.connector.ldap.credentials}") String credentials, - @Value("${config.connector.ldap.baseDN}") String baseDn - )throws Exception{ - - LdapUtils ldapUtils=new LdapUtils( - providerUrl, - principal, - credentials, - baseDn); - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - - - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(FeishuConsumerApplication.class); - } - -} diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Group2Feishu.java b/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Group2Feishu.java deleted file mode 100644 index 10dfadd87..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Group2Feishu.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.feishu; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Feishu extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Feishu.class); - - LdapUtils ldapUtils; - public Group2Feishu() { - - } - - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","groupOfUniqueNames")); - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("uniqueMember","uid=dummy")); - - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - create(group); - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Organization2Feishu.java b/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Organization2Feishu.java deleted file mode 100644 index dd3964dc1..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Organization2Feishu.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.feishu; - -import javax.naming.NamingEnumeration; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Feishu extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Feishu.class); - - LdapUtils ldapUtils; - public Organization2Feishu() { - - } - - @Override - public boolean create(Organizations organization) throws Exception { - logger.info("create"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - logger.info("update"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("id",organization.getId())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgname",organization.getpName())); - //modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgid",organization.getpId())); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - logger.info("delete"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Password2Feishu.java b/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Password2Feishu.java deleted file mode 100644 index f4e2455fc..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/Password2Feishu.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.feishu; - -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component(value = "passwordConnector") -public class Password2Feishu extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Feishu.class); - - LdapUtils ldapUtils; - - public Password2Feishu() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - logger.info("changePassword"); - try { - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/UserInfo2Feishu.java b/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/UserInfo2Feishu.java deleted file mode 100644 index e4aa3d660..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/java/org/maxkey/connector/feishu/UserInfo2Feishu.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.feishu; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -@Component(value = "userInfoConnector") -public class UserInfo2Feishu extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Feishu.class); - - LdapUtils ldapUtils; - - public UserInfo2Feishu() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","inetOrgPerson")); - attributes.put(new BasicAttribute("uid",userInfo.getUsername())); - attributes.put(new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - attributes.put(new BasicAttribute("manager",managerDn)); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=inetOrgPerson)(uid="+userInfo.getUsername()+"))", constraints); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - ModificationItem[] modificationItems = new ModificationItem[10]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - modificationItems[8]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - logger.info("delete"); - try { - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } -} diff --git a/maxkey-connectors/maxkey-connector-feishu/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-feishu/src/main/resources/application.properties deleted file mode 100644 index 063611c9a..000000000 --- a/maxkey-connectors/maxkey-connector-feishu/src/main/resources/application.properties +++ /dev/null @@ -1,47 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-LDAP -application.name=MaxKey-Connector-LDAP -application.formatted-version=v2.0.0 GA - -#server port -server.port=9601 - -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=LdapConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.ldap.providerUrl=ldap:// -config.connector.ldap.principal=maxkey -config.connector.ldap.credentials=maxkey -config.connector.ldap.baseDN=dc=maxkey,dc=top \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-ldap/.classpath b/maxkey-connectors/maxkey-connector-ldap/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-ldap/.project b/maxkey-connectors/maxkey-connector-ldap/.project deleted file mode 100644 index dadcf381a..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-ldap - Project maxkey-connectors-ldap created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.core.prefs b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8f838df8f..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=abort -org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=warning -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.mainOnlyProjectHasTestOnlyDependency=error -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.launching.prefs b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.launching.prefs deleted file mode 100644 index f8a131b56..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.jdt.launching.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.launching.PREF_COMPILER_COMPLIANCE_DOES_NOT_MATCH_JRE=warning -org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=warning diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 9169e826c..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-ldap/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-ldap/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-ldap/build.gradle b/maxkey-connectors/maxkey-connector-ldap/build.gradle deleted file mode 100644 index 9952b29b6..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-ldap" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/LdapConsumerApplication.java b/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/LdapConsumerApplication.java deleted file mode 100644 index 8aff5d437..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/LdapConsumerApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.LdapUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.ldap" - }) -public class LdapConsumerApplication { - - public static void main(String[] args) { - // TODO Auto-generated method stub - ConfigurableApplicationContext context = SpringApplication.run(LdapConsumerApplication.class, args); - - } - - //@Bean(name = "ldapUtils") - public LdapUtils getLdapConnection( - @Value("${config.connector.ldap.providerUrl}") String providerUrl, - @Value("${config.connector.ldap.principal}") String principal, - @Value("${config.connector.ldap.credentials}") String credentials, - @Value("${config.connector.ldap.baseDN}") String baseDn - )throws Exception{ - - LdapUtils ldapUtils=new LdapUtils( - providerUrl, - principal, - credentials, - baseDn); - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - - - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(LdapConsumerApplication.class); - } - -} diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Group2Ldap.java b/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Group2Ldap.java deleted file mode 100644 index c3c4663e0..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Group2Ldap.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.ldap; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Ldap extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Ldap.class); - - LdapUtils ldapUtils; - public Group2Ldap() { - - } - - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","groupOfUniqueNames")); - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("uniqueMember","uid=dummy")); - - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - create(group); - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Organization2Ldap.java b/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Organization2Ldap.java deleted file mode 100644 index 549a9d537..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Organization2Ldap.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.ldap; - -import javax.naming.NamingEnumeration; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Ldap extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Ldap.class); - - LdapUtils ldapUtils; - public Organization2Ldap() { - - } - - @Override - public boolean create(Organizations organization) throws Exception { - logger.info("create"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - logger.info("update"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("id",organization.getId())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgname",organization.getpName())); - //modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgid",organization.getpId())); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - logger.info("delete"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Password2Ldap.java b/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Password2Ldap.java deleted file mode 100644 index 213cb62d6..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/Password2Ldap.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.ldap; - -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component(value = "passwordConnector") -public class Password2Ldap extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Ldap.class); - - LdapUtils ldapUtils; - - public Password2Ldap() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - logger.info("changePassword"); - try { - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/UserInfo2Ldap.java b/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/UserInfo2Ldap.java deleted file mode 100644 index 755d679a2..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/java/org/maxkey/connector/ldap/UserInfo2Ldap.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.ldap; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -@Component(value = "userInfoConnector") -public class UserInfo2Ldap extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Ldap.class); - - LdapUtils ldapUtils; - - public UserInfo2Ldap() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","inetOrgPerson")); - attributes.put(new BasicAttribute("uid",userInfo.getUsername())); - attributes.put(new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - attributes.put(new BasicAttribute("manager",managerDn)); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=inetOrgPerson)(uid="+userInfo.getUsername()+"))", constraints); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - ModificationItem[] modificationItems = new ModificationItem[10]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - modificationItems[8]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - logger.info("delete"); - try { - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } -} diff --git a/maxkey-connectors/maxkey-connector-ldap/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-ldap/src/main/resources/application.properties deleted file mode 100644 index 063611c9a..000000000 --- a/maxkey-connectors/maxkey-connector-ldap/src/main/resources/application.properties +++ /dev/null @@ -1,47 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-LDAP -application.name=MaxKey-Connector-LDAP -application.formatted-version=v2.0.0 GA - -#server port -server.port=9601 - -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=LdapConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.ldap.providerUrl=ldap:// -config.connector.ldap.principal=maxkey -config.connector.ldap.credentials=maxkey -config.connector.ldap.baseDN=dc=maxkey,dc=top \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-welink/.classpath b/maxkey-connectors/maxkey-connector-welink/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-welink/.project b/maxkey-connectors/maxkey-connector-welink/.project deleted file mode 100644 index e9d44fba1..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-welink - Project maxkey-connector-welink created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.component deleted file mode 100644 index b1c083a0c..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-welink/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-welink/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-welink/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-welink/build.gradle b/maxkey-connectors/maxkey-connector-welink/build.gradle deleted file mode 100644 index 01a914bbf..000000000 --- a/maxkey-connectors/maxkey-connector-welink/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-welink" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/WelinkConsumerApplication.java b/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/WelinkConsumerApplication.java deleted file mode 100644 index 271aa69d1..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/WelinkConsumerApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.LdapUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.welink" - }) -public class WelinkConsumerApplication { - - public static void main(String[] args) { - // TODO Auto-generated method stub - ConfigurableApplicationContext context = SpringApplication.run(WelinkConsumerApplication.class, args); - - } - - //@Bean(name = "ldapUtils") - public LdapUtils getLdapConnection( - @Value("${config.connector.ldap.providerUrl}") String providerUrl, - @Value("${config.connector.ldap.principal}") String principal, - @Value("${config.connector.ldap.credentials}") String credentials, - @Value("${config.connector.ldap.baseDN}") String baseDn - )throws Exception{ - - LdapUtils ldapUtils=new LdapUtils( - providerUrl, - principal, - credentials, - baseDn); - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - - - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(WelinkConsumerApplication.class); - } - -} diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Group2Welink.java b/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Group2Welink.java deleted file mode 100644 index e4ea5c4d3..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Group2Welink.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.welink; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Welink extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Welink.class); - - LdapUtils ldapUtils; - public Group2Welink() { - - } - - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","groupOfUniqueNames")); - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("uniqueMember","uid=dummy")); - - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - create(group); - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Organization2Welink.java b/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Organization2Welink.java deleted file mode 100644 index 0e2faa2e5..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Organization2Welink.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.welink; - -import javax.naming.NamingEnumeration; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Welink extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Welink.class); - - LdapUtils ldapUtils; - public Organization2Welink() { - - } - - @Override - public boolean create(Organizations organization) throws Exception { - logger.info("create"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - logger.info("update"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("id",organization.getId())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgname",organization.getpName())); - //modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgid",organization.getpId())); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - logger.info("delete"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Password2Welink.java b/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Password2Welink.java deleted file mode 100644 index 56921ba4d..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/Password2Welink.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.welink; - -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component(value = "passwordConnector") -public class Password2Welink extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Welink.class); - - LdapUtils ldapUtils; - - public Password2Welink() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - logger.info("changePassword"); - try { - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/UserInfo2Welink.java b/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/UserInfo2Welink.java deleted file mode 100644 index fd7c45e18..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/java/org/maxkey/connector/welink/UserInfo2Welink.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.welink; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -@Component(value = "userInfoConnector") -public class UserInfo2Welink extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Welink.class); - - LdapUtils ldapUtils; - - public UserInfo2Welink() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","inetOrgPerson")); - attributes.put(new BasicAttribute("uid",userInfo.getUsername())); - attributes.put(new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - attributes.put(new BasicAttribute("manager",managerDn)); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=inetOrgPerson)(uid="+userInfo.getUsername()+"))", constraints); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - ModificationItem[] modificationItems = new ModificationItem[10]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - modificationItems[8]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - logger.info("delete"); - try { - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } -} diff --git a/maxkey-connectors/maxkey-connector-welink/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-welink/src/main/resources/application.properties deleted file mode 100644 index 063611c9a..000000000 --- a/maxkey-connectors/maxkey-connector-welink/src/main/resources/application.properties +++ /dev/null @@ -1,47 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-LDAP -application.name=MaxKey-Connector-LDAP -application.formatted-version=v2.0.0 GA - -#server port -server.port=9601 - -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=LdapConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.ldap.providerUrl=ldap:// -config.connector.ldap.principal=maxkey -config.connector.ldap.credentials=maxkey -config.connector.ldap.baseDN=dc=maxkey,dc=top \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-workweixin/.classpath b/maxkey-connectors/maxkey-connector-workweixin/.classpath deleted file mode 100644 index eca1d9e92..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/maxkey-connectors/maxkey-connector-workweixin/.project b/maxkey-connectors/maxkey-connector-workweixin/.project deleted file mode 100644 index ca57ab9ba..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.project +++ /dev/null @@ -1,41 +0,0 @@ - - - maxkey-connector-workweixin - Project maxkey-connector-workweixin created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.wst.common.project.facet.core.builder - - - - - org.eclipse.wst.validation.validationbuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.wst.common.project.facet.core.nature - org.eclipse.wst.common.modulecore.ModuleCoreNature - org.eclipse.jem.workbench.JavaEMFNature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.buildship.core.prefs b/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index 62e3e7e80..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir=../.. -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.core.resources.prefs b/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 896a9a53a..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.component b/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.component deleted file mode 100644 index 5a0ce0b47..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.component +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - uses - - - uses - - - uses - - - uses - - - uses - - - diff --git a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.project.facet.core.xml b/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 509bad92c..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.springframework.ide.eclipse.prefs b/maxkey-connectors/maxkey-connector-workweixin/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d68..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/maxkey-connectors/maxkey-connector-workweixin/build.gradle b/maxkey-connectors/maxkey-connector-workweixin/build.gradle deleted file mode 100644 index d2579edf5..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/build.gradle +++ /dev/null @@ -1,17 +0,0 @@ -description = "maxkey-connector-workweixin" - -apply plugin: 'java' -apply plugin: 'eclipse-wtp' - - -dependencies { - //local jars - compile fileTree(dir: '../maxkey-lib/*/', include: '*.jar') - - compile project(":maxkey-core") - compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") - compile project(":maxkey-connectors:maxkey-connector-base") - compile project(":maxkey-identitys:maxkey-identity-kafka") - -} \ No newline at end of file diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/WeixinConsumerApplication.java b/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/WeixinConsumerApplication.java deleted file mode 100644 index 021e045bf..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/WeixinConsumerApplication.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector; - -import org.maxkey.constants.ConstantsProperties; -import org.maxkey.persistence.ldap.LdapUtils; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; - -@Configuration -@PropertySource(ConstantsProperties.applicationPropertySource) -@SpringBootApplication -@ComponentScan(basePackages = { - "org.maxkey.connector", - "org.maxkey.connector.receiver", - "org.maxkey.connector.workweixin" - }) -public class WeixinConsumerApplication { - - public static void main(String[] args) { - // TODO Auto-generated method stub - ConfigurableApplicationContext context = SpringApplication.run(WeixinConsumerApplication.class, args); - - } - - //@Bean(name = "ldapUtils") - public LdapUtils getLdapConnection( - @Value("${config.connector.ldap.providerUrl}") String providerUrl, - @Value("${config.connector.ldap.principal}") String principal, - @Value("${config.connector.ldap.credentials}") String credentials, - @Value("${config.connector.ldap.baseDN}") String baseDn - )throws Exception{ - - LdapUtils ldapUtils=new LdapUtils( - providerUrl, - principal, - credentials, - baseDn); - if(ldapUtils.openConnection()==null){ - throw new Exception("connection to Ldap Error."); - } - return ldapUtils; - } - - - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(WeixinConsumerApplication.class); - } - -} diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Group2Weixin.java b/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Group2Weixin.java deleted file mode 100644 index 9a50cc99d..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Group2Weixin.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.workweixin; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.GroupConnector; -import org.maxkey.domain.GroupMember; -import org.maxkey.domain.Groups; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "groupConnector") -public class Group2Weixin extends GroupConnector { - private final static Logger logger = LoggerFactory.getLogger(Group2Weixin.class); - - LdapUtils ldapUtils; - public Group2Weixin() { - - } - - @Override - public boolean create(Groups group) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","groupOfUniqueNames")); - attributes.put(new BasicAttribute("cn",group.getName())); - attributes.put(new BasicAttribute("uniqueMember","uid=dummy")); - - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(Groups group) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+group.getName()+")", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(group); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(","), oldDn.length()); - - String groupName=dnSplit[0].split("=")[1]; - if(group.getName()!=groupName){ - String newDn="cn="+group.getName()+","+rdn; - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("cn",groupName)); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean delete(Groups group) throws Exception { - logger.info("delete"); - try { - String dn="cn="+group.getName()+",dc=groups,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean addMember(GroupMember groupMember) throws Exception { - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - Groups group =new Groups(); - group.setName(groupMember.getGroupName()); - create(group); - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.ADD_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean deleteMember(GroupMember groupMember) throws Exception{ - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(cn="+groupMember.getGroupName()+")", constraints); - if (results == null || !results.hasMore()) { - return true; - } - - String uniqueMember="uid="+groupMember.getMemberName()+",dc=users,"+ldapUtils.getBaseDN(); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("uniqueMember",uniqueMember)); - - String dn="cn="+groupMember.getGroupName()+",dc=groups,"+ldapUtils.getBaseDN(); - logger.debug("dn : "+dn); - logger.debug("uniqueMember : "+uniqueMember); - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - - -} diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Organization2Weixin.java b/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Organization2Weixin.java deleted file mode 100644 index 4e29e8d58..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Organization2Weixin.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.workweixin; - -import javax.naming.NamingEnumeration; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.OrganizationConnector; -import org.maxkey.domain.Organizations; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -@Component(value = "organizationConnector") -public class Organization2Weixin extends OrganizationConnector{ - private final static Logger logger = LoggerFactory.getLogger(Organization2Weixin.class); - - LdapUtils ldapUtils; - public Organization2Weixin() { - - } - - @Override - public boolean create(Organizations organization) throws Exception { - logger.info("create"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getParentId()+"))", constraints); - String rdn=""; - if (results == null || !results.hasMore()) { - rdn=ldapUtils.getBaseDN(); - }else{ - SearchResult sr = (SearchResult) results.next(); - rdn =sr.getNameInNamespace(); - } - - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","organizationalUnit")); - attributes.put(new BasicAttribute("ou",organization.getName())); - //attributes.put(new BasicAttribute("name",organization.getName())); - //attributes.put(new BasicAttribute("id",organization.getId())); - //attributes.put(new BasicAttribute("porgname",organization.getpName())); - //attributes.put(new BasicAttribute("porgid",organization.getpId())); - attributes.put(new BasicAttribute("description",organization.getId())); - - String dn="ou="+organization.getName()+","+rdn; - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - - return super.create(organization); - } - - @Override - public boolean update(Organizations organization) throws Exception{ - logger.info("update"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String oldDn=""; - String rdn=""; - if (results == null || !results.hasMore()) { - return create(organization); - }else{ - SearchResult sr = (SearchResult) results.next(); - oldDn =sr.getNameInNamespace(); - String[] dnSplit=oldDn.split(","); - rdn=oldDn.substring(oldDn.indexOf(",")+1, oldDn.length()); - - String ouName=dnSplit[0].split("=")[1]; - if(organization.getName()!=ouName){ - String newDn="ou="+organization.getName()+","+rdn; - logger.debug("oldDn : "+oldDn); - logger.debug("newDn : "+newDn); - ldapUtils.getCtx().rename(oldDn, newDn); - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REMOVE_ATTRIBUTE,new BasicAttribute("ou",ouName)); - //modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("name",organization.getName())); - //modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("id",organization.getId())); - //modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgname",organization.getpName())); - //modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("porgid",organization.getpId())); - ldapUtils.getCtx().modifyAttributes(newDn, modificationItems); - } - } - - ldapUtils.close(); - - return super.update(organization); - } - - @Override - public boolean delete(Organizations organization) throws Exception{ - logger.info("delete"); - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=organizationalUnit)(description="+organization.getId()+"))", constraints); - String dn=""; - if (results == null || !results.hasMore()) { - - }else{ - SearchResult sr = (SearchResult) results.next(); - dn =sr.getNameInNamespace(); - ldapUtils.getCtx().destroySubcontext(dn); - } - - ldapUtils.close(); - - return super.delete(organization); - } - -} diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Password2Weixin.java b/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Password2Weixin.java deleted file mode 100644 index da633b329..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/Password2Weixin.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.workweixin; - -import javax.naming.NamingException; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; - -import org.maxkey.connector.PasswordConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - - -@Component(value = "passwordConnector") -public class Password2Weixin extends PasswordConnector{ - private final static Logger logger = LoggerFactory.getLogger(Password2Weixin.class); - - LdapUtils ldapUtils; - - public Password2Weixin() { - - } - - @Override - public boolean sync(UserInfo userInfo) throws Exception{ - logger.info("changePassword"); - try { - ModificationItem[] modificationItems = new ModificationItem[1]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - -} diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/UserInfo2Weixin.java b/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/UserInfo2Weixin.java deleted file mode 100644 index a83c2e891..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/java/org/maxkey/connector/workweixin/UserInfo2Weixin.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright [2020] [MaxKey of copyright http://www.maxkey.top] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.maxkey.connector.workweixin; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attributes; -import javax.naming.directory.BasicAttribute; -import javax.naming.directory.BasicAttributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.ModificationItem; -import javax.naming.directory.SearchControls; -import javax.naming.directory.SearchResult; - -import org.maxkey.connector.UserInfoConnector; -import org.maxkey.crypto.ReciprocalUtils; -import org.maxkey.domain.UserInfo; -import org.maxkey.persistence.ldap.LdapUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; -@Component(value = "userInfoConnector") -public class UserInfo2Weixin extends UserInfoConnector{ - private final static Logger logger = LoggerFactory.getLogger(UserInfo2Weixin.class); - - LdapUtils ldapUtils; - - public UserInfo2Weixin() { - - } - - @Override - public boolean create(UserInfo userInfo) throws Exception{ - logger.info("create"); - try { - Attributes attributes = new BasicAttributes(); - attributes.put(new BasicAttribute("objectClass","inetOrgPerson")); - attributes.put(new BasicAttribute("uid",userInfo.getUsername())); - attributes.put(new BasicAttribute("userPassword",ReciprocalUtils.decoder(userInfo.getDecipherable()))); - attributes.put(new BasicAttribute("displayName",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("cn",userInfo.getDisplayName())); - attributes.put(new BasicAttribute("givenName",userInfo.getGivenName())); - attributes.put(new BasicAttribute("sn",userInfo.getFamilyName())); - - attributes.put(new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - attributes.put(new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - attributes.put(new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - attributes.put(new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - attributes.put(new BasicAttribute("manager",managerDn)); - attributes.put(new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - attributes.put(new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().createSubcontext(dn, attributes); - ldapUtils.close(); - super.create(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - @Override - public boolean update(UserInfo userInfo) throws Exception{ - logger.info("update"); - try { - SearchControls constraints = new SearchControls(); - constraints.setSearchScope(ldapUtils.getSearchScope()); - NamingEnumeration results = ldapUtils.getConnection() - .search(ldapUtils.getBaseDN(), "(&(objectClass=inetOrgPerson)(uid="+userInfo.getUsername()+"))", constraints); - if (results == null || !results.hasMore()) { - return create(loadUser(userInfo)); - } - - ModificationItem[] modificationItems = new ModificationItem[10]; - modificationItems[0]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("displayName",userInfo.getDisplayName())); - modificationItems[1]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("cn",userInfo.getDisplayName())); - modificationItems[2]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("givenName",userInfo.getGivenName())); - modificationItems[3]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("sn",userInfo.getFamilyName())); - - modificationItems[4]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mobile",userInfo.getWorkPhoneNumber()==null?"":userInfo.getWorkPhoneNumber())); - modificationItems[5]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("mail",userInfo.getWorkEmail()==null?"":userInfo.getWorkEmail())); - - modificationItems[6]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("employeeNumber",userInfo.getEmployeeNumber()==null?"":userInfo.getEmployeeNumber())); - modificationItems[7]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("ou",userInfo.getDepartment()==null?"":userInfo.getDepartment())); - modificationItems[8]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("departmentNumber",userInfo.getDepartmentId()==null?"":userInfo.getDepartmentId())); - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("title",userInfo.getJobTitle()==null?"":userInfo.getJobTitle())); - - String managerDn="uid=dummy"; - if(userInfo.getManagerId()==null||userInfo.getManagerId().equals("")){ - - }else{ - UserInfo queryManager=new UserInfo(); - queryManager.setId(userInfo.getManagerId()); - UserInfo manager=loadUser(queryManager); - managerDn="uid="+manager.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - } - modificationItems[9]=new ModificationItem(DirContext.REPLACE_ATTRIBUTE,new BasicAttribute("manager",managerDn)); - - - - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - - ldapUtils.getCtx().modifyAttributes(dn, modificationItems); - ldapUtils.close(); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - - } - - @Override - public boolean delete(UserInfo userInfo) throws Exception{ - logger.info("delete"); - try { - String dn="uid="+userInfo.getUsername()+",dc=users,"+ldapUtils.getBaseDN(); - ldapUtils.getCtx().destroySubcontext(dn); - ldapUtils.close(); - super.delete(userInfo); - } catch (NamingException e) { - e.printStackTrace(); - } - return true; - } - - public UserInfo loadUser(UserInfo UserInfo) { - return null; - } -} diff --git a/maxkey-connectors/maxkey-connector-workweixin/src/main/resources/application.properties b/maxkey-connectors/maxkey-connector-workweixin/src/main/resources/application.properties deleted file mode 100644 index 063611c9a..000000000 --- a/maxkey-connectors/maxkey-connector-workweixin/src/main/resources/application.properties +++ /dev/null @@ -1,47 +0,0 @@ -#spring.profiles.active=dev -#application -application.title=MaxKey-Connector-LDAP -application.name=MaxKey-Connector-LDAP -application.formatted-version=v2.0.0 GA - -#server port -server.port=9601 - -#datasource -spring.datasource.username=root -spring.datasource.password=maxkey -spring.datasource.url=jdbc:mysql://localhost/maxkey?autoReconnect=true&characterEncoding=UTF-8 -spring.datasource.driver-class-name=com.mysql.jdbc.Driver -spring.datasource.type=com.alibaba.druid.pool.DruidDataSource - -spring.kafka.bootstrap-servers=localhost:9092 -###########【初始化消费者配置】########### -# 默认的消费组ID -spring.kafka.consumer.properties.group.id=LdapConsumerGroup -# 是否自动提交offset -spring.kafka.consumer.enable-auto-commit=true -# 提交offset延时(接收到消息后多久提交offset) -spring.kafka.consumer.auto.commit.interval.ms=1000 -# 当kafka中没有初始offset或offset超出范围时将自动重置offset -# earliest:重置为分区中最小的offset; -# latest:重置为分区中最新的offset(消费分区中新产生的数据); -# none:只要有一个分区不存在已提交的offset,就抛出异常; -spring.kafka.consumer.auto-offset-reset=latest -# 消费会话超时时间(超过这个时间consumer没有发送心跳,就会触发rebalance操作) -spring.kafka.consumer.properties.session.timeout.ms=120000 -# 消费请求超时时间 -spring.kafka.consumer.properties.request.timeout.ms=180000 -# Kafka提供的序列化和反序列化类 -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer -# 消费端监听的topic不存在时,项目启动会报错(关掉) -spring.kafka.listener.missing-topics-fatal=false -# 设置批量消费 -# spring.kafka.listener.type=batch -# 批量消费每次最多消费多少条消息 -# spring.kafka.consumer.max-poll-records=50 - -config.connector.ldap.providerUrl=ldap:// -config.connector.ldap.principal=maxkey -config.connector.ldap.credentials=maxkey -config.connector.ldap.baseDN=dc=maxkey,dc=top \ No newline at end of file diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpEncoder.java b/maxkey-core/src/main/java/org/maxkey/util/HttpEncoder.java similarity index 82% rename from maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpEncoder.java rename to maxkey-core/src/main/java/org/maxkey/util/HttpEncoder.java index 31bc34fde..d72ae7dfe 100644 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpEncoder.java +++ b/maxkey-core/src/main/java/org/maxkey/util/HttpEncoder.java @@ -15,15 +15,13 @@ */ -package org.maxkey.client.utils; +package org.maxkey.util; import java.io.*; import java.net.*; import java.util.*; import java.util.regex.*; -import org.maxkey.client.oauth.exceptions.*; - public abstract class HttpEncoder { private static final String CHARSET = "UTF-8"; @@ -37,13 +35,12 @@ public abstract class HttpEncoder { ENCODING_RULES = Collections.unmodifiableMap(rules); } - public static String encode(String plain) { - Preconditions.checkNotNull(plain, "Cannot encode null object"); + public static String encode(String plain) throws Exception { String encoded; try { encoded = URLEncoder.encode(plain, CHARSET); } catch (UnsupportedEncodingException uee) { - throw new OAuthException("Charset not found while encoding string: " + CHARSET, uee); + throw new Exception("Charset not found while encoding string: " + CHARSET, uee); } for (Map.Entry rule : ENCODING_RULES.entrySet()) { encoded = applyRule(encoded, rule.getKey(), rule.getValue()); @@ -56,8 +53,6 @@ public abstract class HttpEncoder { } public static String decode(String encoded) throws UnsupportedEncodingException { - Preconditions.checkNotNull(encoded, "Cannot decode null object"); - return URLDecoder.decode(encoded, CHARSET); } diff --git a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpsTrusts.java b/maxkey-core/src/main/java/org/maxkey/util/HttpsTrusts.java similarity index 98% rename from maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpsTrusts.java rename to maxkey-core/src/main/java/org/maxkey/util/HttpsTrusts.java index 5065112c8..c6601baf4 100644 --- a/maxkey-client-sdk/src/main/java/org/maxkey/client/utils/HttpsTrusts.java +++ b/maxkey-core/src/main/java/org/maxkey/util/HttpsTrusts.java @@ -15,7 +15,7 @@ */ -package org.maxkey.client.utils; +package org.maxkey.util; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; diff --git a/maxkey-identitys/maxkey-identity-rest/.settings/org.eclipse.wst.common.component b/maxkey-identitys/maxkey-identity-rest/.settings/org.eclipse.wst.common.component index ece70642c..8d35ad2cc 100644 --- a/maxkey-identitys/maxkey-identity-rest/.settings/org.eclipse.wst.common.component +++ b/maxkey-identitys/maxkey-identity-rest/.settings/org.eclipse.wst.common.component @@ -9,8 +9,5 @@ uses - - uses - diff --git a/maxkey-identitys/maxkey-identity-rest/build.gradle b/maxkey-identitys/maxkey-identity-rest/build.gradle index f3b5076a7..af68ea8de 100644 --- a/maxkey-identitys/maxkey-identity-rest/build.gradle +++ b/maxkey-identitys/maxkey-identity-rest/build.gradle @@ -10,6 +10,5 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") } \ No newline at end of file diff --git a/maxkey-identitys/maxkey-identity-scim/.settings/org.eclipse.wst.common.component b/maxkey-identitys/maxkey-identity-scim/.settings/org.eclipse.wst.common.component index ee55793d0..12fb4919b 100644 --- a/maxkey-identitys/maxkey-identity-scim/.settings/org.eclipse.wst.common.component +++ b/maxkey-identitys/maxkey-identity-scim/.settings/org.eclipse.wst.common.component @@ -9,8 +9,5 @@ uses - - uses - diff --git a/maxkey-identitys/maxkey-identity-scim/build.gradle b/maxkey-identitys/maxkey-identity-scim/build.gradle index da59b114b..04f2e2063 100644 --- a/maxkey-identitys/maxkey-identity-scim/build.gradle +++ b/maxkey-identitys/maxkey-identity-scim/build.gradle @@ -10,6 +10,5 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") } \ No newline at end of file diff --git a/maxkey-lib/maxkey-client-sdk-2.0.0.RELEASE.jar b/maxkey-lib/maxkey-client-sdk-2.0.0.RELEASE.jar new file mode 100644 index 000000000..38aff5100 Binary files /dev/null and b/maxkey-lib/maxkey-client-sdk-2.0.0.RELEASE.jar differ diff --git a/maxkey-protocols/maxkey-protocol-authorize/build.gradle b/maxkey-protocols/maxkey-protocol-authorize/build.gradle index d2eb4b31c..92420f147 100644 --- a/maxkey-protocols/maxkey-protocol-authorize/build.gradle +++ b/maxkey-protocols/maxkey-protocol-authorize/build.gradle @@ -8,7 +8,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") //compileOnly project(":maxkey-protocols:maxkey-protocol-oauth-2.0") //compileOnly project(":maxkey-protocols:maxkey-protocol-saml-2.0") diff --git a/maxkey-protocols/maxkey-protocol-cas/build.gradle b/maxkey-protocols/maxkey-protocol-cas/build.gradle index 3c0cd1414..b5c921424 100644 --- a/maxkey-protocols/maxkey-protocol-cas/build.gradle +++ b/maxkey-protocols/maxkey-protocol-cas/build.gradle @@ -8,7 +8,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-desktop/build.gradle b/maxkey-protocols/maxkey-protocol-desktop/build.gradle index 5f5825404..2439c271b 100644 --- a/maxkey-protocols/maxkey-protocol-desktop/build.gradle +++ b/maxkey-protocols/maxkey-protocol-desktop/build.gradle @@ -8,7 +8,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-extendapi/build.gradle b/maxkey-protocols/maxkey-protocol-extendapi/build.gradle index 010137a82..7e53d8f15 100644 --- a/maxkey-protocols/maxkey-protocol-extendapi/build.gradle +++ b/maxkey-protocols/maxkey-protocol-extendapi/build.gradle @@ -8,6 +8,5 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-extendapi/src/main/java/org/maxkey/authz/exapi/endpoint/adapter/ExtendApiQQExmailDefaultAdapter.java b/maxkey-protocols/maxkey-protocol-extendapi/src/main/java/org/maxkey/authz/exapi/endpoint/adapter/ExtendApiQQExmailDefaultAdapter.java index 373ecb406..b791f7caa 100644 --- a/maxkey-protocols/maxkey-protocol-extendapi/src/main/java/org/maxkey/authz/exapi/endpoint/adapter/ExtendApiQQExmailDefaultAdapter.java +++ b/maxkey-protocols/maxkey-protocol-extendapi/src/main/java/org/maxkey/authz/exapi/endpoint/adapter/ExtendApiQQExmailDefaultAdapter.java @@ -22,7 +22,7 @@ import java.util.HashMap; import org.maxkey.authz.endpoint.adapter.AbstractAuthorizeAdapter; import org.maxkey.client.oauth.OAuthClient; import org.maxkey.client.oauth.model.Token; -import org.maxkey.client.utils.JsonUtils; +import org.maxkey.util.JsonUtils; import org.maxkey.domain.ExtraAttrs; import org.maxkey.domain.UserInfo; import org.maxkey.domain.apps.Apps; diff --git a/maxkey-protocols/maxkey-protocol-formbased/build.gradle b/maxkey-protocols/maxkey-protocol-formbased/build.gradle index 1a469405f..9071ff4ee 100644 --- a/maxkey-protocols/maxkey-protocol-formbased/build.gradle +++ b/maxkey-protocols/maxkey-protocol-formbased/build.gradle @@ -8,7 +8,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle b/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle index 977c90e8f..66fd5d008 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/build.gradle @@ -6,7 +6,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java index bf3771130..2ddb8be20 100644 --- a/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java +++ b/maxkey-protocols/maxkey-protocol-oauth-2.0/src/main/java/org/maxkey/authz/oauth2/provider/endpoint/AuthorizationEndpoint.java @@ -24,7 +24,6 @@ import java.util.Set; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.maxkey.authz.endpoint.AuthorizeBaseEndpoint; import org.maxkey.authz.oauth2.common.OAuth2AccessToken; import org.maxkey.authz.oauth2.common.exceptions.InvalidClientException; import org.maxkey.authz.oauth2.common.exceptions.InvalidRequestException; @@ -42,10 +41,9 @@ import org.maxkey.authz.oauth2.provider.TokenRequest; import org.maxkey.authz.oauth2.provider.approval.DefaultUserApprovalHandler; import org.maxkey.authz.oauth2.provider.approval.UserApprovalHandler; import org.maxkey.authz.oauth2.provider.code.AuthorizationCodeServices; -import org.maxkey.authz.oauth2.provider.code.InMemoryAuthorizationCodeServices; import org.maxkey.authz.oauth2.provider.implicit.ImplicitTokenRequest; import org.maxkey.authz.oauth2.provider.request.DefaultOAuth2RequestValidator; -import org.maxkey.client.utils.HttpEncoder; +import org.maxkey.util.HttpEncoder; import org.maxkey.configuration.ApplicationConfig; import org.maxkey.domain.apps.oauth2.provider.ClientDetails; import org.maxkey.web.WebContext; @@ -516,11 +514,17 @@ public class AuthorizationEndpoint extends AbstractEndpoint { @PathVariable("id") String id){ ClientDetails clientDetails =clientDetailsService.loadClientByClientId(id); _logger.debug(""+clientDetails); - String authorizationUrl = String.format(OAUTH_V20_AUTHORIZATION_URL, - applicationConfig.getServerPrefix(), - clientDetails.getClientId(), - HttpEncoder.encode(clientDetails.getRegisteredRedirectUri().toArray()[0].toString()) - ); + String authorizationUrl = ""; + try { + authorizationUrl = String.format(OAUTH_V20_AUTHORIZATION_URL, + applicationConfig.getServerPrefix(), + clientDetails.getClientId(), + HttpEncoder.encode(clientDetails.getRegisteredRedirectUri().toArray()[0].toString()) + ); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } _logger.debug("authorizationUrl "+authorizationUrl); diff --git a/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle b/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle index 67a5de083..fb1324922 100644 --- a/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle +++ b/maxkey-protocols/maxkey-protocol-tokenbased/build.gradle @@ -8,7 +8,6 @@ dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-authorize") } \ No newline at end of file diff --git a/maxkey-web-manage/.project b/maxkey-web-manage/.project index cd20de139..0167961c5 100644 --- a/maxkey-web-manage/.project +++ b/maxkey-web-manage/.project @@ -6,7 +6,6 @@ maxkey-protocol-authorize maxkey-jose-jwt maxkey-core - maxkey-client-sdk maxkey-protocol-oauth-2.0 maxkey-protocol-saml-2.0 maxkey-identity-scim diff --git a/maxkey-web-manage/build.gradle b/maxkey-web-manage/build.gradle index b3bcd0adf..2c4995fc8 100644 --- a/maxkey-web-manage/build.gradle +++ b/maxkey-web-manage/build.gradle @@ -19,7 +19,6 @@ buildscript { dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-protocols:maxkey-protocol-oauth-2.0") compile project(":maxkey-protocols:maxkey-protocol-saml-2.0") compile project(":maxkey-identitys:maxkey-identity-scim") diff --git a/maxkey-web-maxkey/.project b/maxkey-web-maxkey/.project index 57b762ddf..59895fa49 100644 --- a/maxkey-web-maxkey/.project +++ b/maxkey-web-maxkey/.project @@ -8,7 +8,6 @@ maxkey-protocol-oauth-2.0 maxkey-protocol-saml-2.0 maxkey-core - maxkey-client-sdk maxkey-authentications maxkey-protocol-authorize maxkey-protocol-cas diff --git a/maxkey-web-maxkey/build.gradle b/maxkey-web-maxkey/build.gradle index 504a6b0ff..c07b84378 100644 --- a/maxkey-web-maxkey/build.gradle +++ b/maxkey-web-maxkey/build.gradle @@ -18,7 +18,6 @@ buildscript { dependencies { compile project(":maxkey-core") compile project(":maxkey-persistence") - compile project(":maxkey-client-sdk") compile project(":maxkey-authentications") diff --git a/settings.gradle b/settings.gradle index abe455627..8e205441e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,7 +4,6 @@ rootProject.name = 'MaxKey' //Common -include 'maxkey-client-sdk' include 'maxkey-core' include 'maxkey-persistence' include 'maxkey-authentications' @@ -14,22 +13,6 @@ include 'maxkey-identitys:maxkey-identity-scim' include 'maxkey-identitys:maxkey-identity-kafka' include 'maxkey-identitys:maxkey-identity-rest' - -//connectors -include 'maxkey-connectors:maxkey-connector-base' -//MS Active Directory -include 'maxkey-connectors:maxkey-connector-activedirectory' -//OpenLDAP -include 'maxkey-connectors:maxkey-connector-ldap' -//企业微信 -include 'maxkey-connectors:maxkey-connector-workweixin' -//阿里钉钉 -include 'maxkey-connectors:maxkey-connector-dingding' -//字节跳动飞书 -include 'maxkey-connectors:maxkey-connector-feishu' -//华为WeLink -include 'maxkey-connectors:maxkey-connector-welink' - //Protocol //include 'maxkey-protocols' include 'maxkey-protocols:maxkey-protocol-oauth-2.0'