-
Notifications
You must be signed in to change notification settings - Fork 1
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 #95 from scc-digitalhub/user-secrets
User secrets
- Loading branch information
Showing
12 changed files
with
204 additions
and
1 deletion.
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
.../main/java/it/smartcommunitylabdhub/core/components/security/SecureCredentialsHelper.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 @@ | ||
package it.smartcommunitylabdhub.core.components.security; | ||
|
||
import java.io.Serializable; | ||
import org.springframework.security.core.Authentication; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||
import org.springframework.util.Assert; | ||
|
||
public class SecureCredentialsHelper { | ||
|
||
public static Serializable extractCredentials(Authentication auth) { | ||
if (auth == null) { | ||
return null; | ||
} | ||
|
||
if (auth instanceof JwtAuthenticationToken) { | ||
return convertCredentials((JwtAuthenticationToken) auth); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public static Serializable convertCredentials(JwtAuthenticationToken auth) { | ||
Assert.notNull(auth, "auth token can not be null"); | ||
Assert.notNull(auth.getToken(), "jwt token can not be null"); | ||
|
||
//token value is the credential | ||
return auth.getToken(); | ||
} | ||
|
||
private SecureCredentialsHelper() {} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ommons/src/main/java/it/smartcommunitylabdhub/commons/infrastructure/SecuredRunnable.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,8 @@ | ||
package it.smartcommunitylabdhub.commons.infrastructure; | ||
|
||
import java.io.Serializable; | ||
|
||
public interface SecuredRunnable { | ||
Serializable getCredentials(); | ||
void setCredentials(Serializable credentials); | ||
} |
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
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
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.