tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
private Response configureUserPolicies(String token, UserDetails userDetails, IAMServiceAccountUser iamServiceAccountUser,
														 OIDCEntityResponse oidcEntityResponse, String groups, List<String> policies) {
		String policiesString = org.apache.commons.lang3.StringUtils.join(policies, ",");

		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, IAMServiceAccountConstants.ADD_USER_TO_IAMSVCACC_MSG)
				.put(LogMessage.MESSAGE, String.format("Policies [%s] before calling configure user", policies))
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
		Response userConfigresponse = new Response();
		if (TVaultConstants.USERPASS.equals(vaultAuthMethod)) {
			userConfigresponse = ControllerUtil.configureUserpassUser(iamServiceAccountUser.getUsername(), policiesString, token);
		} else if (TVaultConstants.LDAP.equals(vaultAuthMethod)) {
			userConfigresponse = ControllerUtil.configureLDAPUser(iamServiceAccountUser.getUsername(), policiesString, groups, token);
		} else if (TVaultConstants.OIDC.equals(vaultAuthMethod)) {
			// OIDC Implementation : Entity Update
			try {
				userConfigresponse = oidcUtil.updateOIDCEntity(policies, oidcEntityResponse.getEntityName());
				oidcUtil.renewUserToken(userDetails.getClientToken());
			} catch (Exception e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, IAMServiceAccountConstants.ADD_USER_TO_IAMSVCACC_MSG)
						.put(LogMessage.MESSAGE, String.format("Exception while adding or updating the identity for entity [%s]", oidcEntityResponse.getEntityName()))
						.put(LogMessage.STACKTRACE, Arrays.toString(e.getStackTrace()))
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
						.build()));
			}
		}

		return userConfigresponse;
	}
/**
	 * Method to update policies for add user to IAM service account.
	 * @param token
	 * @param userDetails
	 * @param iamServiceAccountUser
	 * @param oidcEntityResponse
	 * @param groups
	 * @param policies
	 * @return
	 */
Method to update policies for add user to IAM service account.
Method to update policies for add user to IAM service account .
private Response configureUserPolicies(String token, UserDetails userDetails, IAMServiceAccountUser iamServiceAccountUser,
														 OIDCEntityResponse oidcEntityResponse, String groups, List<String> policies) {
		String policiesString = org.apache.commons.lang3.StringUtils.join(policies, ",");
		log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
				.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
				.put(LogMessage.ACTION, IAMServiceAccountConstants.ADD_USER_TO_IAMSVCACC_MSG)
				.put(LogMessage.MESSAGE, String.format("Policies [%s] before calling configure user", policies))
				.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).build()));
		Response userConfigresponse = new Response();
		if (TVaultConstants.USERPASS.equals(vaultAuthMethod)) {
			userConfigresponse = ControllerUtil.configureUserpassUser(iamServiceAccountUser.getUsername(), policiesString, token);
		} else if (TVaultConstants.LDAP.equals(vaultAuthMethod)) {
			userConfigresponse = ControllerUtil.configureLDAPUser(iamServiceAccountUser.getUsername(), policiesString, groups, token);
		} else if (TVaultConstants.OIDC.equals(vaultAuthMethod)) {
			try {
				userConfigresponse = oidcUtil.updateOIDCEntity(policies, oidcEntityResponse.getEntityName());
				oidcUtil.renewUserToken(userDetails.getClientToken());
			} catch (Exception e) {
				log.error(e);
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder()
						.put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER))
						.put(LogMessage.ACTION, IAMServiceAccountConstants.ADD_USER_TO_IAMSVCACC_MSG)
						.put(LogMessage.MESSAGE, String.format("Exception while adding or updating the identity for entity [%s]", oidcEntityResponse.getEntityName()))
						.put(LogMessage.STACKTRACE, Arrays.toString(e.getStackTrace()))
						.put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL))
						.build()));
			}
		}
		return userConfigresponse;
	}
private Response configureUserPolicies ( String token , UserDetails userDetails , IAMServiceAccountUser iamServiceAccountUser , OIDCEntityResponse oidcEntityResponse , String groups , List < String > policies ) { String policiesString = org . apache . commons . lang3 . StringUtils . join ( policies , "," ) ; log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . ADD_USER_TO_IAMSVCACC_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Policies [%s] before calling configure user" , policies ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; Response userConfigresponse = new Response ( ) ; if ( TVaultConstants . USERPASS . equals ( vaultAuthMethod ) ) { userConfigresponse = ControllerUtil . configureUserpassUser ( iamServiceAccountUser . getUsername ( ) , policiesString , token ) ; } else if ( TVaultConstants . LDAP . equals ( vaultAuthMethod ) ) { userConfigresponse = ControllerUtil . configureLDAPUser ( iamServiceAccountUser . getUsername ( ) , policiesString , groups , token ) ; } else if ( TVaultConstants . OIDC . equals ( vaultAuthMethod ) ) { try { userConfigresponse = oidcUtil . updateOIDCEntity ( policies , oidcEntityResponse . getEntityName ( ) ) ; oidcUtil . renewUserToken ( userDetails . getClientToken ( ) ) ; } catch ( Exception e ) { log . error ( e ) ; log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . ADD_USER_TO_IAMSVCACC_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Exception while adding or updating the identity for entity [%s]" , oidcEntityResponse . getEntityName ( ) ) ) . put ( LogMessage . STACKTRACE , Arrays . toString ( e . getStackTrace ( ) ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; } } return userConfigresponse ; }
Method to update policies for add user to IAM service account.
Method to update policies for add user to IAM service account .
// OIDC Implementation : Entity Update