NextcloudRequest.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /*
  2. *
  3. * Nextcloud Android client application
  4. *
  5. * @author Tobias Kaminsky
  6. * Copyright (C) 2021 Tobias Kaminsky
  7. * Copyright (C) 2021 Nextcloud GmbH
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. /*
  23. * Nextcloud SingleSignOn
  24. *
  25. * @author David Luhmer
  26. *
  27. * This program is free software: you can redistribute it and/or modify
  28. * it under the terms of the GNU General Public License as published by
  29. * the Free Software Foundation, either version 3 of the License, or
  30. * (at your option) any later version.
  31. *
  32. * This program is distributed in the hope that it will be useful,
  33. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  34. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  35. * GNU General Public License for more details.
  36. *
  37. * You should have received a copy of the GNU General Public License
  38. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  39. */
  40. package com.nextcloud.android.sso.aidl;
  41. import java.io.Serializable;
  42. import java.util.Collection;
  43. import java.util.HashMap;
  44. import java.util.LinkedList;
  45. import java.util.List;
  46. import java.util.Map;
  47. public class NextcloudRequest implements Serializable {
  48. private static final long serialVersionUID = 215521212534240L; //assign a long value
  49. private String method;
  50. private Map<String, List<String>> header = new HashMap<>();
  51. private Map<String, String> parameter = new HashMap<>();
  52. private final Collection<com.nextcloud.android.sso.api.QueryPair> parameterV2 = new LinkedList<>();
  53. private String requestBody;
  54. private String url;
  55. private String token;
  56. private String packageName;
  57. private String accountName;
  58. private boolean followRedirects;
  59. private NextcloudRequest() { }
  60. public static class Builder {
  61. private NextcloudRequest ncr;
  62. public Builder() {
  63. ncr = new NextcloudRequest();
  64. }
  65. public NextcloudRequest build() {
  66. return ncr;
  67. }
  68. public Builder setMethod(String method) {
  69. ncr.method = method;
  70. return this;
  71. }
  72. public Builder setHeader(Map<String, List<String>> header) {
  73. ncr.header = header;
  74. return this;
  75. }
  76. public Builder setParameter(Map<String, String> parameter) {
  77. ncr.parameter = parameter;
  78. return this;
  79. }
  80. public Builder setRequestBody(String requestBody) {
  81. ncr.requestBody = requestBody;
  82. return this;
  83. }
  84. public Builder setUrl(String url) {
  85. ncr.url = url;
  86. return this;
  87. }
  88. public Builder setToken(String token) {
  89. ncr.token = token;
  90. return this;
  91. }
  92. public Builder setAccountName(String accountName) {
  93. ncr.accountName = accountName;
  94. return this;
  95. }
  96. /**
  97. * Default value: true
  98. * @param followRedirects
  99. * @return
  100. */
  101. public Builder setFollowRedirects(boolean followRedirects) {
  102. ncr.followRedirects = followRedirects;
  103. return this;
  104. }
  105. }
  106. public String getMethod() {
  107. return this.method;
  108. }
  109. public Map<String, List<String>> getHeader() {
  110. return this.header;
  111. }
  112. public Map<String, String> getParameter() {
  113. return this.parameter;
  114. }
  115. public String getRequestBody() {
  116. return this.requestBody;
  117. }
  118. public String getUrl() {
  119. return this.url;
  120. }
  121. public String getToken() {
  122. return this.token;
  123. }
  124. public void setToken(String token) {
  125. this.token = token;
  126. }
  127. public String getPackageName() {
  128. return this.packageName;
  129. }
  130. public void setPackageName(String packageName) {
  131. this.packageName = packageName;
  132. }
  133. public String getAccountName() {
  134. return this.accountName;
  135. }
  136. public void setAccountName(String accountName) {
  137. this.accountName = accountName;
  138. }
  139. public boolean isFollowRedirects() {
  140. return this.followRedirects;
  141. }
  142. public Collection<com.nextcloud.android.sso.api.QueryPair> getParameterV2() {
  143. return parameterV2;
  144. }
  145. }