Mckenzie John

Greenhorn
+ Follow
since Sep 21, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mckenzie John

Can you give me a code snippet?
8 years ago
Hello experts,

I have a requirement to query the database for a particular set of records. the query is based on specific date interval. The date from the front end is going to be "mm/dd/yyyy" format. But i need to convert it to timeinmilliseconds format to query the timestamp.

I face the following challenge:

When i select the dates i should be able to search the database from 00:00:00 of the start date to 23:59:59 of the end date for a valid case. How do i get this done. I am not able to find out how to add 23:59:59 to the end date formatted.

Need help here.

My piece of code:

SimpleDateFormat format1 = new SimpleDateFormat("MM/dd/yyyy");
SimpleDateFormat format2 = new SimpleDateFormat("dd-M-yyyy HH:mm:ss");
SimpleDateFormat format3 = new SimpleDateFormat("dd-M-yyyy 23:59:59");
Date date = format1.parse(fromUI);
String convertedFormatStartString = format2.format(date);
String convertedFormatEndString = format3.format(date);

System.out.println(convertedFormatStartString);
System.out.println(convertedFormatEndString);

DateFormat format = new SimpleDateFormat("dd-M-yyyy HH:mm:ss");
Date finalStartDate = format.parse(convertedFormatStartString);
System.out.println("P"+finalStartDate);

System.out.println(finalStartDate.getTime());

DateFormat eformat = new SimpleDateFormat("dd-M-yyyy 23:59:59");
Date finalEndDate = eformat.parse(convertedFormatEndString);
System.out.println(finalEndDate);

System.out.println(finalEndDate.getTime());

-----------------------------

OUTPUT:
30-9-2015 00:00:00
30-9-2015 23:59:59
PWed Sep 30 00:00:00 PDT 2015 ------------ Start
1443596400000
Wed Sep 30 00:00:00 PDT 2015 ------------ END (this needs to be 23:59:59 further from the 00:00:00)
1443596400000

Please guide
8 years ago
Jerry,

Can you please Provide a working snippet
8 years ago
A code snippet would help me better. Can you please share one?
8 years ago
How do i extract the HTML content from a HttpResponse Object.?

I have a response object which i need to intercept and modify the appearance before it gets rendered in the browser. I have a separate API which does the modification but how do i pass the response object to the API which accepts only HTM as string to get this done.

Is there a way to get the entire html content of the end page from the response object using a custom filter. We have this application with a spring filter chain to intercept URLs.

Helpful ideas are useful.
8 years ago
Hi all,

We need to read and parse XLS and XLSX fomat files . But as a security measure we need to check for any embedded files and find their Mime types to check if parsing has to continue or not. For XLS sheets i came across the logic :

workbook.getAllEmbeddedObjects()

Which returns the OLE2ClassName. But is there anyway where we can get the file type as which is returned by the MimeType Detectors we have. Any ideas / Coding logic to resolve this will be very useful. The idea is to obtain the Mimetype of the files , if any , embedded within the Excel sheets and to take necessary action if they fall under the Disallowed mimetypes.


Thanks,
Mckenzie
10 years ago
Hi all,

i have a regex to validate a username with the following requirements -

1) Can start with lowerCase or Uppercase A-Z
2) Can include_ or . or - anywhere in the string but not at the first character
3) Can Include special characters - @ & anywhere in the string but not at the first character
4) Should be of minimum 3 characters in length
5) Should not include special characters - !#$%^*()/*-+/\

I had come up with a Regex :
String user = "[a-zA-Z0-9\\._\\-](?!#$%^*()/*-+/\]) {3,}"; \\ Not sure how to exlcude / and \ here

Can some one help me in this and also help me understand the right expression.

I also have another requirement where i need to meet default AD password Policy. in net i came across the following patter:

(?=^.{8,255}$)((?=.*[A-Z])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[a-z])|(?=.*[^A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])|(?=.*[A-Z])(?=.*[^A-Za-z0-9]))^.*

Can some one help me make sense of this?

Thanks in Advance !!!
10 years ago
Bill Gorder ,

Thanks for the response. The root cause is that i can see that the CAS TGC cookie still existing on the browser , which needs to be invalidated. If you could see the spring config shared , you can see that i am exactly doing the same



1) calling j_spring_security_logout which invalidates application session and also clears security context.

2) On the success , we are directly calling the /cas/logout (please see the constructor arg for LogoutFilter) with which we have appended the url param to where the user has to be finally sent.


What I can see is that the TGT for the session in CAS is getting destroyed, but we can see the CASTGC cookie still sits in the browser. There is also no trail in the logs as to the cookie being destroyed or expired.

I understand that we need to somehow incorporate the /j_spring_cas_security_logout which will invoke the Single SignOut Filter that i believe will expire/remove the cookie. But my requirement is it has to be in addition to my already configured j_spring_security_logout.

Some help in this direction will be helpful.

And yeah my URLs are absolute

Thanks,
Mckenzie
11 years ago
Hi,

I have a problem with my Logout functionality in my application which using CAS integrated with Spring security. My spring configuration is as below:

