-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2783 from atmire/w2p-71342_Authorization-for-Down…
…loads-of-restricted-Bitstreams-1 Authorization for Downloads of restricted Bitstreams: Short lived token endpoint
- Loading branch information
Showing
19 changed files
with
859 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...rver-webapp/src/main/java/org/dspace/app/rest/converter/AuthenticationTokenConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.converter; | ||
|
||
import org.dspace.app.rest.model.AuthenticationTokenRest; | ||
import org.dspace.app.rest.model.wrapper.AuthenticationToken; | ||
import org.dspace.app.rest.projection.Projection; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* This is the converter from the AuthenticationToken to the REST data model | ||
*/ | ||
@Component | ||
public class AuthenticationTokenConverter implements DSpaceConverter<AuthenticationToken, AuthenticationTokenRest> { | ||
@Override | ||
public AuthenticationTokenRest convert(AuthenticationToken modelObject, Projection projection) { | ||
AuthenticationTokenRest token = new AuthenticationTokenRest(); | ||
token.setToken(modelObject.getToken()); | ||
return token; | ||
} | ||
|
||
@Override | ||
public Class<AuthenticationToken> getModelClass() { | ||
return AuthenticationToken.class; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...rver-webapp/src/main/java/org/dspace/app/rest/link/AuthenticationTokenHalLinkFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.link; | ||
|
||
import java.util.LinkedList; | ||
|
||
import org.dspace.app.rest.AuthenticationRestController; | ||
import org.dspace.app.rest.model.hateoas.AuthenticationTokenResource; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.hateoas.IanaLinkRelations; | ||
import org.springframework.hateoas.Link; | ||
import org.springframework.stereotype.Component; | ||
|
||
/** | ||
* This class adds the self link to the AuthenticationTokenResource. | ||
*/ | ||
@Component | ||
public class AuthenticationTokenHalLinkFactory | ||
extends HalLinkFactory<AuthenticationTokenResource, AuthenticationRestController> { | ||
|
||
@Override | ||
protected void addLinks(AuthenticationTokenResource halResource, Pageable pageable, LinkedList<Link> list) | ||
throws Exception { | ||
|
||
list.add(buildLink(IanaLinkRelations.SELF.value(), getMethodOn().shortLivedToken(null))); | ||
} | ||
|
||
@Override | ||
protected Class<AuthenticationRestController> getControllerClass() { | ||
return AuthenticationRestController.class; | ||
} | ||
|
||
@Override | ||
protected Class<AuthenticationTokenResource> getResourceClass() { | ||
return AuthenticationTokenResource.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
dspace-server-webapp/src/main/java/org/dspace/app/rest/model/AuthenticationTokenRest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.model; | ||
|
||
import org.dspace.app.rest.RestResourceController; | ||
|
||
/** | ||
* The authentication token REST HAL Resource. The HAL Resource wraps the REST Resource | ||
* adding support for the links and embedded resources | ||
*/ | ||
public class AuthenticationTokenRest extends RestAddressableModel { | ||
public static final String NAME = "shortlivedtoken"; | ||
public static final String CATEGORY = RestAddressableModel.AUTHENTICATION; | ||
|
||
private String token; | ||
|
||
@Override | ||
public String getCategory() { | ||
return CATEGORY; | ||
} | ||
|
||
@Override | ||
public Class getController() { | ||
return RestResourceController.class; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return NAME; | ||
} | ||
|
||
public String getToken() { | ||
return token; | ||
} | ||
|
||
public void setToken(String token) { | ||
this.token = token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...r-webapp/src/main/java/org/dspace/app/rest/model/hateoas/AuthenticationTokenResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.model.hateoas; | ||
|
||
import org.dspace.app.rest.model.AuthenticationTokenRest; | ||
|
||
/** | ||
* Token resource, wraps the AuthenticationToken object | ||
*/ | ||
public class AuthenticationTokenResource extends HALResource<AuthenticationTokenRest> { | ||
|
||
public AuthenticationTokenResource(AuthenticationTokenRest content) { | ||
super(content); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...ce-server-webapp/src/main/java/org/dspace/app/rest/model/wrapper/AuthenticationToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
package org.dspace.app.rest.model.wrapper; | ||
|
||
/** | ||
* This class represents an authentication token. It acts as a wrapper for a String object to differentiate between | ||
* actual Strings and AuthenticationToken | ||
*/ | ||
public class AuthenticationToken { | ||
private String token; | ||
|
||
public AuthenticationToken(String token) { | ||
this.token = token; | ||
} | ||
|
||
public String getToken() { | ||
return token; | ||
} | ||
|
||
public void setToken(String token) { | ||
this.token = token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.