Commit 72142151 authored by Alok Joshi's avatar Alok Joshi
Browse files

update oid

parent 5ac2e4e2
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
package org.opengroup.osdu.azure.entitlements.service; package org.opengroup.osdu.azure.entitlements.service;
import com.ctc.wstx.util.StringUtil;
import com.microsoft.azure.spring.autoconfigure.aad.UserPrincipal; import com.microsoft.azure.spring.autoconfigure.aad.UserPrincipal;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Value; ...@@ -34,6 +35,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.*; import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -400,8 +402,10 @@ public class EntitlementsAzure ...@@ -400,8 +402,10 @@ public class EntitlementsAzure
type = UserType.REGULAR_USER; type = UserType.REGULAR_USER;
else if (u.getUniqueName() != null) else if (u.getUniqueName() != null)
type = UserType.GUEST_USER; type = UserType.GUEST_USER;
else else if (!StringUtils.isEmpty(u.getClaim("appid")))
type = UserType.SERVICE_PRINCIPAL; type = UserType.SERVICE_PRINCIPAL;
else
type = UserType.OTHER;
return type; return type;
} }
...@@ -455,6 +459,12 @@ public class EntitlementsAzure ...@@ -455,6 +459,12 @@ public class EntitlementsAzure
} else if (type == UserType.SERVICE_PRINCIPAL){ } else if (type == UserType.SERVICE_PRINCIPAL){
context.setUid(userPrincipal.getClaim("appid").toString()); context.setUid(userPrincipal.getClaim("appid").toString());
context.setOid(userPrincipal.getClaim("oid").toString()); context.setOid(userPrincipal.getClaim("oid").toString());
} else if (type == UserType.OTHER){
String oId = userPrincipal.getClaim("email").toString();
if(StringUtils.isEmpty(oId)) {
oId = userPrincipal.getClaim("appcode").toString();
}
context.setOid(oId);
} }
return context; return context;
} }
......
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