Example usage for java.lang SecurityException getMessage

List of usage examples for java.lang SecurityException getMessage

Introduction

In this page you can find the example usage for java.lang SecurityException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testNoXML() throws Exception {
    String signResponse = Base64.encode("foobar".getBytes());

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            "foobar-token-key".getBytes(), null);
    session.setDestination("destination-foobar");
    session.setInResponseTo("in-response-to");
    try {/*from   w w w .j  a va  2 s.  c  o  m*/
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testNoBase64() throws Exception {
    String signResponse = "foobar";

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            "foobar-token-key".getBytes(), null);
    session.setDestination("destination-foobar");
    session.setInResponseTo("in-response-to");
    try {//from ww w  .  j a va2 s .com
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java

private void registerTracingReceiverWhenIdle() {
    // Delay tracing receiver registration until the main loop is idle.
    Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() {
        @Override/*from   w ww.j  a  v a 2  s .  c  om*/
        public boolean queueIdle() {
            // Will retry if the native library is not initialized yet.
            if (!LibraryLoader.isInitialized())
                return true;
            try {
                getTracingController().registerReceiver(XWalkViewShellActivity.this);
            } catch (SecurityException e) {
                Log.w(TAG, "failed to register tracing receiver: " + e.getMessage());
            }
            return false;
        }
    });
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testMessageIDDoesNotMatch() throws Exception {
    byte[] tokenKey = new byte[256 / 8];
    SecureRandom secureRandom = new SecureRandom();
    secureRandom.nextBytes(tokenKey);/*from w ww  .j  a  va 2s  . c  o  m*/
    String signResponse = SignResponseFactory.createSignResponse("response-id", "destination", "in-response-to",
            "token-id", tokenKey);
    LOG.debug("SignResponse: " + signResponse);

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id-foobar",
            "token-id", tokenKey, null);
    session.setDestination("destination");
    session.setInResponseTo("in-response-to");
    try {
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testReplyToNotMatch() throws Exception {
    byte[] tokenKey = new byte[256 / 8];
    SecureRandom secureRandom = new SecureRandom();
    secureRandom.nextBytes(tokenKey);//from   ww  w  . j  av  a  2  s.  c o m
    String signResponse = SignResponseFactory.createSignResponse("response-id", "destination", "in-response-to",
            "token-id", tokenKey);
    LOG.debug("SignResponse: " + signResponse);

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            tokenKey, null);
    session.setDestination("destination");
    session.setInResponseTo("in-response-to-foobar");
    try {
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testDestinationDoesNotMatch() throws Exception {
    byte[] tokenKey = new byte[256 / 8];
    SecureRandom secureRandom = new SecureRandom();
    secureRandom.nextBytes(tokenKey);//  w ww .j av  a  2s.c o m
    String signResponse = SignResponseFactory.createSignResponse("response-id", "destination", "in-response-to",
            "token-id", tokenKey);
    LOG.debug("SignResponse: " + signResponse);

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            tokenKey, null);
    session.setDestination("destination-foobar");
    session.setInResponseTo("in-response-to");
    try {
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testTokenKeyDoesNotMatch() throws Exception {
    byte[] tokenKey = new byte[256 / 8];
    SecureRandom secureRandom = new SecureRandom();
    secureRandom.nextBytes(tokenKey);//from  w w w  .  jav  a2  s .com
    String signResponse = SignResponseFactory.createSignResponse("response-id", "destination", "in-response-to",
            "token-id", tokenKey);
    LOG.debug("SignResponse: " + signResponse);

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            "foobar-token-key".getBytes(), null);
    session.setDestination("destination-foobar");
    session.setInResponseTo("in-response-to");
    try {
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}

From source file:org.mule.providers.AbstractMessageDispatcher.java

public final UMOMessage send(UMOEvent event) throws DispatchException {
    try {//w ww.  j  a va2 s.  c om
        event.setSynchronous(true);
        event.setProperty(MuleProperties.MULE_ENDPOINT_PROPERTY,
                event.getEndpoint().getEndpointURI().toString());
        RequestContext.setEvent(event);
        // Apply Security filter if one is set
        UMOEndpoint endpoint = event.getEndpoint();
        if (endpoint.getSecurityFilter() != null) {
            try {
                endpoint.getSecurityFilter().authenticate(event);
            } catch (org.mule.umo.security.SecurityException e) {
                logger.warn("Outbound Request was made but was not authenticated: " + e.getMessage(), e);
                connector.fireEvent(new SecurityEvent(e, SecurityEvent.SECURITY_AUTHENTICATION_FAILED));
                connector.handleException(e);
                return event.getMessage();
            } catch (UMOException e) {
                dispose();
                throw new DispatchException(event.getMessage(), event.getEndpoint(), e);
            }
        }
        // the security filter may update the payload so we need to get the
        // latest event again
        event = RequestContext.getEvent();
        try {
            UMOMessage result = doSend(event);
            if (connector.isEnableMessageEvents()) {
                connector.fireEvent(new MessageEvent(event.getMessage(), event.getEndpoint(),
                        event.getComponent().getDescriptor().getName(), MessageEvent.MESSAGE_SENT));
            }
            //Once a dispatcher has done its work we need to romve this property so that
            //it is not propagated to the next request
            if (result != null)
                result.removeProperty(MuleProperties.MULE_REMOTE_SYNC_PROPERTY);
            return result;
        } catch (DispatchException e) {
            dispose();
            throw e;
        } catch (Exception e) {
            dispose();
            throw new DispatchException(event.getMessage(), event.getEndpoint(), e);
        }
    } finally {
        if (connector.isCreateDispatcherPerRequest()) {
            dispose();
        }
    }
}

From source file:org.mule.providers.AbstractMessageDispatcher.java

public final void dispatch(UMOEvent event) throws DispatchException {
    try {/*from w  w w  .  jav  a 2  s .c  o m*/
        event.setSynchronous(false);
        event.setProperty(MuleProperties.MULE_ENDPOINT_PROPERTY,
                event.getEndpoint().getEndpointURI().toString());
        RequestContext.setEvent(event);
        // Apply Security filter if one is set
        UMOEndpoint endpoint = event.getEndpoint();
        if (endpoint.getSecurityFilter() != null) {
            try {
                endpoint.getSecurityFilter().authenticate(event);
            } catch (org.mule.umo.security.SecurityException e) {
                logger.warn("Outbound Request was made but was not authenticated: " + e.getMessage(), e);
                connector.fireEvent(new SecurityEvent(e, SecurityEvent.ADMIN_EVENT_ACTION_START_RANGE));
                connector.handleException(e);
                return;
            } catch (UMOException e) {
                dispose();
                throw new DispatchException(event.getMessage(), event.getEndpoint(), e);
            }
        }
        // the security filter may update the payload so we need to get the
        // latest event again
        event = RequestContext.getEvent();

        try {
            UMOTransaction tx = TransactionCoordination.getInstance().getTransaction();
            if (doThreading && !event.isSynchronous() && tx == null) {
                workManager.scheduleWork(new Worker(event));
            } else {
                doDispatch(event);
                if (connector.isEnableMessageEvents()) {
                    connector.fireEvent(new MessageEvent(event.getMessage(), event.getEndpoint(),
                            event.getComponent().getDescriptor().getName(), MessageEvent.MESSAGE_DISPATCHED));
                }
            }
        } catch (DispatchException e) {
            dispose();
            throw e;
        } catch (Exception e) {
            dispose();
            throw new DispatchException(event.getMessage(), event.getEndpoint(), e);
        }
    } finally {
        if (connector.isCreateDispatcherPerRequest()) {
            dispose();
        }
    }
}

From source file:test.unit.be.e_contract.dssp.client.SignResponseVerifierTest.java

@Test
public void testMissingSignature() throws Exception {
    byte[] tokenKey = new byte[256 / 8];
    SecureRandom secureRandom = new SecureRandom();
    secureRandom.nextBytes(tokenKey);//from w  ww .j a va  2  s .  co m
    String signResponse = SignResponseFactory.createSignResponse("response-id", "destination", "in-response-to",
            "token-id", tokenKey);
    LOG.debug("SignResponse: " + signResponse);

    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setNamespaceAware(true);
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse(new ByteArrayInputStream(Base64.decode(signResponse)));
    Node signatureNode = document.getElementsByTagNameNS("http://www.w3.org/2000/09/xmldsig#", "Signature")
            .item(0);
    signatureNode.getParentNode().removeChild(signatureNode);

    signResponse = Base64.encode(toString(document).getBytes());

    DigitalSignatureServiceSession session = new DigitalSignatureServiceSession("response-id", "token-id",
            tokenKey, null);
    session.setDestination("destination");
    session.setInResponseTo("in-response-to");
    try {
        SignResponseVerifier.checkSignResponse(signResponse, session);
        fail();
    } catch (SecurityException e) {
        LOG.debug("expected exception: " + e.getMessage());
        // expected
        assertFalse(session.isSignResponseVerified());
    }
}