Package org.openengsb.core.api.remote

Examples of org.openengsb.core.api.remote.MethodCallMessage


    }

    private static MethodResult call(MethodCall call, String username, Object credentails) throws IOException,
        JMSException, InterruptedException, ClassNotFoundException, EncryptionException, DecryptionException {
        MethodCallMessage methodCallRequest = new MethodCallMessage(call);
        SecretKey sessionKey = CipherUtils.generateKey("AES", 128);
        String requestString = marshalRequest(methodCallRequest, sessionKey, username, credentails);
        String resultString = sendMessage(requestString);
        return convertStringToResult(resultString, sessionKey);
    }
View Full Code Here


        producer = session.createProducer(destination);
    }

    private static MethodResult call(MethodCall call, String username, Object credentials) throws IOException,
        JMSException, InterruptedException, ClassNotFoundException, EncryptionException, DecryptionException {
        MethodCallMessage methodCallRequest = new MethodCallMessage(call);
        String requestString = marshalSecureRequest(methodCallRequest, username, credentials);
        sendMessage(requestString);
        String resultString = getResultFromQueue(methodCallRequest.getCallId());
        return convertStringToResult(resultString);
    }
View Full Code Here

    private final ObjectMapper mapper = new ObjectMapper();

    @Override
    protected byte[] doFilter(byte[] input, Map<String, Object> metaData) {
        MethodCallMessage request;
        try {
            LOGGER.trace("attempt to read SecureRequest from inputData");
            request = mapper.readValue(input, MethodCallMessage.class);
        } catch (IOException e) {
            throw new FilterException(e);
        }
        String callId = request.getCallId();
        LOGGER.info("extracted callId \"{}\" from message", callId);
        metaData.put("callId", callId);
        LOGGER.debug("converting arguments of inputmessage");
        JsonUtils.convertAllArgs(request);
        LOGGER.debug("invoking next filter: {}", next.getClass().getName());
View Full Code Here

        }
    }

    @Override
    public Document doFilter(Document input, Map<String, Object> metadata) throws FilterException {
        MethodCallMessage call;
        try {
            call = parseMethodCall(input);
        } catch (JAXBException e) {
            throw new FilterException(e);
        }
View Full Code Here

        }
        return (Document) domResult.getNode();
    }

    private MethodCallMessage parseMethodCall(Document input) throws JAXBException {
        MethodCallMessage request = unmarshaller.unmarshal(input, MethodCallMessage.class).getValue();
        MethodCall result = request.getMethodCall();
        List<String> classNames = result.getClasses();
        Class<?>[] clazzes = new Class<?>[classNames.size()];
        ClassLoader cl = this.getClass().getClassLoader();
        for (int i = 0; i < classNames.size(); i++) {
            try {
View Full Code Here

    protected abstract MethodResultMessage decryptAndDecode(EncodingType message, SecretKey sessionKey)
        throws Exception;

    @Test
    public void testProcessMethodCall_shouldReturnOriginalArgAsResult() throws Exception {
        MethodCallMessage secureRequest = prepareSecureRequest();

        MethodResultMessage response = processRequest(secureRequest);

        MethodResultMessage mr = response;
        assertThat((String) mr.getResult().getArg(), is(METHOD_ARG));
View Full Code Here

        return prepareSecureRequest("test", new Password("password"));
    }

    private MethodCallMessage prepareSecureRequest(String username, Object credentials) {
        MethodCall methodCall = new MethodCall("doSomething", new Object[]{ METHOD_ARG, });
        MethodCallMessage request = new MethodCallMessage(methodCall, "c42");
        request.setPrincipal(username);
        request.setCredentials(BeanDescription.fromObject(credentials));
        return request;
    }
View Full Code Here

    @Test
    public void testInvalidAuthentication_shouldNotInvokeRequestHandler() throws Exception {
        when(authManager.authenticate(anyString(), any(Credentials.class))).thenThrow(
            new AuthenticationException("bad"));
        MethodCallMessage secureRequest = prepareSecureRequest();
        try {
            processRequest(secureRequest);
            fail("Expected exception");
        } catch (FilterException e) {
            assertThat(e.getCause(), is(org.apache.shiro.authc.AuthenticationException.class));
View Full Code Here

        verify(requestHandler, never()).handleCall(any(MethodCall.class));
    }

    @Test
    public void testManipulateMessage_shouldCauseVerificationException() throws Exception {
        MethodCallMessage secureRequest = prepareSecureRequest();

        SecretKey sessionKey = CipherUtils.generateKey("AES", 128);
        EncodingType encryptedRequest = encodeAndEncrypt(secureRequest, sessionKey);

        logRequest(encryptedRequest);
View Full Code Here

    }

    @Test
    public void testReplayMessage_shouldBeRejected() throws Exception {
        MethodCallMessage secureRequest = prepareSecureRequest();
        SecretKey sessionKey = CipherUtils.generateKey("AES", 128);
        EncodingType encryptedRequest = encodeAndEncrypt(secureRequest, sessionKey);
        secureRequestHandler.filter(encryptedRequest, new HashMap<String, Object>());
        try {
            secureRequestHandler.filter(encryptedRequest, new HashMap<String, Object>());
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.remote.MethodCallMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.