Beispiel #1
0
  @Test
  public void shouldThrowExceptionWhenUserIsDisabled() throws Exception {

    when(user.isEnabled()).thenReturn(false);
    try {
      // act
      wsSecurityHandler.processEnvelope(envelope);

      fail("Should have thrown WSSecurityHandlerException");
    } catch (WSSecurityHandlerException e) {

      assertEquals("User null is not enabled", e.getMessage());
    }
  }
Beispiel #2
0
  @Before
  public void before() throws Exception {

    wsSecurityEngineResults = new Vector<WSSecurityEngineResult>();
    wsSecurityEngineResults.add(new WSSecurityEngineResult(WSConstants.TS, new Object()));
    wsSecurityEngineResults.add(new WSSecurityEngineResult(WSConstants.BST, new Object()));
    wsSecurityEngineResults.add(signatureSecurityResult);

    when(signatureSecurityResult.get(WSSecurityEngineResult.TAG_ACTION))
        .thenReturn(WSConstants.SIGN);
    when(signatureSecurityResult.get(WSSecurityEngineResult.TAG_PRINCIPAL)).thenReturn(principal);
    when(signatureSecurityResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE))
        .thenReturn(requestCertificate);

    when(principal.getName()).thenReturn("a=b,c=d,O=" + USER_ID + ",e=f");

    when(cryptoWrapper.processSecurityHeader(envelope)).thenReturn(wsSecurityEngineResults);

    when(cryptoWrapper.getUserCertificate(USER_ID, requestCertificate)).thenReturn(userCertificate);
    when(userCertificate.getPublicKey()).thenReturn(publicKey);
    when(userManagementService.getUser(USER_ID)).thenReturn(user);
    when(user.isEnabled()).thenReturn(true);
  }