MarshallerFactory.java revision 27121b5c17e206894afd6d337a5d7fc6e4e8bb27
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2007 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: MarshallerFactory.java,v 1.5 2008/06/25 05:43:34 qcheng Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
*/
public class MarshallerFactory {
// All the various marshallers..
// ===================================================================
// Fields
// ===================================================================
// No support for JSON yet
}
}
/**
* Returns the Marshaller Map for the mechanism
*/
Map getMarshallerMap() {
return _map;
}
// initalize the map..
_map = getMarshallerMap();
}
// something is not right throw..
throw new IllegalArgumentException();
}
try {
} catch (Exception e) {
throw new RuntimeException(e);
}
return ret;
}
public String getProtocol() {
return (protocol);
}
//=======================================================================
// Marshalling w/ XML
//=======================================================================
/**
* Marshall the Token into XML format.
*/
static class XMLTokenMarshaller implements Marshaller {
// get an XMl factory for use..
}
throws Exception {
}
}
}
/**
* Marshall an Attribute into XML.
*/
static class XMLAttributeMarshaller implements Marshaller {
// get an XMl factory for use..
}
throws Exception {
}
}
}
}
/**
* Marshall an Exception class into XML format.
*/
static class XMLGeneralFailureMarshaller implements Marshaller {
// get an XMl factory for use..
}
throws Exception {
// StringWriter sw = new StringWriter(200);
// gf.printStackTrace(new PrintWriter(sw));
// wrt.writeAttribute("stacktrace", sw.toString());
// sw.close();
}
}
}
/**
* Marshall an Throwable exception into XML format.
*/
static class XMLThrowableMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
}
}
}
/**
* Marshall an ObjectNotFound exception into XML format.
*/
static class XMLObjectNotFoundMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
}
}
}
/**
* Marshall the UserDetails into Xml format.
*/
static class XMLUserDetailsMarshaller implements Marshaller {
// get an XMl factory for use..
}
throws Exception {
// write out the userdetails element..
// marshall the token using the XMLTokenMarshaller..
// write each of the roles..
}
// write each of the attributes
new XMLAttributeMarshaller();
}
}
// end the userdetails..
}
}
/**
* Marshall the UserDetails into Xml format.
*/
static class XMLIdentityDetailsMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
// write out the identitydetails element..
// marshall the name.
// marshall the identity type
// marshall the realm
// write the roles.
}
}
// write the groups.
}
}
// write the memberships.
if (memberList != null) {
}
}
// write each of the attributes
new XMLAttributeMarshaller();
}
}
// end the identitydetails..
}
}
/**
* Marshall a List into Xml format.
*/
static class XMLListMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
// write out the identitydetails element..
}
}
// end the List
}
}
/**
* Marshall the Boolean into XML format.
*/
static class XMLBooleanMarshaller implements Marshaller {
// get an XMl factory for use..
}
throws Exception {
}
}
/**
* Marshall a String into XML format.
*/
static class XMLStringMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
}
}
static class XMLStringArrayMarshaller
implements Marshaller
{
throws Exception
{
// get an XMl factory for use..
}
throws Exception
{
}
}
}
}
//=======================================================================
// Marshalling w/ JSON
//=======================================================================
/**
* Marshall the Token into JSON format.
*/
static class JSONTokenMarshaller implements Marshaller {
}
return token;
}
}
static class JSONBooleanMarshaller implements Marshaller {
}
return ret;
}
}
static class JSONStringMarshaller implements Marshaller {
}
return ret;
}
}
static class JSONStringArrayMarshaller implements Marshaller {
}
return ret;
}
}
static class JSONUserDetailsMarshaller implements Marshaller {
}
// add token..
// add roles..
}
}
// add attributes..
}
}
return obj;
}
}
/**
* Marshall an Attribute object into JSON.
*/
static class JSONAttributeMarshaller implements Marshaller {
}
// add name..
// add values..
}
}
return obj;
}
}
static class JSONIdentityDetailsMarshaller implements Marshaller {
}
}
}
}
}
}
}
if (memberList != null) {
}
}
}
}
}
return obj;
}
}
/**
* Marshall an Exception class into JSON format.
*/
static class JSONThrowableMarshaller implements Marshaller {
}
}
return obj;
}
}
//=======================================================================
// Marshalling w/ Properties
//=======================================================================
/**
* Marshall the Token into Properties format.
*/
static class PropertiesTokenMarshaller implements Marshaller {
}
throws Exception {
}
}
}
/**
* Marshall an Attribute object into Properties format.
*/
static class PropertiesAttributeMarshaller implements Marshaller {
}
throws Exception {
}
}
}
}
/**
* Marshall a UserDetails object into Properties format.
*/
static class PropertiesUserDetailsMarshaller implements Marshaller {
}
throws Exception {
// write the token..
new PropertiesTokenMarshaller();
// write the roles..
// add prefix to denote a parent object..
}
// write the attributes..
}
}
}
}
/**
* Marshall an IdentityDetails object into Properties format.
*/
static class PropertiesIdentityDetailsMarshaller
implements Marshaller
{
throws Exception
{
}
{
// write the name
// write the identity type
// write the realm
// write the roles.
// add prefix to denote a parent object..
}
}
// write the groups.
// add prefix to denote a parent object..
}
}
// write the members.
if (memberList != null) {
// add prefix to denote a parent object..
}
}
// write the attributes..
}
}
}
}
/**
* Marshall an IdentityDetails array into Properties format.
*/
static class PropertiesIdentityDetailsArrayMarshaller
implements Marshaller
{
throws Exception
{
}
{
}
}
}
}
/**
* Marshall an IdentityDetails object into Properties format.
*/
static class PropertiesListMarshaller
implements Marshaller
{
throws Exception
{
}
throws Exception
{
}
}
}
}
/**
* Marshall an Exception class into Properties format.
*/
static class PropertiesGeneralFailureMarshaller implements Marshaller {
}
{
} else {
}
}
}
/**
* Marshall the Throwable exception class into Properties format.
*/
static class PropertiesThrowableMarshaller
implements Marshaller
{
{
}
{
} else {
}
}
}
/**
* Marshall the ObjectNotFound exception class into Properties format.
*/
static class PropertiesObjectNotFoundMarshaller
implements Marshaller
{
{
}
{
} else {
}
}
}
/**
* Marshall the Boolean into Properties format.
*/
static class PropertiesBooleanMarshaller implements Marshaller {
}
throws Exception {
}
}
/**
* Marshall a String into Properties format.
*/
static class PropertiesStringMarshaller
implements Marshaller
{
throws Exception
{
}
throws Exception
{
}
}
/**
* Marshall a String array into Properties format.
*/
static class PropertiesStringArrayMarshaller
implements Marshaller
{
throws Exception
{
}
throws Exception
{
new PropertiesStringMarshaller();
}
}
}
}
}