javax.xml.ws.WebServiceContext Java Examples

The following examples show how to use javax.xml.ws.WebServiceContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountServiceWSTest.java    From development with Apache License 2.0 7 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #2
Source File: CategorizationServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #3
Source File: InjectionHelper.java    From kumuluzee with MIT License 6 votes vote down vote up
public static void injectWebServiceContext(final Object instance, final WebServiceContext ctx) {
    final Class<?> instanceClass = instance.getClass();

    //method injection not supported!

    // inject @Resource
    final Field[] resourceAnnotatedFields = instanceClass.getDeclaredFields();
    for (Field field : resourceAnnotatedFields) {
        try {
            if (field.getDeclaredAnnotation(Resource.class) != null && field.getType() == WebServiceContext.class) {
                setField(instance, field, ctx);
            }
        } catch (Exception e) {
            throw new RuntimeException("Cannot inject @Resource annotated field: " + field, e);
        }
    }
}
 
Example #4
Source File: IdentityServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #5
Source File: XMLDocAuthenticator.java    From juddi with Apache License 2.0 6 votes vote down vote up
@Override
public UddiEntityPublisher identify(String authInfo, String authorizedName, WebServiceContext ctx) throws AuthenticationException {

        EntityManager em = PersistenceManager.getEntityManager();
        EntityTransaction tx = em.getTransaction();
        try {
                tx.begin();
                Publisher publisher = em.find(Publisher.class, authorizedName);
                if (publisher == null) {
                        throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
                }

                return publisher;
        } finally {
                if (tx.isActive()) {
                        tx.rollback();
                }
                em.close();
        }

}
 
Example #6
Source File: ReviewServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #7
Source File: SessionServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #8
Source File: MarketplaceServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #9
Source File: LdapSimpleAuthenticator.java    From juddi with Apache License 2.0 6 votes vote down vote up
public UddiEntityPublisher identify(String authInfo, String authorizedName, WebServiceContext ctx) throws AuthenticationException, FatalErrorException {
    EntityManager em = PersistenceManager.getEntityManager();
    EntityTransaction tx = em.getTransaction();
    try {
        tx.begin();
        Publisher publisher = em.find(Publisher.class, authorizedName);
        if (publisher == null)
            throw new UnknownUserException(new ErrorMessage("errors.auth.NoPublisher", authorizedName));
        return publisher;
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        em.close();
    }
}
 
Example #10
Source File: ServiceProvisioningServiceWSTest.java    From development with Apache License 2.0 6 votes vote down vote up
private WebServiceContext createWebServiceContextMock(String expectedIP,
        String expectedUser) {
    requestMock = mock(HttpServletRequest.class);
    when(requestMock.getRemoteAddr()).thenReturn(expectedIP);

    Principal principalMock = mock(Principal.class);
    when(principalMock.getName()).thenReturn(expectedUser);

    MessageContext msgContextMock = mock(MessageContext.class);
    when(msgContextMock.get(anyString())).thenReturn(requestMock);

    WebServiceContext wsContextMock = mock(WebServiceContext.class);
    when(wsContextMock.getUserPrincipal()).thenReturn(principalMock);
    when(wsContextMock.getMessageContext()).thenReturn(msgContextMock);

    return wsContextMock;
}
 
Example #11
Source File: InvokerTube.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #12
Source File: InvokerTube.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #13
Source File: InvokerTube.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #14
Source File: InvokerTube.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #15
Source File: EndpointImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testEndpointStop() throws Exception {
    String address = "http://localhost:8080/test";

    GreeterImpl greeter = new GreeterImpl();
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, (String)null)) {

        WebServiceContext ctx = greeter.getContext();
        assertNull(ctx);
        try {
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException)ex.getCause()).getCode());
        }
        ctx = greeter.getContext();

        assertNotNull(ctx);

        // Test that calling stop on the Endpoint works
        assertTrue(endpoint.isPublished());
        endpoint.stop();
        assertFalse(endpoint.isPublished());

        // Test that the Endpoint cannot be restarted.
        try {
            endpoint.publish(address);
            fail("stopped endpoint restarted.");
        } catch (IllegalStateException e) {
            // expected.
        }
    }
}
 
