File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
share-oauth-repo/src/main
java/org/sharextras/oauth/repo/webscripts
templates/webscripts/org/sharextras/slingshot/oauth Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ package org .sharextras .oauth .repo .webscripts ;
2
+
3
+ import java .io .IOException ;
4
+
5
+ import org .alfresco .service .cmr .oauth2 .OAuth2CredentialsStoreService ;
6
+ import org .springframework .extensions .webscripts .AbstractWebScript ;
7
+ import org .springframework .extensions .webscripts .Status ;
8
+ import org .springframework .extensions .webscripts .WebScriptException ;
9
+ import org .springframework .extensions .webscripts .WebScriptRequest ;
10
+ import org .springframework .extensions .webscripts .WebScriptResponse ;
11
+
12
+ /**
13
+ * Delete an OAuth 2.0 ticket from the credentials store.
14
+ *
15
+ * @author Will Abson
16
+ */
17
+ public class DeleteOAuthToken extends AbstractWebScript
18
+ {
19
+
20
+ // Services
21
+ private OAuth2CredentialsStoreService oauth2CredentialsStoreService ;
22
+
23
+ public void setOauth2CredentialsStoreService (OAuth2CredentialsStoreService oauth2CredentialsStoreService )
24
+ {
25
+ this .oauth2CredentialsStoreService = oauth2CredentialsStoreService ;
26
+ }
27
+
28
+ @ Override
29
+ public void execute (WebScriptRequest req , WebScriptResponse resp )
30
+ throws IOException
31
+ {
32
+ String keyName = req .getServiceMatch ().getTemplateVars ().get ("name" );
33
+
34
+ if (keyName == null || "" .equals (keyName ))
35
+ {
36
+ throw new WebScriptException ("A key name must be specified" );
37
+ }
38
+
39
+ boolean result = oauth2CredentialsStoreService .deletePersonalOAuth2Credentials (keyName );
40
+
41
+ if (!result )
42
+ {
43
+ throw new WebScriptException (Status .STATUS_NOT_FOUND , "Could not find credentials with name " + keyName );
44
+ }
45
+ }
46
+
47
+ }
Original file line number Diff line number Diff line change 16
16
</property >
17
17
</bean >
18
18
19
+ <bean id =" webscript.org.sharextras.slingshot.oauth.oauth-token.delete"
20
+ class =" org.sharextras.oauth.repo.webscripts.DeleteOAuthToken" parent =" webscript" >
21
+ <property name =" oauth2CredentialsStoreService" >
22
+ <ref bean =" oauth2CredentialsStoreService" />
23
+ </property >
24
+ </bean >
25
+
19
26
</beans >
Original file line number Diff line number Diff line change
1
+ <webscript >
2
+ <shortname >OAuth2-delete-token</shortname >
3
+ <description >Script to delete an OAuth 2.0 token</description >
4
+ <url >/extras/oauth2/token/{name}</url >
5
+ <authentication >user</authentication >
6
+ <format default =" json" >any</format >
7
+ </webscript >
You can’t perform that action at this time.
0 commit comments