use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSLogoutNotification method parseXML.
/**
* Constructor create <code>FSLogoutNotification</code> from a
* <code>XML</code> string.
*
* @param xml the <code>XML</code> string.
* @throws FSMsgException if there is an error creating
* this object.
*/
public static FSLogoutNotification parseXML(String xml) throws FSMsgException {
Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
if (doc == null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSLogoutNotification.parseXML:Error " + "while parsing input xml string");
}
throw new FSMsgException("parseError", null);
}
Element root = doc.getDocumentElement();
return new FSLogoutNotification(root);
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSAuthnResponse method parseAuthnResponseXML.
/**
* Creates <code>FSAuthnResponse</code> object from XML Schema.
*
* @param xml the XML Schema for this object.
* @throws <code>SAMLException</code> on error.
* @throws FSMsgException on error.
*/
public static FSAuthnResponse parseAuthnResponseXML(String xml) throws SAMLException, FSMsgException {
// parse the xml string
FSUtils.debug.message("FSAuthnResponse.parseAuthnResponseXML: Called");
Element root;
Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
if (doc == null) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAuthnResponse.parseXML:Error " + "while parsing input xml string");
}
throw new FSMsgException("parseError", null);
}
root = doc.getDocumentElement();
return new FSAuthnResponse(root);
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSAuthnResponseEnvelope method parseXML.
/**
* Returns the <code>FSAuthnResponseEnvelope</code> object.
*
* @param xml the XML string to create this object from
* @return <code>FSAuthnResponseEnvelope</code> object.
* @throws FSMsgException if there is error creating the object.
*/
public static FSAuthnResponseEnvelope parseXML(String xml) throws FSMsgException {
try {
Document doc = XMLUtils.toDOMDocument(xml, FSUtils.debug);
Element root = doc.getDocumentElement();
return new FSAuthnResponseEnvelope(root);
} catch (SAMLException ex) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSAuthnResponseEnvelope.parseXML: " + "Error while parsing input xml string");
}
throw new FSMsgException("parseError", null);
}
}
use of com.sun.identity.federation.message.common.FSMsgException in project OpenAM by OpenRock.
the class FSFederationTerminationNotification method parseURLEncodedRequest.
/**
* Returns <code>FSFederationTerminationNotification</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 <code>FSFederationTerminationNotification</code> object.
*/
public static FSFederationTerminationNotification parseURLEncodedRequest(HttpServletRequest request) throws FSMsgException, SAMLException {
FSFederationTerminationNotification retFederationTerminationNotification = new FSFederationTerminationNotification();
try {
FSUtils.debug.message("checking minor version");
retFederationTerminationNotification.majorVersion = Integer.parseInt(request.getParameter(IFSConstants.MAJOR_VERSION));
retFederationTerminationNotification.minorVersion = Integer.parseInt(request.getParameter(IFSConstants.MINOR_VERSION));
} catch (NumberFormatException ex) {
throw new FSMsgException("invalidNumber", null);
}
String requestID = request.getParameter(IFSConstants.REQUEST_ID);
if (request != null) {
retFederationTerminationNotification.requestID = requestID;
} else {
String[] args = { IFSConstants.REQUEST_ID };
throw new FSMsgException("missingAttribute", args);
}
String instantString = request.getParameter(IFSConstants.ISSUE_INSTANT);
if (instantString == null || instantString.length() == 0) {
String[] args = { IFSConstants.ISSUE_INSTANT };
throw new FSMsgException("missingAttribute", args);
}
try {
retFederationTerminationNotification.issueInstant = DateUtils.stringToDate(instantString);
} catch (ParseException e) {
throw new FSMsgException("parseError", null);
}
String providerID = request.getParameter(IFSConstants.PROVIDER_ID);
if (providerID != null) {
retFederationTerminationNotification.providerId = providerID;
} else {
throw new FSMsgException("missingElement", null);
}
String nameFormat = request.getParameter(IFSConstants.NAME_FORMAT);
String nameQualifier = request.getParameter(IFSConstants.NAME_QUALIFIER);
String name = request.getParameter("Name");
if (name == null) {
throw new FSMsgException("missingNameIdentifier", null);
}
String relayState = request.getParameter(IFSConstants.RELAY_STATE);
if (relayState != null) {
retFederationTerminationNotification.relayState = relayState;
}
retFederationTerminationNotification.nameIdentifier = new NameIdentifier(name, nameQualifier, nameFormat);
FSUtils.debug.message("Returning Termination Object");
return retFederationTerminationNotification;
}
use of com.sun.identity.federation.message.common.FSMsgException 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