List of usage examples for org.apache.commons.httpclient.auth AuthPolicy AUTH_SCHEME_PRIORITY
String AUTH_SCHEME_PRIORITY
To view the source code for org.apache.commons.httpclient.auth AuthPolicy AUTH_SCHEME_PRIORITY.
Click Source Link
From source file:org.iavante.sling.gad.channel.ChannelToolsIT.java
@org.junit.Before protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;/*from w ww .j a v a 2 s .c o m*/ } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); col_title = "it_col"; content_title = "it_content"; source_title = "it_source"; file = "it_for_channel_tests.mpeg"; mimetype = "video/flv"; schema = "default"; title = "Test case content"; schema = "default"; slug_collection = "admin"; slug_content = "it_content"; tags_request = " test, case"; tags_response = "test,case"; channel_title = "IT Channel"; channel_slug = "it_channel"; channel_subtitle = "it_channel"; channel_schema = "default"; channel_distribution_format = "ies_web_medium,preview"; channel_distribution_server = "s3"; source_default_slug = "fuente_default"; tag1_input = "AEIOU"; tag2_input = "Recetas Equilibradas"; tag1_title = "aeiou"; tag2_title = "recetas equilibradas"; tag1_slug = "aeiou"; tag2_slug = "recetas-equilibradas"; defaultcreds = new UsernamePasswordCredentials("admin", "admin"); file_trans_preview = "file_preview.flv"; file_trans_ies = "file_ies.flv"; authPrefs = new ArrayList(2); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // Delete the collection PostMethod post_delete = new PostMethod(SLING_URL + COL_URL + col_title); NameValuePair[] data_delete = { new NameValuePair(":operation", "delete"), }; post_delete.setDoAuthentication(true); post_delete.setRequestBody(data_delete); try { client.executeMethod(post_delete); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_delete.releaseConnection(); // Create collection PostMethod post_create_col = new PostMethod(SLING_URL + COL_URL + col_title); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", col_title), new NameValuePair("schema", schema), new NameValuePair("subtitle", ""), new NameValuePair("extern_storage", "on"), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col); // post.setDoAuthentication(true); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Collection created assertEquals(201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create content in collection PostMethod post_create_content = new PostMethod( SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title); post_create_content.setDoAuthentication(true); NameValuePair[] data_create_content = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", content_title), new NameValuePair("schema", schema), new NameValuePair("description", "Content description generated by test case. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"), new NameValuePair("lang", "es"), new NameValuePair("tags@TypeHint", "String[]"), new NameValuePair("tags", tag1_input), new NameValuePair("tags", tag2_input), new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_content.setRequestBody(data_create_content); try { client.executeMethod(post_create_content); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Content created assertEquals(201, post_create_content.getStatusCode()); post_create_content.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create the source PostMethod post_create = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title + "/" + SOURCES_FOLDER + "/" + source_title); post_create.setDoAuthentication(true); NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/source"), new NameValuePair("title", source_title), new NameValuePair("file", file), new NameValuePair("mimetype", ""), new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""), new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", ""), new NameValuePair("bitrate", ""), new NameValuePair("tags", ""), new NameValuePair("tracks_number", ""), new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""), new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""), new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create.setRequestBody(data_create); try { client.executeMethod(post_create); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(201, post_create.getStatusCode()); post_create.releaseConnection(); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create transformation try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create the trans preview preview PostMethod post_create_trans = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title + "/" + SOURCES_FOLDER + "/fuente_default/transformations/preview"); post_create.setDoAuthentication(true); NameValuePair[] data_create_trans = { new NameValuePair("sling:resourceType", "gad/transformation"), new NameValuePair("file", file_trans_preview) }; post_create_trans.setRequestBody(data_create_trans); try { client.executeMethod(post_create_trans); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(201, post_create_trans.getStatusCode()); post_create_trans.releaseConnection(); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create transformation try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create the trans ies PostMethod post_create_trans2 = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title + "/" + SOURCES_FOLDER + "/fuente_default/transformations/ies_web_medium"); post_create.setDoAuthentication(true); NameValuePair[] data_create_trans2 = { new NameValuePair("sling:resourceType", "gad/transformation"), new NameValuePair("file", file_trans_ies) }; post_create_trans2.setRequestBody(data_create_trans2); try { client.executeMethod(post_create_trans2); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // assertEquals(201,post_create_trans2.getStatusCode()); post_create_trans2.releaseConnection(); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Send the content to revision PostMethod post_send_to_revision = new PostMethod( SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title); String catalog_pending_url = CATALOG_URL + PENDING_FOLDER + "/"; post_send_to_revision.setDoAuthentication(true); NameValuePair[] data_send_to_revision = { new NameValuePair(":operation", "copy"), new NameValuePair(":dest", catalog_pending_url), new NameValuePair("replace", "true") }; post_send_to_revision.setRequestBody(data_send_to_revision); try { client.executeMethod(post_send_to_revision); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(201, post_send_to_revision.getStatusCode()); post_send_to_revision.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Revise the content PostMethod post_revise_content = new PostMethod( SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title); String catalog_revised_url = CATALOG_URL + REVISED_FOLDER + "/"; post_send_to_revision.setDoAuthentication(true); NameValuePair[] data_revise_content = { new NameValuePair(":operation", "move"), new NameValuePair(":dest", catalog_revised_url), new NameValuePair("replace", "true") }; post_revise_content.setRequestBody(data_revise_content); try { client.executeMethod(post_revise_content); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(201, post_revise_content.getStatusCode()); post_revise_content.releaseConnection(); // Create channel PostMethod post_create_channel = new PostMethod(SLING_URL + CHANNEL_URL + channel_slug); post_create_channel.setDoAuthentication(true); NameValuePair[] data_create_channel = { new NameValuePair("sling:resourceType", "gad/channel"), new NameValuePair("title", channel_title), new NameValuePair("schema", channel_schema), new NameValuePair("distribution_server_config", "{'bucket':'test', 'public_read':'1'}"), new NameValuePair("distribution_format_video", channel_distribution_format), new NameValuePair("distribution_format_image", "preview"), new NameValuePair("distribution_server", channel_distribution_server), new NameValuePair("subtitle", channel_subtitle), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", ""), }; post_create_channel.setRequestBody(data_create_channel); try { client.executeMethod(post_create_channel); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_create_channel.releaseConnection(); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Publish the content PostMethod post_publish = new PostMethod(SLING_URL + CATALOG_URL + REVISED_FOLDER + "/" + content_title); String channel = CHANNEL_URL + channel_slug + "/contents/"; post_publish.setDoAuthentication(true); NameValuePair[] data_publish = { new NameValuePair(":operation", "copy"), new NameValuePair(":dest", channel), new NameValuePair("replace", "true") }; post_publish.setRequestBody(data_publish); try { client.executeMethod(post_publish); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(201, post_publish.getStatusCode()); post_publish.releaseConnection(); }
From source file:org.iavante.sling.gad.channel.ChannelValidationFilterIT.java
@org.junit.Before protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;/*from ww w . jav a 2 s . c o m*/ } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); col_title = "it_col"; content_title = "it_content"; source_title = "it_source"; file = "it_for_channel_tests.mpeg"; mimetype = "video/flv"; schema = "default"; title = "Test case content"; schema = "default"; slug_collection = "admin"; slug_content = "it_content"; tags_request = " test, case"; tags_response = "test,case"; channel_title = "IT Channel"; channel_slug = "it_channel"; channel_subtitle = "it_channel"; channel_schema = "default"; channel_distribution_format = "preview"; channel_distribution_server = "s3"; source_default_slug = "fuente_default"; defaultcreds = new UsernamePasswordCredentials("admin", "admin"); authPrefs = new ArrayList(2); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // Delete the collection PostMethod post_delete = new PostMethod(SLING_URL + COL_URL + col_title); NameValuePair[] data_delete = { new NameValuePair(":operation", "delete"), }; post_delete.setDoAuthentication(true); post_delete.setRequestBody(data_delete); try { client.executeMethod(post_delete); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_delete.releaseConnection(); // Create collection PostMethod post_create_col = new PostMethod(SLING_URL + COL_URL + col_title); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", col_title), new NameValuePair("schema", schema), new NameValuePair("subtitle", ""), new NameValuePair("extern_storage", "on"), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col); // post.setDoAuthentication(true); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Collection created assertEquals(post_create_col.getStatusCode(), 201); post_create_col.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create content in collection PostMethod post_create_content = new PostMethod( SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title); post_create_content.setDoAuthentication(true); NameValuePair[] data_create_content = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", content_title), new NameValuePair("schema", schema), new NameValuePair("description", "Content description generated by test case. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"), new NameValuePair("lang", "es"), new NameValuePair("tags", "test case"), new NameValuePair("tags@TypeHint", "String[]"), new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_content.setRequestBody(data_create_content); try { client.executeMethod(post_create_content); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Content created assertEquals(post_create_content.getStatusCode(), 201); post_create_content.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Create the source PostMethod post_create = new PostMethod(SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title + "/" + SOURCES_FOLDER + "/" + source_title); post_create.setDoAuthentication(true); NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/source"), new NameValuePair("title", source_title), new NameValuePair("file", file), new NameValuePair("mimetype", ""), new NameValuePair("text_encoding", ""), new NameValuePair("lang", ""), new NameValuePair("length", ""), new NameValuePair("size", ""), new NameValuePair("type", ""), new NameValuePair("bitrate", ""), new NameValuePair("tags", ""), new NameValuePair("tracks_number", ""), new NameValuePair("track_1_type", ""), new NameValuePair("track_1_encoding", ""), new NameValuePair("track_1_features", ""), new NameValuePair("track_2_type", ""), new NameValuePair("track_2_encoding", ""), new NameValuePair("track_2_features", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create.setRequestBody(data_create); try { client.executeMethod(post_create); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(post_create.getStatusCode(), 201); post_create.releaseConnection(); try { Thread.sleep(5000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Send the content to revision PostMethod post_send_to_revision = new PostMethod( SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title); String catalog_pending_url = CATALOG_URL + PENDING_FOLDER + "/"; post_send_to_revision.setDoAuthentication(true); NameValuePair[] data_send_to_revision = { new NameValuePair(":operation", "copy"), new NameValuePair(":dest", catalog_pending_url), new NameValuePair("replace", "true") }; post_send_to_revision.setRequestBody(data_send_to_revision); try { client.executeMethod(post_send_to_revision); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(post_send_to_revision.getStatusCode(), 201); post_send_to_revision.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Revise the content PostMethod post_revise_content = new PostMethod( SLING_URL + CATALOG_URL + PENDING_FOLDER + "/" + content_title); String catalog_revised_url = CATALOG_URL + REVISED_FOLDER + "/"; post_send_to_revision.setDoAuthentication(true); NameValuePair[] data_revise_content = { new NameValuePair(":operation", "move"), new NameValuePair(":dest", catalog_revised_url), new NameValuePair("replace", "true") }; post_revise_content.setRequestBody(data_revise_content); try { client.executeMethod(post_revise_content); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(post_revise_content.getStatusCode(), 201); post_revise_content.releaseConnection(); // Create channel PostMethod post_create_channel = new PostMethod(SLING_URL + CHANNEL_URL + channel_slug); post_create_channel.setDoAuthentication(true); NameValuePair[] data_create_channel = { new NameValuePair("sling:resourceType", "gad/channel"), new NameValuePair("title", channel_title), new NameValuePair("schema", channel_schema), new NameValuePair("distribution_format", channel_distribution_format), new NameValuePair("distribution_server", channel_distribution_server), new NameValuePair("subtitle", channel_subtitle), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_channel.setRequestBody(data_create_channel); try { client.executeMethod(post_create_channel); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_create_channel.releaseConnection(); try { Thread.sleep(4000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Publish the content PostMethod post_publish = new PostMethod(SLING_URL + CATALOG_URL + REVISED_FOLDER + "/" + content_title); String channel = CHANNEL_URL + channel_slug + "/contents/"; post_publish.setDoAuthentication(true); NameValuePair[] data_publish = { new NameValuePair(":operation", "copy"), new NameValuePair(":dest", channel), new NameValuePair("replace", "true") }; post_publish.setRequestBody(data_publish); try { client.executeMethod(post_publish); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertEquals(post_publish.getStatusCode(), 201); post_publish.releaseConnection(); }
From source file:org.iavante.sling.gad.collection.CollectionServiceTestIT.java
protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;// www . ja va2 s . c om } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); title = "IT col"; schema = "default"; slug = "it_col"; subtitle = "subtitle it"; extern_storage = "on"; authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); defaultcreds = new UsernamePasswordCredentials("admin", "admin"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); PostMethod post_create = new PostMethod(SLING_URL + COLLECTION_URL + slug); post_create.setDoAuthentication(true); NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", title), new NameValuePair("schema", schema), new NameValuePair("subtitle", subtitle), new NameValuePair("extern_storage", extern_storage), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create.setRequestBody(data_create); try { client.executeMethod(post_create); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_create.releaseConnection(); }
From source file:org.iavante.sling.gad.content.ContentServiceTestIT.java
protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;/*from w ww.jav a2 s.c o m*/ } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); title = "Test case content"; schema = "default"; slug_collection = "admin"; slug_content = "it_content"; slug_content_dos = "it_content_dos"; tag1_input = "AEIOU"; tag2_input = "Recetas Equilibradas"; tag1_title = "aeiou"; tag2_title = "recetas equilibradas"; tag1_slug = "aeiou"; tag2_slug = "recetas-equilibradas"; authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); defaultcreds = new UsernamePasswordCredentials("admin", "admin"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // Create collection PostMethod post_create_col = new PostMethod(SLING_URL + COLLECTIONS_URL + slug_collection); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", title), new NameValuePair("subtitle", ""), new NameValuePair("schema", schema), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_create_col.releaseConnection(); // Create content in collection try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } PostMethod post_create = new PostMethod( SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content); post_create.setDoAuthentication(true); NameValuePair[] data_create = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", title), new NameValuePair("schema", schema), new NameValuePair("description", "Content description generated by test case. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"), new NameValuePair("lang", "es"), new NameValuePair("tags", tag1_input), new NameValuePair("tags", tag2_input), new NameValuePair("tags@TypeHint", "String[]"), new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", ""), new NameValuePair("_charset_", "utf-8") }; post_create.setRequestBody(data_create); try { client.executeMethod(post_create); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } post_create.releaseConnection(); try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } // Edit the content PostMethod post_edit = new PostMethod( SLING_URL + COLLECTIONS_URL + slug_collection + "/" + CONTENTS_FOLDER + "/" + slug_content); post_edit.setDoAuthentication(true); NameValuePair[] data_edit = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", title), new NameValuePair("schema", schema), new NameValuePair("description", "Edited aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."), new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"), new NameValuePair("lang", "es"), new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", ""), new NameValuePair("_charset_", "utf-8") }; post_edit.setRequestBody(data_edit); // post.setDoAuthentication(true); try { client.executeMethod(post_edit); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Get the content try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } post_edit.releaseConnection(); // Edit the content again post_edit.setRequestBody(data_edit); try { client.executeMethod(post_edit); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Get the content try { Thread.sleep(2000); } catch (InterruptedException e1) { e1.printStackTrace(); } post_edit.releaseConnection(); }
From source file:org.iavante.sling.gad.content.impl.DirectPublication.java
/** * Initial http client configuration.//from w ww . j a va 2 s .c o m */ private void setup() { client = new HttpClient(); // defaultCreds = new UsernamePasswordCredentials(authInfo.getUserID(), // authInfo.getPassword().toString()); int colIdx = userPass.indexOf(':'); if (colIdx < 0) { userCreds = new UsernamePasswordCredentials(userPass); } else { userCreds = new UsernamePasswordCredentials(userPass.substring(0, colIdx), userPass.substring(colIdx + 1)); } defaultCreds = new UsernamePasswordCredentials("admin", "admin"); authPrefs = new ArrayList(2); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultCreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); }
From source file:org.iavante.sling.gad.red5backend.Red5BackendImplIT.java
protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;/* ww w .j a va2 s.com*/ } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); defaultcreds = new UsernamePasswordCredentials("admin", "admin"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); }
From source file:org.iavante.sling.gad.source.SourceServiceTestIT.java
protected void setUp() { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); boolean hashost = false; while (it.hasNext()) { String key = (String) it.next(); if (key.compareTo(HOSTVAR) == 0) { SLING_URL = SLING_URL + (String) envs.get(key); hashost = true;//from w w w.j av a 2s . co m } } if (hashost == false) SLING_URL = SLING_URL + HOSTPREDEF; client = new HttpClient(); col_title = "it_col"; content_title = "it_content"; source_title = "it_source"; file = "integration-test.flv"; mimetype = "video/flv"; type = "video"; schema = "default"; authPrefs = new ArrayList(2); authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); defaultcreds = new UsernamePasswordCredentials("admin", "admin"); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); // Create collection PostMethod post_create_col = new PostMethod(SLING_URL + COL_URL + col_title); post_create_col.setDoAuthentication(true); NameValuePair[] data_create_col = { new NameValuePair("sling:resourceType", "gad/collection"), new NameValuePair("title", col_title), new NameValuePair("schema", schema), new NameValuePair("subtitle", ""), new NameValuePair("extern_storage", "on"), new NameValuePair("picture", ""), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_col.setRequestBody(data_create_col); // post.setDoAuthentication(true); try { client.executeMethod(post_create_col); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Collection created assertEquals(201, post_create_col.getStatusCode()); post_create_col.releaseConnection(); // Create content in collection PostMethod post_create_content = new PostMethod( SLING_URL + COL_URL + col_title + "/" + CONTENTS_FOLDER + "/" + content_title); post_create_content.setDoAuthentication(true); NameValuePair[] data_create_content = { new NameValuePair("sling:resourceType", "gad/content"), new NameValuePair("title", content_title), new NameValuePair("schema", schema), new NameValuePair("description", "Content description generated by test case. Lorem ipsum " + "dolor sit amet, consectetur adipisicing elit, sed do eiusmod " + "tempor incididunt ut labore et dolore magna aliqua. Ut enim ad " + "minim veniam, quis nostrud exercitation ullamco laboris nisi ut " + "aliquip ex ea commodo consequat. Duis aute irure dolor in " + "reprehenderit in voluptate velit esse cillum dolore eu fugiat " + "nulla pariatur."), new NameValuePair("author", "Test case"), new NameValuePair("origin", "Test case"), new NameValuePair("lang", "es"), new NameValuePair("tags", "test case"), new NameValuePair("tags@TypeHint", "String[]"), new NameValuePair("state", "pending"), new NameValuePair("jcr:created", ""), new NameValuePair("jcr:createdBy", ""), new NameValuePair("jcr:lastModified", ""), new NameValuePair("jcr:lastModifiedBy", "") }; post_create_content.setRequestBody(data_create_content); // post.setDoAuthentication(true); try { client.executeMethod(post_create_content); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } // Content created assertEquals(201, post_create_content.getStatusCode()); post_create_content.releaseConnection(); }
From source file:org.iavante.sling.gad.transcoder.impl.TranscoderServiceImpl.java
public int sendConversionTask3(String conversionType, String sourceLocation, String targetLocation, String notificationUrl, String externalStorageServer, String externalStorageUrl, String params, String ds_custom_props) { Map<String, String> envs = System.getenv(); Set<String> keys = envs.keySet(); Iterator<String> it = keys.iterator(); List authPrefs = new ArrayList(2); Credentials defaultcreds;/*from w ww .j a va2 s. c om*/ authPrefs.add(AuthPolicy.DIGEST); authPrefs.add(AuthPolicy.BASIC); defaultcreds = new UsernamePasswordCredentials(transcodingServerUser, transcodingServerPassword); // Set client connection params MultiThreadedHttpConnectionManager connManager = new MultiThreadedHttpConnectionManager(); HttpConnectionManagerParams connParams = connManager.getParams(); connParams.setConnectionTimeout(800); HttpClient client = new HttpClient(connManager); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); if (log.isInfoEnabled()) log.info("Sending conversion task"); Node convTypeNode = null; try { convTypeNode = rootNode.getNode(baseRepoDir + "/" + COMPONENTS_FOLDER + "/" + TRANSCODER_FOLDER) .getNode(conversionType); } catch (PathNotFoundException e) { e.printStackTrace(); } catch (RepositoryException e) { e.printStackTrace(); } String executable = null; try { executable = convTypeNode.getProperty("command").getValue().getString(); if (params == null) { params = convTypeNode.getProperty("params").getValue().getString(); } if (ds_custom_props == null) { ds_custom_props = ""; } } catch (ValueFormatException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (PathNotFoundException e) { e.printStackTrace(); } catch (RepositoryException e) { e.printStackTrace(); } PostMethod post = new PostMethod(sendConversionUrl); //post.getParams().setParameter("http.socket.timeout", new Integer(50)); post.setDoAuthentication(true); NameValuePair[] data = { new NameValuePair("source_location", sourceLocation), new NameValuePair("target_location", targetLocation), new NameValuePair("executable", executable), new NameValuePair("params", params), new NameValuePair("ds_custom_props", ds_custom_props), new NameValuePair("notification_url", notificationUrl), new NameValuePair("extern_storage_server", externalStorageServer), new NameValuePair("sling:resourceType", "gad/job"), new NameValuePair("extern_storage_url", externalStorageUrl) }; post.setRequestBody(data); post.setDoAuthentication(true); int status = 0; int intentos = 0; while ((status != 201) && (intentos < 2)) { try { client.executeMethod(post); status = post.getStatusCode(); log.info("Conversion sent. Status code: " + status); } catch (HttpException e1) { log.error("Excepcion: HttpException"); e1.printStackTrace(); post.releaseConnection(); return status; } catch (IOException e1) { log.error("Excepcion: IOexception"); e1.printStackTrace(); post.releaseConnection(); return status; } finally { intentos++; } } post.releaseConnection(); return status; }
From source file:org.iavante.sling.permissions.PermissionsFilterTest.java
License:asdf
@org.junit.Test public void test_Path_Credentials_OK1() { // Ok access//from w w w .j a v a 2s.c o m GetMethod okaccess = new GetMethod(SLING_URL + OK1_URL); okaccess.setDoAuthentication(true); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(okaccess); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertTrue(okaccess.getStatusCode() == 200 || okaccess.getStatusCode() == 404); okaccess.releaseConnection(); }
From source file:org.iavante.sling.permissions.PermissionsFilterTest.java
License:asdf
@org.junit.Test public void test_Path_Credentials_OK2() { // Ok access/*from ww w.j a v a 2s.c o m*/ GetMethod okaccess = new GetMethod(SLING_URL + OK2_URL); okaccess.setDoAuthentication(true); client.getParams().setAuthenticationPreemptive(true); client.getState().setCredentials(AuthScope.ANY, defaultcreds); client.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs); try { client.executeMethod(okaccess); } catch (HttpException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } assertTrue(okaccess.getStatusCode() == 200 || okaccess.getStatusCode() == 404); okaccess.releaseConnection(); }