Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts
Wednesday, April 16, 2008
Migrating from acegi to spring security
So I migrated my current project from acegi 1.0.5 to spring security 2.0.0-RC1. Here are my notes incase anyone might find this useful. Pom.xml changes: org.springframework.security spring-security-core ${spring.security.version} spring-aop org.springframework spring-dao org.springframework spring-jdbc org.springframework spring-remoting org.springframework spring-support org.springframework org.springframework spring org.springframework.security spring-security-taglibs ${spring.security.version} org.springframework.security spring-security-acl ${spring.security.version} And I defined a variable in our root pom 2.0.0-RC1 The new jars also change all the package name from 'org.acegisecurity' to 'org.springframework.security' I just did a find and replace in idea and that seemed to work fine. Static variable have also changed their prefix from 'AGEGI_' to 'SPRING_SECURITY_'. I did another replace in path with IDEA to do this as well. Taglibs. Tag libs have changed a little too. You should replace <%@ taglib uri="http://acegisecurity.org/authz" prefix="authz" %> with <%@ taglib uri="http://www.springframework.org/security/tags" prefix="authz" %> The authentication tag also works differently. I had to replace things like with ${user.fullName} After all this everything seems to be working perfectly. Next step is to refactor our security configuration to the newer model.
Wednesday, March 28, 2007
Microsoft Coding Question #1
I recently had the privilege of interviewing at Microsoft. I figured I'd post the technical questions and answers in case they might help someone out there.
So here is the first one:
Given a Binary Tree, provide a method to traverse it depth first. Print the value of each node to the console.
We will assume there are methods to get the root node of a tree (rootNode) and the left and right nodes of a node (leftNode, rightNode)
Ex:

Should print 2,3,1,4,5
Solution (Recursive):
public void printTree(BinaryTree tree)
{
if(tree !=null)
printNodes(tree.rootNode);
}
private void printNode(Node node)
{
if(node != null)
{
Console.writeLine(node.data);
printNode(node.leftNode);
printNode(node.rightNode);
}
}
Solution (Non-recursive):
public void printTree(BinaryTree tree)
{
if(tree !=null)
{
Stack<binarytree.node> stack = new Stack<binarytree.node>;
stack.Push(tree.rootNode);
while (stack.Count != 0)
{
BinaryTree.Node currentNode = stack.Pop();
Console.WriteLine(currentNode.data);
if (currentNode.rightNode != null)
stack.Push(currentNode.rightNode);
if (currentNode.leftNode != null)
stack.Push(currentNode.leftNode); }
}
}
So here is the first one:
Given a Binary Tree, provide a method to traverse it depth first. Print the value of each node to the console.
We will assume there are methods to get the root node of a tree (rootNode) and the left and right nodes of a node (leftNode, rightNode)
Ex:
Should print 2,3,1,4,5
Solution (Recursive):
public void printTree(BinaryTree tree)
{
if(tree !=null)
printNodes(tree.rootNode);
}
private void printNode(Node node)
{
if(node != null)
{
Console.writeLine(node.data);
printNode(node.leftNode);
printNode(node.rightNode);
}
}
Solution (Non-recursive):
public void printTree(BinaryTree tree)
{
if(tree !=null)
{
Stack<binarytree.node> stack = new Stack<binarytree.node>;
stack.Push(tree.rootNode);
while (stack.Count != 0)
{
BinaryTree.Node currentNode = stack.Pop();
Console.WriteLine(currentNode.data);
if (currentNode.rightNode != null)
stack.Push(currentNode.rightNode);
if (currentNode.leftNode != null)
stack.Push(currentNode.leftNode); }
}
}
Subscribe to:
Posts (Atom)