Skip to main content
summaryrefslogtreecommitdiffstats
blob: b8b0574aba2b41f1d83a429d68832472da21df90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*******************************************************************************
 * Copyright (c) 2014 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.jaxrs.server.internal.security.oauth2.provider.adapters;

import javax.ws.rs.core.Response;
import org.apache.cxf.rs.security.oauth2.common.Client;
import org.apache.cxf.rs.security.oauth2.common.OOBAuthorizationResponse;
import org.apache.cxf.rs.security.oauth2.provider.OOBResponseDeliverer;
import org.apache.cxf.rs.security.oauth2.services.AuthorizationCodeGrantService;

/**
 * @author Roberto E. Escobar
 */
public class CxfAuthorizationCodeService extends AuthorizationCodeGrantService {

   private boolean canSupportPublicClients;
   private OOBResponseDeliverer oobDeliverer;

   @Override
   protected Response deliverOOBResponse(OOBAuthorizationResponse response) {
      if (oobDeliverer != null) {
         return oobDeliverer.deliver(response);
      } else {
         return Response.ok(response).build();
      }
   }

   @Override
   protected boolean canSupportPublicClient(Client c) {
      return canSupportPublicClients && !c.isConfidential() && c.getClientSecret() == null;
   }

   @Override
   public void setCanSupportPublicClients(boolean support) {
      this.canSupportPublicClients = support;
   }

   public void setOobDeliverer(OOBResponseDeliverer oobDeliverer) {
      this.oobDeliverer = oobDeliverer;
   }
}

Back to the top