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

hash home dir

parent 693bad73
......@@ -48,6 +48,8 @@ import;
import org.keycloak.common.util.Time;
import java.nio.charset.StandardCharsets;
public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAuthenticator{
private static Logger logger = Logger.getLogger(EoscCreateUserIfUniqueAuthenticator.class);
private DirContext ctx = null;
......@@ -199,9 +201,19 @@ public class EoscCreateUserIfUniqueAuthenticator extends IdpCreateUserIfUniqueAu
attributes.put("givenName", firstname);
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("homeDirectory", "/home/"+username);
attributes.put("homeDirectory", "/home/"+hashed_un.substring(0,16));
attributes.put("shadowLastChange", 15140+"");
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