Skip to content
This repository has been archived by the owner on Jan 17, 2022. It is now read-only.

HTTP/1.1 500 Internal Server Error #10

Open
gabicavalcante opened this issue Mar 1, 2018 · 2 comments
Open

HTTP/1.1 500 Internal Server Error #10

gabicavalcante opened this issue Mar 1, 2018 · 2 comments

Comments

@gabicavalcante
Copy link

Hello,

I'm trying tu run the project, but always I get "HTTP/1.1 500 Internal Server Error".

My code:

import java.io.IOException;
import java.io.InputStream;

import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;

import de.tudarmstadt.ukp.shibhttpclient.ShibHttpClient;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient; 
import org.apache.http.client.methods.HttpGet; 
 

public class Main {
	
	private static final String Username = "...";
	private static final String Password = "..."; 
	private static final String IdpUrl = "https://<idp>/profile/SAML2/SOAP/ECP"; 
	private static final String protected_url = "https://<sp>/secure/index.php";  

	public static void main(String[] args) throws ConfigurationException, ClientProtocolException, IOException { 
		DefaultBootstrap.bootstrap();
		
		HttpClient client = new ShibHttpClient(IdpUrl, Username, Password, true);
		
		try {
			HttpGet req = new HttpGet(protected_url);
			System.out.println(req.toString());
			HttpResponse res = client.execute(req);
			
			InputStream output = res.getEntity().getContent(); // returns an InputStream
			System.out.println(output.read());
		} finally { 
	    }
	}

}

My Idp log:

2018-03-01 16:58:03,477 - DEBUG [org.opensaml.profile.action.impl.DecodeMessage:64] - Profile Action DecodeMessage: Decoding message using message decoder of type org.opensaml.saml.saml2.binding.decoding.impl.HTTPSOAP11Decoder for this request
2018-03-01 16:58:03,481 - DEBUG [org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder:66] - Beginning to decode message from HttpServletRequest
2018-03-01 16:58:03,481 - DEBUG [org.opensaml.messaging.decoder.servlet.BaseHttpServletRequestXMLMessageDecoder:68] - HttpServletRequest indicated Content-Type: text/plain; charset=ISO-8859-1
2018-03-01 16:58:03,482 - WARN [org.opensaml.soap.soap11.decoder.http.impl.HTTPSOAP11Decoder:146] - Saw unsupported request Content-Type: text/plain; charset=ISO-8859-1
2018-03-01 16:58:03,491 - ERROR [org.opensaml.profile.action.impl.DecodeMessage:73] - Profile Action DecodeMessage: Unable to decode incoming request
org.opensaml.messaging.decoder.MessageDecodingException: Content-Type 'text/plain; charset=ISO-8859-1' was not a supported media type
	at org.opensaml.soap.soap11.decoder.http.impl.HTTPSOAP11Decoder.validateHttpRequest(HTTPSOAP11Decoder.java:147)
