List of usage examples for java.util UUID fromString
public static UUID fromString(String name)
From source file:occi.infrastructure.Network.java
public Network(HashMap<String, String> attributes) throws SchemaViolationException, URISyntaxException { super(attributes); networkList.put(UUID.fromString(getId().toString()), this); generateActionNames();/*from w w w. j a v a 2s .c om*/ generateAttributeList(); }
From source file:net.sf.mpaxs.spi.server.MpaxsImpl.java
@Override public UUID getAuthenticationToken() { return UUID.fromString(Settings.getInstance().getString(ConfigurationKeys.KEY_AUTH_TOKEN)); }
From source file:eu.planets_project.tb.impl.system.batch.backends.ifwee.TestbedWEEBatchProcessor.java
public synchronized int getJobPercentComplete(String job_key) { if (this.isCompleted(job_key)) { return 100; } else {// w w w. j ava 2 s . c o m try { return weeService.getProgress(UUID.fromString(job_key)); } catch (Exception e) { log.debug("WEE getProgress error for job: " + job_key); return -1; } } }
From source file:org.openlmis.fulfillment.web.LocalTransferPropertiesControllerIntegrationTest.java
@Override LocalTransferProperties generateProperties() { LocalTransferProperties local = new LocalTransferProperties(); local.setId(UUID.randomUUID()); local.setFacilityId(UUID.fromString(FACILITY_ID)); local.setPath(LOCAL_DIR);/* w w w. ja v a 2s. co m*/ return local; }
From source file:io.github.apfelcreme.LitePortals.Bungee.LitePortals.java
/** * returns the uuid of the player with the given uuid * * @param name a players name/*from w ww . ja v a 2 s.c om*/ * @return his uuid */ public UUID getUUIDByName(String name) { name = name.toUpperCase(); if (uuidCache.containsKey(name)) { return uuidCache.get(name); } else if (getProxy().getPluginManager().getPlugin("UUIDDB") != null) { UUID uuid = UUID.fromString(UUIDDB.getInstance().getStorage().getUUIDByName(name, false)); uuidCache.put(name, uuid); return uuid; } else { try { URL url = new URL(LitePortalsConfig.getInstance().getConfiguration().getString("uuidUrl") .replace("{0}", name)); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); StringBuilder json = new StringBuilder(); int read; while ((read = in.read()) != -1) { json.append((char) read); } if (json.length() == 0) { return null; } JSONObject jsonObject = (JSONObject) (new JSONParser().parse(json.toString())); String id = jsonObject.get("id").toString(); UUID uuid = UUID .fromString(id.replaceAll("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5")); uuidCache.put(name, uuid); return uuid; } catch (Exception e) { e.printStackTrace(); } } return null; }
From source file:com.kolich.havalo.client.service.HavaloClient.java
public HavaloClient(final String key, final String secret, final String apiEndpoint) { this(UUID.fromString(key), secret, apiEndpoint); }
From source file:com.kolich.havalo.filters.HavaloAuthenticationFilter.java
@Override public final void filter(final CuracaoContext context) throws Exception { try {// w w w . j a v a2 s . c o m final HttpServletRequest request = context.request_; // Extract the Authorization header from the incoming HTTP request. String header = request.getHeader(AUTHORIZATION); // If the header does not exist or does not start with the correct // token, give up immediately. if (header == null || !header.startsWith(HAVALO_AUTHORIZATION_PREFIX)) { throw new AuthenticationException( "Request did not contain " + "a valid '" + AUTHORIZATION + "' header."); } // Extract just the part of the Authorization header that follows // the Havalo authorization prefix. header = header.substring(HAVALO_AUTHORIZATION_PREFIX.length()); final String[] tokens = header.split(HAVALO_AUTHORIZATION_SEPARATOR, 2); if (tokens == null || tokens.length != 2) { throw new AuthenticationException( "Failed to extract correct " + "number of tokens from '" + AUTHORIZATION + "' header."); } // If we get here, then we must have had some valid input // Authorization header with a real access key and signature. final String accessKey = tokens[0], signature = tokens[1]; // request.getRequestURI(); // Extract username from incoming signed request header. // Expected format is ... // Authorization: Havalo AccessKey:Signature // ... where the AccessKey is the unique UUID used to identify the user. // And, the Signature is ... // Base64( HMAC-SHA256( UTF-8-Encoding-Of( AccessSecret, StringToSign ) ) ); // And, the StringToSign is .... // HTTP-Verb (GET, PUT, POST, or DELETE) + "\n" + // RFC822 Date (from 'Date' request header, must exist) + "\n" + // Content-Type (from 'Content-Type' request header, optional) + "\n" + // CanonicalizedResource (the part of this request's URL from // the protocol name up to the query string in the first line // of the HTTP request) // Call the user details service to load the user data for the UUID. final KeyPair userKp = userService_.loadKeyPairById(UUID.fromString(accessKey)); if (userKp == null) { throw new AuthenticationException( "User service returned " + "null, which is an interface contract violation."); } // Get the string to sign -- will fail gracefully if the incoming // request does not have the proper headers attached to it. final String stringToSign = getStringToSign(request); // Compute the resulting signed signature. final String computed = HMACSHA256Signer.sign(userKp, stringToSign); // Does the signature match what was passed to us in the // Authorization request header? if (!computed.equals(signature)) { throw new BadCredentialsException( "Signatures did not " + "match (request=" + signature + ", computed=" + computed + ")"); } // Success! request.setAttribute(HAVALO_AUTHENTICATION_ATTRIBUTE, userKp); } catch (Exception e) { logger__.debug("Authentication failure; service failed " + "to authenticate request.", e); throw new AuthenticationException( "Authentication " + "failed; either the provided signature did not match, " + "or you do not have permission to access the requested " + "resource.", e); } }
From source file:com.microsoft.alm.plugin.context.soap.CatalogServiceImpl.java
public List<TeamProjectCollectionReference> getProjectCollections() { final QueryData queryForOrganizationRoot = new QueryData(SINGLE_RECURSE_STAR, QUERY_OPTIONS_NONE, ORGANIZATIONAL_ROOT);//from w w w .j av a2 s. c o m final CatalogData catalogDataOrganizationRoot = getCatalogDataFromServer(queryForOrganizationRoot); //If auth fails, you can get here and catalogDataOrganizationRoot is null if (catalogDataOrganizationRoot == null) { logger.warn("getProjectCollections catalogDataOrganizationRoot is null"); throw new TeamServicesException(TeamServicesException.KEY_TFS_AUTH_FAILED); } final CatalogResource organizationRoot = catalogDataOrganizationRoot.catalogResources.get(0); final QueryData queryForFoundationServer = new QueryData( organizationRoot.nodeReferencePaths[0] + SINGLE_RECURSE_STAR, QUERY_OPTIONS_EXPAND_DEPENDENCIES, TEAM_FOUNDATION_SERVER_INSTANCE); final CatalogData catalogDataFoundationServer = getCatalogDataFromServer(queryForFoundationServer); final CatalogResource foundationServer = catalogDataFoundationServer.catalogResources.get(0); final QueryData queryForProjectCollections = new QueryData( foundationServer.nodeReferencePaths[0] + SINGLE_RECURSE_STAR, QUERY_OPTIONS_EXPAND_DEPENDENCIES, PROJECT_COLLECTION); final CatalogData catalogDataProjectCollections = getCatalogDataFromServer(queryForProjectCollections); final List<TeamProjectCollectionReference> projectCollections = new ArrayList<TeamProjectCollectionReference>( catalogDataProjectCollections.catalogResources.size()); for (CatalogResource catalogResource : catalogDataProjectCollections.catalogResources) { final TeamProjectCollectionReference collectionReference = new TeamProjectCollectionReference(); collectionReference.setId(UUID.fromString(catalogResource.instanceId)); collectionReference.setName(catalogResource.displayName); final String collectionPath = "_apis/projectCollections/" + catalogResource.instanceId; //$NON-NLS-1$ final URI collectionUri = UrlHelper.resolveEndpointUri(context.getUri(), collectionPath); collectionReference.setUrl(collectionUri.toString()); projectCollections.add(collectionReference); } return projectCollections; }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgRqstHandler.CFAsteriskXMsgRqstSecUserDeleteByDefDevIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFAsteriskXMsgSchemaMessageFormatter schemaFormatter = null; try {//from w ww.j a va2s .c om // Common XML Attributes String attrId = null; String attrDefaultDevSecUserId = null; String attrDefaultDevName = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecUserDeleteByDefDevIdx"); CFAsteriskXMsgRqstHandler xmsgRqstHandler = (CFAsteriskXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFAsteriskSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevSecUserId")) { if (attrDefaultDevSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevName")) { if (attrDefaultDevName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natDefaultDevSecUserId; natDefaultDevSecUserId = UUID.fromString(attrDefaultDevSecUserId); String natDefaultDevName; natDefaultDevName = attrDefaultDevName; // Delete the objects schemaObj.getSecUserTableObj().deleteSecUserByDefDevIdx(natDefaultDevSecUserId, natDefaultDevName); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSecUserMessageFormatter.formatSecUserRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFAsteriskXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFAsteriskXMsgRqstHandler xmsgRqstHandler = ((CFAsteriskXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFAsteriskXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }
From source file:net.sourceforge.msscodefactory.cffreeswitch.v2_4.CFFreeSwitchXMsgRqstHandler.CFFreeSwitchXMsgRqstSecUserDeleteByDefDevIdxHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { CFFreeSwitchXMsgSchemaMessageFormatter schemaFormatter = null; try {//from w w w . java 2s . c om // Common XML Attributes String attrId = null; String attrDefaultDevSecUserId = null; String attrDefaultDevName = null; // Attribute Extraction String attrLocalName; int numAttrs; int idxAttr; final String S_ProcName = "startElement"; final String S_LocalName = "LocalName"; assert qName.equals("RqstSecUserDeleteByDefDevIdx"); CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = (CFFreeSwitchXMsgRqstHandler) getParser(); if (xmsgRqstHandler == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); ICFFreeSwitchSchemaObj schemaObj = xmsgRqstHandler.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } // Extract Attributes numAttrs = attrs.getLength(); for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) { attrLocalName = attrs.getLocalName(idxAttr); if (attrLocalName.equals("Id")) { if (attrId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevSecUserId")) { if (attrDefaultDevSecUserId != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevSecUserId = attrs.getValue(idxAttr); } else if (attrLocalName.equals("DefaultDevName")) { if (attrDefaultDevName != null) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName, S_LocalName, attrLocalName); } attrDefaultDevName = attrs.getValue(idxAttr); } else if (attrLocalName.equals("schemaLocation")) { // ignored } else { throw CFLib.getDefaultExceptionFactory().newUnrecognizedAttributeException(getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName); } } // Ensure that required attributes have values // Save named attributes to context CFLibXmlCoreContext curContext = getParser().getCurContext(); // Convert string attributes to native Java types UUID natDefaultDevSecUserId; natDefaultDevSecUserId = UUID.fromString(attrDefaultDevSecUserId); String natDefaultDevName; natDefaultDevName = attrDefaultDevName; // Delete the objects schemaObj.getSecUserTableObj().deleteSecUserByDefDevIdx(natDefaultDevSecUserId, natDefaultDevName); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSecUserMessageFormatter.formatSecUserRspnDeleted() + "\n" + schemaFormatter.formatRspnXmlPostamble(); ((CFFreeSwitchXMsgRqstHandler) getParser()).appendResponse(response); } catch (RuntimeException e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } catch (Error e) { CFFreeSwitchXMsgRqstHandler xmsgRqstHandler = ((CFFreeSwitchXMsgRqstHandler) getParser()); schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter(); String response = schemaFormatter.formatRspnXmlPreamble() + "\n" + "\t" + CFFreeSwitchXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e) + "\n" + schemaFormatter.formatRspnXmlPostamble(); xmsgRqstHandler.resetResponse(); xmsgRqstHandler.appendResponse(response); xmsgRqstHandler.setCaughtException(true); } }