org.zalando.nakadiproducer.StupsTokenComponent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nakadi-producer-spring-boot-starter Show documentation
Show all versions of nakadi-producer-spring-boot-starter Show documentation
Spring Boot Auto Configuration for Nakadi event producer
package org.zalando.nakadiproducer;
import java.net.URI;
import java.util.Collection;
import org.zalando.stups.tokens.AccessTokens;
import org.zalando.stups.tokens.Tokens;
class StupsTokenComponent implements AccessTokenProvider {
private static final String TOKEN_ID = "nakadi";
private AccessTokens accessTokens;
public StupsTokenComponent(URI accessTokenUri, Collection accessTokenScopes) {
accessTokens = Tokens.createAccessTokensWithUri(accessTokenUri)
.manageToken(TOKEN_ID)
.addScopesTypeSafe(accessTokenScopes)
.done()
.start();
}
public void stop() {
accessTokens.stop();
}
@Override
public String getAccessToken() {
return accessTokens.get(TOKEN_ID);
}
}