<bean id="logoutFilter" class="org.springframework.security.web.authentica tion.logout.LogoutFilter">
<!-- URL redirected to after logout success -->
<constructor-arg value="https://casURL/cas-server-webapp-3.5.1/logout?service=applnURL"/>

<constructor-arg>
<list>
<bean class="org.springframework.security.web.authentica tion.logout.SecurityContextLogoutHandler"/>
<bean class="com.blah.blah.sso.logout.CustomLogoutHandle r"/>
</list>
</constructor-arg>
</bean>

On clicking of the Logout link in my application URL with URl /j_spring_security_logout which invalidates session in SecurityContextLogoutHandler and redirects to the service as in the constructor. Our expected behaviour is that the CAS must log itself out ,invalidate session both in CAS and application and redirect to the service configured as above.

What actually happens is that i am getting the service URL getting called but CAS is not creating the ST for the valid user i give at THIS point of time in the CAS login page.

Any help please.

Thanks,
Mckenzie
11 years ago
Hi,

I have a problem with my Logout functionality in my application which using CAS integrated with Spring security. My spring configuration is as below:

<bean id="logoutFilter" class="org.springframework.security.web.authentica tion.logout.LogoutFilter">
<!-- URL redirected to after logout success -->
<constructor-arg value="https://casURL/cas-server-webapp-3.5.1/logout?service=applnURL"/>

<constructor-arg>
<list>
<bean class="org.springframework.security.web.authentica tion.logout.SecurityContextLogoutHandler"/>
<bean class="com.blah.blah.sso.logout.CustomLogoutHandle r"/>
</list>
</constructor-arg>
</bean>

On clicking of the Logout link in my application URL with URl /j_spring_security_logout which invalidates session in SecurityContextLogoutHandler and redirects to the service as in the constructor. Our expected behaviour is that the CAS must log itself out ,invalidate session both in CAS and application and redirect to the service configured as above.

What actually happens is that i am getting the service URL getting called but CAS is not creating the ST for the valid user i give at THIS point of time in the CAS login page.

Any help please.

Thanks,
Mckenzie
11 years ago
Hi,

I am facing a problem with logout of my CAS integrated with Spring security. My requirements are - when i click on the logout of my application - i need to logout of my application, and also invalidate the session in CAS and be redirected to the CAS login page on successful logout.

I am getting an Exception encountered - java.lang.IllegalStateException when i try to redirect my application using the customLogoutHandler to the CAS login page. My logout method in customLogoutHandler implementing Spring LgoutHandler is


public void logout(HttpServletRequest request, HttpServletResponse response,
Authentication auth) {
// TODO Auto-generated method stub

try {
response.sendRedirect("https://application URL /logout.jspa");

} catch (IOException e) {

e.printStackTrace();
}


}

From the logs in the application i see this exception - Exception encountered -
java.lang.IllegalStateException

Websites say that i am trying to redirect a page and one of the following has occurred before it:

A response header has been set before.
A forward() or include() has been invoked on the same response before.
More than 2KB of data is been written to response.
Less than 2KB is been written and flush() is invoked


Need some help in this.

Thanks,
Mckenzie
11 years ago
Hi all,

We are looking for a way to implement a custom logout filter in our application which has a CAS setup. Our requirement is to have the session cleared both in CAS and the application from where our logout is called from. I am a newbie to Spring security. I understand from some of the sites that we may need to write our own custom logout handler which implements LogoutHandler. My Spring config file looks lie

<bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
<!-- URL redirected to after logout success -->
<constructor-arg value="URL to Which i want to redirect on successful logout"/>
<constructor-arg>
<list>
<bean class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"/>
</list>
</constructor-arg>
</bean>

I would like to have some help in the following areas:

1) any pointers which can help me the functionality of the logout action in Spring security context.

2) A simple example of how to write a custom logout handler with which i can invalidate the session created.

3) Help on the part of invalidating session in CAS along with this code will be much appreciated.


Thanks ,
McK
11 years ago
Hi,

I have some queries regarding the logic behind the java and javac commands searching for a class file and the jar file in the class path and also the javac command searching for the java file in the specified directories.

Assume we are in a directory A(dir A) which is a direct sub directory of root(/) which has 2 more directories named as Dir B, Dir C within it. Now we have a JavaFile.java in the Dir C.

Can you please check if my assumptions are correct with respect to the above?

a) at Dir A javac classpath:/dirA/dir C : dir A JavaFile.java - My understanding is it will search the dirC first and will be able to compile the same.

b) at Dir A javac JavaFile.java - will it still be able to find the java file as javac command will search the current directory(which will also look into the Dir C) contained in it? Please clarify

c) at Dir A javac classpath:/dir A JavaFile.java - this is similar as B because the classpath is just for classes and also javac will search for java files in the current directory. In this case if assumption b is true , this also will compile

Please clarify the above. Thanks
Hi

i need to understand the file I/O operations in the following code

package com.scjp;


[Anayonkar]: Added code tags


I have added my questions against the lines as comment. Please help me understanding the concepts.

Thanks,
Mckenzie
Which of the objects will be eligible for garbage collection at the end of this program and why. i just want a very brief explanation step by step which can help me understand the concept