从wso2IS STS获取令牌时出错

时间:2017-04-23 19:58:18

标签: wso2 saml-2.0 wso2is wso2as

我正在尝试从wso2示例运行Sample STS客户端 我创建了具有常驻身份提供者和服务提供者的Identity Server。

我遵循了以下教程

https://docs.wso2.com/display/IS530/Configuring+an+Identity+Provider#ConfiguringanIdentityProvider-Configuringaresidentidentityprovider
https://docs.wso2.com/display/IS530/Configuring+WS-Trust+STS
https://docs.wso2.com/display/IS510/Configuring+a+Service+Provider#ConfiguringaServiceProvider-Addingaserviceprovider

org.apache.rahas.TrustException: Error in obtaining token from : "https://localhost:9443/services/wso2carbon-sts"
    at org.apache.rahas.client.STSClient.requestSecurityToken(STSClient.java:174)
    at org.apache.rahas.client.STSClient.requestSecurityToken(STSClient.java:182)
    at org.wso2.carbon.identity.samples.sts.Client.run(Client.java:131)
    at org.wso2.carbon.identity.samples.sts.Client.main(Client.java:94)
Caused by: org.apache.axis2.AxisFault: Error in hostname verification
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:199)
    at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:451)
    at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:278)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
    at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:430)
    at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:225)
    at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
    at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:554)
    at org.apache.rahas.client.STSClient.requestSecurityToken(STSClient.java:165)
    ... 3 more
Caused by: javax.net.ssl.SSLException: Error in hostname verification
    at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.verifyHostname(TLSProtocolSocketFactory.java:241)
    at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.createSocket(TLSProtocolSocketFactory.java:194)
    at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
    at org.apache.commons.httpclient.MultiThreadedHttpConnectionManager$HttpConnectionAdapter.open(MultiThreadedHttpConnectionManager.java:1361)
    at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
    at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
    at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
    at org.apache.axis2.transport.http.AbstractHTTPSender.executeMethod(AbstractHTTPSender.java:630)
    at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:195)
    ... 12 more
Caused by: java.lang.NoSuchMethodError: org.bouncycastle.asn1.ASN1InputStream.readObject()Lorg/bouncycastle/asn1/ASN1Primitive;
    at org.opensaml.xml.security.x509.X509Util.getCommonNames(X509Util.java:162)
    at org.opensaml.xml.security.x509.tls.StrictHostnameVerifier.check(StrictHostnameVerifier.java:47)
    at org.apache.commons.ssl.HostnameVerifier$AbstractVerifier.verify(HostnameVerifier.java:244)
    at org.opensaml.ws.soap.client.http.TLSProtocolSocketFactory.verifyHostname(TLSProtocolSocketFactory.java:232)
    ... 20 more

这是我的完整代码
https://github.com/muke5hy/Axis2Client-wso2IS.git

1 个答案:

答案 0 :(得分:0)

