use of com.sun.identity.saml.protocol.StatusCode in project OpenAM by OpenRock.
the class FSLogoutResponse method parseURLEncodedRequest.
/**
* Returns <code>FSLogoutResponse</code> object. The
* object is creating by parsing the <code>HttpServletRequest</code>
* object.
*
* @param request the <code>HttpServletRequest</code> object.
* @throws FSMsgException if there is an error creating this object.
* @throws SAMLException if there is an error.
*/
public static FSLogoutResponse parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
FSLogoutResponse retLogoutResponse = new FSLogoutResponse();
try {
FSUtils.debug.message("checking minor version");
retLogoutResponse.majorVersion = Integer.parseInt(request.getParameter(IFSConstants.MAJOR_VERSION));
retLogoutResponse.minorVersion = Integer.parseInt(request.getParameter(IFSConstants.MINOR_VERSION));
} catch (NumberFormatException ex) {
throw new FSMsgException("invalidNumber", null);
}
String requestID = request.getParameter(IFSConstants.RESPONSE_ID);
if (requestID != null) {
retLogoutResponse.responseID = requestID;
} else {
String[] args = { IFSConstants.RESPONSE_ID };
throw new FSMsgException("missingAttribute", args);
}
retLogoutResponse.inResponseTo = request.getParameter(IFSConstants.IN_RESPONSE_TO);
String instantString = request.getParameter(IFSConstants.ISSUE_INSTANT);
if (instantString == null || instantString.length() == 0) {
String[] args = { IFSConstants.ISSUE_INSTANT };
throw new FSMsgException("missingAttribute", args);
}
try {
retLogoutResponse.issueInstant = DateUtils.stringToDate(instantString);
} catch (ParseException e) {
throw new FSMsgException("parseError", null);
}
FSUtils.debug.message(" get provider Id");
String providerID = request.getParameter(IFSConstants.PROVIDER_ID);
if (providerID != null) {
retLogoutResponse.providerId = providerID;
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("ProviderID : " + retLogoutResponse.providerId);
}
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("ProviderID : " + retLogoutResponse.providerId);
}
throw new FSMsgException("missingElement", null);
}
String relayState = request.getParameter(IFSConstants.RELAY_STATE);
if (relayState != null) {
retLogoutResponse.relayState = relayState;
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("RelayState:" + retLogoutResponse.relayState);
}
}
String value = request.getParameter(IFSConstants.VALUE);
if (value != null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Status : " + value);
}
StatusCode statusCode = new StatusCode(value);
retLogoutResponse.status = new Status(statusCode);
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("Status : " + value);
}
throw new FSMsgException("missingElement", null);
}
FSUtils.debug.message("Returning Logout response Object");
return retLogoutResponse;
}
Aggregations