Example #16
Source File: TestContainer.java    From development with Apache License 2.0 5 votes vote down vote up
public TestContainer(TestPersistence persistence) throws Exception {
    this.persistence = persistence;
    this.sessionContext = new TestSessionContext(
            persistence.getTransactionManager(), sessionBeans);
    this.timerService = new TestTimerService();

    resources.put(SessionContext.class, sessionContext);
    resources.put(TimerService.class, timerService);
    resources.put(ConnectionFactory.class, new TestJMSConnectionFactory());
    resources.put(Queue.class, TestJMSQueue.getInstance());
    resources.put(WebServiceContext.class, new TestWebServiceContext(
            sessionContext));
    contextManager = new ContextManager(this);
    addBean(new TestEvent(contextManager));
}
 
Example #17
Source File: OrganizationalUnitServiceWSTest.java    From development with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
    service.WS_LOGGER = mock(WebServiceLogger.class);
    service.dataService = mock(DataService.class);
    service.wsContext = mock(WebServiceContext.class);
    service.localService = mock(UserGroupServiceLocalBean.class);
}
 
Example #18
Source File: KumuluzWebServiceContext.java    From kumuluzee with MIT License 5 votes vote down vote up
private WebServiceContext getWebServiceContext() {
    final WebServiceContext delegate = contexts.get();

    if (delegate == null) {
        throw new IllegalStateException();
    }

    return delegate;
}
 
Example #19
Source File: InvokerTube.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #20
Source File: InvokerTube.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public <T>void invokeAsyncProvider(Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt) throws IllegalAccessException, InvocationTargetException {
    Packet old = set(p);
    try {
        invoker.invokeAsyncProvider(p, arg, cbak, ctxt);
    } finally {
        set(old);
    }
}
 
Example #21
Source File: Invoker.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes {@link AsyncProvider#invoke(Object, AsyncProviderCallback, WebServiceContext)}
 */
public <T> void invokeAsyncProvider( @NotNull Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt ) throws IllegalAccessException, InvocationTargetException {
    // default slow implementation that delegates to the other invoke method.
    invoke(p, asyncInvokeMethod, arg, cbak, ctxt);
}
 
Example #22
Source File: RenewOperation.java    From steady with Apache License 2.0 4 votes vote down vote up
RequestSecurityTokenResponseType renew(RequestSecurityTokenType request,
WebServiceContext context);
 
Example #23
Source File: Invoker.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Invokes {@link AsyncProvider#invoke(Object, AsyncProviderCallback, WebServiceContext)}
 */
public <T> void invokeAsyncProvider( @NotNull Packet p, T arg, AsyncProviderCallback cbak, WebServiceContext ctxt ) throws IllegalAccessException, InvocationTargetException {
    // default slow implementation that delegates to the other invoke method.
    invoke(p, asyncInvokeMethod, arg, cbak, ctxt);
}
 
Example #24
Source File: AnnotatedGreeterImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Resource
public void setContext(WebServiceContext ctx) {
    context = ctx;
}
 
Example #25
Source File: IssueSingleOperation.java    From steady with Apache License 2.0 4 votes vote down vote up
RequestSecurityTokenResponseType issueSingle(
RequestSecurityTokenType request,
WebServiceContext context);
 
Example #26
Source File: HttpNumberImpl.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected WebServiceContext getWebSercviceContext() {
    return aContext;
}
 
Example #27
Source File: IPResolver.java    From development with Apache License 2.0 4 votes vote down vote up
public static String resolveIpAddress(WebServiceContext wsContext) {
    HttpServletRequest request = (HttpServletRequest) wsContext
            .getMessageContext().get(MessageContext.SERVLET_REQUEST);
    return resolveIpAddress(request);
}
 
Example #28
Source File: KeyExchangeTokenOperation.java    From steady with Apache License 2.0 4 votes vote down vote up
RequestSecurityTokenResponseType keyExchangeToken(
RequestSecurityTokenType request,
WebServiceContext context);
 
Example #29
Source File: UDDISecurityImpl.java    From juddi with Apache License 2.0 4 votes vote down vote up
/**
 * used for unit tests only
 * @param ctx 
 */
protected UDDISecurityImpl(WebServiceContext ctx) {
    super();
    this.ctx = ctx;
    serviceCounter = ServiceCounterLifecycleResource.getServiceCounter(UDDISecurityImpl.class);
}
 
Example #30
Source File: DefaultResourceInjector.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void inject(@NotNull WSWebServiceContext context, @NotNull Object instance) {
    InjectionPlan.buildInjectionPlan(
        instance.getClass(),WebServiceContext.class,false).inject(instance,context);
}