您的问题在于依赖项,请查看此pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.Axis2Client</groupId>
  <artifactId>Axis2Client</artifactId>
  <version>1.0.0</version>
  <packaging>service/axis2</packaging>
  <name>Axis2Client</name>
  <description>Axis2Client</description>
  <properties>
    <joda.wso2.version>2.8.2.wso2v1</joda.wso2.version>
    <wss4j.wso2.version>1.5.11.wso2v16</wss4j.wso2.version>
    <axis2.client.version>1.6.1.wso2v12</axis2.client.version>
    <axis2.jibx.wso2.version>1.6.1.wso2v11</axis2.jibx.wso2.version>
    <openws.version>1.5.4</openws.version>
    <XmlSchema.version>1.4.7.wso2v3</XmlSchema.version>
    <sevlet.api.version>2.5</sevlet.api.version>
    <testng.version>6.1.1</testng.version>
    <carbon.kernel.version>4.4.11</carbon.kernel.version>
    <commons.codec.version>1.8</commons.codec.version>
    <junit.version>3.8.1</junit.version>
    <httpclient.version>4.3.3</httpclient.version>
    <securevault.wso2.version>1.0.0</securevault.wso2.version>
    <xercesImpl.version>2.8.1</xercesImpl.version>
    <axiom.impl.version>1.2.12</axiom.impl.version>
    <identity.user.ws.version>5.1.4</identity.user.ws.version>
    <wsdl4j.version>1.6.2.wso2v2</wsdl4j.version>
    <neethi.wso2.version>2.0.4.wso2v5</neethi.wso2.version>
    <slf4j.version>1.7.0</slf4j.version>
    <taglibs.version>1.1.2</taglibs.version>
    <commons.httpclient.version>3.1</commons.httpclient.version>
    <rampart.wso2.version>1.6.1.wso2v24</rampart.wso2.version>
    <axiom.wso2.version>1.2.11.wso2v10</axiom.wso2.version>
    <xmlsec.version>1.4.4</xmlsec.version>
    <version.commons.logging>1.1.1</version.commons.logging>
    <rampart.wso2.version.1>1.6.1-wso2v23</rampart.wso2.version.1>
    <jstl.version>1.1.2</jstl.version>
    <httpcore.wso2.version>4.3.3.wso2v1</httpcore.wso2.version>
    <axis2.wso2.version>1.6.1.wso2v12</axis2.wso2.version>
    <orbit.version.commons.httpclient>4.2.5.wso2v1</orbit.version.commons.httpclient>
    <opensaml2.wso2.version>2.6.4.wso2v3</opensaml2.wso2.version>
    <xmltooling.version>1.3.1</xmltooling.version>
    <opensaml.version>2.6.4</opensaml.version>
    <axis2.jaxb.wso2.version>1.6.1.wso2v11</axis2.jaxb.wso2.version>
    <axiom.version>1.2.11-wso2v6</axiom.version>
  </properties>
  <dependencies>
    <!--dependency>
      <groupId>org.apache.axis2.wso2</groupId>
      <artifactId>axis2-jibx</artifactId>
      <version>${axis2.jibx.wso2.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.apache.axis2.wso2</groupId>
      <artifactId>axis2-jaxbri</artifactId>
      <version>${axis2.jaxb.wso2.version}</version>
    </dependency-->
    <dependency>
      <groupId>org.apache.axis2.wso2</groupId>
      <artifactId>axis2</artifactId>
      <version>${axis2.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom.wso2</groupId>
      <artifactId>axiom</artifactId>
      <version>${axiom.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <!--dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>${sevlet.api.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>jstl</artifactId>
      <version>${jstl.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>${taglibs.version}</version>
    </dependency-->
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>${version.commons.logging}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-impl</artifactId>
      <version>${axiom.impl.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.commons.axiom</groupId>
      <artifactId>axiom-api</artifactId>
      <version>${axiom.version}</version>
    </dependency>
    <dependency>
      <groupId>org.opensaml</groupId>
      <artifactId>opensaml</artifactId>
      <version>${opensaml.version}</version>
    </dependency>
    <!--dependency>
      <groupId>org.wso2.orbit.joda-time</groupId>
      <artifactId>joda-time</artifactId>
      <version>${joda.wso2.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.wso2.orbit.org.apache.neethi</groupId>
      <artifactId>neethi</artifactId>
      <version>${neethi.wso2.version}</version>
    </dependency-->
    <dependency>
      <groupId>org.apache.neethi.wso2</groupId>
      <artifactId>neethi</artifactId>
      <version>2.0.4.wso2v4</version>
    </dependency>
    <!--dependency>
      <groupId>org.wso2.orbit.org.opensaml</groupId>
      <artifactId>opensaml</artifactId>
      <version>${opensaml2.wso2.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.wso2.carbon</groupId>
      <artifactId>org.wso2.carbon.addressing</artifactId>
      <version>${carbon.kernel.version}</version>
    </dependency-->
    <dependency>
      <groupId>org.apache.rampart.wso2</groupId>
      <artifactId>rampart-core</artifactId>
      <version>${rampart.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.rampart.wso2</groupId>
      <artifactId>rampart-policy</artifactId>
      <version>${rampart.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.rampart.wso2</groupId>
      <artifactId>rampart-trust</artifactId>
      <version>${rampart.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.ws.security.wso2</groupId>
      <artifactId>wss4j</artifactId>
      <version>${wss4j.wso2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.httpcomponents.wso2</groupId>
      <artifactId>httpcore</artifactId>
      <version>${httpcore.wso2.version}</version>
    </dependency>
    <!--dependency>
      <groupId>org.wso2.carbon.identity.user.ws</groupId>
      <artifactId>org.wso2.carbon.um.ws.api.stub</artifactId>
      <version>${identity.user.ws.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.wso2.securevault</groupId>
      <artifactId>org.wso2.securevault</artifactId>
      <version>${securevault.wso2.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${httpclient.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
      <version>${commons.httpclient.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng.version}</version>
      <scope>test</scope>
    </dependency-->
    <dependency>
      <groupId>org.apache.rampart</groupId>
      <artifactId>rampart</artifactId>
      <version>${rampart.wso2.version.1}</version>
      <type>mar</type>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <!--dependency>
      <groupId>org.apache.httpcomponents.wso2</groupId>
      <artifactId>httpclient</artifactId>
      <version>${orbit.version.commons.httpclient}</version>
    </dependency-->
    <dependency>
      <groupId>org.apache.axis2.wso2</groupId>
      <artifactId>axis2-client</artifactId>
      <version>${axis2.client.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat.wso2</groupId>
      <artifactId>tomcat</artifactId>
      <version>7.0.52.wso2v5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.santuario</groupId>
      <artifactId>xmlsec</artifactId>
      <version>${xmlsec.version}</version>
    </dependency>
    <!--dependency>
      <groupId>org.opensaml</groupId>
      <artifactId>xmltooling</artifactId>
      <version>${xmltooling.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.opensaml</groupId>
      <artifactId>openws</artifactId>
      <version>${openws.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>xerces</groupId>
      <artifactId>xercesImpl</artifactId>
      <version>${xercesImpl.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>${commons.codec.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>org.apache.ws.commons.schema.wso2</groupId>
      <artifactId>XmlSchema</artifactId>
      <version>${XmlSchema.version}</version>
    </dependency-->
    <!--dependency>
      <groupId>wsdl4j.wso2</groupId>
      <artifactId>wsdl4j</artifactId>
      <version>${wsdl4j.version}</version>
    </dependency-->
  </dependencies>
  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
        <checksumPolicy>ignore</checksumPolicy>
      </releases>
      <id>wso2-nexus</id>
      <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
        <checksumPolicy>ignore</checksumPolicy>
      </releases>
      <id>wso2-nexus</id>
      <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <plugins>
      <plugin>
        <groupId>org.wso2.maven</groupId>
        <artifactId>maven-axis2-plugin</artifactId>
        <version>2.1.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>aar</id>
            <phase>package</phase>
            <goals>
              <goal>aar</goal>
            </goals>
          </execution>
        </executions>
        <configuration />
      </plugin>
      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <buildcommands>
            <buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
          </buildcommands>
          <projectnatures>
            <projectnature>org.wso2.developerstudio.eclipse.axis2.project.nature</projectnature>
            <projectnature>org.eclipse.jdt.core.javanature</projectnature>
          </projectnatures>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>Sign-Artifacts</id>
      <activation>
        <property>
          <name>sign</name>
        </property>
      </activation>
      <build>
        <plugins>
          <!--plugin>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>1.0-alpha-3</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin-->
        </plugins>
      </build>
    </profile>
  </profiles>
</project>

我的输出:

log4j:WARN No appenders could be found for logger (org.apache.axis2.deployment.FileSystemConfigurator).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="urn:uuid:B4D7B0EE29E065C5731493064516315" IssueInstant="2017-04-24T20:08:36.309Z" Version="2.0"><saml2:Issuer>https://localhost</saml2: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="#urn:uuid:B4D7B0EE29E065C5731493064516315">
<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>6+dLEPjOin1cVWYxCZ79tOX7rdk=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
LMZqT8ccsK+dcoG8CeDW9ohh1MjHBTPiprtYjbQmOL3QQJHmLap9WDJNxmLwKc1MkgQvn+3tyRsW
3D1F7Mf2fp8afBw/wMXJ8ArF20KoMjriO4zZQRQGE3FRMgmnofqE685xOPtc+IJC/9amaqm5ah1h
4DbHU1GkuDwcMCK3gqE=
</ds:SignatureValue>
<ds:KeyInfo><ds:X509Data><ds:X509Certificate>MIICNTCCAZ6gAwIBAgIES343gjANBgkqhkiG9w0BAQUFADBVMQswCQYDVQQGEwJVUzELMAkGA1UE
CAwCQ0ExFjAUBgNVBAcMDU1vdW50YWluIFZpZXcxDTALBgNVBAoMBFdTTzIxEjAQBgNVBAMMCWxv
Y2FsaG9zdDAeFw0xMDAyMTkwNzAyMjZaFw0zNTAyMTMwNzAyMjZaMFUxCzAJBgNVBAYTAlVTMQsw
CQYDVQQIDAJDQTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzENMAsGA1UECgwEV1NPMjESMBAGA1UE
AwwJbG9jYWxob3N0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCUp/oV1vWc8/TkQSiAvTou
sMzOM4asB2iltr2QKozni5aVFu818MpOLZIr8LMnTzWllJvvaA5RAAdpbECb+48FjbBe0hseUdN5
HpwvnH/DW8ZccGvk53I6Orq7hLCv1ZHtuOCokghz/ATrhyPq+QktMfXnRS4HrKGJTzxaCcU7OQID
AQABoxIwEDAOBgNVHQ8BAf8EBAMCBPAwDQYJKoZIhvcNAQEFBQADgYEAW5wPR7cr1LAdq+IrR44i
QlRG5ITCZXY9hI0PygLP2rHANh+PYfTmxbuOnykNGyhM6FjFLbW2uZHQTY1jMrPprjOrmyK5sjJR
O4d1DeGHT/YnIjs9JogRKv4XHECwLtIVdAbIdWHEtVZJyMSktcyysFcvuhPQK8Qc/E/Wq8uHSCo=</ds:X509Certificate></ds:X509Data></ds:KeyInfo></ds:Signature><saml2:Subject><saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">admin</saml2:NameID><saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"/></saml2:Subject><saml2:Conditions NotBefore="2017-04-24T20:08:36.309Z" NotOnOrAfter="2017-04-24T20:13:36.309Z"><saml2:AudienceRestriction><saml2:Audience>https://localhost:9446/services/HelloService/</saml2:Audience></saml2:AudienceRestriction></saml2:Conditions><saml2:AuthnStatement AuthnInstant="2017-04-24T20:08:36.315Z"><saml2:AuthnContext><saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml2:AuthnContextClassRef></saml2:AuthnContext></saml2:AuthnStatement></saml2:Assertion>
Response SAML 2.0 Token is valid