Example usage for java.util UUID fromString

List of usage examples for java.util UUID fromString

Introduction

In this page you can find the example usage for java.util UUID fromString.

Prototype

public static UUID fromString(String name) 

Source Link

Document

Creates a UUID from the string standard representation as described in the #toString method.

Usage

From source file:com.spleefleague.core.utils.DatabaseConnection.java

public static UUID getUUID(String username) {
    username = username.toLowerCase();/*from   w  ww  .  j  a  v  a  2s  .  c  o m*/
    UUID uuid = uuidCache.getUUID(username);
    if (uuid != null) {
        return uuid;
    }
    Document dbo = SpleefLeague.getInstance().getPluginDB().getCollection("Players")
            .find(new Document("lookupUsername", username)).first();
    if (dbo != null) {
        uuid = UUID.fromString((String) dbo.get("uuid"));
        updateCache(uuid, username);
        return uuid;
    } else {
        return null;
    }
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmSecUserPKey.java

public CFCrmSecUserPKey() {
    requiredSecUserId = UUID.fromString(CFCrmSecUserBuff.SECUSERID_INIT_VALUE.toString());
}

From source file:com.blackducksoftware.integration.hub.api.report.UserData.java

public UUID getUUId() {
    if (StringUtils.isBlank(id)) {
        return null;
    }/*w  w  w  .  java 2s.  com*/
    try {
        return UUID.fromString(id);
    } catch (final IllegalArgumentException e) {
        return null;
    }
}

From source file:org.stockwatcher.web.BaseController.java

protected User getUser(String userId) {
    User user = null;//from   ww  w.j a v  a 2 s  .  c o  m
    if (userId == null) {
        throw new IllegalArgumentException("userId is null or zero length");
    }
    try {
        UUID id = UUID.fromString(userId);
        user = userDAO.getUser(id);
    } catch (Exception e) {
        LOGGER.debug("Invalid userId ({}) specified", userId);
    }
    return user;
}

From source file:com.microsoft.azuretools.adauth.ResponseUtils.java

public static AuthorizationResult parseAuthorizeResponse(String webAuthenticationResult, CallState callState)
        throws URISyntaxException, UnsupportedEncodingException {
    AuthorizationResult result = null;//from   ww  w.j av  a2s  .  c om

    URI resultUri = new URI(webAuthenticationResult);
    // NOTE: The Fragment property actually contains the leading '#' character and that must be dropped
    String resultData = resultUri.getQuery();
    if (resultData != null && !resultData.isEmpty()) {
        // Remove the leading '?' first
        Map<String, String> map = UriUtils.formQueryStirng(resultData);

        if (map.containsKey(OAuthHeader.CorrelationId)) {
            String correlationIdHeader = (map.get(OAuthHeader.CorrelationId)).trim();
            try {
                UUID correlationId = UUID.fromString(correlationIdHeader);
                if (!correlationId.equals(callState.correlationId)) {
                    log.log(Level.WARNING, "Returned correlation id '" + correlationId
                            + "' does not match the sent correlation id '" + callState.correlationId + "'");
                }
            } catch (IllegalArgumentException ex) {
                log.log(Level.WARNING,
                        "Returned correlation id '" + correlationIdHeader + "' is not in GUID format.");
            }
        }
        if (map.containsKey(OAuthReservedClaim.Code)) {
            result = new AuthorizationResult(map.get(OAuthReservedClaim.Code));
        } else if (map.containsKey(OAuthReservedClaim.Error)) {
            result = new AuthorizationResult(map.get(OAuthReservedClaim.Error),
                    map.get(OAuthReservedClaim.ErrorDescription), map.get(OAuthReservedClaim.ErrorSubcode));
        } else {
            result = new AuthorizationResult(AuthError.AuthenticationFailed,
                    AuthErrorMessage.AuthorizationServerInvalidResponse);
        }
    }
    return result;
}

From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmSecSessionPKey.java

public CFCrmSecSessionPKey() {
    requiredSecSessionId = UUID.fromString(CFCrmSecSessionBuff.SECSESSIONID_INIT_VALUE.toString());
}

From source file:com.censoredsoftware.infractions.bukkit.legacy.compat.LegacyInfraction.java

@SuppressWarnings("unchecked")
public static Infraction unserialize(Map<String, Object> map) {
    try {/*from w  w  w  . j a  v  a 2  s. c  o  m*/
        UUID playerId = UUID.fromString(map.get("playerId").toString());
        Issuer issuer = ((LegacyIssuer) DataManager.getManager().getFor(LegacyIssuer.class,
                map.get("issuer").toString())).toIssuer();
        Long timeCreated = Long.parseLong(map.get("timeCreated").toString());
        String reason = map.get("reason").toString();
        Integer score = Integer.parseInt(map.get("score").toString());
        Set<Evidence> evidence = Sets.newHashSet();
        if (map.containsKey("evidence") && !((List<Map<String, Object>>) map.get("evidence")).isEmpty()) {
            evidence = Sets.newHashSet(Collections2.transform((List<Map<String, Object>>) map.get("evidence"),
                    new Function<Map<String, Object>, Evidence>() {
                        @Override
                        public Evidence apply(Map<String, Object> map) {
                            Issuer issuer = ((LegacyIssuer) DataManager.getManager().getFor(LegacyIssuer.class,
                                    map.get("issuer").toString())).toIssuer();
                            EvidenceType type = EvidenceType.valueOf(map.get("type").toString());
                            Long timeCreated = Long.parseLong(map.get("timeCreated").toString());
                            String data = map.get("data").toString();
                            return new Evidence(issuer, type, timeCreated, data);
                        }
                    }));
        }
        List<String> notes = (List<String>) (map.containsKey("notes") ? map.get("notes")
                : Lists.newArrayList());
        Infraction infraction = new Infraction(playerId, timeCreated, reason, score, issuer, evidence);
        infraction.setNotes(notes);
        return infraction;
    } catch (NullPointerException ex) {
        return null;
    }
}

From source file:net.sourceforge.msscodefactory.cfinternet.v2_0.CFInternet.CFInternetSecSessionPKey.java

public CFInternetSecSessionPKey() {
    requiredSecSessionId = UUID.fromString(CFInternetSecSessionBuff.SECSESSIONID_INIT_VALUE.toString());
}

From source file:com.spectralogic.ds3cli.command.DeleteTapeDrive.java

@Override
public DefaultResult call() throws Exception {
    getClient().deleteTapeDriveSpectraS3(new DeleteTapeDriveSpectraS3Request(UUID.fromString(this.id)));
    return new DefaultResult("Success: Deleted tape drive '" + this.id + "'.");
}

From source file:com.haulmont.cuba.testsupport.TestUserSessionSource.java

@Override
public synchronized UserSession getUserSession() {
    if (exceptionOnGetUserSession) {
        throw new NoUserSessionException(UUID.fromString(USER_ID));
    }/*from   w ww .  j  av a 2  s  .c om*/
    if (session == null) {
        User user = new User();
        user.setId(UUID.fromString(USER_ID));
        user.setLogin("test_admin");
        user.setName("Test Administrator");
        user.setPassword(DigestUtils.md5Hex("test_admin"));

        session = new UserSession(UUID.randomUUID(), user, Collections.<Role>emptyList(),
                Locale.forLanguageTag("en"), false);
    }
    return session;
}