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


Java StringprepException类代码示例

本文整理汇总了Java中gnu.inet.encoding.StringprepException的典型用法代码示例。如果您正苦于以下问题:Java StringprepException类的具体用法?Java StringprepException怎么用?Java StringprepException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: deleteUser

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
/**
 * Deletes a user (optional operation).
 *
 * @param user the user to delete.
 */
public void deleteUser(User user) {
    if (provider.isReadOnly()) {
        throw new UnsupportedOperationException("User provider is read-only.");
    }

    String username = user.getUsername();
    // Make sure that the username is valid.
    try {
        /*username =*/ Stringprep.nodeprep(username);
    }
    catch (StringprepException se) {
        throw new IllegalArgumentException("Invalid username: " + username,  se);
    }

    // Fire event.
    Map<String,Object> params = Collections.emptyMap();
    UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_deleting, params);

    provider.deleteUser(user.getUsername());
    // Remove the user from cache.
    userCache.remove(user.getUsername());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:28,代码来源:UserManager.java

示例2: verifyJabberID

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
public static String verifyJabberID(String jid)
		throws YaximXMPPAdressMalformedException {
	try {
		String parts[] = jid.split("@");
		if (parts.length != 2 || parts[0].length() == 0 || parts[1].length() == 0)
			throw new YaximXMPPAdressMalformedException(
					"Configured Jabber-ID is incorrect!");
		StringBuilder sb = new StringBuilder();
		sb.append(Stringprep.nodeprep(parts[0]));
		sb.append("@");
		sb.append(Stringprep.nameprep(parts[1]));
		return sb.toString();
	} catch (StringprepException spe) {
		throw new YaximXMPPAdressMalformedException(spe);
	} catch (NullPointerException e) {
		throw new YaximXMPPAdressMalformedException("Jabber-ID wasn't set!");
	}
}
 
开发者ID:ufo22940268,项目名称:maven-yaxim,代码行数:19,代码来源:XMPPHelper.java

示例3: createUser

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
/**
 * Creates a new User. Required values are username and password. The email address
 * and name can optionally be <tt>null</tt>, unless the UserProvider deems that
 * either of them are required.
 *
 * @param username the new and unique username for the account.
 * @param password the password for the account (plain text).
 * @param name the name of the user, which can be <tt>null</tt> unless the UserProvider
 *      deems that it's required.
 * @param email the email address to associate with the new account, which can
 *      be <tt>null</tt>, unless the UserProvider deems that it's required.
 * @return a new User.
 * @throws UserAlreadyExistsException if the username already exists in the system.
 * @throws UnsupportedOperationException if the provider does not support the
 *      operation.
 */
public User createUser(String username, String password, String name, String email)
        throws UserAlreadyExistsException
{
    if (provider.isReadOnly()) {
        throw new UnsupportedOperationException("User provider is read-only.");
    }
    if (username == null || username.isEmpty()) {
        throw new IllegalArgumentException("Null or empty username.");
    }
    if (password == null || password.isEmpty()) {
        throw new IllegalArgumentException("Null or empty password.");
    }
    // Make sure that the username is valid.
    try {
        username = Stringprep.nodeprep(username);
    }
    catch (StringprepException se) {
        throw new IllegalArgumentException("Invalid username: " + username,  se);
    }
    if (provider.isNameRequired() && (name == null || name.matches("\\s*"))) {
        throw new IllegalArgumentException("Invalid or empty name specified with provider that requires name. User: "
                                            + username + " Name: " + name);
    }
    if (provider.isEmailRequired() && !StringUtils.isValidEmailAddress(email)) {
        throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address. User: "
                                            + username + " Email: " + email);
    }
    User user = provider.createUser(username, password, name, email);
    userCache.put(username, user);

    // Fire event.
    Map<String,Object> params = Collections.emptyMap();
    UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_created, params);

    return user;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:53,代码来源:UserManager.java

示例4: createUser

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
/**
 * Creates a new User. Required values are username and password. The email address
 * and name can optionally be <tt>null</tt>, unless the UserProvider deems that
 * either of them are required.
 *
 * @param username the new and unique username for the account.
 * @param password the password for the account (plain text).
 * @param name the name of the user, which can be <tt>null</tt> unless the UserProvider
 *      deems that it's required.
 * @param email the email address to associate with the new account, which can
 *      be <tt>null</tt>, unless the UserProvider deems that it's required.
 * @return a new User.
 * @throws UserAlreadyExistsException if the username already exists in the system.
 * @throws UnsupportedOperationException if the provider does not support the
 *      operation.
 */
