forked from jyqq163/keycloak-services-social-weixin
-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
858bc1e
commit b409e3d
Showing
8 changed files
with
789 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.keycloak.social.weixin; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
public class Util { | ||
public static String inspect(String varName, Object thing) { | ||
StringBuilder sb = new StringBuilder(); | ||
|
||
sb.append(varName).append(" >>>").append("\n"); | ||
for (Field field : thing.getClass().getDeclaredFields()) { | ||
field.setAccessible(true); | ||
String name = field.getName(); | ||
Object value = null; | ||
try { | ||
value = field.get(thing); | ||
} catch (IllegalAccessException e) { | ||
e.printStackTrace(); | ||
} | ||
sb.append("\t").append(name).append(": ").append(value).append("\n"); | ||
} | ||
sb.append(varName).append(" <<<").append("\n"); | ||
|
||
return sb.toString(); | ||
} | ||
} |
688 changes: 688 additions & 0 deletions
688
src/main/java/org/keycloak/social/weixin/WeiXinIdentityBrokerService.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.keycloak.social.weixin; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.keycloak.broker.provider.BrokeredIdentityContext; | ||
|
||
public class UtilTest { | ||
@Test | ||
public void inspectBrokeredIdentityContext() { | ||
BrokeredIdentityContext context = new BrokeredIdentityContext("1234"); | ||
|
||
String inspected = Util.inspect("context", context); | ||
|
||
Assert.assertEquals("context >>>\n" + | ||
"\tid: 1234\n" + | ||
"\tusername: null\n" + | ||
"\tmodelUsername: null\n" + | ||
"\temail: null\n" + | ||
"\tfirstName: null\n" + | ||
"\tlastName: null\n" + | ||
"\tbrokerSessionId: null\n" + | ||
"\tbrokerUserId: null\n" + | ||
"\tcode: null\n" + | ||
"\ttoken: null\n" + | ||
"\tidpConfig: null\n" + | ||
"\tidp: null\n" + | ||
"\tcontextData: {}\n" + | ||
"\tauthenticationSession: null\n" + | ||
"context <<<\n", inspected); | ||
} | ||
} |