private Map < String , Object > getUserinfoFromRegistryMap ( Set < String > claims , Map < String , Object > inputMap , boolean isJson ) throws Exception { Map < String , Object > result = inputMap ; VMMService vmmService = JwtUtils . getVMMService ( ) ; if ( vmmService != null ) { PropertyControl vmmServiceProps = new PropertyControl ( ) ; Properties claimsToVMMProperties = new Properties ( ) ; if ( ! claims . isEmpty ( ) ) { // Properties claimsToVMMProps = jwtConfig.getClaimToUserRegistryMap(); //TODO for ( String claim : claims ) { String vmmProperty = claim ; // claimsToVMMProps.getProperty(claim); // if (vmmProperty == null) { // vmmProperty = claim; // if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // Tr.debug(tc, "claim: " + claim + " is not mapped to a vmm property, using the claim name as the vmm property name"); // } // } // else if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) { // Tr.debug(tc, "claim: " + claim + " mapped to vmmProperty: " + vmmProperty); // } claimsToVMMProperties . put ( claim , vmmProperty ) ; vmmServiceProps . getProperties ( ) . add ( vmmProperty ) ; } } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "claimsToVMMProperties: " + claimsToVMMProperties ) ; Tr . debug ( tc , "getting VMM properties: " + vmmServiceProps . getProperties ( ) ) ; } if ( ! vmmServiceProps . getProperties ( ) . isEmpty ( ) ) { // Call VMM to get the user's properties // IdentifierType id = new IdentifierType(); // String uniqueId = RegistryHelper.getUserRegistry(null).getUniqueUserId(userName); // id.setUniqueName(uniqueId); // Entity entity = new Entity(); // entity.setIdentifier(id); // Root root = new Root(); // root.getEntities().add(entity); // root.getControls().add(vmmServiceProps); // root = vmmService.get(root); // PersonAccount person = (PersonAccount) root.getEntities().get(0); PersonAccount person = getUser ( vmmService , vmmServiceProps ) ; // Now add the claims/values to the JSON for ( Entry < Object , Object > e : claimsToVMMProperties . entrySet ( ) ) { String claim = ( String ) e . getKey ( ) ; String vmmProperty = ( String ) e . getValue ( ) ; Object value = person . get ( vmmProperty ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "get for claim: " + claim + " vmmProperty: " + vmmProperty + ", returned: " + value ) ; } String strValue = vmmPropertyToString ( value ) ; if ( strValue != null && ! strValue . isEmpty ( ) ) { result . put ( claim , strValue ) ; // if (isJson && claim.equals("address")) { // JSONObject addressJSON = new JSONObject(); // addressJSON.put("formatted", strValue); // result.put(claim, addressJSON); // } else { // result.put(claim, strValue); // } } } } } else { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "VMM service not available - not returning any extra claims" ) ; } } return result ; }
Get the JSONObject that will be returned for userinfo endpoint from the user registry