Package org.cilogon.oauth2.servlet.util
Class DBServiceSerializer
- java.lang.Object
-
- org.cilogon.oauth2.servlet.util.DBServiceSerializer
-
- Direct Known Subclasses:
DBServiceSerializer2
public class DBServiceSerializer 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 static String
CILOGON_CALLBACK_URI
static String
CILOGON_FAILURE_URI
static String
CILOGON_PORTAL_NAME
static String
CILOGON_SUCCESS_URI
protected org.oa4mp.delegation.common.storage.clients.ClientApprovalKeys
clientApprovalKeys
protected org.oa4mp.delegation.common.storage.clients.ClientKeys
clientKeys
protected IDPKeys
idpKeys
protected TwoFactorSerializationKeys
tfKeys
protected UserKeys
userKeys
static String
UTF8_ENCODING
-
Constructor Summary
Constructors Constructor Description DBServiceSerializer(UserKeys userKeys, IDPKeys idpKeys, TwoFactorSerializationKeys tfk, org.oa4mp.delegation.common.storage.clients.ClientKeys cKeys, org.oa4mp.delegation.common.storage.clients.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)
List<IdentityProvider>
deserializeIdps(InputStream is)
edu.uiuc.ncsa.security.storage.XMLMap
deserializeToMap(InputStream is)
This takes the serialized payload and pulls it into a simple map.User
deserializeUser(InputStream is, User user)
This takes a user as the argument since the user requires a reference to the namespace resolution machinery of the server environment.edu.uiuc.ncsa.security.core.Identifier
deserializeUserID(InputStream is)
protected void
doUserSerialization(PrintWriter w, User user)
Override this method if you have to extend the user.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, edu.uiuc.ncsa.security.core.Identifier userid)
void
serialize(PrintWriter w, Collection<IdentityProvider> idps)
void
serialize(PrintWriter w, Map<String,Object> map)
void
serialize(PrintWriter w, TwoFactorInfo tfi, int statusCode)
void
serialize(PrintWriter w, User user, int statusCode)
void
serialize(PrintWriter w, User user, TwoFactorInfo tfi, int statusCode)
void
serialize(PrintWriter w, org.oa4mp.delegation.server.ServiceTransaction t)
protected void
setUserField(User user, String head, String tail)
protected String[]
splitLine(String linein)
void
writeMessage(PrintWriter w, int statusCode)
void
writeMessage(PrintWriter w, String message)
-
-
-
Field Detail
-
CILOGON_SUCCESS_URI
public static final String CILOGON_SUCCESS_URI
- See Also:
- Constant Field Values
-
CILOGON_FAILURE_URI
public static final String CILOGON_FAILURE_URI
- See Also:
- Constant Field Values
-
CILOGON_PORTAL_NAME
public static final String CILOGON_PORTAL_NAME
- See Also:
- Constant Field Values
-
CILOGON_CALLBACK_URI
public static final String CILOGON_CALLBACK_URI
- See Also:
- Constant Field Values
-
UTF8_ENCODING
public static final String UTF8_ENCODING
- See Also:
- Constant Field Values
-
userKeys
protected UserKeys userKeys
-
idpKeys
protected IDPKeys idpKeys
-
tfKeys
protected TwoFactorSerializationKeys tfKeys
-
clientKeys
protected org.oa4mp.delegation.common.storage.clients.ClientKeys clientKeys
-
clientApprovalKeys
protected org.oa4mp.delegation.common.storage.clients.ClientApprovalKeys clientApprovalKeys
-
-
Constructor Detail
-
DBServiceSerializer
public DBServiceSerializer(UserKeys userKeys, IDPKeys idpKeys, TwoFactorSerializationKeys tfk, org.oa4mp.delegation.common.storage.clients.ClientKeys cKeys, org.oa4mp.delegation.common.storage.clients.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
-
serialize
public void serialize(PrintWriter w, TwoFactorInfo tfi, int statusCode) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, User user, TwoFactorInfo tfi, int statusCode) throws IOException
- Throws:
IOException
-
doUserSerialization
protected void doUserSerialization(PrintWriter w, User user) throws IOException
Override this method if you have to extend the user. This is where the user is written- Parameters:
w
-user
-- Throws:
IOException
-
onlyPrintIfNotTrivial
protected void onlyPrintIfNotTrivial(PrintWriter w, String key, String value) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, User user, int statusCode) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, Collection<IdentityProvider> idps) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, edu.uiuc.ncsa.security.core.Identifier userid) throws IOException
- Throws:
IOException
-
serialize
public void serialize(PrintWriter w, org.oa4mp.delegation.server.ServiceTransaction t) throws IOException
- Throws:
IOException
-
deserializeToMap
public edu.uiuc.ncsa.security.storage.XMLMap deserializeToMap(InputStream is) throws IOException
This takes the serialized payload and pulls it into a simple map. This is mostly used to deserialize things that might not be available to a client, such as a server transaction.Caveats
- The status is always stored as a Long
- List values are stored as List<String>'s
- This never throws an exception if there is an issue. You must decide on the course of action from the returned status code.
- Parameters:
is
-- Returns:
- 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
-
deserializeUserID
public edu.uiuc.ncsa.security.core.Identifier deserializeUserID(InputStream is) throws IOException
- Throws:
IOException
-
deserializeUser
public User deserializeUser(InputStream is, User user) throws IOException, ParseException
This takes a user as the argument since the user requires a reference to the namespace resolution machinery of the server environment. It deserializes the stream into it, overwriting any of its content.- Parameters:
is
-user
-- Returns:
- Throws:
IOException
ParseException
-
setUserField
protected void setUserField(User user, String head, String tail) throws ParseException, UnsupportedEncodingException
-
deserializeIdps
public List<IdentityProvider> deserializeIdps(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
-
-