File tree 7 files changed +53
-15
lines changed
src/main/java/com/tersesystems/debugjsse
7 files changed +53
-15
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ Debug sysErrDebug = new PrintStreamDebug(System.err);
56
56
provider. setDebug(sysErrDebug);
57
57
```
58
58
59
+ or use java.util.logging:
60
+
61
+ ``` java
62
+ provider. setDebug(new LoggingDebug (DEBUG , debugLogger));
63
+ ```
64
+
59
65
And you can add your own logging framework by extending ` AbstractDebug ` :
60
66
61
67
``` java
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ plugins {
10
10
`java- library`
11
11
`maven- publish` // https://docs.gradle.org/current/userguide/publishing_maven.html
12
12
signing
13
+ id(" com.diffplug.spotless" ) version " 7.0.0.BETA4"
13
14
}
14
15
15
16
repositories {
Original file line number Diff line number Diff line change 9
9
import java .util .*;
10
10
import java .util .concurrent .atomic .AtomicInteger ;
11
11
12
+ /**
13
+ * This is an abstract class that provides helpful defaults for most of the Debug interface.
14
+ *
15
+ * There's three methods you have to implement, but the key/trust manager is taken care of for you.
16
+ */
12
17
public abstract class AbstractDebug implements Debug {
13
18
14
19
public abstract void enter (String message );
Original file line number Diff line number Diff line change 1
1
package com .tersesystems .debugjsse ;
2
2
3
- import javax .net .ssl .KeyManagerFactory ;
4
- import javax .net .ssl .SSLContext ;
5
- import javax .net .ssl .SSLContextSpi ;
6
- import javax .net .ssl .TrustManagerFactory ;
7
-
8
3
import java .security .NoSuchAlgorithmException ;
9
4
import java .security .NoSuchProviderException ;
10
5
import java .security .Provider ;
11
6
import java .security .Security ;
12
7
import java .util .Arrays ;
13
8
import java .util .Collections ;
14
- import java .util .Set ;
15
9
16
10
public class DebugJSSEProvider extends Provider {
17
11
18
- private static String defaultKeyManagerAlgorithm ;
19
- private static String defaultTrustManagerAlgorithm ;
20
-
21
12
public final static String NAME = "debugJSSE" ;
22
13
public final static Double VERSION = 1.0 ;
23
14
public final static String INFO = "Debug JSSE" ;
24
15
25
- private static final String SSL_KEY_MANAGER_FACTORY_SECPROP = "ssl.KeyManagerFactory.algorithm" ;
26
- private static final String SSL_TRUST_MANAGER_FACTORY_SECPROP = "ssl.TrustManagerFactory.algorithm" ;
27
- private static final String KEY_MANAGER_FACTORY = "KeyManagerFactory" ;
28
- private static final String TRUST_MANAGER_FACTORY = "TrustManagerFactory" ;
16
+ private static final String KEY_MANAGER_FACTORY = "KeyManagerFactory" ;
17
+ private static final String TRUST_MANAGER_FACTORY = "TrustManagerFactory" ;
29
18
30
19
private static boolean enabled = false ;
31
20
Original file line number Diff line number Diff line change
1
+ package com .tersesystems .debugjsse ;
2
+
3
+ import java .util .logging .Level ;
4
+ import java .util .logging .Logger ;
5
+
6
+ /**
7
+ * This is a class that logs to the given logger at the given log level.
8
+ */
9
+ public class LoggingDebug extends AbstractDebug {
10
+
11
+ private final Logger logger ;
12
+ private final Level level ;
13
+
14
+ public LoggingDebug (Level level , Logger logger ) {
15
+ this .level = level ;
16
+ this .logger = logger ;
17
+ }
18
+
19
+ @ Override
20
+ public void enter (String message ) {
21
+ logger .log (level , message );
22
+ }
23
+
24
+ @ Override
25
+ public void exit (String message ) {
26
+ logger .log (level , message );
27
+ }
28
+
29
+ @ Override
30
+ public void exception (String message , Exception e ) {
31
+ logger .log (level , message );
32
+ }
33
+ }
Original file line number Diff line number Diff line change 1
1
package com .tersesystems .debugjsse ;
2
2
3
- import javax .net .ssl .KeyManagerFactory ;
4
- import javax .net .ssl .TrustManagerFactory ;
5
3
import java .io .PrintStream ;
6
4
5
+ /**
6
+ * This is a class that prints to a PrintStream on debug output.
7
+ */
7
8
public class PrintStreamDebug extends AbstractDebug {
8
9
9
10
private final PrintStream stream ;
Original file line number Diff line number Diff line change 1
1
package com .tersesystems .debugjsse ;
2
2
3
+ /**
4
+ * This class writes to System.out for debugging output.
5
+ */
3
6
public class SystemOutDebug extends PrintStreamDebug {
4
7
public SystemOutDebug () {
5
8
super (System .out );
You can’t perform that action at this time.
0 commit comments