usermanagerpasswordcallbackhandler.java
来自「开源的OpenId的一个java实现」· Java 代码 · 共 72 行
JAVA
72 行
/* * Copyright 2005-2007 WSO2, Inc. (http://wso2.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package org.wso2.solutions.identity;import org.apache.axis2.AxisFault;import org.apache.ws.security.WSPasswordCallback;import javax.security.auth.callback.Callback;import javax.security.auth.callback.CallbackHandler;import javax.security.auth.callback.UnsupportedCallbackException;import java.io.IOException;/** * This is the <code>javax.security.auth.callback.CallbackHandler</code> * implementation for Apache Rampart's user authentication. * * This uses the WSO2 Commons Usermanager to carry out authentication using the * information passed in. * * IMPORTANT : This can only be used in the cases where plain text passwords are * used with a UsernameToken. */public class UsermanagerPasswordCallbackHandler implements CallbackHandler { // TODO Add a constructor that takes in the new usermanager instance /** * {@inheritDoc} */ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[i]; if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { String username = pwcb.getIdentifer(); String passwd = pwcb.getPassword(); if (passwd != null) { // TODO USe the new usermanager to auth // if(connector.authenticate(username, passwd) == true){ // continue; // }else{ // throw new AxisFault("User not authenticated"); // } } else { throw new AxisFault("User not authenticated"); } } else { throw new UnsupportedCallbackException(pwcb); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?