TCS Security API Programming
Quiz covering TCS Security API methods for password hashing, encoding, XSS/SQL injection prevention, CSRF protection, and digital signatures
Questions
What is the signature of the sign method in the security API?
- java.lang.String sign(java.lang.String data, java.lang.String key) throws EncryptionException
- java.lang.String sign(java.lang.String data, java.lang.String key)
- java.lang.String sign(java.lang.String data)
- java.lang.String sign(java.lang.String data) throws SecurityException
What is the signature of the seal method in the security API?
- java.lang.String seal(java.lang.String data,long timestamp) throws SecurityException
- java.lang.String seal(java.lang.String data,long timestamp) throws EncryptionException
- java.lang.String seal(java.lang.String data)
- java.lang.String seal(java.lang.String data) throws EncryptionException
"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?
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(validatedUserId);
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL(validatedUserId);
- "SELECT name FROM users WHERE id = " + com.tcs.sapi.io.ValidationUtil.encodeForSQL( new Codec(), validatedUserId);
- None of the above
What is the best methodology to remediate the SQL Injection vulnerability in a Java based web application?
- Use the com.tcs.sapi.io.ValidationUtil.encodeForOraSQL(String input) method
- Use PreparedStatement constructs and use the setXXX methods on the PreparedStatement object
- Use the Java createStatement construct to execute the query
- Concatenate your SQL string together using dynamic input and create and execute a PreparedStatement object using that query
Which among the below is the correct way to safely encode the URL "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" )
- String safeURIToDisplay= "/admin/findUser.do?name=" + TCSSAPI.encoder().encodeForJavaScript(request.getParameter( "dangerousInput"));
- String safeURIToDisplay = TCSSAPI.encoder().encodeForURL( "/admin/findUser.do?name=" + request.getParameter( "dangerousInput" ) );
- String safeURIToDisplay= "/admin/findUser.do?name=" + com.tcs.sapi.io.ValidationUtil.encodeForURL(request.getParameter( "dangerousInput"));
- None of the above
Whats the use of adding the CSRF Token to the urls?
- Prevent Cross Site Scripting
- Prevent Cross Site Request Forgery
- Prevent Cross Site Tracing
- None of the above
What does isSecureRequest(HttpServletRequest request) method accomplish?
- It checks if the http request is made on an SSL channel
- It checks if the http method is a POST
- Both of the above
- None of the above
What messages does an object of EnterpriseSecurityException class contain?
- Log Message which gets logged in the log file and not safe to display to users
- User Message which is safe to display to users
- Both of the above
- None of the above
What exception is thrown by the security API when a user attempts to access a resource that they are not authorized for?
- SecurityException
- AccessException
- AuthenitcationException
- Exception
What is the most common exception thrown by the validation methods in the security API?
- Validation Exception
- SecurityException
- Encoding Exception
- Encryption Exception
The usage of setRememberToken is
- Generally recommended
- Generally not recommended
- Should always be used
- Should not be used at all
What are the different levels of logging provided in the API?
- Trace, warn, error and fatal
- Trace, debug, info, warn, error and fatal
- Debug, info, error, fatal
- Debug, Warn, Error
Which methods in the TCS SAPI can be used to prevent Cross Site Scripting Attacks?
- isSafeHTML(java.lang.String context, java.lang.String input, boolean allowNull) and encodeForHTML(java.lang.String input)
- isSafeHTML(java.lang.String context, java.lang.String input)
- SafeHTML(java.lang.String context, java.lang.String input)
- ValidHTML(java.lang.String context, java.lang.String input)
What is the base class for all Security related exceptions in the security API?
- SecurityException
- EnterpriseException
- EnterpriseSecurityException
- None of the above
What is used as the salt value in the hash function available in the TCS SAPI?
- A constant value stored as plain text within a configuration file
- There is no salt added while calculating the hash value
- The accountName is used as the salt value
- The salt value is calculated from the password value
What is meant by Canonicalization?
- Its a form of encoding
- Its a form of encryption
- Its a form of decryption
- Its simply the operation of reducing a possibly encoded string down to its simplest form
What is the functionality of the sign() method?
- Encrypts the input and returns the encrypted string
- Encodes the data
- Hashes the data
- Create a digital signature for the provided input data and return the signature in a string
Which methods in the TCS SAPI can be used to prevent Path Traversal?
- isValidDirectory( java.lang.String context, java.lang.String input)
- isValidDirectory( java.lang.String context, java.lang.String input) and isValidFileName(java.lang.String context, java.lang.String input)
- isSafeDirectoryPath(java.lang.String context, java.lang.String input,boolean allowNull) and isSafeFileName(java.lang.String context, java.lang.String input,boolean allowNull)
- ValidateDirectoryPath(java.lang.String context, java.lang.String input,boolean allowNull)
What is the method signature for hashing password?
- String hashPassword(String password)
- String hashPassword(String password, String accountName)
- String hashpassword(String password)
- None of the above
What is the return type of the verifyPasswordStrength() method in the security API?
- Boolean
- String
- Integer
- void