2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.oauth.api;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
27 import org.onap.aaf.auth.env.AuthzTrans;
28 import org.onap.aaf.auth.layer.Result;
29 import org.onap.aaf.auth.oauth.AAF_OAuth;
30 import org.onap.aaf.auth.oauth.OACode;
31 import org.onap.aaf.auth.oauth.facade.OAFacade;
32 import org.onap.aaf.auth.oauth.mapper.Mapper.API;
33 import org.onap.aaf.auth.rserv.HttpMethods;
35 import aafoauth.v2_0.Introspect;
42 public class API_Token {
43 // Hide Public Constructor
44 private API_Token() {}
47 * Normal Init level APIs
53 public static void init(final AAF_OAuth authzAPI, OAFacade<Introspect> facade) throws Exception {
57 authzAPI.route(HttpMethods.POST,"/token",API.TOKEN,new OACode(facade,"OAuth Token", true) {
59 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
60 Result<Void> r = context.createBearerToken(trans,req, resp);
62 resp.setStatus(201/*HttpStatus.CREATED_201*/);
64 context.error(trans,resp,r);
69 authzAPI.route(HttpMethods.POST,"/introspect",API.INTROSPECT,new OACode(facade,"AAF Token Information", true) {
71 public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
72 Result<Void> r = context.introspect(trans,req, resp);
74 resp.setStatus(200 /*HttpStatus.OK_200*/);
76 context.error(trans,resp,r);