summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/oauth-provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/oauth-provider')
-rw-r--r--sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java25
-rw-r--r--sdnr/wt/oauth-provider/provider-osgi/pom.xml6
2 files changed, 22 insertions, 9 deletions
diff --git a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java
index 47d5fee01..d8720e823 100644
--- a/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java
+++ b/sdnr/wt/oauth-provider/provider-jar/src/main/java/org/onap/ccsdk/features/sdnr/wt/oauthprovider/providers/TokenCreator.java
@@ -95,7 +95,7 @@ public class TokenCreator {
private Algorithm createAlgorithm(String alg, String secret, String pubkey)
throws IllegalArgumentException, IOException {
- if(alg==null) {
+ if (alg == null) {
alg = Config.TOKENALG_HS256;
}
switch (alg) {
@@ -153,24 +153,31 @@ public class TokenCreator {
public String getBearerToken(HttpServletRequest req) {
return this.getBearerToken(req, false);
}
+
public String getBearerToken(HttpServletRequest req, boolean checkCookie) {
final String authHeader = req.getHeader("Authorization");
if ((authHeader == null || !authHeader.startsWith("Bearer")) && checkCookie) {
- Optional<Cookie> ocookie =
- Arrays.stream(req.getCookies()).filter(c -> COOKIE_NAME_AUTH.equals(c.getName())).findFirst();
- if(ocookie.isEmpty()) {
+ Cookie[] cookies = req.getCookies();
+ Optional<Cookie> ocookie = Optional.empty();
+ if (cookies != null) {
+ ocookie = Arrays.stream(cookies).filter(c -> c != null && COOKIE_NAME_AUTH.equals(c.getName()))
+ .findFirst();
+ }
+ if (ocookie.isEmpty()) {
return null;
}
return ocookie.get().getValue();
}
return authHeader.substring(7);
}
+
public UserTokenPayload decode(HttpServletRequest req) throws JWTDecodeException {
final String token = this.getBearerToken(req);
- return token!=null?this.decode(token):null;
+ return token != null ? this.decode(token) : null;
}
- public UserTokenPayload decode(String token){
- if(token == null){
+
+ public UserTokenPayload decode(String token) {
+ if (token == null) {
return null;
}
DecodedJWT jwt = JWT.decode(token);
@@ -185,8 +192,8 @@ public class TokenCreator {
}
public Cookie createAuthCookie(BearerToken data) {
- Cookie cookie = new Cookie(COOKIE_NAME_AUTH, data.getToken());
- cookie.setMaxAge((int)this.tokenLifetimeSeconds);
+ Cookie cookie = new Cookie(COOKIE_NAME_AUTH, data.getToken());
+ cookie.setMaxAge((int) this.tokenLifetimeSeconds);
cookie.setPath("/");
cookie.setHttpOnly(true);
cookie.setSecure(true);
diff --git a/sdnr/wt/oauth-provider/provider-osgi/pom.xml b/sdnr/wt/oauth-provider/provider-osgi/pom.xml
index 3d4d138a2..41fe3c599 100644
--- a/sdnr/wt/oauth-provider/provider-osgi/pom.xml
+++ b/sdnr/wt/oauth-provider/provider-osgi/pom.xml
@@ -119,13 +119,18 @@
org.opendaylight.aaa.api.shiro.principal,
org.opendaylight.aaa.shiro.realm,
org.opendaylight.aaa.shiro.filters,
+ org.opendaylight.aaa.shiro.web.env,
org.opendaylight.mdsal.binding.api,
+ org.opendaylight.mdsal.common.api,
org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619,
org.opendaylight.yang.gen.v1.urn.opendaylight.aaa.app.config.rev170619.shiro.configuration,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.authorization,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.authorization.policies,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.aaa.rev161214.http.permission,
+ org.opendaylight.yangtools.concepts,
org.opendaylight.yangtools.yang.binding,
+ org.opendaylight.yangtools.yang.common,
com.fasterxml.jackson.databind,
com.fasterxml.jackson.databind.deser.std,
com.fasterxml.jackson.databind.ser.std,
@@ -134,6 +139,7 @@
com.fasterxml.jackson.core.type,
com.fasterxml.jackson.core,
org.apache.commons.codec.binary,
+ com.google.common.base,
com.google.common.collect,
com.google.common.util.concurrent
</Import-Package>