TCS Security API Programming

Quiz covering TCS Security API methods for password hashing, encoding, XSS/SQL injection prevention, CSRF protection, and digital signatures

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

What is the signature of the sign method in the security API?

  1. java.lang.String sign(java.lang.String data, java.lang.String key) throws EncryptionException
  2. java.lang.String sign(java.lang.String data, java.lang.String key)
  3. java.lang.String sign(java.lang.String data)
  4. java.lang.String sign(java.lang.String data) throws SecurityException
Question 2 Multiple Choice (Single Answer)

What is the signature of the seal method in the security API?

  1. java.lang.String seal(java.lang.String data,long timestamp) throws SecurityException
  2. java.lang.String seal(java.lang.String data,long timestamp) throws EncryptionException
  3. java.lang.String seal(java.lang.String data)
  4. java.lang.String seal(java.lang.String data) throws EncryptionException
Question 3 Multiple Choice (Single Answer)

"SELECT name FROM users WHERE id = " + form.getUserID()"; Using TCS SAPI what is the best way to remediate the SQL injection vulnerability in the above query to an Oracle Database?

  1. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(validatedUserId);
  2. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL(validatedUserId);
  3. "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL( new Codec(), validatedUserId);
  4. None of the above
Question 4 Multiple Choice (Single Answer)

What is the best methodology to remediate the SQL Injection vulnerability in a Java based web application?

  1. Use the com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(String input) method
  2. Use PreparedStatement constructs and use the setXXX methods on the PreparedStatement object
  3. Use the Java createStatement construct to execute the query
  4. Concatenate your SQL string together using dynamic input and create and execute a PreparedStatement object using that query
Question 5 Multiple Choice (Single Answer)

Which among the below is the correct way to safely encode the URL "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" )

  1. String safeURIToDisplay= "/admin/findUser.do?name=" + TCSSAPI.encoder().encodeForJavaScript(request.getParameter( "dangerousInput"));
  2. String safeURIToDisplay = TCSSAPI.encoder().encodeForURL( "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" ) );
  3. String safeURIToDisplay= "/admin/findUser.do?name=" + com.tcs.sapi.io.ValidationUtil.encodeForURL(request.getParameter( "dangerousInput"));
  4. None of the above
Question 6 Multiple Choice (Single Answer)

Whats the use of adding the CSRF Token to the urls?

  1. Prevent Cross Site Scripting
  2. Prevent Cross Site Request Forgery
  3. Prevent Cross Site Tracing
  4. None of the above
Question 7 Multiple Choice (Single Answer)

What does isSecureRequest(HttpServletRequest request) method accomplish?

  1. It checks if the http request is made on an SSL channel
  2. It checks if the http method is a POST
  3. Both of the above
  4. None of the above
Question 8 Multiple Choice (Single Answer)

What messages does an object of EnterpriseSecurityException class contain?

  1. Log Message which gets logged in the log file and not safe to display to users
  2. User Message which is safe to display to users
  3. Both of the above
  4. None of the above
Question 9 Multiple Choice (Single Answer)

What exception is thrown by the security API when a user attempts to access a resource that they are not authorized for?

  1. SecurityException
  2. AccessException
  3. AuthenitcationException
  4. Exception
Question 10 Multiple Choice (Single Answer)

What is the most common exception thrown by the validation methods in the security API?

  1. Validation Exception
  2. SecurityException
  3. Encoding Exception
  4. Encryption Exception
Question 11 Multiple Choice (Single Answer)

The usage of setRememberToken is

  1. Generally recommended
  2. Generally not recommended
  3. Should always be used
  4. Should not be used at all
Question 12 Multiple Choice (Single Answer)

What are the different levels of logging provided in the API?

  1. Trace, warn, error and fatal
  2. Trace, debug, info, warn, error and fatal
  3. Debug, info, error, fatal
  4. Debug, Warn, Error
Question 13 Multiple Choice (Single Answer)

Which methods in the TCS SAPI can be used to prevent Cross Site Scripting Attacks?

  1. isSafeHTML(java.lang.String context, java.lang.String input, boolean allowNull) and encodeForHTML(java.lang.String input)
  2. isSafeHTML(java.lang.String context, java.lang.String input)
  3. SafeHTML(java.lang.String context, java.lang.String input)
  4. ValidHTML(java.lang.String context, java.lang.String input)
Question 14 Multiple Choice (Single Answer)

What is the base class for all Security related exceptions in the security API?

  1. SecurityException
  2. EnterpriseException
  3. EnterpriseSecurityException
  4. None of the above
Question 15 Multiple Choice (Single Answer)

What is used as the salt value in the hash function available in the TCS SAPI?

  1. A constant value stored as plain text within a configuration file
  2. There is no salt added while calculating the hash value
  3. The accountName is used as the salt value
  4. The salt value is calculated from the password value
Question 16 Multiple Choice (Single Answer)

What is meant by Canonicalization?

  1. Its a form of encoding
  2. Its a form of encryption
  3. Its a form of decryption
  4. Its simply the operation of reducing a possibly encoded string down to its simplest form
Question 17 Multiple Choice (Single Answer)

What is the functionality of the sign() method?

  1. Encrypts the input and returns the encrypted string
  2. Encodes the data
  3. Hashes the data
  4. Create a digital signature for the provided input data and return the signature in a string
Question 18 Multiple Choice (Single Answer)

Which methods in the TCS SAPI can be used to prevent Path Traversal?

  1. isValidDirectory( java.lang.String context, java.lang.String input)
  2. isValidDirectory( java.lang.String context, java.lang.String input) and isValidFileName(java.lang.String context, java.lang.String input)
  3. isSafeDirectoryPath(java.lang.String context, java.lang.String input,boolean allowNull) and isSafeFileName(java.lang.String context, java.lang.String input,boolean allowNull)
  4. ValidateDirectoryPath(java.lang.String context, java.lang.String input,boolean allowNull)
Question 19 Multiple Choice (Single Answer)

What is the method signature for hashing password?

  1. String hashPassword(String password)
  2. String hashPassword(String password, String accountName)
  3. String hashpassword(String password)
  4. None of the above
Question 20 Multiple Choice (Single Answer)

What is the return type of the verifyPasswordStrength() method in the security API?

  1. Boolean
  2. String
  3. Integer
  4. void