当前位置: 首页>>代码示例>>Java>>正文


Java WSPasswordCallback.getUsage方法代码示例

本文整理汇总了Java中org.apache.ws.security.WSPasswordCallback.getUsage方法的典型用法代码示例。如果您正苦于以下问题:Java WSPasswordCallback.getUsage方法的具体用法?Java WSPasswordCallback.getUsage怎么用?Java WSPasswordCallback.getUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ws.security.WSPasswordCallback的用法示例。


在下文中一共展示了WSPasswordCallback.getUsage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

		WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0];
		String id = pwcb.getIdentifier();
		int usage = pwcb.getUsage();

		if (usage == WSPasswordCallback.USERNAME_TOKEN) {

			if ("admin".equals(id)) {
				pwcb.setPassword("admin");
			} else if ("[email protected]".equals(id)) {
				pwcb.setPassword("admin123");
			}

		} else if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) {

			if ("wso2carbon".equals(id)) {
				pwcb.setPassword("wso2carbon");
			}
		}
	}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:SecurityWithServiceDescriptorTest.java

示例2: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
@Override
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
	log.info("handle({})", callbacks);
	WSPasswordCallback pwdCallback = (WSPasswordCallback) callbacks[0];

	log.debug("identifier: " + pwdCallback.getIdentifier());
	log.debug("usage: " + pwdCallback.getUsage());
	int usage = pwdCallback.getUsage();

	if (usage == WSPasswordCallback.USERNAME_TOKEN) {
		String password = pwdCallback.getPassword();
		Authentication authentication = new UsernamePasswordAuthenticationToken(pwdCallback.getIdentifier(), password);
		authentication = authenticationManager.authenticate(authentication);
		SecurityContextHolder.getContext().setAuthentication(authentication);

		// Return the password to the caller
		pwdCallback.setPassword(password);
	}
}
 
开发者ID:openkm,项目名称:document-management-system,代码行数:20,代码来源:ClientPasswordCallback.java

示例3: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

        WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0];
        String id = pwcb.getIdentifer();
        int usage = pwcb.getUsage();

        if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) {
            // Logic to get the private key password for signture or decryption
            if ("client".equals(id)) {
                pwcb.setPassword("automation");

            } else if ("service".equals(id)) {
                pwcb.setPassword("automation");

            } else if ("wso2carbon".equals(id)) {
                pwcb.setPassword("wso2carbon");

            } else if ("alice".equals(id)) {
                pwcb.setPassword("password");

            } else if ("bob".equals(id)) {
                pwcb.setPassword("password");

            }
        }
    }
 
开发者ID:wso2,项目名称:product-ei,代码行数:27,代码来源:SecureAxisServiceClient.java

示例4: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
        UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {

        //When the server side need to authenticate the user
        WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
        if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
            if(pwcb.getIdentifer().equals("alice") && pwcb.getPassword().equals("bobPW")) {
                return;
            } else {
                throw new UnsupportedCallbackException(callbacks[i], "check failed");
            }
        }

        //When the client requests for the password to be added in to the
        //UT element
        pwcb.setPassword("bobPW");
    }
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:20,代码来源:PWCBHandler.java

示例5: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
    /*
     * here call a function/method to lookup the password for
     * the given identifier (e.g. a user name or keystore alias)
     * e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
     * for testing we supply a fixed name/fixed key here.
     */
            if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
                pc.setKey(key);
            }
            else {
                pc.setPassword("security");
            }
        } else {
            throw new UnsupportedCallbackException(
                    callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:windup,项目名称:windup-rulesets,代码行数:24,代码来源:PWCallback.java

示例6: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0];
    String id = pwcb.getIdentifier();
    int usage = pwcb.getUsage();
    if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) {
        // Logic to get the private key password for signture or decryption
        if ("client".equals(id)) {
            pwcb.setPassword("automation");
        } else if ("service".equals(id)) {
            pwcb.setPassword("automation");
        } else if ("wso2carbon".equals(id)) {
            pwcb.setPassword("wso2carbon");
        } else if ("alice".equals(id)) {
            pwcb.setPassword("password");
        } else if ("bob".equals(id)) {
            pwcb.setPassword("password");
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-platform-integration-utils,代码行数:20,代码来源:SecureAxisServiceClient.java

示例7: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
/**
 * Method handle
 * 
 * @param callbacks 
 * @throws IOException                  
 * @throws UnsupportedCallbackException 
 */
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];

            /*
             * here call a function/method to lookup the password for
             * the given identifier (e.g. a user name or keystore alias)
             * e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
             * for Testing we supply a fixed name here.
             */
            if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
                pc.setKey(key);
            } else {
                pc.setPassword("security");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i],
                    "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:32,代码来源:PWCallback.java

