/** * Creates a {@code OnBehalfOfType} instance that contains a {@code UsernameTokenType}. * * @param username a {@code String} that represents the username of the {@code UsernameTokenType}. * @param id an optional {@code String} that uniquely identifies the {@code UsernameTokenType}. * @return the constructed {@code OnBehalfOfType} instance. */ public static OnBehalfOfType createOnBehalfOfWithUsername(String username, String id) { AttributedString attrString = new AttributedString(); attrString.setValue(username); UsernameTokenType usernameToken = new UsernameTokenType(); usernameToken.setId(id); usernameToken.setUsername(attrString); // create the OnBehalfOfType and set the UsernameTokenType. OnBehalfOfType onBehalfOf = new OnBehalfOfType(); onBehalfOf.add(usernameToken); return onBehalfOf; }