2018-03-01 16:58:03,499 - WARN [org.opensaml.profile.action.impl.LogEvent:105] - A non-proceed event occurred while processing the request: UnableToDecode
2018-03-01 16:58:03,503 - DEBUG [net.shibboleth.idp.saml.saml2.profile.config.logic.SOAPErrorPredicate:73] - No RelyingPartyContext found, assuming error handled with SOAP fault
2018-03-01 16:58:03,505 - DEBUG [net.shibboleth.idp.saml.profile.impl.InitializeOutboundMessageContextForError:191] - Profile Action InitializeOutboundMessageContextForError: Initialized outbound message context for error delivery
2018-03-01 16:58:03,510 - DEBUG [org.opensaml.soap.soap11.profile.impl.AddSOAPFault:192] - Profile Action AddSOAPFault: Detailed errors are disabled
2018-03-01 16:58:03,510 - DEBUG [org.opensaml.soap.soap11.profile.impl.AddSOAPFault:251] - Profile Action AddSOAPFault: Failed to resolve any Fault instance via context strategy
2018-03-01 16:58:03,511 - DEBUG [org.opensaml.soap.soap11.profile.impl.AddSOAPFault:289] - Profile Action AddSOAPFault: Setting faultstring to defaulted value
2018-03-01 16:58:03,513 - DEBUG [net.shibboleth.idp.saml.profile.impl.SpringAwareMessageEncoderFactory:100] - Looking up message encoder based on binding URI: urn:oasis:names:tc:SAML:2.0:bindings:PAOS
2018-03-01 16:58:03,514 - DEBUG [org.opensaml.profile.action.impl.EncodeMessage:128] - Profile Action EncodeMessage: Encoding outbound response using message encoder of type org.opensaml.saml.saml2.binding.encoding.impl.HTTPSOAP11Encoder for this response
2018-03-01 16:58:03,514 - DEBUG [org.opensaml.profile.action.impl.EncodeMessage:132] - Profile Action EncodeMessage: Encoder was not initialized, injecting MessageContext and initializing
2018-03-01 16:58:03,515 - DEBUG [org.opensaml.soap.soap11.encoder.http.impl.HTTPSOAP11Encoder:83] - Saw SOAP 1.1 Fault payload with fault code, replacing any existing context message: {http://schemas.xmlsoap.org/soap/envelope/}Client
2018-03-01 16:58:03,515 - DEBUG [org.opensaml.profile.action.impl.EncodeMessage:143] - Profile Action EncodeMessage: Invoking message handler of type org.opensaml.messaging.handler.impl.BasicMessageHandlerChain for this response
2018-03-01 16:58:03,516 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,523 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,523 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,524 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,524 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,524 - DEBUG [org.opensaml.messaging.handler.AbstractMessageHandler:148] - Message Handler:  Activation condition for handler returned true
2018-03-01 16:58:03,525 - DEBUG [org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder:96] - Marshalling message
2018-03-01 16:58:03,525 - DEBUG [org.opensaml.core.xml.util.XMLObjectSupport:302] - Marshalling XMLObject
2018-03-01 16:58:03,533 - DEBUG [org.opensaml.core.xml.util.XMLObjectSupport:302] - Marshalling XMLObject
2018-03-01 16:58:03,534 - DEBUG [org.opensaml.core.xml.util.XMLObjectSupport:305] - XMLObject already had cached DOM, returning that element
2018-03-01 16:58:03,534 - DEBUG [PROTOCOL_MESSAGE:70] - 
<?xml version="1.0" encoding="UTF-8"?>
<soap11:Envelope xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/">
    <soap11:Body>
        <soap11:Fault>
            <faultcode>soap11:Client</faultcode>
            <faultstring>An error occurred.</faultstring>
        </soap11:Fault>
    </soap11:Body>
</soap11:Envelope>

2018-03-01 16:58:03,539 - DEBUG [org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder:54] - Successfully encoded message.
2018-03-01 16:58:03,539 - DEBUG [org.opensaml.profile.action.impl.EncodeMessage:154] - Profile Action EncodeMessage: Outbound message was encoded from protocol-specific data rather than MessageContext#getMessage()
2018-03-01 16:58:03,542 - DEBUG [net.shibboleth.idp.profile.impl.RecordResponseComplete:89] - Profile Action RecordResponseComplete: Record response complete
2018-03-01 16:58:03,543 - INFO [Shibboleth-Audit.SSO:241] - 20180301T195803Z||||http://shibboleth.net/ns/profiles/saml2/sso/ecp|||||||||
2018-03-01 16:58:03,543 - DEBUG [org.opensaml.profile.action.AbstractConditionalProfileAction:79] - Profile Action WriteFTICKSLog: Activation condition for action returned false
@reckart
Copy link
Member

reckart commented Mar 2, 2018

I would love to help, but it has been quite a while since I was working on this. Unfortunately, I have no idea what problem you are running into. However, if you manage to solve it, I would encourage you to post a message here explaining how you did it in case other people run into the same kind of trouble.

Good luck!

@gabicavalcante
Copy link
Author

When the code try to logging in to the IdP, It does not define the content-type. I added:

idpLoginRequest.addHeader(HttpHeaders.CONTENT_TYPE, "text/xml; charset=utf-8");

And now it's working

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants