Wednesday, 30 October 2013

Linux - Routing

Linux - Routing

So in the past week I have had a challenge with regards to Routing in IPTABLES, and one of the problems I faced was I had no GUI to implement it, only terminal.

I needed routing enabled on network card: eth0

I am assuming you are logged in as root.

IPTables


The first thing we need to do is check to see if iptables are enabled, or just enable them.
One way to see if your iptables are enabled it to run
iptables -L
iptables -L

to enable the iptables temporarily, run
iptables start

if you want to enable iptables on boot us this
chkconfig iptables on

Routing


Now that we have iptables enabled, we can start with the forwarding.

Firstly check to see if the network device has forwarding enabled
by running 
cat /proc/sys/net/ipv4/conf/eth0/forwarding

if this returns 0, run this
echo '1' > /proc/sys/net/ipv4/conf/eth0/forwarding


Now that this is enabled, we need to enable MASQUERADE.
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Ok, so I needed to route two ports, SSH and HTTP, the IP i needed routing two was 192.168.1.18
To do that I used these commands:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 9022 -j DNAT --to 192.168.1.18:22
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 9001 -j DNAT --to 192.168.1.18:80

To make sure these have been enabled, you can use more than one command but the one I prefer is
iptables -t nat -L -n -v


Note: This is what I did to get routing working on OEL5, if this does not work for you, please leave a comment and I will try help you as much as I can.

#bearMan out.

Monday, 28 October 2013

https://forums.oracle.com/thread/2596857

I tried to reply to you.

https://forums.oracle.com/thread/2596857




Sorry..

#bearMan

ADF - Region Error Multiple Root Components

The region component with id: x has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.

This error does not have anything to do with your Page holding your Region, it has to do with your Region (r1 - tfdAssignGraph).

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:f="http://java.sun.com/jsf/core">
  <af:decorativeBox id="db1">
    <f:facet name="center"/>
    <f:facet name="top"/>
  </af:decorativeBox>
  <af:decorativeBox id="db2">
    <f:facet name="center"/>
    <f:facet name="top"/>
  </af:decorativeBox>
</jsp:root>


You can solve the issue by having some other component as the "Root" component, like this:
Resolved is replacing what you have with one "Root" Component.

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:f="http://java.sun.com/jsf/core">
  <af:panelGroupLayout id="pgl1">
    <af:decorativeBox id="db1">
      <f:facet name="center"/>
      <f:facet name="top"/>
    </af:decorativeBox>
    <af:decorativeBox id="db2">
      <f:facet name="center"/>
      <f:facet name="top"/>
    </af:decorativeBox>
  </af:panelGroupLayout>
</jsp:root>

I hope this helps.

#bearMan

Friday, 25 October 2013

ADF CheatSheet: Create Bindings Quickly

ADF CheatSheet: Create Bindings Quickly


Hello and welcome back to my evolutionary blog ;)

Have you ever needed to create many Page Bindings, quickly, but not needed a UI for them?

A quick way to create them is to find the attribute you needed in the Bindings area, and drag and drop that binding as though you were creating the UI for it. Once the UI part of it is done, you can cut that component off, there will be a dialog to ask if you want to remove the Bindings as well, and you must say no.

ctrl+X

Before
After

#bearMan out.

Wednesday, 23 October 2013

ADF - Synchronizing form with recursive tree


ADF - Synchronizing form with recursive tree

We have a recursive tree, and we need a table to be edited. The form needs to update on tree selection.

Firstly, I am am going to be using the HR schema and the Employees Table.

My Data Controls
Data Controls, with employee Recursion

Firstly I created the Tree on the page (With the Employees1 Data Control) this resulted in the following bindings:

Page Bindings - Tree


Then I Created the Form on the Page (with EmployeesForm Data Control), this resulted in the following Bindings.
Page Bindings - Tree and Form
Once that was completed, I selected the Employees1 Binding, and changed the EL Expression, by clicking the "EL Picker" button, selecting the "EmployeesFormIterator".

EL EXpression Picker
Then on the Page, I changed the Forms Partial Trigger to being the Tree

Then you are ready to go.

Run the Application, and here are two screen shots of the results.

Screen Shot 1

Screen Shot 2

Hope this helps you.

#bearMan out.

ADF - Tree Table Display Field

ADF - Tree Table Display Specific Field

If you need to display a certain field in within a tree Component, but are not wanting to display that attribute, this will help you to display.
Unclean Display
Clean Display

if you only want to display one Attribute, you can follow these steps.

Firstly you need to click on the tree, and take note of what attributes you want to display.
Country Display Attribute
For this Tree level we want to display the Country Name -> "CountryName"
Location Display Attributes
For the second level of the tree, we want to display the Province -> "StateProvince"

Once you have gotten that, you must go to the page, and select the tree you want to display.
Change the Output text Value from #{node} to #{node.CountryName}
Output Text Value Selection and Change
Add a Output Text to the Node Stamp, this can either be done using the component Palette or By Coping and Pasting the Current Output Text.

Once that has been done, select and change that value to "#{node.StateProvince}"


The reason this works is because when there is no country there will be nothing in that Output Text.

If you get an error while doing this, you can change the rendered Value to 
#{node.StateProvince eq null?"false":"true"}

Enjoy ;)

#bearMan

Tuesday, 22 October 2013

Linux - Port Scan Command

Linux - Port Scan Command

Yesterday I was tasked to get open and closed ports on a specific IP address.

I found a website that I started from http://www.catonmat.net/blog/tcp-port-scanner-in-bash/

Once I was there I modified his one procedure and came up with mine.


