неверное утверждение для подтверждения носителя SAML 2.0 для SalesForce.com - PullRequest
2 голосов
/ 07 марта 2012

Я пытаюсь сделать "Утверждение носителя SAML 2.0 для SalesForce"

Я получаю {"error": "invalid_grant", "error_description": "неверное утверждение"}

Есть ли способ проверить утверждение на предъявителя в salesforce?

Я сделал следующее в своем коде

String environment = "https://login.salesforce.com/services/oauth2/token?saml=MgoTx78aEPRbRaz0CkRqjaqrhP3sCa7w7.Y5wbrpGMNT07zKRYwcNWf0zs";
Map<String, String> map = new HashMap<String, String>();
HttpClient httpclient = new HttpClient();
PostMethod post = new PostMethod(environment);
post.addParameter("grant_type", "urn:ietf:params:oauth:grant-type:saml2-bearer");
post.addParameter("client_assertion", Base64.encode(samlResponse.getBytes()));
post.addParameter("client_assertion_type","urn:ietf:params:oauth:client_assertion_type:saml2-bearer");

post.addParameter("format", "json");
    String accessToken= null;
    String instanceUrl = null;
    try {
        httpclient.executeMethod(post);
        JSONObject authResponse = new JSONObject(new JSONTokener(new InputStreamReader(post.getResponseBodyAsStream())));
        System.out.println(authResponse.toString());


    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        post.releaseConnection();
    }

Я сгенерировал следующее утверждение

<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="s2d3a451cf30560ca819118cf5785e722ea6da7b64" IssueInstant="2012-03-06T12:34:13Z"
Version="2.0">
<saml:Issuer>http://localhost:8080/opensso
</saml:Issuer>
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <ds:SignedInfo>
        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
        <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
        <ds:Reference URI="#s2d3a451cf30560ca819118cf5785e722ea6da7b64">
            <ds:Transforms>
                <ds:Transform
            Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <ds:DigestValue>seHyxsFzsHCs0GaY7usF0DfMV58=
            </ds:DigestValue>
        </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue> signature.....</ds:SignatureValue>
    <ds:KeyInfo>
        <ds:X509Data>
            <ds:X509Certificate> certificate.....</ds:X509Certificate>
        </ds:X509Data>
    </ds:KeyInfo>
</ds:Signature>
<saml:Subject>
    <saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient"
        NameQualifier="http://localhost:8080/opensso" SPNameQualifier="https://saml.salesforce.com">deepakmule</saml:NameID>
    <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
        <saml:SubjectConfirmationData
            NotOnOrAfter="2012-03-06T12:44:13Z"
            Recipient="https://login.salesforce.com/?saml=MgoTx78aEPRbRaz0CkRqjaqrhP3sCa7w7.Y5wbrpGMNT07zKRYwcNWf0zs" />
    </saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2012-03-06T12:34:13Z"
    NotOnOrAfter="2012-03-06T12:44:13Z">
    <saml:AudienceRestriction>
        <saml:Audience>https://saml.salesforce.com</saml:Audience>
    </saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2012-03-06T12:34:13Z"
    SessionIndex="s27fb03a2b73bd8dc6846851bed7885b85e1d9ed6f">
    <saml:AuthnContext>
        <saml:AuthnContextClassRef>             urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
        </saml:AuthnContextClassRef>
    </saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
    <saml:Attribute Name="userid">
        <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">deepakmule</saml:AttributeValue>
    </saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>

1 Ответ

2 голосов
/ 12 марта 2012

Вы пытаетесь использовать тот же IDP, который вы настроили для единого входа для своей организации, или вы пытаетесь использовать сертификат, добавленный в приложение удаленного доступа?

Если вы пытаетесь использовать свойКонфигурация SSO, тогда это выглядит довольно хорошо - я бы проверил валидатор утверждений SAML

Если вы пытаетесь использовать поток Bearer с приложением удаленного доступа, то я бы посмотрел на следующее

1) Эмитентом должен быть ваш Ключ потребителя из приложения удаленного доступа (oauth client_id)

2) Публикация на нашей обычной конечной точке токена

3) Используйте имя пользователя salesforce каксубъект

4) Сократите время жизни вашего утверждения до минуты

...