get cors policy
This commit is contained in:
parent
c2289a3f83
commit
76f6a39915
4 changed files with 18 additions and 18 deletions
|
@ -29,7 +29,7 @@ public class CorsConfig extends AppCompatActivity {
|
|||
AmazonS3 s3client;
|
||||
BucketCrossOriginConfiguration bucketcors;
|
||||
boolean style;
|
||||
boolean allorigins, pdfcompatible = false;
|
||||
boolean allorigins, pdfcompatible, found = false;
|
||||
TextView origins;
|
||||
|
||||
@Override
|
||||
|
@ -66,13 +66,16 @@ public class CorsConfig extends AppCompatActivity {
|
|||
bucketcors = s3client.getBucketCrossOriginConfiguration(bucket);
|
||||
if (bucketcors != null) {
|
||||
List<CORSRule> corsRules = bucketcors.getRules();
|
||||
for (CORSRule rule: corsRules) {
|
||||
System.out.println("allowOrigins: "+rule.getAllowedOrigins());
|
||||
System.out.println("AllowedMethod: "+rule.getAllowedMethods());
|
||||
if (rule.getAllowedOrigins().toString().equals("[*]")) {
|
||||
allorigins = true;
|
||||
} else if (rule.getAllowedOrigins().toString().equals("["+pdfendpoint+"]")) {
|
||||
pdfcompatible = true;
|
||||
if (!corsRules.isEmpty()) {
|
||||
found = true;
|
||||
for (CORSRule rule: corsRules) {
|
||||
System.out.println("allowOrigins: "+rule.getAllowedOrigins());
|
||||
System.out.println("AllowedMethod: "+rule.getAllowedMethods());
|
||||
if (rule.getAllowedOrigins().toString().equals("[*]")) {
|
||||
allorigins = true;
|
||||
} else if (rule.getAllowedOrigins().toString().equals("["+pdfendpoint+"]")) {
|
||||
pdfcompatible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +88,8 @@ public class CorsConfig extends AppCompatActivity {
|
|||
origins.setText(getResources().getString(R.string.cors_all));
|
||||
} else if (pdfcompatible) {
|
||||
origins.setText(getResources().getString(R.string.cors_pdf));
|
||||
} else if (found) {
|
||||
origins.setText(getResources().getString(R.string.cors_npdf));
|
||||
} else {
|
||||
origins.setText(getResources().getString(R.string.cors_none));
|
||||
}
|
||||
|
|
|
@ -7,13 +7,6 @@
|
|||
android:orientation="vertical"
|
||||
tools:context=".CorsConfig">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cors_status"
|
||||
android:textAlignment="center"
|
||||
android:textSize="30sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/origins"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
<string name="cors_config">Política CORS</string>
|
||||
<string name="cors_status">Orígenes permitidos</string>
|
||||
<string name="cors_all">Permitidos todos los orígenes</string>
|
||||
<string name="cors_pdf">Permitido el uso de endpoint PDF</string>
|
||||
<string name="cors_none">Uso de endpoint PDF permitido</string>
|
||||
<string name="cors_pdf">Uso de endpoint PDF permitido</string>
|
||||
<string name="cors_npdf">Uso de endpoint PDF no permitido</string>
|
||||
<string name="cors_none">Política CORS no encontrada</string>
|
||||
</resources>
|
|
@ -102,5 +102,6 @@
|
|||
<string name="cors_status">Allowed origins</string>
|
||||
<string name="cors_all">All origins allowed</string>
|
||||
<string name="cors_pdf">PDF Endpoint allowed</string>
|
||||
<string name="cors_none">PDF Endpoint not allowed</string>
|
||||
<string name="cors_npdf">PDF Endpoint not allowed</string>
|
||||
<string name="cors_none">CORS policy not found</string>
|
||||
</resources>
|
Loading…
Reference in a new issue