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'