Authorize.java
/*******************************************************************************
* Copyright (c) 2019, RISE AB
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
package se.sics.ace.as;
import java.util.logging.Level;
import java.util.logging.Logger;
import se.sics.ace.AceException;
import se.sics.ace.Endpoint;
import se.sics.ace.Message;
/**
* Implements the OAuth authorize endpoint.
*
* @author Ludwig Seitz
*
*/
public class Authorize implements Endpoint, AutoCloseable {
/**
* The database connector for storing and retrieving stuff.
*/
private DBConnector db;
/**
* The logger
*/
private static final Logger LOGGER
= Logger.getLogger(Authorize.class.getName());
/**
* Constructor
*
* @param db
*/
public Authorize(DBConnector db) {
this.db = db;
}
@Override
public void close() throws AceException {
this.db.close();
}
@Override
public Message processMessage(Message msg) {
LOGGER.log(Level.INFO, "Authorize received message: "
+ msg.getParameters());
//TODO: Implement the authorize endpoint
// response_type = "code".
// client_id REQUIRED. The client identifier as described in Section 2.2.
// scope OPTIONAL. The scope of the access request as described by
// state RECOMMENDED. An opaque value used by the client to maintain
// state between the request and callback.
//
// code
// REQUIRED. The authorization code generated by the
// authorization server. The authorization code MUST expire
// shortly after it is issued to mitigate the risk of leaks. A
// maximum authorization code lifetime of 10 minutes is
// RECOMMENDED. The client MUST NOT use the authorization code
// more than once. If an authorization code is used more than
// once, the authorization server MUST deny the request and SHOULD
// revoke (when possible) all tokens previously issued based on
// that authorization code. The authorization code is bound to
// the client identifier and redirection URI.
//
// state
// REQUIRED if the "state" parameter was present in the client
// authorization request. The exact value received from the
// client.
return null;
}
}