35d69d3e62a03ca4650d0362945840c51ede39d4
java/com.sap.sse.security/src/com/sap/sse/security/util/SecuredServer.java
| ... | ... | @@ -57,6 +57,12 @@ public interface SecuredServer { |
| 57 | 57 | void setGroupAndUserOwner(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId, |
| 58 | 58 | Optional<String> displayName, Optional<UUID> groupId, Optional<String> username) |
| 59 | 59 | throws MalformedURLException, ClientProtocolException, IOException, ParseException; |
| 60 | + |
|
| 61 | + void deleteOwnership(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId) |
|
| 62 | + throws MalformedURLException, ClientProtocolException, IOException, ParseException; |
|
| 63 | + |
|
| 64 | + void deleteAccessControlLists(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId) |
|
| 65 | + throws MalformedURLException, ClientProtocolException, IOException, ParseException; |
|
| 60 | 66 | |
| 61 | 67 | Iterable<Pair<WildcardPermission, Boolean>> hasPermissions(Iterable<WildcardPermission> permissions) throws UnsupportedEncodingException, MalformedURLException, ClientProtocolException, IOException, ParseException; |
| 62 | 68 | /** |
java/com.sap.sse.security/src/com/sap/sse/security/util/impl/SecuredServerImpl.java
| ... | ... | @@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream; |
| 4 | 4 | import java.io.ByteArrayOutputStream; |
| 5 | 5 | import java.io.IOException; |
| 6 | 6 | import java.io.InputStreamReader; |
| 7 | +import java.net.MalformedURLException; |
|
| 7 | 8 | import java.net.URL; |
| 8 | 9 | import java.net.URLEncoder; |
| 9 | 10 | import java.util.ArrayList; |
| ... | ... | @@ -176,6 +177,36 @@ public class SecuredServerImpl implements SecuredServer { |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | @Override |
| 180 | + public void deleteOwnership(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId) |
|
| 181 | + throws MalformedURLException, ClientProtocolException, IOException, ParseException { |
|
| 182 | + final URL deleteOwnershipUrl = new URL(getBaseUrl(), |
|
| 183 | + SECURITY_API_PREFIX + OwnershipResource.RESTSECURITY_OWNERSHIP + "/" |
|
| 184 | + + type.getName() + "/" + typeRelativeObjectId.toString()); |
|
| 185 | + final HttpDelete deleteRequest = new HttpDelete(deleteOwnershipUrl.toString()); |
|
| 186 | + deleteRequest.setHeader(HTTP.CONTENT_TYPE, "application/json"); |
|
| 187 | + authenticate(deleteRequest); |
|
| 188 | + final CloseableHttpResponse response = createHttpClient().execute(deleteRequest); |
|
| 189 | + if (response.getStatusLine().getStatusCode() >= 300) { |
|
| 190 | + throw new IllegalArgumentException(response.getStatusLine().getReasonPhrase()); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + @Override |
|
| 195 | + public void deleteAccessControlLists(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId) |
|
| 196 | + throws MalformedURLException, ClientProtocolException, IOException, ParseException { |
|
| 197 | + final URL deleteACLUrl = new URL(getBaseUrl(), |
|
| 198 | + SECURITY_API_PREFIX + OwnershipResource.RESTSECURITY_OWNERSHIP + "/" |
|
| 199 | + + type.getName() + "/" + typeRelativeObjectId.toString() + "/" + OwnershipResource.KEY_ACL); |
|
| 200 | + final HttpDelete deleteRequest = new HttpDelete(deleteACLUrl.toString()); |
|
| 201 | + deleteRequest.setHeader(HTTP.CONTENT_TYPE, "application/json"); |
|
| 202 | + authenticate(deleteRequest); |
|
| 203 | + final CloseableHttpResponse response = createHttpClient().execute(deleteRequest); |
|
| 204 | + if (response.getStatusLine().getStatusCode() >= 300) { |
|
| 205 | + throw new IllegalArgumentException(response.getStatusLine().getReasonPhrase()); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + @Override |
|
| 179 | 210 | public Map<UUID, Set<String>> getAccessControlLists(HasPermissions type, TypeRelativeObjectIdentifier typeRelativeObjectId) throws ClientProtocolException, IOException, ParseException { |
| 180 | 211 | final URL getGroupAndUserOwnerUrl = new URL(getBaseUrl(), SECURITY_API_PREFIX + OwnershipResource.RESTSECURITY_OWNERSHIP |
| 181 | 212 | + "/" + type.getName() + "/" + typeRelativeObjectId.toString() + "/" + OwnershipResource.KEY_ACL); |