public User createUser(String username, String password, String name, String email)
        throws UserAlreadyExistsException
{
    if (provider.isReadOnly()) {
        throw new UnsupportedOperationException("User provider is read-only.");
    }
    // Make sure that the username is valid.
    try {
        username = Stringprep.nodeprep(username);
    }
    catch (StringprepException se) {
        throw new IllegalArgumentException("Invalid username: " + username,  se);
    }
    if (provider.isNameRequired() && (name == null || name.matches("\\s*"))) {
        throw new IllegalArgumentException("Invalid or empty name specified with provider that requires name. User: "
                                            + username + " Name: " + name);
    }
    if (provider.isEmailRequired() && !StringUtils.isValidEmailAddress(email)) {
        throw new IllegalArgumentException("Invalid or empty email address specified with provider that requires email address. User: "
                                            + username + " Email: " + email);
    }
    User user = provider.createUser(username, password, name, email);
    userCache.put(username, user);

    // Fire event.
    Map<String,Object> params = Collections.emptyMap();
    UserEventDispatcher.dispatchEvent(user, UserEventDispatcher.EventType.user_created, params);

    return user;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:47,代码来源:UserManager.java

示例5: localprep

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
@Override
public String localprep(String string) throws XmppStringprepException {
	try {
		// Allow unassigned codepoints as of RFC6122 A.2
		return Stringprep.nodeprep(string, true);
	} catch (StringprepException e) {
		throw new XmppStringprepException(string, e);
	}
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:10,代码来源:LibIdnXmppStringprep.java

示例6: domainprep

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
@Override
public String domainprep(String string) throws XmppStringprepException {
	try {
		// Don't allow unassigned because this is a "stored string". See
		// RFC3453 7, RFC3490 4 1) and RFC6122 2.2
		return Stringprep.nameprep(string);
	} catch (StringprepException e) {
		throw new XmppStringprepException(string, e);
	}
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:11,代码来源:LibIdnXmppStringprep.java

示例7: resourceprep

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
@Override
public String resourceprep(String string) throws XmppStringprepException {
	try {
		// Allow unassigned codepoints as of RFC6122 B.2
		return Stringprep.resourceprep(string, true);
	} catch (StringprepException e) {
		throw new XmppStringprepException(string, e);
	}
}
 
开发者ID:igniterealtime,项目名称:jxmpp,代码行数:10,代码来源:LibIdnXmppStringprep.java

示例8: createWorkgroup

import gnu.inet.encoding.StringprepException; //导入依赖的package包/类
/**
 * Create a new Workgroup.
 *
 * @param workgroupName the name of the workgroup.
 * @param description the description of the workgroup.
 * @param agents the agents, in a comma delimited string.
 * @return a map of errors (if any)
 */
public static Map<String, String> createWorkgroup(String workgroupName, String description, String agents) {
    Map<String, String> errors = new HashMap<String, String>();

    // Get a workgroup manager
    WorkgroupManager wgManager = WorkgroupManager.getInstance();
    if (wgManager == null) {
        errors.put("general_error", "The server is down");
        return errors;
    }

    String defaultQueueName = "Default Queue";
    // Validate
    if (workgroupName == null) {
        errors.put("wgName", "");
    }
    else {
        try {
            workgroupName = workgroupName.trim().toLowerCase();
            workgroupName = Stringprep.nodeprep(workgroupName);
        }
        catch (StringprepException se) {
            errors.put("wgName", "");
        }
    }
    // do a create if there were no errors
    RequestQueue queue = null;
    if (errors.size() == 0) {
        try {
            // Create new workgroup
            Workgroup workgroup = wgManager.createWorkgroup(workgroupName);
            workgroup.setDescription(description);
            // Create a default workgroup queue
            queue = workgroup.createRequestQueue(defaultQueueName);
            //workgroup.setMaxChats(maxChats);
            //workgroup.setMinChats(minChats);
            // Make the workgroup ready by default:
            workgroup.setStatus(Workgroup.Status.READY);
            // Create default messages and images for the new workgroup
            ChatSettingsCreator.getInstance().createDefaultSettings(workgroup.getJID());

            // Add generic web form
            FormManager formManager = FormManager.getInstance();
            formManager.createGenericForm(workgroup);
        }
        catch (UserAlreadyExistsException uaee) {
            errors.put("exists", "");
        }
        catch (Exception e) {
            Log.error(e.getMessage(), e);
            errors.put("general", "");
        }
    }

    if (ModelUtil.hasLength(agents)) {
        addAgents(queue, agents);
    }
    return errors;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:67,代码来源:WorkgroupUtils.java


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