Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2024 3A Systems LLC.
*/

package org.forgerock.openam.authentication.modules.oauth2.profile;

import org.forgerock.openam.authentication.modules.oauth2.HttpRequestContent;
import org.forgerock.openam.authentication.modules.oauth2.OAuthConf;

import javax.security.auth.login.LoginException;
import java.util.HashMap;
import java.util.Map;

public class MailRuProfileProvider implements ProfileProvider {

private static final ProfileProvider INSTANCE = new MailRuProfileProvider();

public static ProfileProvider getInstance() {
return INSTANCE;
}
@Override
public String getProfile(OAuthConf config, String token) throws LoginException {
Map<String, String> profileServiceGetParameters = new HashMap<>();
profileServiceGetParameters.put("access_token", token);
profileServiceGetParameters.putAll(config.getProfileServiceGetParameters());
return HttpRequestContent.getInstance().getContentUsingGET(config.getProfileServiceUrl(), null,
profileServiceGetParameters);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2018-2024 3A Systems LLC.
*/

package org.forgerock.openam.authentication.modules.oauth2.profile;

import java.io.UnsupportedEncodingException;
Expand Down Expand Up @@ -39,7 +55,6 @@ public String getProfile(OAuthConf config, String token) throws LoginException {
Map<String, String> parameters = new HashMap<>();
parameters.put("application_key", publicKey);
parameters.put("format", "JSON");
System.err.println(profileServiceUrl);
try {
signRequest(token, parameters, privateKey);
} catch(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2018-2024 3A Systems LLC.
*/

package org.forgerock.openam.authentication.modules.oauth2.profile;

import org.apache.commons.lang.StringUtils;
Expand All @@ -11,6 +27,8 @@ public static ProfileProvider getProfileProvider(OAuthConf config) {
return VkontakteProvider.getInstance();
if(StringUtils.defaultString(config.getProfileServiceUrl()).contains("esia"))
return ESIAProfileProvider.getInstance();
if(StringUtils.defaultString(config.getProfileServiceUrl()).contains("mail.ru"))
return MailRuProfileProvider.getInstance();
return DefaultProfileProvider.getInstance();
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2018-2024 3A Systems LLC.
*/

package org.forgerock.openam.authentication.modules.oauth2.profile;

import java.util.HashMap;
Expand All @@ -17,6 +33,8 @@ public class VkontakteProvider implements ProfileProvider {

private static Debug DEBUG = Debug.getInstance("amAuthOAuth2");

public static final String VK_API_VERSION = "[vk-api-version]";

private static final ProfileProvider INSTANCE = new VkontakteProvider();

public static ProfileProvider getInstance() {
Expand All @@ -40,7 +58,10 @@ public String getProfile(OAuthConf config, String token) throws LoginException {
Map<String, String> parameters = new HashMap<>();
parameters.put("fields", PROFILE_FIELDS);
parameters.put("access_token", token);
parameters.put("v", "5.74");
parameters.put("v", "5.199");
if(config.getCustomProperties().get(VK_API_VERSION) != null) {
parameters.put("v", config.getCustomProperties().get(VK_API_VERSION));
}
String jsonResponse = HttpRequestContent.getInstance().getContentUsingGET(config.getProfileServiceUrl(), null,
parameters);

Expand Down