CoreTokenResource.java revision a329900f13c59aa829b6b857a5e96119d249880c
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2009 Sun Microsystems 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 at opensso/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 Copyrighted [year] [name of copyright owner]"
*
* $Id: CoreTokenResource.java,v 1.1 2009/11/19 00:10:38 qcheng Exp $
*/
/**
* Defines REST resources for Core Token Service.
*
*/
@Path("/1/token")
public class CoreTokenResource extends ResourceBase {
/**
* Creates a token.
*
* @param headers HTTPHeaders object of the request.
* @param request HTTPServletRequest object of the request.
* @param msgBody Message body containing the JSON-encoded token attributes.
* @return JSON-encoded token.id attribute of the new token.
*/
@POST
@Consumes("application/json")
@Produces("application/json")
public Response createToken(
try {
// retrieve token.id attribute and set as part of Location header
.getString(0);
+ newTokenId);
// logging
// TODO : get the request session and used in login field
return retResponse;
} catch (JSONException ex) {
try {
} catch (JSONException ex1) {
}
} else {
}
} catch (CoreTokenException ce) {
try {
} catch (JSONException ex1) {
}
} else {
}
}
}
/**
* Reads token attributes.
*
* @param headers HTTPHeaders object of the request.
* @param request HTTPServletRequest object of the request.
* @param tokenId token.id of the token to be retrieved.
* @return JSON-encoded token attributes.
*/
@GET
@Produces("application/json")
@Path("{token.id}")
try {
// retrieve etag attribute and set it as ETag header value.
.getString(0);
// remove version tag in return
// logging
return retResponse;
} catch (CoreTokenException ce) {
} catch (JSONException je) {
}
}
/**
* Updates a token.
*
* @param headers HTTPHeaders object of the request.
* @param request HTTPServletRequest object of the request.
* @param tokenId value of token.id in the request path parameter.
* @param eTag value of the If-Match header in the request.
* @param msgBody Message body containing the JSON-encoded token attributes.
*/
@PUT
@Consumes("application/json")
@Path("{token.id}")
public void updateToken(
try {
// logging
} catch (CoreTokenException ce) {
} catch (JSONException je) {
}
}
/**
* Deletes a token.
*
* @param headers HTTPHeaders object of the request.
* @param request HTTPServletRequest object of the request.
* @param tokenId value of token.id in the request path parameter.
*/
@Path("{token.id}")
public void deleteToken(
try {
// logging
} catch (CoreTokenException ex) {
}
}
/**
* Searches tokens.
*
* @param headers HTTPHeaders object of the request.
* @param request HTTPServletRequest object of the request.
* @return JSON array of tokens matching the queryString
*/
@GET
@Produces("application/json")
public String searchTokens(
try {
// logging
return retArray;
} catch (CoreTokenException ex) {
}
}
}