Skip to content

Commit 4392d37

Browse files
authored
Merge pull request #7 from SafinWasi/agama-lab-branch
feat: switch to jansAuthenticator
2 parents 081eb38 + dd149f3 commit 4392d37

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/org/gluu/agama/typekey/IdentityProcessor.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import io.jans.orm.exception.operation.EntryNotFoundException;
77
import io.jans.service.cdi.util.CdiUtil;
88
import io.jans.as.server.service.AuthenticationService;
9+
import io.jans.service.UserAuthenticatorService;
10+
import io.jans.model.user.authenticator.UserAuthenticator;
911
import io.jans.util.StringHelper;
1012
import io.jans.orm.model.base.CustomObjectAttribute;
1113

@@ -70,15 +72,19 @@ public void enroll(String username, Map<String, Object> typekeyAttributes) {
7072
User user = getUser(UID, username);
7173
logger.info("Adding Typekey claims to UID {}", username);
7274
UserService userService = CdiUtil.bean(UserService.class);
73-
user.getCustomAttributes().add(new CustomObjectAttribute("typekeyData", typekeyAttributes));
75+
UserAuthenticatorService userAuthenticatorService = CdiUtil.bean(UserAuthenticatorService.class);
76+
UserAuthenticator authenticator = userAuthenticatorService.createUserAuthenticator("typekey", "typekey",
77+
typekeyAttributes);
78+
userAuthenticatorService.addUserAuthenticator(user, authenticator);
7479
userService.updateUser(user);
7580
}
7681

7782
public boolean enrolled(String username) {
7883
User user = getUser(UID, username);
7984
UserService userService = CdiUtil.bean(UserService.class);
80-
CustomObjectAttribute typekeyClaims = userService.getCustomAttribute(user, "typekeyData");
81-
if (typekeyClaims != null) {
85+
UserAuthenticatorService userAuthenticatorService = CdiUtil.bean(UserAuthenticatorService.class);
86+
UserAuthenticator authenticator = userAuthenticatorService.getUserAuthenticatorById(user, "typekey");
87+
if (authenticator != null) {
8288
logger.info("{} has enrolled", username);
8389
return true;
8490
}
@@ -88,9 +94,9 @@ public boolean enrolled(String username) {
8894

8995
public Map<String, Object> getTypekeyData(String username) {
9096
User user = getUser(UID, username);
91-
UserService userService = CdiUtil.bean(UserService.class);
92-
CustomObjectAttribute typekeyClaims = userService.getCustomAttribute(user, "typekeyData");
93-
LinkedHashMap<String, Object> data = typekeyClaims.getValue();
97+
UserAuthenticatorService userAuthenticatorService = CdiUtil.bean(UserAuthenticatorService.class);
98+
UserAuthenticator authenticator = userAuthenticatorService.getUserAuthenticatorById(user, "typekey");
99+
LinkedHashMap<String, Object> data = authenticator.getCustom();
94100
return data;
95101
}
96102

0 commit comments

Comments
 (0)