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:Main.java

public static void main(String[] args) {
    // creating UUID      
    UUID x = UUID.fromString("00000000-00000-0000-0000-0000000000000");

    // checking UUID value
    System.out.println("UUID value is: " + x);
}

From source file:com.microsoft.windowsazure.services.media.samples.contentprotection.playreadywidevine.Program.java

public static void main(String[] args) {
    try {/*from ww w.  j a v a2  s . co m*/
        // Set up the MediaContract object to call into the Media Services account
        Configuration configuration = MediaConfiguration.configureWithOAuthAuthentication(mediaServiceUri,
                oAuthUri, clientId, clientSecret, scope);
        mediaService = MediaService.create(configuration);

        System.out.println("Azure SDK for Java - PlayReady & Widevine Dynamic Encryption Sample");

        // Upload a local file to a media asset.
        AssetInfo uploadAsset = uploadFileAndCreateAsset("Azure-Video.wmv");
        System.out.println("Uploaded Asset Id: " + uploadAsset.getId());

        // Transform the asset.
        AssetInfo encodedAsset = encode(uploadAsset);
        System.out.println("Encoded Asset Id: " + encodedAsset.getId());

        // Create the ContentKey
        ContentKeyInfo contentKeyInfo = createCommonTypeContentKey(encodedAsset);
        System.out.println("Common Encryption Content Key: " + contentKeyInfo.getId());

        // Create the ContentKeyAuthorizationPolicy
        String tokenTemplateString = null;
        if (tokenRestriction) {
            tokenTemplateString = addTokenRestrictedAuthorizationPolicy(contentKeyInfo, tokenType);
        } else {
            addOpenAuthorizationPolicy(contentKeyInfo);
        }

        // Create the AssetDeliveryPolicy
        createAssetDeliveryPolicy(encodedAsset, contentKeyInfo);

        if (tokenTemplateString != null) {
            // Deserializes a string containing the XML representation of the TokenRestrictionTemplate
            TokenRestrictionTemplate tokenTemplate = TokenRestrictionTemplateSerializer
                    .deserialize(tokenTemplateString);

            // Generate a test token based on the the data in the given
            // TokenRestrictionTemplate.
            // Note: You need to pass the key id Guid because we specified
            // TokenClaim.ContentKeyIdentifierClaim in during the creation
            // of TokenRestrictionTemplate.
            UUID rawKey = UUID.fromString(contentKeyInfo.getId().substring("nb:kid:UUID:".length()));

            // Token expiration: 1-year
            Calendar date = Calendar.getInstance();
            date.setTime(new Date());
            date.add(Calendar.YEAR, 1);

            // Generate token
            String testToken = TokenRestrictionTemplateSerializer.generateTestToken(tokenTemplate, null, rawKey,
                    date.getTime(), null);

            System.out.println(tokenTemplate.getTokenType().toString() + " Test Token: Bearer " + testToken);
        }

        // Create the Streaming Origin Locator
        String url = getStreamingOriginLocator(encodedAsset);

        System.out.println("Origin Locator Url: " + url);
        System.out.println("Sample completed!");
    } catch (ServiceException se) {
        System.out.println("ServiceException encountered.");
        System.out.println(se.toString());
    } catch (Exception e) {
        System.out.println("Exception encountered.");
        System.out.println(e.toString());
    }
}

From source file:com.modwiz.sponge.statue.utils.skins.SkinResolverService.java

public static void main(String[] args) {
    SkinResolverService service = new SkinResolverService(new File("skinCache"));
    MinecraftSkin skin = service.getSkin(UUID.fromString("8e5ff5f0-1e6f-4137-9eda-3d0bcf55d470"));
    System.out.println(skin.type);
    System.out.println(skin.uuid.toString());
    System.out.println(skin.texture.toString());
}

From source file:Main.java

public static UUID UUID16(final String s) {
    return UUID.fromString(String.format("0000%4s-0000-1000-8000-00805f9b34fb", s));
}

From source file:Main.java

public static long getTimestamp(String uuid) {
    UUID uu = UUID.fromString(uuid);
    return uu.timestamp();
}

From source file:Main.java

public static BluetoothGattService getService(BluetoothGatt gatt, String serviceUUID) {
    return gatt.getService(UUID.fromString(serviceUUID));
}

From source file:Main.java

public static UUID createUUIDFromAssignedNumber(String an) {
    if (an.startsWith("0x")) {
        an = an.substring(2);//from w  w  w  .ja v a  2s. c  om
    }

    return UUID.fromString(String.format("0000%s-0000-1000-8000-00805f9b34fb", an));
}

From source file:Main.java

public static UUID getUUID(String uuid) {
    try {//from  www . ja  v  a2  s .  com
        return UUID.fromString(uuid);
    } catch (IllegalArgumentException iae) {
        if (uuid.matches("[0-9a-fA-F]{4}")) {
            return UUID.fromString(String.format(BASE_UUID_FORMAT, uuid.toUpperCase()));
        }
    }
    return null;
}

From source file:Main.java

public static UUID toUuid(String uuidString) {
    return UUID.fromString(uuidString);
}

From source file:Main.java

public static UUID uuidFromString(String uuid) {

    if (uuid.length() == 4) {
        uuid = UUID_BASE.replace("XXXX", uuid);
    }// ww w . j  a  v a 2 s.c  om
    return UUID.fromString(uuid);
}