Package org.oa4mp.di
Class DIServiceSerializer
- java.lang.Object
-
- org.oa4mp.di.DIServiceSerializer
-
public class DIServiceSerializer extends Object
A class that serializes to a print writer or deserializes to streams.Created by Jeff Gaynor
on Nov 19, 2010 at 11:03:15 AM
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientApprovalKeys
clientApprovalKeys
protected ClientKeys
clientKeys
static String
UTF8_ENCODING
-
Constructor Summary
Constructors Constructor Description DIServiceSerializer(ClientKeys cKeys, ClientApprovalKeys caKeys)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkForStatus(String head, String tail)
Checks the status line in the serialized object for error codes and throws a corresponding exception.String
decode(String x)
protected String
encode(String x)
protected String
encode(URI x)
protected void
onlyPrintIfNotTrivial(PrintWriter w, String key, String value)
protected String[]
parseLine(String linein)
protected void
print(PrintWriter w, String key, edu.uiuc.ncsa.security.core.Identifier identifier)
void
print(PrintWriter w, String key, Object value)
void
print(PrintWriter w, String key, String value)
protected void
print(PrintWriter w, String key, URI uri)
protected void
print(PrintWriter w, String key, Date date)
int
readResponseOnly(InputStream is)
boolean
reponseOk(InputStream is)
Checks that the serialized content of the input stream has an ok as its status.void
serialize(PrintWriter w, Map<String,Object> map)
void
serialize(PrintWriter w, OA2ServiceTransaction oa2ServiceTransaction, int status)
void
serialize(PrintWriter w, OA2ServiceTransaction oa2ServiceTransaction, Err errResponse)
protected String[]
splitLine(String linein)
void
writeMessage(PrintWriter w, int statusCode)
void
writeMessage(PrintWriter w, String message)
void
writeMessage(PrintWriter w, Err errResponse)
-
-
-
Field Detail
-
UTF8_ENCODING
public static final String UTF8_ENCODING
- See Also:
- Constant Field Values
-
clientKeys
protected ClientKeys clientKeys
-
clientApprovalKeys
protected ClientApprovalKeys clientApprovalKeys
-
-
Constructor Detail
-
DIServiceSerializer
public DIServiceSerializer(ClientKeys cKeys, ClientApprovalKeys caKeys)
-
-
Method Detail
-
writeMessage
public void writeMessage(PrintWriter w, String message) throws IOException
- Throws:
IOException
-
writeMessage
public void writeMessage(PrintWriter w, int statusCode) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, Map<String,Object> map) throws IOException
- Throws:
IOException
-
onlyPrintIfNotTrivial
protected void onlyPrintIfNotTrivial(PrintWriter w, String key, String value) throws IOException
- Throws:
IOException
-
reponseOk
public boolean reponseOk(InputStream is) throws IOException
Checks that the serialized content of the input stream has an ok as its status. This ignores the rest of the stream and discards it! Only use when you are sure there is nothing else to parse, but want to check that an operation worked. If there are other status codes, this will throw an exception corresponding to the error.- Parameters:
is
-- Returns:
- Throws:
Exception
IOException
-
readResponseOnly
public int readResponseOnly(InputStream is) throws IOException
- Throws:
IOException
-
splitLine
protected String[] splitLine(String linein) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
parseLine
protected String[] parseLine(String linein) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
checkForStatus
protected void checkForStatus(String head, String tail)
Checks the status line in the serialized object for error codes and throws a corresponding exception. If the status is ok, the call succeeds.- Parameters:
head
-tail
-
-
encode
protected String encode(String x) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
encode
protected String encode(URI x) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
decode
public String decode(String x) throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
-
print
protected void print(PrintWriter w, String key, edu.uiuc.ncsa.security.core.Identifier identifier) throws IOException
- Throws:
IOException
-
print
protected void print(PrintWriter w, String key, URI uri) throws IOException
- Throws:
IOException
-
print
protected void print(PrintWriter w, String key, Date date) throws IOException
- Throws:
IOException
-
print
public void print(PrintWriter w, String key, String value) throws IOException
- Throws:
IOException
-
print
public void print(PrintWriter w, String key, Object value) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, OA2ServiceTransaction oa2ServiceTransaction, int status) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, OA2ServiceTransaction oa2ServiceTransaction, Err errResponse) throws IOException
- Throws:
IOException
-
writeMessage
public void writeMessage(PrintWriter w, Err errResponse) throws IOException
- Throws:
IOException
-
-