scan() {
  if [[ -z $1 || -z $2 ]]; then
    echo "Usage: $0 <host> <port, ports, or port-range>"
    return
  fi

  local host=$1
  local ports=()
  local endS=0
  local exS=''
  case $2 in
    *-*)
      IFS=- read start end <<< "$2"

      if ((end - start > 10)); then
        endS=$start
        while [ $endS -lt  $(($end-10)) ]; do
          endS=$(($endS+10));
          (scan $host $(($endS-10))-$endS) &
        done
        wait
        echo "done $(date -d "today" +"%Y%m%d%H%M")"
        return
      fi

      for ((port=start; port <= end; port++)); do
        ports+=($port)
      done
      ;;
    *,*)
      IFS=, read -ra ports <<< "$2"
      ;;
    *)
      ports+=($2)
      ;;
  esac

  for port in "${ports[@]}"; do
    timeout 1 bash -c  "echo >/dev/tcp/$host/$port" &&
      echo -e "<$(date -d "today" +"%Y%m%d%H%M")>\t<$host>\tport $port is open" >> ~/Documents/@hack/log-$host.log ||
        echo -e "<$(date -d "today" +"%Y%m%d%H%M")>\t<$host>\tport $port NOT open" >> ~/Documents/@hack/log-$host.log
  done
}

Example use:
scan www.bjorn.co.za 80


#bearMan

Monday, 21 October 2013

JDeveloper: Making the most of your IDE, Java Block Coloring

Java Block Coloring

JDeveloper has an awesome feature of coloring some of your java Code Blocks.

This is a nice feature and can be useful when Coding.

Below is an image of the "default" look.

No Coloring
You can enable this through the icon pointed out below.
Icon to Color
An example of what the code looks like when its colored.
Code Colored

Enjoy!

#bearMan

Friday, 18 October 2013

JDeveloper: Making the most of your IDE, External Applications

External Application

I had this issue of when I am working on my projects I either get lazy and don't want to navigate to where the application is, or I need to edit a file outside of JDeveloper.

JDeveloper has built in functionality to allow us to execute external application. This is how to do it.

Step 1: Click on tools and then External Tools
Step 2: Click on Find Tools
 If you are happy with just those Tools then proceed to step 9. If you want to include an external tool, then you can continue to step 4.

Adding a "External Tool Manually"

Step 4: Click on new after that, a popup screen will be displayed.
Step 4: Keep the Tool Type as External Program, and click next.
Step 5: Browse to the application you want, in "Program Executable", in the "arguments"choose insert, all the rest should be inserted automatically.
Step 4 and 5

Macro, Argument
Step 6: Choose for yourself, what you want to name the shortcut and add a ToolTip.
Viewing Names

Step 7: The next step, you will be selecting where the application will be displayed.
Shortcut Location
 Step 8: Once you have completed the location settings, you choose under what conditions your shortcut will be displayed / enabled. Once you have done this, click Finish.
Display Criteria
Step 9: Save Changes, and click Ok.

Results




#bearMan out.

Wednesday, 16 October 2013

ADF Security: Display User Roles

ADF Security: Display User Roles

so today I want to show you two things you can do, and this is how to display user roles in the Console.

The first method is,
ADFContext.getCurrent().getSecurityContext().getUserRoles();

This returns an array of Strings, this is an array of all the roles the user has against his / her name.

This code
for (String s : ADFContext.getCurrent().getSecurityContext().getUserRoles()) {
    System.out.println("\t\t" + s);
}

will display all the roles the logged in user has.

the import you will need for this code to work is:
import oracle.adf.share.ADFContext;

#bearMan out.

Monday, 14 October 2013

JDeveloper: Making the most of your IDE, Application Navigator

Application Navigator Project Explorer

So sometimes, you want to view your application in a different light or with a different level of package names.

Here is my default view of a basic Project.
To change how many packages you see, or how the project is displayed, you must click on the highlighted icon on the image below.


Note: View Controller and Model packages are controlled independently 




Here are my favorite Package Levels, they range from between 2 and 4.


#bearMan

Friday, 11 October 2013

Linux - Display Firewall Rules

Linux - Display Firewall Rules

iptables -L -n

This will display all the firewall Rules

Commands I often use.

#bearMan

Wednesday, 9 October 2013

Linux - Search History

Linux - Search History

An awesome command Kevin Stroud showed me.

history | grep <Search Term>

#bearMan

Monday, 7 October 2013

ADF CheatSheet: VO Attribute value

ADF CheatSheet: VO Attribute value

One thing I also do alot for auditing is setting Attributes to who created it or when it was created for those.

To see who edited something, or to set a value to an Attribute that is stored in a Session Variable you can use the code below in order to set the default value to that attribute.

adf.context.current.sessionScope.get('empId')
For Date
adf.currentDate
For Date and Time
adf.currentDateTime
Just one thing, make sure you set the sessionScope variable to the same Object type as the Attribute.
#bearMan

Friday, 4 October 2013

ADF CheatSheet: EO Sequence

ADF CheatSheet: EO Sequence

One thing I use alot is sequences, one thing you can do to set a default value to the sequence, is change a Attribute to Type: DBSequence and set the default value to

(new oracle.jbo.server.SequenceImpl("USERS_SEQ", object.getDBTransaction())).getSequenceNumber()

#bearMan

Thursday, 3 October 2013

ADF - XML-20108

ADF - XML-20108

Today my colleague had an error "XML-20108"

Error(1,1): <Line 1, Column 1>: XML-20108: (Fatal Error) Start of root element expected.

If the File that is causing the error is a ".rdf".
To fix this error all you need to do is delete the

If the file is another file, ie "xml" please make sure the first line in the file is
<?xml version="1.0" encoding="UTF-8"?>

#bearMan