use of com.sun.identity.federation.message.FSAuthnResponse in project OpenAM by OpenRock.
the class CDCServlet method createAuthnResponse.
private FSAuthnResponse createAuthnResponse(String providerID, String responseID, String inResponseTo, Status status, FSAssertion assertion, String relayState) throws SAMLException, FSMsgException {
List contents = new ArrayList(1);
contents.add(assertion);
FSAuthnResponse response = new FSAuthnResponse(null, inResponseTo, status, contents, relayState);
response.setProviderId(providerID);
return response;
}
use of com.sun.identity.federation.message.FSAuthnResponse in project OpenAM by OpenRock.
the class FSSSOAndFedHandler method processAuthnRequest.
/**
* Processes authentication request.
* @param authnRequest authentication request
* @param bPostAuthn <code>true</code> indicates it's post authentication;
* <code>false</code> indicates it's pre authentication.
*/
public void processAuthnRequest(FSAuthnRequest authnRequest, boolean bPostAuthn) {
FSUtils.debug.message("FSSSOAndFedHandler.processAuthnRequest: Called");
this.authnRequest = authnRequest;
String message = null;
String inResponseTo = authnRequest.getRequestID();
Status status = null;
FSAuthnResponse errResponse = null;
spEntityId = authnRequest.getProviderId();
try {
spDescriptor = metaManager.getSPDescriptor(realm, spEntityId);
spConfig = metaManager.getSPDescriptorConfig(realm, spEntityId);
if (!metaManager.isTrustedProvider(realm, hostedEntityId, spEntityId)) {
FSUtils.debug.error("FSSSOAndFedHandler.processAuthnRequest: " + "RemoteProvider is not trusted");
message = FSUtils.bundle.getString("AuthnRequestProcessingFailed");
status = new Status(new StatusCode("samlp:Responder"), message, null);
errResponse = new FSAuthnResponse(null, inResponseTo, status, null, relayState);
errResponse.setMinorVersion(authnRequest.getMinorVersion());
sendAuthnResponse(errResponse);
return;
}
if (bPostAuthn) {
if (processPostAuthnSSO(authnRequest)) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOAndFedHandler." + "processAuthnRequest: AuthnRequest Processing " + "successful");
}
return;
} else {
if (FSUtils.debug.warningEnabled()) {
FSUtils.debug.warning("FSSSOAndFedHandler.processAuthnRequest: " + "AuthnRequest Processing failed");
}
message = FSUtils.bundle.getString("AuthnRequestProcessingFailed");
if (noFedStatus != null) {
status = noFedStatus;
} else {
status = new Status(new StatusCode("samlp:Responder"), message, null);
}
errResponse = new FSAuthnResponse(null, inResponseTo, status, null, relayState);
errResponse.setMinorVersion(authnRequest.getMinorVersion());
sendAuthnResponse(errResponse);
return;
}
} else {
boolean authnRequestSigned = spDescriptor.isAuthnRequestsSigned();
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOAndFedHandler.processAuthnRequest: " + "ProviderID : " + spEntityId + " AuthnRequestSigned :this is for testing " + authnRequestSigned);
}
if (FSServiceUtils.isSigningOn()) {
if (authnRequestSigned) {
//verify request signature
if (!verifyRequestSignature(authnRequest)) {
FSUtils.debug.error("FSSSOAndFedHandler." + "processAuthnRequest: " + "AuthnRequest Signature Verification Failed");
message = FSUtils.bundle.getString("signatureVerificationFailed");
String[] data = { message };
LogUtil.error(Level.INFO, LogUtil.SIGNATURE_VERIFICATION_FAILED, data, ssoToken);
status = new Status(new StatusCode("samlp:Responder", new StatusCode("lib:UnsignedAuthnRequest", null)), message, null);
errResponse = new FSAuthnResponse(null, inResponseTo, status, null, relayState);
errResponse.setMinorVersion(authnRequest.getMinorVersion());
sendAuthnResponse(errResponse);
return;
} else {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOAndFedHandler. processAuthnRequest" + ": AuthnRequest Signature Verified");
}
}
}
}
if (processPreAuthnSSO(authnRequest)) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOAndFedHandler.processAuthnRequest: " + "AuthnRequest Processing successful");
}
return;
} else {
if (FSUtils.debug.warningEnabled()) {
FSUtils.debug.warning("FSSSOAndFedHandler.processAuthnRequest: " + "AuthnRequest Processing failed");
}
String[] data = { FSUtils.bundle.getString("AuthnRequestProcessingFailed") };
LogUtil.error(Level.INFO, LogUtil.AUTHN_REQUEST_PROCESSING_FAILED, data, ssoToken);
message = FSUtils.bundle.getString("AuthnRequestProcessingFailed");
status = new Status(new StatusCode("samlp:Responder"), message, null);
if (noFedStatus != null) {
status = noFedStatus;
}
errResponse = new FSAuthnResponse(null, inResponseTo, status, null, relayState);
errResponse.setMinorVersion(authnRequest.getMinorVersion());
sendAuthnResponse(errResponse);
return;
}
}
} catch (Exception e) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
e.printStackTrace(new PrintStream(out));
FSUtils.debug.error("FSSSOAndFedHandler.processAuthnRequest: " + "Exception Occured: " + e.getMessage() + "Stack trace is " + out.toString());
message = FSUtils.bundle.getString("AuthnRequestProcessingFailed");
try {
status = new Status(new StatusCode("samlp:Responder"), message, null);
errResponse = new FSAuthnResponse(null, inResponseTo, status, null, relayState);
errResponse.setMinorVersion(authnRequest.getMinorVersion());
sendAuthnResponse(errResponse);
} catch (Exception ex) {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOAndFedHandler.processAuthnRequest: " + "Exception Occured: ", ex);
}
}
}
}
use of com.sun.identity.federation.message.FSAuthnResponse in project OpenAM by OpenRock.
the class FSSSOBrowserPostProfileHandler method doSingleSignOn.
protected boolean doSingleSignOn(Object ssoToken, String inResponseTo, NameIdentifier spHandle, NameIdentifier idpHandle) {
FSUtils.debug.message("FSSSOBrowserPostProfileHandler.doSingleSignOn: Called");
this.ssoToken = ssoToken;
FSAuthnResponse authnResponse = createAuthnResponse(ssoToken, inResponseTo, spHandle, idpHandle);
try {
if (FSUtils.debug.messageEnabled()) {
FSUtils.debug.message("FSSSOBrowserPostProfileHandler.doSingleSignOn: " + "AuthnResponse created: " + authnResponse.toXMLString());
}
} catch (FSException ex) {
FSUtils.debug.error("FSSSOBrowserPostProfileHandler.doSingleSignOn: " + "Created AuthnResponse is not valid: ", ex);
return false;
}
if (authnResponse == null) {
FSUtils.debug.error("FSSSOBrowserPostProfileHandler.doSingleSignOn: " + "No valid AuthnResponse could be created. " + "Sending error AuthnResponse");
return false;
}
sendAuthnResponse(authnResponse);
return true;
}
Aggregations