示例8: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
                && "bob".equals(pc.getIdentifier())) {
                if (WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded()) {
                    // "jux7xGGAjguKKHg9C+waOiLrCCE=" is the Base64 encoded SHA-1 hash of "security".
                    pc.setPassword("jux7xGGAjguKKHg9C+waOiLrCCE=");
                } else {
                    pc.setPassword("security");
                }
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:22,代码来源:TestWSSecurityUTDK.java

示例9: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                    && "alice".equals(pc.getIdentifier())) {
                pc.setPassword("verySecret");
            } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE
                    && "wss86".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:20,代码来源:TestWSSecurityWSS194.java

示例10: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            /*
             * here call a function/method to lookup the password for
             * the given identifier (e.g. a user name or keystore alias)
             * e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
             * for Testing we supply a fixed name here.
             */
            if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
                pc.setKey(key);
            }
            else {
                pc.setPassword("security");
            }
        } else {
            throw new UnsupportedCallbackException(
                callbacks[i],
                "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:25,代码来源:TestWSSecurityNew9.java

示例11: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            assertEquals(pc.getPasswordType(), WSConstants.PASSWORD_TEXT);
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
                if (!"wernerd".equals(pc.getIdentifier())
                      && !"verySecret".equals(pc.getPassword())) {
                    throw new IOException("Authentication failed");
                }
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:20,代码来源:TestWSSecurityWSS199.java

示例12: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks) throws IOException,
    UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN) {
                pc.setPassword("Sri Lanka Sri Lanka UOM ");
            } else if (pc.getUsage() == WSPasswordCallback.DECRYPT) {
                pc.setKey("Sri Lanka Sri Lanka UOM ".getBytes());

            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i],
                    "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:18,代码来源:TestWSSecurityNew10.java

示例13: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
                && "bob".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                && "bob".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:20,代码来源:TestWSSecurityUTSignature.java

示例14: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
public void handle(Callback[] callbacks)
    throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            boolean passwordsAreEncoded = WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded();
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                && "wernerd".equals(pc.getIdentifier())) {
                if (passwordsAreEncoded) {
                    // "hGqoUreBgahTJblQ3DbJIkE6uNs=" is the Base64 encoded SHA-1 hash of "verySecret".
                    pc.setPassword("hGqoUreBgahTJblQ3DbJIkE6uNs=");
                } else {
                    pc.setPassword("verySecret");
                }
            } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN
                && "emptyuser".equals(pc.getIdentifier())) {
                pc.setPassword("");
            }  
            else if (
                pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
            ) {
                if ("wernerd".equals(pc.getIdentifier())
                    && "verySecret".equals(pc.getPassword())) {
                    return;
                } else if ("customUser".equals(pc.getIdentifier())) {
                    return;
                } else if ("wernerd".equals(pc.getIdentifier())
                    && "".equals(pc.getPassword())) {
                    return;
                } else {
                    throw new IOException("Authentication failed");
                }
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:39,代码来源:TestWSSecurityNew5.java

示例15: handle

import org.apache.ws.security.WSPasswordCallback; //导入方法依赖的package包/类
/**
 * Method handle
 * 
 * @param callbacks 
 * @throws java.io.IOException                  
 * @throws javax.security.auth.callback.UnsupportedCallbackException 
 */
public void handle(Callback[] callbacks)
        throws IOException, UnsupportedCallbackException {

    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];

            /*
             * This usage type is used only in case we received a
             * username token with a password of type PasswordText or
             * an unknown password type.
             * 
             * This case the WSPasswordCallback object contains the
             * identifier (aka username), the password we received, and
             * the password type string to identify the type.
             * 
             * Here we perform only a very simple check.
             */

            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
                if(pc.getIdentifier().equals("Ron") && pc.getPassword().equals("noR")) {
                    return;
                }
                if (pc.getPassword().equals("sirhC")) {
                    return;
                }
                throw new UnsupportedCallbackException(callbacks[i],
                "check failed");
            }

            /*
             * here call a function/method to lookup the password for
             * the given identifier (e.g. a user name or keystore alias)
             * e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
             * for Testing we supply a fixed name here.
             */

            if (pc.getUsage() == WSPasswordCallback.KEY_NAME) {
                pc.setKey(key);
            } else if(pc.getIdentifier().equals("alice")) {
                pc.setPassword("password");
            } else if(pc.getIdentifier().equals("bob")) {
                pc.setPassword("password");
            } else if(pc.getIdentifier().equals("Ron")) {
                pc.setPassword("noR");
            } else {
                pc.setPassword("sirhC");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i],
                    "Unrecognized Callback");
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:62,代码来源:PWCallback1.java


注:本文中的org.apache.ws.security.WSPasswordCallback.getUsage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。