Commit 78297cc0 authored by Yi Sun's avatar Yi Sun
Browse files

hash home dir

parent 693bad73
...@@ -48,6 +48,8 @@ import org.keycloak.storage.ldap.LDAPStorageProviderFactory; ...@@ -48,6 +48,8 @@ import org.keycloak.storage.ldap.LDAPStorageProviderFactory;
import org.keycloak.storage.user.ImportSynchronization; import org.keycloak.storage.user.ImportSynchronization;
import org.keycloak.common.util.Time; import org.keycloak.common.util.Time;
import java.nio.charset.StandardCharsets;
public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAuthenticator{ public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAuthenticator{
private static Logger logger = Logger.getLogger(EoscCreateUserIfUniqueAuthenticator.class); private static Logger logger = Logger.getLogger(EoscCreateUserIfUniqueAuthenticator.class);
private DirContext ctx = null; private DirContext ctx = null;
...@@ -199,9 +201,19 @@ public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAu ...@@ -199,9 +201,19 @@ public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAu
//givenName //givenName
attributes.put("givenName", firstname); attributes.put("givenName", firstname);
//uid //uid
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] bytes = digest.digest(username.getBytes(StandardCharsets.UTF_8));
StringBuilder sb = new StringBuilder();
for(int i=0; i< bytes.length ;i++)
{
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
}
String hashed_un = sb.toString();
attributes.put("uid", username); attributes.put("uid", username);
//homedir //homedir
attributes.put("homeDirectory", "/home/"+username);
attributes.put("homeDirectory", "/home/"+hashed_un.substring(0,16));
//shadowLastChange //shadowLastChange
attributes.put("shadowLastChange", 15140+""); attributes.put("shadowLastChange", 15140+"");
//shadowMin //shadowMin
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment