chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Srinivas Chivukula <schivuk...@gmail.com>
Subject Re: Fwd: how to send any element in wsse usernametoken
Date Tue, 06 Nov 2012 15:17:02 GMT
Hello Florian,
Do we have any example for the custom authentication?, I tried to create
custom authentication and use that but I am getting error that its missing
credentials
public static final String CUSTOM_AUTHENTICATION_PROVIDER =
"com.eohhs.cmis.example.MyAuthenticationProvider";

parameter.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS,CUSTOM_AUTHENTICATION_PROVIDER);
parameter.put("com.eohhs.cmis.example.user", "testuser"); //
MyAuthenticationProvider can get and evaluate this
parameter.put("com.eohhs.cmis.example.password", "testpassword");
parameter.put(SessionParameter.BINDING_TYPE,
BindingType.WEBSERVICES.value());
thanks
Srinivas

*MyAuthenticationProvider - Class*
package com.eohhs.cmis.example;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import
org.apache.chemistry.opencmis.client.bindings.spi.AbstractAuthenticationProvider;

public class MyAuthenticationProvider extends
AbstractAuthenticationProvider {

public String user, password;
@Override
public Map<String, List<String>> getHTTPHeaders(String url) {
 Map<String, List<String>> result = new HashMap<String, List<String>>();
// get user and password
               user = getUser();
               password = getPassword();
String appId="testappid";

                List<String> lUser = new ArrayList<String>();
 List<String> lPwd = new ArrayList<String>();
List<String> lappID = new ArrayList<String>();
               lUser.add(user);
lPwd.add(password);
lappID.add(appId);

result.put(org.apache.chemistry.opencmis.commons.SessionParameter.USER,
lUser);
 result.put(org.apache.chemistry.opencmis.commons.SessionParameter.PASSWORD,
lPwd);
result.put("mass.gov.eohhs.edm.edmAppID", lappID);
                return result;
//return super.getHTTPHeaders(url);
}
}




On Thu, Nov 1, 2012 at 4:11 PM, Florian Müller <fmui@apache.org> wrote:

