X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-oauth%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Foauth%2Fmapper%2FMapper1_0.java;h=154654c30bd93fda9c7ee9ccffc1c6d2321f3a8c;hb=deb396a3d53a84b2eb5a46d40122b4902d72c601;hp=4be079e41a467e230dcc756e3a03650b6940aa14;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/Mapper1_0.java b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/Mapper1_0.java index 4be079e4..154654c3 100644 --- a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/Mapper1_0.java +++ b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/Mapper1_0.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import org.onap.aaf.auth.oauth.service.OAuthService; import org.onap.aaf.auth.oauth.service.OCreds; import org.onap.aaf.auth.oauth.service.OAuthService.CLIENT_TYPE; import org.onap.aaf.auth.oauth.service.OAuthService.GRANT_TYPE; -import org.onap.aaf.cadi.client.Holder; +import org.onap.aaf.cadi.util.Holder; import org.onap.aaf.cadi.oauth.OAuth2Principal; import org.onap.aaf.cadi.util.Vars; import org.onap.aaf.misc.env.util.Split; @@ -49,7 +49,7 @@ public class Mapper1_0 extends MapperIntrospect1_0 implements Mapper getClass(API api) { switch(api) { - case TOKEN_REQ: return TokenRequest.class; + case TOKEN_REQ: return TokenRequest.class; case TOKEN: return Token.class; case INTROSPECT: return Introspect.class; case ERROR: return Error.class; @@ -73,13 +73,13 @@ public class Mapper1_0 extends MapperIntrospect1_0 implements Mapper map = req.getParameterMap(); - for(Entry es : map.entrySet()) { + for (Entry es : map.entrySet()) { switch(es.getKey()) { case "client_id": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setClientId(es.getValue()[0]); data = true; } break; case "client_secret": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setClientSecret(es.getValue()[0]); data = true; } break; case "username": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setUsername(es.getValue()[0]); data = true; } break; case "password": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setPassword(es.getValue()[0]); data = true; } break; case "scope": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setScope(es.getValue()[0]); data = true; } break; case "grant_type": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setGrantType(es.getValue()[0]); data = true; } break; case "refresh_token": - if(es.getValue().length==1) { + if (es.getValue().length==1) { tr.setRefreshToken(es.getValue()[0]); data = true; } break; - } + } } return data?tr:null; } - - + + /* (non-Javadoc) * @see org.onap.aaf.auth.oauth.mapper.Mapper#credsFromReq(javax.servlet.http.HttpServletRequest) @@ -156,19 +156,19 @@ public class Mapper1_0 extends MapperIntrospect1_0 implements Mapper hgt) { OAuthTokenDAO.Data tdd = new OAuthTokenDAO.Data(); - tdd.client_id = tokReq.getClientId(); + tdd.client_id = tokReq.getClientId(); tdd.user = tokReq.getUsername(); - if(tokReq.getRefreshToken()!=null) { + if (tokReq.getRefreshToken()!=null) { tdd.refresh=tokReq.getRefreshToken(); } - - for(GRANT_TYPE ttt : GRANT_TYPE.values()) { - if(ttt.name().equals(tokReq.getGrantType())) { + + for (GRANT_TYPE ttt : GRANT_TYPE.values()) { + if (ttt.name().equals(tokReq.getGrantType())) { hgt.set(ttt); break; } } - + switch(hgt.get()) { case client_credentials: case password: @@ -179,26 +179,26 @@ public class Mapper1_0 extends MapperIntrospect1_0 implements Mapper ss = tdd.scopes(true); - for(String s: Split.split(' ', tokReq.getScope())) { + for (String s: Split.split(' ', tokReq.getScope())) { ss.add(s); } } - + tdd.state = tokReq.getState(); return tdd; } @Override public Result tokenFromData(Result rd) { - if(rd.notOK()) { + if (rd.notOK()) { return Result.err(rd); } Data d = rd.value; Token token = new Token(); - if(OAuthService.TOKEN_TYPE.values().length>d.type) { + if (OAuthService.TOKEN_TYPE.values().length>d.type) { token.setTokenType(OAuthService.TOKEN_TYPE.values()[d.type].name()); } else { token.setTokenType("Invalid");