OAuth2Proxy.java revision c3791e48cd72e76169350053ac1c737d2a081cd6
/*
* DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2012 ForgeRock Inc. 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 Copyrighted [year] [name of copyright owner]"
*/
/**
* An OAuth2Proxy does ...
*
* @author Laszlo Hordos
*/
extends Restlet {
/**
* The OAuth2 Request handler.
*/
private volatile Uniform oAuth2Client;
this.oAuth2Proxy = null;
this.oAuth2Client = oAuth2Client;
}
super(context);
this.oAuth2Client = oAuth2Client;
this.oAuth2Proxy = null;
}
/**
* @param authorizationEndpoint
* @return
* @see <a href=
* "http://tools.ietf.org/html/draft-ietf-oauth-v2-25#section-3.1>Authorizati
* o n Endpoint</a>
*/
return this;
}
public Reference getAuthorizationEndpoint() {
return authorizationEndpoint;
}
/**
* @param tokenEndpoint
* @return
* @see <a href=
* "http://tools.ietf.org/html/draft-ietf-oauth-v2-25#section-3.2>Token
* Endpoint</a>
*/
this.tokenEndpoint = tokenEndpoint;
return this;
}
public Reference getTokenEndpoint() {
return tokenEndpoint;
}
protected Protocol getProtocol() {
}
} else {
return ref.getSchemeProtocol();
}
}
/**
* @return
* @see <a href=
* "http://tools.ietf.org/html/draft-ietf-oauth-v2-25#section-3.1.2>Redirecti
* o n Endpoint</a>
*/
return this;
}
public Reference getRedirectionEndpoint() {
return new Reference(redirectionEndpoint);
}
this.challengeResponse = challengeResponse;
return this;
}
public ChallengeResponse getChallengeResponse() {
return challengeResponse;
}
this.client_secret = client_secret;
} else {
this.client_secret = null;
}
return this;
}
public String getClientId() {
return client_id;
}
public String getClientSecret() {
return client_secret;
}
} else {
}
return this;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
return flow;
}
public abstract T getAccessTokenExtractor();
public Uniform getClientResource() {
synchronized (this) {
result = this.oAuth2Client;
}
}
}
}
return result;
}
this.oAuth2Client = oauth2Client;
}
/**
* Creates a next Restlet is no one is set. By default, it creates a new
* {@link Client} based on the protocol of the resource's URI reference.
*
* @return The created next Restlet or null.
*/
protected Uniform createRestletClient() {
// Prefer the outbound root
// Try using directly the client dispatcher
}
// As a final option, try creating a client connector
Protocol p = getProtocol();
// SslContextFactory factory = new
// CustomSSLContextFactory(keyManagers, trustManagers,
// configuration.getClientKeyAlias());
// client.getContext().getAttributes().put("sslContextFactory",
// factory);
}
}
return result;
}
// Authorization Redirects
"ISO-8859-1", false), parameters);
}
}
}
"ISO-8859-1", false), parameters);
}
}
}
// Token Requests
/**
* @param code
* @return
* @throws ResourceException
* @throws OAuthProblemException
*/
response);
}
/**
* @param code
* @return
* @throws ResourceException
* @throws OAuthProblemException
*/
}
}
}
}
}
}
}
if (null != parameters) {
}
response);
}
}
}
}
// Request Factories
}
public ImplicitRequest getImplicitRequest() {
}
getClientSecret());
}
public PasswordRequest getPasswordRequest() {
}
getClientSecret());
}
}
public SAML20AssertionRequest getSAML20AssertionRequest() {
}
// TODO Have it as an inner class this can not work without parent
// OAuth2Proxy<T, U> oAuth2Proxy
// TODO Have a factory method: public InnerOAuth2Proxy newOAuth2Proxy(Flow
// flow)
// ----------------------------------------------------------------------------------------------
public enum Flow {
}
public enum AuthenticationStatus {
}
this.oAuth2Proxy = oAuth2Proxy;
}
super(context);
this.oAuth2Proxy = oAuth2Proxy;
}
/**
* The OAuth2Proxy.
*/
private volatile OAuth2Proxy<T, U> oAuth2Proxy;
/**
* The next Restlet.
*/
public OAuth2Proxy<T, U> getOAuth2Proxy() {
return oAuth2Proxy;
}
/**
* Returns the next Restlet.
*
* @return The next Restlet or null.
*/
return this.next;
}
/**
* Sets the next Restlet.
* <p/>
* In addition, this method will set the context of the next Restlet if it
* is null by passing a reference to its own context.
*
* @param next
* The next Restlet.
*/
}
}
}
return scope;
}
if (requiredScope instanceof Set) {
} else if (null == requiredScope) {
} else {
}
}
/**
* Get a new instance of the parameters
* <p/>
* If the initial parameters is null the this method return null as well. If
* the initial parameters is not null then it return a new modifiable copy
* of the original parameters.
*
* @return null or new instance of initial parameters
*/
if (null != parameters) {
}
return null;
}
this.parameters = parameters;
}
case AUTHENTICATED: {
break;
}
case UNAUTHENTICATED: {
break;
}
case REDIRECTED: {
// The ClientResource should know to STOP processing the request
// and let the User-Agent to redirected
}
}
// Re-associate the response to the current thread
// Associate the context to the current thread
if (getContext() != null) {
}
} else {
}
}
// TODO Call the REFRESH_TOKEN if it's possible
switch (au) {
case AUTHORIZATION_CODE: {
break;
}
case PASSWORD: {
break;
}
}
}
switch (au) {
case AUTHORIZATION_CODE: {
}
case IMPLICIT: {
}
case PASSWORD: {
token =
break;
}
case CLIENT_CREDENTIALS: {
token =
break;
}
case REFRESH_TOKEN: {
return AuthenticationStatus.UNAUTHENTICATED;
}
token =
break;
}
case SAML20_INSERTION: {
break;
}
}
}
}
if (authenticated) {
if (null != tokenLocation) {
switch (tokenLocation) {
case HTTP_HEADER: {
token));
break;
}
case HTTP_BODY: {
continue;
}
}
}
break;
}
}
case HTTP_FRAGMENT: {
break;
}
case HTTP_QUERY: {
}
break;
}
}
}
}
}
}