java,encryption,encoding,signature,amazon-snsRelated issues-Collection of common programming errors


  • oers
    java junit
    I’ve written a JUnit where it is calling a Constant class, here we are trying to access a static final Listpublic static final List<String> SKIPPED_DIMENSION_LIST = new ArrayList<String>();static{ SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_DISPLAY); SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB); SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB_GROUP); SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB_GROUP_ID); SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_ID); SKIPPED_DIMENSION_LIST.

  • maenu
    java validation constraints playframework
    I’m using the Play! framework and discovered while writing tests that I can save an invalid model instance, e.g. with invalid values for some instance variables. I guess that’s expected behaviour to keep validation and persistence separated. But is there any way to reuse the validation annotations as database constraints?

  • DT7
    java hl7 hapi
    I am trying to get the value in ORC-21://————– ORC orcObj = messageObj.getCOMMON_ORDER().getORC();String result = orcObj.getOrc21_OrderingFacilityName(0).getOrganizationName().getValue();//————– But it turns out that I have to put the ORC field between PID and FT1, as a “global ORC”. Otherwise, the return is null.Does anyone know how to fix this? I use PipeParser()

  • clav
    java arrays
    I have the code below:int lines = 0; while(lines < 2) {int[] oldarr = parr;for(int i = 0; i < arrsize; i++)System.out.print(” ” + oldarr[i]);System.out.println();for(int i = 0; i < arrsize; i++){if(i == 0)parr[i] = 0;elseparr[i] = Math.abs(oldarr[i] – oldarr[i-1]);}lines++; }parr is an array of integers of size [arrsize]. Each time through this loop I want to print the value of each index in parr, then set each index to the difference between the index before it and itself. Currently it

  • danny.lesnik
    java json thrift thrift-protocol
    I created the following Thrift Object:struct Student{1: string id;2: string firstName;3: string lastName }Now I would like to read this object from JSON. According to this post this is possibleSo I wrote the following code:String json = “{\”id\”:\”aaa\”,\”firstName\”:\”Danny\”,\”lastName\”:\”Lesnik\”}”;StudentThriftObject s = new StudentThriftObject();byte[] jsonAsByte = json.getBytes(“UTF-8”);TMemoryBuffer memBuffer = new TMemoryBuffer(jsonAsByte.length);memBuffer.write(jsonAsByte);TProtocol pr

  • ernies
    java arraylist
    I am working on a complicated computer science lab. I need to create a method called countItem which returns the quantity of a specified item. If the item is not in the list, it should return 0. Cart is an arraylist of Items. Getquantity returns the quantity which is a instance field of the item file.After building I get two unexpected type errors. Can anyone help me fix this problem? I can post more code if needed. ThanksEDIt: THE PROBLEM IS SOLVED THANKS SO MUCH!public int countItem(Item purc

  • Jim
    java
    i want to know what’s the difference between public or private class and try, and when do i have to use one of them and not the other? try { date1 = sdf.parse(duration);date2 = sdf.parse(Time2);long diff = date1.getTime() – date2.getTime();if(diff > 0){long jour = diff/(60*24*60*1000);int jor = (int)jour;String jr = Integer.toString(jor);long heur = (diff%(60*24*60*1000))/(60*60*1000);int her = (int)heur;String hr = Integer.toString(her);long minu = ((diff%(60*24*60*1000))%(60*60*1000))/(60*1

  • Behe
    java playframework playframework-1.x mongolab
    I’m using playframework -v 1.2.4, and using the morphia plugin. When I run play test, and connect with mongolab db, an exception is thrown with the following error:Oops: RuntimeException An unexpected error occured caused by exception RuntimeException: MongoDB authentication failed: mydbMy application.conf as follows..,application.mode=dev %prod.application.mode=prod morphia.db.host=ds033187.mongolab.com morphia.db.port=33187 morphia.db.username=demo morphia.db.password=demo morphia.db.name=mydb

  • user1888440
    java spring hibernate jpa
    I’m having a difficult time understanding Spring Transactions. First off, I am trying to use as little of Spring as possible. Basically, I want to use @Transactional and some of its injection capabilities with JPA/Hibernate. My transactional usage is in my service layer. I try to keep them out of test cases. I use CTW and am spring-configured. I have component scan on the root of my packages right now. I also am using Java configuration for my datasource, JpaTransactionManager, and EntityManager

  • David W.
    java bash shell compilation
    I need to write a bash script to compile my java program. I know it’s a bit artificial but it is homework. (although I’m not sure the bash script is even marked, just used for the automated marking system)I only have one java file test.java and the script is to only search its own directory: I tried:#!/bin/bash javac test.javaand saved as build.sh, i tried to run this from the terminal as both sh build.sh and bash build.sh both gave me errors. Can anyone offer any help?included errors:

  • mjv
    java encryption
    I have to implement the following scenario. User calls a webservice sending a request with a text which must be encrypted by my service if it isn’t encrypted. After that it should be stored in the database. Is it a good idea to declare this attribute in xsd as String or is it a better type? Should I allow to use CDATA?Using Jaxb I will convert this xml to a class with password stored in String object. Is it ok assuming that String is unicode (2 bytes)? I have to use API which is a wraper for RSA

  • praveenLal
    android encryption rsa
    I have a private key and exponent, i need to implement RSA encryption of string in android application. How can i do this? Is there any default class for the RSA encryption?

  • svick
    c# encryption cryptography rsa key
    I am building a custom shopping cart where CC numbers and Exp date will be stored in a database until processing (then deleted). I need to encrypt this data (obviously).I want to use the RSACryptoServiceProvider class.Here is my code to create my keys.public static void AssignNewKey(){const int PROVIDER_RSA_FULL = 1;const string CONTAINER_NAME = “KeyContainer”;CspParameters cspParams;cspParams = new CspParameters(PROVIDER_RSA_FULL);cspParams.KeyContainerName = CONTAINER_NAME;cspParams.Flags = Cs

  • user3183409
    java exception encryption aes cipher
    I’m using the following example:http://compscipleslab.wordpress.com/category/java/But I’m getting an exception and when I log the exceptions it it appears in my logcat stating: InvalidKeyExceptionI’m not sure exactly what I’ve done wrong. I haven’t really modified the methods from the tutorial (perhaps this is the problem) so I’m not sure exactly why I’m getting this error. Source:public class FileChooser extends ListActivity {private File currentDir;private File moveToDir;private FileArrayAdapt

  • e-sushi
    encryption
    So I wrote a simple encryption algorithm (Not very secure, just a starting point. I don’t want criticism on it.) and I have been having trouble finding a way to decrypt the text. The algorithm is here (You may need an ASCII table to understand it):Key = key DecimalKey: k + e + y = 107 + 101 + 121 = 329 / 3(Length of actual key) = 110 Each Char: (charDec * keyLength) – DecimalKeyExample: p (112 * 3 = 336) – 110 = 226Then I would subtract 127 from 226 so it will correspond to ASCII (this will be c

  • Charles Menguy
    .net authentication encryption ssl
    Most recent edits in bold I am using the .net HttpListener class, but I’m won’t be running on IIS and am not using ASP.net. This web site describes what code to actual use to implement SSL with asp.net and this site describes how to set up the certificates (although I’m not sure if it works only for IIS or not). When I the class documentation, it describes various types of authentication (basic, digest, Windows, etc.) – none of them refer to SSL. It does say that if HTTPS is used, you will ne

  • CodeCaster
    c# security encryption
    Microsoft’s sample code for encryption / decryption in C# has an unexplained line where they pin the secret key in memory. I understand the concept of pinning well enough – it’s used to indicate the GC should not move the contents of that memory to other locations. Sure, fine.What’s the benefit of pinning the secret key? I am fairly sure there is one – a very intelligent developer I worked with once upon a time mentioned that it was an important step for our software to be secure. The relevant c

  • Gerardo agustin Riera
    java encryption jar client-server aes
    As we now, a .jar file, we can open it and see the code and classes with any decompiler. Now suppose the following situation:I developed a Client-Server application under JAVA, in both Client and Server, i used AES-256 for encrypting the data sent over internet. So, i give the “Client” to my friend. Now.. The question is… can he hack my Server knowing how are the packets received in the Client, treated, and sent back? I mean… encrypting the data when you have a revealed code, it’s.. in vain

  • MarcinJuraszek
    c# algorithm encryption password-encryption
    this piece of code does return the right answer whenever i run it once on the right crypting key, but if i run it twice it gives completely different resultint key = Int32.Parse(MinKeyTB.Text, System.Globalization.NumberStyles.HexNumber); CR = new Crypto(key); textBox3.Text = string.Empty; foreach (string temp in (ASCIIEncoding.ASCII.GetString(CR.Decrypt(ToBurtal))).Split(‘\n’)) {textBox3.Text += temp + Environment.NewLine; } key++; MinKeyTB.Text = (key).ToString(“X”);the min key textbox is wher

  • Duncan
    java encryption vigenere
    I have this Vigenère cipher code that works, but it spits out a number one on the first encryption when I put “Attack at Dawn” (POTTER). It comes out as 1inuhc Qi Xubf. What is causing this?public class vigenere {public static void main(String[] args) {System.out.println();char[] message = args[0].toCharArray();int code;int index = 0;code = args[1].charAt(index%args[1].length()) – 96;for(int i = 0; i < message.length; i++){code = args[1].charAt(index%args[1].length()) – 96;if(65 <= message

  • George
    php encoding
    I have tried to fix this myself and I just keep on making it worse. It was stupid but I played a little with the encoding and now I am getting Parse error: syntax error, unexpected T_STRING on line 1First It double spaced everything which was annoying But I could live with it. Now if I copy the text into microsoft notepad I loose all cariage returns. I take it in the end I want to be in utf-8. Is there way to do this without retyping.I am using windows and a shared host. As a side note I have g

  • Lissy
    java encoding utf-8
    I have to read the name of some files and put them in a list as a string. Its not so hard I just have some Problems with some characters like ä,ö,ü … they are always as a ‘?’ in my string.Whats the Problem? Well the encoding. Ok this should be easy… thats what i thought. So I tried to use functions like:new String(insert.getBytes(“UTF-8”) or new String(insert.getBytes(“ISO-8859-1”), “UTF-8”) because the most of the files are ISO-8859-1Its not helping. This is my code:… File[] fileList = di

  • Trace
    ruby-on-rails ruby ruby-on-rails-3 encoding
    I have a rails application and i keep getting this error /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: invalid multibyte char (US-ASCII) /srv/projects/app/controllers/application_controller.rb:174: syntax error, unexpected $end, expecting ‘)’ …e_title = h(“#{project_name} – #{name || translate_locatio… … ^and the fix should be here but when i added the line on top of my application

  • Marcelo
    python url encoding
    When I enter a URL into maps.google.com such as https://dl.dropbox.com/u/94943007/file.kml , it will encode this URL into:https:%2F%2Fdl.dropbox.com%2Fu%2F94943007%2Ffile.kmlI am wondering what is this encoding called and is there a way to encode a URL like this using python?I tried this:The process is called URL encoding:>>> urllib.quote(‘https://dl.dropbox.com/u/94943007/file.kml’, ”) ‘https%3A%2F%2Fdl.dropbox.com%2Fu%2F94943007%2Ffile.kml’but did not get the expected results:’https%

  • Toki Tom
    python unicode encoding utf-8
    Is there any harm to encoding a string multiple times in python, with the same encoding format? (i.e, UTF-8)?I have a function that uses another function to get a string from a document, and then serialize the string. Currently, the only user of the second function(the one which gets the string from the document) is the first function. This might change in the future, and someone might decide to use it in another serialization (or such) function, without encoding its result to UTF-8 first. I’m w

  • George Bailey
    html html5 encoding xss
    When encoding possibly unsafe data, is there a reason to encode >?It validates either way. The browser interprets the same either way, (In the cases of attr=”data”, attr=’data’, <tag>data</tag>)I think the reasons somebody would do this areTo simplify regex based tag removal. <[^>]+>? (rare) Non-quoted strings attr=data. 😮 (not happening!) Aesthetics in the code. (so what?)Am I missing anything?

  • Marius Zilenas
    csv unicode encoding utf-8 text-files
    I am reading a text file which I guess is encoded in utf-8. Some lines can only be decoded as latin-1 though. I would say this is very bad practice, but nevertheless I have to cope with it.I have the following questions:First: how can I “guess” the encoding of a file? I have tried enca, but in my machine:enca –list languages belarussian: CP1251 IBM866 ISO-8859-5 KOI8-UNI maccyr IBM855 KOI8-Ubulgarian: CP1251 ISO-8859-5 IBM855 maccyr ECMA-113czech: ISO-8859-2 CP1250 IBM852 KEYBCS2 macce KOI-8_CS

  • Anton
    r unicode encoding utf-8
    I have some special characters in my UTF-8 .R file and the attempt to run code as a file in the R command line returns unexpected INCOMPLETE_STRING.Meanwhile, the code runs okay line by line, say, in RStudio or Eclipse.I suggest I need to change the locale via Sys.setlocale(locale=), but all my attempts (including SO’s answers) to find the right locale parameter for UTF-8 gave OS reports request to set locale to “UTF-8” cannot be honored. I can set up something like Sys.setlocale(locale=”English

  • Dave L.
    java string encoding
    Using Java, I need to encode a Map<String, String> of name value pairs to store into a String, and be able to decode it again. These will be stored in a database column, and will probably usually be short and simple, so the common case should produce a simple nice looking line, but shouldn’t corrupt the data, even if it contains unexpected characters, etc.How would you choose to do it such that:The encoded form is a single, human readable line It doesn’t require a big library or much con

  • eli
    mysql encoding mysql-python
    I am getting the following Exception when trying to save a row to a db:Unexpected error: (<type ‘exceptions.UnicodeEncodeError’>, UnicodeEncodeError(‘latin-1’, u”First ‘A\u043a’ Last”, 7, 8, ‘ordinal not in range(256)’), <traceback object at 0x106562908>)Before inserting, I am converting every string in a dictionary to latin-1 like this:for k,v in row.items():if type(v) is str:row[k] = v.decode(‘utf-8’).encode(‘latin-1’)The offending character seems to be ‘A\u043a’ – in other cases t

  • PulpSpy
    signature certificates integrity timestamping
    I have a PDF document intended for long-term (many years, maybe decades) archival which I would like to digitally sign with my personal certificate to ensure its integrity.As far as I understand, I need to timestamp the signature in order to ensure it remains valid even after certificate expiration.Let’s say I use a trustworthy TSA. From what I understand they sign the timestamp with they own signature.Now, let’s suppose the original TSA bankrupts or is compromised and its certificates revoked.

  • Private
    gnupg signature
    I was trying to install the newest version of libpcap (as the version in the repositories doesn’t seem current) and ran into the following problem. I copied the tcpdump-workers.asc text from the tcpdump website (which hosts libpcap as well) and imported the key to my keyring using gpg –import tcpdump-workers.asc. That when all well and fine but when I tried to verify the libpcap-1.4.0.tar.gz file against the key with gpg –verify, I ended up getting the message that unexpected data. was found

  • Brett Powell
    c++ signature
    Im trying to get the engine version of a game from a global pointer, but I am fairly new to this. Here is a very small example I found…http://ampaste.net/mb42243And this is the disassembly for what I am trying to get, the pointer (gpszVersionString) is the highlighted line (line 5)http://ampaste.net/m2a8f8887So what I need to find out is basically using the example approach I found to get it, would I need to basically sig out the first part of the function and find the offset to that line?Like

  • bh9042
    c++ signature main
    The standard explicitly states that main has two valid (i.e., guaranteed to work) signatures; namely:int main(); int main(int, char*[]);My question is simple, would something like the following be legal?int main(const unsigned int, const char* const* argv);My tests say ‘yes’, but I’m unsure of the answer because am I not overloading main by changing int to unsigned int as well as the non top-level const-ness of argv? If I am, then that’s clearly prohibited.So, are these modifications guaranteed

  • Tim Schmelter
    c# signature
    I have the following code. Why it always goes to “take(ICollection a)” method? I think the object it self should be LinkedList or HashSet, so it should be calling the other two take method.class Program {static void Main(string[] args){Program p = new Program();ICollection<String>[] ary = { new LinkedList<String>(), new HashSet<String>() };foreach (ICollection<String> a in ary){p.take(a);}for (int i = 0; i < ary.Length; i++){p.take(ary[i]);}}public void take(HashSet&l

  • Elviss Strazdins
    ios xcode signature
    Is it possible to check if iOS application is signed by its developer at applications runtime? I tried to download .ipa of some apps and resigning them with my developer ID and almost all of them worked on my iOS device. But some of them didn’t, so I guess they are somehow checking if signature has changed and forbidding them to run if it is.I know, there is Code Signing Services for OSX, but I haven’t found a way to do this in iOS.Also I have read that after reviewing, apple signs application w

  • jWeaver
    java main signature main-method
    class NewClass{ public static void main(String a){System.out.print(“Hello”); } }When I’m trying to execute above code, then it shows an error, main method not found. But when I changed public static void main(String a) to public static void main(String… a) or public static void main(String a[]). Then, it works..!! So, My question is how many different ways we can write legal main method signature and what this signature public static void main(String… a) means ?

  • yafeya
    .net serialization version signature strongname
    I have a assembly with C# code. And the version of this assembly is 1.0.0.0. This Assembly’s information is serialized when i serialize the data of this assembly into binary. And then i update this assembly version into 4.0.0.0, **and i remove the signature**. When i de-serialize the data of assembly, an exception occur, which is “Could not load file or assembly ‘[AssemblyName], Version=1.0.0.0, Culture=neutral, PublicKeyToken=[TokenKey]’ or one of its dependencies. A strongly-named assembly is

  • Lelouch Lamperouge
    windows-7 dll signature
    On running SigCheck on my Windows box, I noticed quite a few dlls that are unsigned. For eg:c:\windows\system32\amdocl64.dll:Verified: UnsignedFile date: 10:47 AM 9/14/2011Publisher: Advanced Micro Devices Inc.Description: AMD Accelerated Parallel Processing OpenCL 1.1 RuntimeProduct: OpenCL 1.1 AMD-APP-SDK-v2.5 (732.1)Version: 2, 5, 732, 1File version: 2, 5, 732, 1 c:\windows\system32\amdoclcl64.dll:Verified: UnsignedFile date: 10:38 AM 9/14/2011Pub

  • CodesInChaos

  • Katherine Perotta
    java encryption encoding signature amazon-sns
    I am using exact code from here: http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AuthJavaSampleHMACSignature.htmlto generate a signature for my application. However, one line of code is not recognized in Eclipseresult = Encoding.EncodeBase64(rawHmac);Eclipse is saying it does not recognize the “Encoding” class. This is the exact error: The method EncodeBase64(byte[]) is undefined for the type Encoding I’ve tried importing the following 3 things:javax.sound.samp

Web site is in building