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%2FMapperIntrospect1_0.java;h=05b99c3200b9f7829347b867f5b1ce3c825c3b20;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=00a94fdf20f732fe6f9952db4d2ba71278837960;hpb=71037c39a37d3549dcfe31926832a657744fbe05;p=aaf%2Fauthz.git diff --git a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/MapperIntrospect1_0.java b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/MapperIntrospect1_0.java index 00a94fdf..05b99c32 100644 --- a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/MapperIntrospect1_0.java +++ b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/MapperIntrospect1_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. @@ -31,44 +31,44 @@ import aafoauth.v2_0.Introspect; public class MapperIntrospect1_0 implements MapperIntrospect { - public Result introspect(Result rs) { - if(rs.isOKhasData()) { - Data data = rs.value; - Introspect ti = new Introspect(); - ti.setAccessToken(data.id); - ti.setActive(data.active); - ti.setClientId(data.client_id); - for(CLIENT_TYPE ct : CLIENT_TYPE.values()) { - if(data.type==ct.ordinal()) { - ti.setClientType(ct.name()); - break; - } - } - if(ti.getClientType()==null) { - ti.setClientType(CLIENT_TYPE.unknown.name()); - } - ti.setActive(data.active); - ti.setScope(getScopes(data.scopes(false))); - ti.setContent(data.content); - ti.setUsername(data.user); - ti.setExp(data.exp_sec); // want seconds from Jan 1, 1970 - return Result.ok(ti); - } - return Result.err(rs); - } - - protected static String getScopes(Set scopes) { - StringBuilder sb = new StringBuilder(); - boolean start = true; - for(String s : scopes) { - if(start) { - start = false; - } else { - sb.append(' '); - } - sb.append(s); - } - return sb.toString(); - } + public Result introspect(Result rs) { + if (rs.isOKhasData()) { + Data data = rs.value; + Introspect ti = new Introspect(); + ti.setAccessToken(data.id); + ti.setActive(data.active); + ti.setClientId(data.client_id); + for (CLIENT_TYPE ct : CLIENT_TYPE.values()) { + if (data.type==ct.ordinal()) { + ti.setClientType(ct.name()); + break; + } + } + if (ti.getClientType()==null) { + ti.setClientType(CLIENT_TYPE.unknown.name()); + } + ti.setActive(data.active); + ti.setScope(getScopes(data.scopes(false))); + ti.setContent(data.content); + ti.setUsername(data.user); + ti.setExp(data.exp_sec); // want seconds from Jan 1, 1970 + return Result.ok(ti); + } + return Result.err(rs); + } + + protected static String getScopes(Set scopes) { + StringBuilder sb = new StringBuilder(); + boolean start = true; + for (String s : scopes) { + if (start) { + start = false; + } else { + sb.append(' '); + } + sb.append(s); + } + return sb.toString(); + } }