Java Code Examples for org.apache.ws.security.handler.WSHandlerConstants#ENCRYPT

The following examples show how to use org.apache.ws.security.handler.WSHandlerConstants#ENCRYPT . 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: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testDigestPasswordUnauthorized() throws Exception {
    setUpService("managers", true, false);
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    try {
        echo.echo("test");
        fail("Exception expected");
    } catch (Exception ex) {
        assertEquals("Unauthorized", ex.getMessage());
    }
}
 
Example 2
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testDigestPasswordUnauthorized() throws Exception {
    setUpService("managers", true, false);
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    try {
        echo.echo("test");
        fail("Exception expected");
    } catch (Exception ex) {
        assertEquals("Unauthorized", ex.getMessage());
    }
}
 
Example 3
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testDigestPasswordUnauthorized() throws Exception {
    setUpService("managers", true, false);
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    try {
        echo.echo("test");
        fail("Exception expected");
    } catch (Exception ex) {
        assertEquals("Unauthorized", ex.getMessage());
    }
}
 
Example 4
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 6 votes vote down vote up
@Test
public void testDigestPasswordUnauthorized() throws Exception {
    setUpService("managers", true, false);
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    try {
        echo.echo("test");
        fail("Exception expected");
    } catch (Exception ex) {
        assertEquals("Unauthorized", ex.getMessage());
    }
}
 
Example 5
Source File: AbstractPolicySecurityTest.java    From steady with Apache License 2.0 5 votes vote down vote up
protected PolicyBasedWSS4JInInterceptor getInInterceptor(List<CoverageType> types) {
    PolicyBasedWSS4JInInterceptor inHandler = new PolicyBasedWSS4JInInterceptor();
    String action = "";
    
    for (CoverageType type : types) {
        switch(type) {
        case SIGNED:
            action += " " + WSHandlerConstants.SIGNATURE;
            break;
        case ENCRYPTED:
            action += " " + WSHandlerConstants.ENCRYPT;
            break;
        default:
            fail("Unsupported coverage type.");
        }
    }
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 6
Source File: RoundTripTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testUsernameToken() throws Exception {
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 7
Source File: AbstractPolicySecurityTest.java    From steady with Apache License 2.0 5 votes vote down vote up
protected PolicyBasedWSS4JInInterceptor getInInterceptor(List<CoverageType> types) {
    PolicyBasedWSS4JInInterceptor inHandler = new PolicyBasedWSS4JInInterceptor();
    String action = "";
    
    for (CoverageType type : types) {
        switch(type) {
        case SIGNED:
            action += " " + WSHandlerConstants.SIGNATURE;
            break;
        case ENCRYPTED:
            action += " " + WSHandlerConstants.ENCRYPT;
            break;
        default:
            fail("Unsupported coverage type.");
        }
    }
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 8
Source File: RoundTripTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testUsernameToken() throws Exception {
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 9
Source File: DefaultCryptoCoverageCheckerTest.java    From steady with Apache License 2.0 5 votes vote down vote up
private PhaseInterceptor<SoapMessage> getWss4jInInterceptor() {
    final WSS4JInInterceptor inHandler = new WSS4JInInterceptor(true);
    final String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
    
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 10
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 5 votes vote down vote up
private PhaseInterceptor<SoapMessage> getWss4jInInterceptor() {
    final WSS4JInInterceptor inHandler = new WSS4JInInterceptor(true);
    final String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
    
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 11
Source File: AbstractPolicySecurityTest.java    From steady with Apache License 2.0 5 votes vote down vote up
protected PolicyBasedWSS4JInInterceptor getInInterceptor(List<CoverageType> types) {
    PolicyBasedWSS4JInInterceptor inHandler = new PolicyBasedWSS4JInInterceptor();
    String action = "";
    
    for (CoverageType type : types) {
        switch(type) {
        case SIGNED:
            action += " " + WSHandlerConstants.SIGNATURE;
            break;
        case ENCRYPTED:
            action += " " + WSHandlerConstants.ENCRYPT;
            break;
        default:
            fail("Unsupported coverage type.");
        }
    }
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 12
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncyptedClearPasswordAuthorized() throws Exception {
    setUpService("developers", false, true);
    String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 13
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncryptedDigestPasswordAuthorized() throws Exception {
    setUpService("developers", true, true);
    String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 14
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncyptedClearPasswordAuthorized() throws Exception {
    setUpService("developers", false, true);
    String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 15
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testDigestPasswordAuthorized() throws Exception {
    setUpService("developers", true, false);
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 16
Source File: RoundTripTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testUsernameToken() throws Exception {
    String actions = WSHandlerConstants.ENCRYPT + " " + WSHandlerConstants.SIGNATURE + " "
                     + WSHandlerConstants.TIMESTAMP + " " + WSHandlerConstants.USERNAME_TOKEN;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 17
Source File: CryptoCoverageCheckerTest.java    From steady with Apache License 2.0 5 votes vote down vote up
private PhaseInterceptor<SoapMessage> getWss4jInInterceptor() {
    final WSS4JInInterceptor inHandler = new WSS4JInInterceptor(true);
    final String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
    
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 18
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncyptedClearPasswordAuthorized() throws Exception {
    setUpService("developers", false, true);
    String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}
 
Example 19
Source File: AbstractPolicySecurityTest.java    From steady with Apache License 2.0 5 votes vote down vote up
protected PolicyBasedWSS4JInInterceptor getInInterceptor(List<CoverageType> types) {
    PolicyBasedWSS4JInInterceptor inHandler = new PolicyBasedWSS4JInInterceptor();
    String action = "";
    
    for (CoverageType type : types) {
        switch(type) {
        case SIGNED:
            action += " " + WSHandlerConstants.SIGNATURE;
            break;
        case ENCRYPTED:
            action += " " + WSHandlerConstants.ENCRYPT;
            break;
        default:
            fail("Unsupported coverage type.");
        }
    }
    inHandler.setProperty(WSHandlerConstants.ACTION, action);
    inHandler.setProperty(WSHandlerConstants.SIG_PROP_FILE, 
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.DEC_PROP_FILE,
            "insecurity.properties");
    inHandler.setProperty(WSHandlerConstants.PW_CALLBACK_CLASS, 
            TestPwdCallback.class.getName());
    inHandler.setProperty(WSHandlerConstants.IS_BSP_COMPLIANT, "false");
    
    return inHandler;
}
 
Example 20
Source File: UserNameTokenAuthorizationTest.java    From steady with Apache License 2.0 5 votes vote down vote up
@Test
public void testEncyptedClearPasswordAuthorized() throws Exception {
    setUpService("developers", false, true);
    String actions = WSHandlerConstants.USERNAME_TOKEN + " " + WSHandlerConstants.ENCRYPT;

    wsIn.setProperty(WSHandlerConstants.ACTION, actions);
    wsOut.setProperty(WSHandlerConstants.ACTION, actions);

    assertEquals("test", echo.echo("test"));
}