OAuth2RestUtils.java revision 70a8ada12c9190e612610da5fae0028704d0a9c3
/*
* DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2013 ForgeRock AS All rights reserved.
*
* 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
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* 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]"
*/
/**
* A Collection of OAuth2 Rest Helper Methods
*/
public class OAuth2RestUtils {
// Client Variables
// Administrative Variables
private static ServiceConfigManager sm;
// Service Default Variables
private static String scopeImplementationClass = "org.forgerock.openam.oauth2.provider.impl.ScopeImpl";
static {
}
/**
* Constructor used for testing OAuth2RestUtils
* @param sm service configuration manager
*/
}
/**
* Create an OAuth2 Client in specified realm
* @param clientID name of the client to be created
* @param realm realm in which client will be created
* @return OAuth2 Client AMIdentity if successful; null if otherwise
*/
public static AMIdentity createOAuth2Client(String clientID, String realm) throws NotFoundException {
try {
// Check to see if client exists already
idsc.setRecursive(true);
idsc.setAllReturnAttributes(true);
if (searchResults != null) {
// Do nothing, skip to create identity
// Identity found
}
}
// Client ID
// Client Secret
// Client Type - Public
return amIdent;
} catch (Exception e){
RestDispatcher.debug.error("IdentityResource.createOAuth2Client :: Cannot create OAuth2 Client " + e);
throw new NotFoundException(e.getMessage(), e);
}
}
/**
* Creates an OAuth2 Service in the realm provided
* @param sm Serivce Configuration Manager for the OAuth2 provider
* @param realm Realm in which to create the service
* @throws NotFoundException
*/
public static void createOAuth2Service(ServiceConfigManager sm, String realm) throws NotFoundException {
try {
// Get instances from service config manager
// Check if service has been created already
return;
}
// Create service attrs
} catch (Exception e){
RestDispatcher.debug.error("IdentityResource.createOAuth2Service:: Cannot create OAuth2 Service " + e);
throw new NotFoundException(e.getMessage(), e);
}
}
/**
* Validates the OAuth2 access token on the server
* @param fullDeploymentURL full server url
* @param access_token OAuth2 access_token
* @return response from the token info endpoint
*/
public static Response validateOAuth2Token(StringBuilder fullDeploymentURL, String access_token) throws BadRequestException {
try {
if(fullDepURL == null){
fullDepURL.toString());
}
// Append the tokeninfo endpoint
// Build up request
}
// Get Response from Request
// Return the response
return clientResource.getResponse();
} catch (Exception e) {
}
}
}