agave-apps/clients/ProfileService.java
/**
	 * Creates an InternalUser bound to the token user's API credentials. Users
	 * created via this method will not be users in terms of the API and cannot
	 * authenticate against the API themself, but they can be attached to an
	 * AuthenticationToken and have an AuthConfig on a RemoteSystem attached to
	 * them, thus allowing for 3rd party user authentication and accounting from
	 * a single set of API credentials. 
	 * 
	 * @param user
	 * @return
	 * @throws AuthenticationException
	 * @throws ProfileException
	 */
Creates an InternalUser bound to the token user's API credentials. Users
created via this method will not be users in terms of the API and cannot
authenticate against the API themself, but they can be attached to an
AuthenticationToken and have an AuthConfig on a RemoteSystem attached to
them, thus allowing for 3rd party user authentication and accounting from
a single set of API credentials.

@param user
@return
@throws AuthenticationException
@throws ProfileException
Creates an InternalUser bound to the token user ' s API credentials . Users created via this method will not be users in terms of the API and cannot authenticate against the API themself but they can be attached to an AuthenticationToken and have an AuthConfig on a RemoteSystem attached to them thus allowing for 3rd party user authentication and accounting from a single set of API credentials . @param user @return @throws AuthenticationException @throws ProfileException
public InternalUser createInternalUser(InternalUser user) 
	throws AuthenticationException, ProfileException
	{
		if (user == null) {
			throw new ProfileException("No internal user profile provided.");
		} else if (StringUtils.isEmpty(user.getUsername())) {
			throw new ProfileException("Unique username must be provided for internal users.");
		} else if (!ClientUtils.isValidEmailAddress(user.getEmail())) {
			throw new ProfileException("Unique username must be provided for internal users.");
		} 
		APIResponse response = null;
		try 
		{
			List <NameValuePair> nvps = new ArrayList<NameValuePair>();
			ObjectMapper mapper = new ObjectMapper();
			JsonFactory factory = mapper.getFactory();
			JsonParser jp = factory.createJsonParser(mapper.writeValueAsString(user));
			JsonNode node = mapper.readTree(jp);
			Iterator<String> fieldNames = node.fieldNames();
			while(fieldNames.hasNext()) {
				String fieldName = fieldNames.next();
				nvps.add(new BasicNameValuePair(fieldName, node.get(fieldName).asText()));
			}
			response = post( Settings.SERVICE_BASE_URL + "profile-v1/internal", token, nvps );
		} 
		catch (APIClientException e) {
			throw new ProfileException("Error querying service.", e);
		}
		catch (JsonParseException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		catch (JsonProcessingException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		catch (IOException e)
		{
			throw new ProfileException("Failed to create new user from the given internal user.", e);
		}
		if (response.isSuccess()) {
			List<InternalUser> users = parseInternalUsers(response.getResult());
			return users.get(0);
		} else {
			throw new ProfileException(response.getMessage());
		}
	}
public InternalUser createInternalUser ( InternalUser user ) throws AuthenticationException , ProfileException { if ( user == null ) { throw new ProfileException ( "No internal user profile provided." ) ; } else if ( StringUtils . isEmpty ( user . getUsername ( ) ) ) { throw new ProfileException ( "Unique username must be provided for internal users." ) ; } else if ( ! ClientUtils . isValidEmailAddress ( user . getEmail ( ) ) ) { throw new ProfileException ( "Unique username must be provided for internal users." ) ; } APIResponse response = null ; try { List < NameValuePair > nvps = new ArrayList < NameValuePair > ( ) ; ObjectMapper mapper = new ObjectMapper ( ) ; JsonFactory factory = mapper . getFactory ( ) ; JsonParser jp = factory . createJsonParser ( mapper . writeValueAsString ( user ) ) ; JsonNode node = mapper . readTree ( jp ) ; Iterator < String > fieldNames = node . fieldNames ( ) ; while ( fieldNames . hasNext ( ) ) { String fieldName = fieldNames . next ( ) ; nvps . add ( new BasicNameValuePair ( fieldName , node . get ( fieldName ) . asText ( ) ) ) ; } response = post ( Settings . SERVICE_BASE_URL + "profile-v1/internal" , token , nvps ) ; } catch ( APIClientException e ) { throw new ProfileException ( "Error querying service." , e ) ; } catch ( JsonParseException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } catch ( JsonProcessingException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } catch ( IOException e ) { throw new ProfileException ( "Failed to create new user from the given internal user." , e ) ; } if ( response . isSuccess ( ) ) { List < InternalUser > users = parseInternalUsers ( response . getResult ( ) ) ; return users . get ( 0 ) ; } else { throw new ProfileException ( response . getMessage ( ) ) ; } }
Creates an InternalUser bound to the token user's API credentials.
Creates an InternalUser bound to the token user ' s API credentials .