001/* 002 * Copyright 2022 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.extrausermgt.authentication.oidc; 017 018import java.net.MalformedURLException; 019import java.net.URI; 020import java.net.URL; 021 022import org.ametys.runtime.authentication.AccessDeniedException; 023 024import com.nimbusds.oauth2.sdk.Scope; 025import com.nimbusds.oauth2.sdk.id.Issuer; 026 027/** 028 * Sign in through Facebook, using the OpenId Connect protocol. 029 */ 030public class FacebookCredentialProvider extends AbstractOIDCCredentialProvider 031{ 032 private final Scope _scopeFb = new Scope("openid", "email", "public_profile"); 033 034 @Override 035 protected void initUrisScope() throws AccessDeniedException 036 { 037 try 038 { 039 _authUri = URI.create("https://www.facebook.com/v13.0/dialog/oauth"); 040 _tokenEndpointUri = URI.create("https://graph.facebook.com/v13.0/oauth/access_token"); 041 _iss = new Issuer("https://www.facebook.com"); 042 _jwkSetURL = new URL("https://www.facebook.com/.well-known/oauth/openid/jwks/"); 043 _userInfoEndpoint = URI.create("https://graph.facebook.com/me?fields=email,family_name,given_name,name,id"); 044 _scope = _scopeFb; 045 } 046 catch (MalformedURLException e) 047 { 048 getLogger().error("Encountered a problem when creating the jwkSetURL", e); 049 throw new AccessDeniedException("Encountered a problem when creating the jwkSetURL"); 050 } 051 } 052}