> Hi Srinivas,
>
> It looks like your server is using Basic Authentication (or something
> similar). The status code 401 is not returned by the Web Services server,
> but by some other component that looks at the HTTP headers. Is this
> intentional? Do you have any reverse proxy in front of your service or some
> SSO setup in place?
>
> It may also use UsernameTokens but it doesn't seem to reach that check.
> OpenCMIS does also send Basic Authentication credentials, but it assumes
> that the UsernameTokens credentials and the Basic Authentication
> credentials are the same. If that's not the case, you have to code that
> into your own authentication provider.
>
>
> Florian
>
>
>  Hello Florian,
>> Thanks for the info, I still have some issue, I cant get the cmis client
>> to
>> send the username and password at all, I get authorization failed, below
>> is
>> the snippet of the code. please let me know if you see anything incorrect,
>> the user and password work fine if I use it in SoapUI, I checked the soap
>> xml at the CMIS Webservice and it does not have username and password tag
>> coming in at all
>> thanks
>> Srinivas
>>
>> SessionFactory f = SessionFactoryImpl.**newInstance();
>> Map<String, String>  parameter = new HashMap<String, String>();
>>   String wsdl = "http://IP:8100/cmis/services/**RepositoryService?wsdl<http://IP:8100/cmis/services/RepositoryService?wsdl>
>> ";
>>   parameter.put(**SessionParameter.USER, "username");
>> parameter.put(**SessionParameter.PASSWORD, "password");
>>   parameter.put(**SessionParameter.BINDING_TYPE,
>> BindingType.WEBSERVICES.value(**));
>> parameter.put(**SessionParameter.WEBSERVICES_**ACL_SERVICE, wsdl);
>>   parameter.put(**SessionParameter.WEBSERVICES_**DISCOVERY_SERVICE,
>> wsdl);
>> parameter.put(**SessionParameter.WEBSERVICES_**MULTIFILING_SERVICE,
>> wsdl);
>>   parameter.put(**SessionParameter.WEBSERVICES_**NAVIGATION_SERVICE,
>> wsdl);
>> parameter.put(**SessionParameter.WEBSERVICES_**OBJECT_SERVICE, wsdl);
>>   parameter.put(**SessionParameter.WEBSERVICES_**POLICY_SERVICE, wsdl);
>> parameter.put(**SessionParameter.WEBSERVICES_**RELATIONSHIP_SERVICE,
>> wsdl);
>>   parameter.put(**SessionParameter.WEBSERVICES_**REPOSITORY_SERVICE,
>> wsdl);
>> parameter.put(**SessionParameter.WEBSERVICES_**VERSIONING_SERVICE, wsdl);
>>   parameter.put(**SessionParameter.REPOSITORY_**ID, "repo_dev");
>> Session s = f.createSession(parameter);
>>   System.out.println("CMISTest.**main()"+s.getRepositoryInfo())**;
>> System.out.println("done!");
>>
>> Error:
>> Exception in thread "main"
>> org.apache.chemistry.opencmis.**commons.exceptions.**
>> CmisRuntimeException:
>> Error: The server sent HTTP status code 401: Unauthorized
>> at
>> org.apache.chemistry.opencmis.**client.bindings.spi.**webservices.**
>> RepositoryServiceImpl.**getRepositoryInfos(**
>> RepositoryServiceImpl.java:76)
>>   at
>> org.apache.chemistry.opencmis.**client.bindings.impl.**
>> RepositoryServiceImpl.**getRepositoryInfos(**
>> RepositoryServiceImpl.java:85)
>> at
>> org.apache.chemistry.opencmis.**client.runtime.**SessionFactoryImpl.**
>> getRepositories(**SessionFactoryImpl.java:111)
>>   at
>> org.apache.chemistry.opencmis.**client.runtime.**SessionFactoryImpl.**
>> getRepositories(**SessionFactoryImpl.java:98)
>> at com.eohhs.cmis.example.**CMISTest.main(CMISTest.java:**66)
>> Caused by: com.sun.xml.ws.client.**ClientTransportException: The server
>> sent
>> HTTP status code 401: Unauthorized
>> at
>> com.sun.xml.ws.transport.http.**client.HttpTransportPipe.**
>> checkStatusCode(**HttpTransportPipe.java:203)
>>   at
>> com.sun.xml.ws.transport.http.**client.HttpTransportPipe.**
>> process(HttpTransportPipe.**java:179)
>> at
>> com.sun.xml.ws.transport.http.**client.HttpTransportPipe.**
>> processRequest(**HttpTransportPipe.java:94)
>>   at
>> com.sun.xml.ws.transport.**DeferredTransportPipe.**processRequest(**
>> DeferredTransportPipe.java:**116)
>> at com.sun.xml.ws.api.pipe.Fiber.**__doRun(Fiber.java:598)
>>   at com.sun.xml.ws.api.pipe.Fiber.**_doRun(Fiber.java:557)
>> at com.sun.xml.ws.api.pipe.Fiber.**doRun(Fiber.java:542)
>>   at com.sun.xml.ws.api.pipe.Fiber.**runSync(Fiber.java:439)
>> at com.sun.xml.ws.client.Stub.**process(Stub.java:222)
>>   at com.sun.xml.ws.client.sei.**SEIStub.doProcess(SEIStub.**java:135)
>> at
>> com.sun.xml.ws.client.sei.**SyncMethodHandler.invoke(**
>> SyncMethodHandler.java:109)
>>   at
>> com.sun.xml.ws.client.sei.**SyncMethodHandler.invoke(**
>> SyncMethodHandler.java:89)
>> at com.sun.xml.ws.client.sei.**SEIStub.invoke(SEIStub.java:**118)
>>   at $Proxy40.getRepositories(**Unknown Source)
>> at
>> org.apache.chemistry.opencmis.**client.bindings.spi.**webservices.**
>> RepositoryServiceImpl.**getRepositoryInfos(Repository
>>
>>
>>
>>
>> On Wed, Oct 31, 2012 at 12:40 PM, Florian Müller<fmui@apache.org>  wrote:
>>
>>  Hi Srinivas,
>>>
>>> You need your own authentication provider for that.
>>>
>>> Have a look at this class:
>>> org.apache.chemistry.opencmis.****client.bindings.spi.**
>>>
>>> StandardAuthenticationProvider
>>>
>>> The getSOAPHeaders() method generates the SOAP header. It should be easy
>>> to add an additional tag there.
>>>
>>> You activate your custom authentication provider like this:
>>>
>>> parameter.put(****SessionParameter.****AUTHENTICATION_PROVIDER_CLASS,
>>> "com.example.custom.****authentication.provider");
>>>
>>>
>>> You can also add your custom session parameters (->  AppID) and access
>>> them
>>> in the authentication provider.
>>>
>>>
>>> - Florian
>>>
>>>
>>>
>>>   Hello I am new to this forum, If I have posted to the wrong address,
>>>
>>>> please
>>>> direct me to the correct forum, I am writing a client using apache
>>>> chemistry and I am having hard time in sending a custom element in the
>>>> username token
>>>>   <oas:UsernameToken>
>>>>   <oas:Username>myuser</oas:****Username>
>>>>                   <oas:Password>mypassword</oas:****Password>
>>>>                   <edm:AppID>testappid</edm:****AppID>
>>>>
>>>> </oas:UsernameToken>
>>>>
>>>> How do I send in the AppID in the UsernameToken element, below only has
>>>> USER and PASSWORD. the AppID is of a different namespace
>>>>
>>>> parameter.put(****SessionParameter.USER, "myuser");
>>>> parameter.put(****SessionParameter.PASSWORD, "mypassword");
>>>>
>>>>
>>>> your input is greatly appreciated.
>>>> thanks
>>>> --
>>>> Srinivas
>>>>
>>>>
>>>
>>
>>
>


-- 
Srinivas

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message