waffel’s Weblog

März 5, 2018

How to disable the visualization of Inject Environment variables jenkins

Filed under: administration,webmaster — Thomas Wabner @ 6:27 pm
Tags:

Today I was forced by a Jenkins warning, that my settings for the EnvInjectPlugin where not ok.

So I searched about the security warning and found this here:

„Disable the visualization of Injected Environment variables in the global configuration.“

Now I started to search around where I can made this setting. I ended up on the „Configure Global Security“ settings site. There is a checkbox at the bottom of the site to let me do this. Not so easy to find.

So go to Jenkins >> manage >> Configure Global Security and check mark „Do not show injected variables“

Advertisements

Juli 27, 2017

calling NTLMv2 protected ASPX webservice with Spring Boot

Filed under: java,spring — Thomas Wabner @ 9:06 am

What a challenge. I tried to call a REST webservice from a ASPX website with my springboot application. The REST service only supports POST requests (I do not understand why, but this is maybe another story).

When I use the default spring RestTemplate to invoke a REST request I always get error 404 or 401 from the REST service. Doing the same with Chrome or IE the request works without any problem. So what is the difference?

It seems our browsers doing more than the spring RestTemplate. They are doing some roundtrips to handle NTLM authentication. The question is now: How can I do the same with spring?

The answer is fairly simple but I do not have found any official documentation about this. Simple do something like the following:


RestTemplate template = new RestTemplate();
// !!! We require this request to work with NTLMv2
template.headForHeaders("https://mydomain/theAspxService/");

The headForHeaders() method do the NTLMv2 authentication stuff. Any further requests using then the Ntlm auth header to talk with the ASPX service and they can then authenticate and invoke the requests.

For sure, you need general able to authenticate to the service. So check first with your browser if the requests really working for your windows user.

Januar 8, 2015

update wrong timestamp for a page in mediawiki

Filed under: administration — Thomas Wabner @ 4:54 pm
Tags:

I had the problem, that one of my VMs, serving our wiki, got the wrong system date. The date was pointing to year 2018.

Some users of our wiki changed the content while the VM has the wrong date. After I see the problem I update the VM and re-connect it to NTP again and the time was corrected.

But, the paged changed in the the „wrong“ timeframe are stored with this wrong timeframe in the wiki database.

Now every call on recent changes shows the pages, changed in the wrong timeframe“ always at top (because of this future date).

Now I found a way to „fix“ this in the database. To do this, you need access to your wiki DB with RW rights. I have done this on mysql (but these SQL statements should also work on other database systems):


update revision set rev_timestamp=20150101000000 where rev_timestamp > 20150108115205;

update recentchanges set rc_timestamp = 20150101000000 where rc_timestamp > 20150108115205;

find and remove dead links in linux

Filed under: administration — Thomas Wabner @ 1:17 pm
Tags:

I asked myself the question, what would be the best way under Linux to find and remove dead links?

Here is the short answer (only tested on bash):


find . -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print | tr "\n" "" | xargs -0 rm

März 13, 2014

no running imapd / slapd under gentoo

Filed under: administration,webmaster — Thomas Wabner @ 2:46 pm

Today, I discovered that my mailserver was down on a root server (running gentoo). I tried to search why and whats the problem.

  1. I see error messages, that some processes cannot connect to ldap
  2. I tried to use phpldapadmin to check whats wrong. Here I got the next error: Fatal error: Cannot redeclare password_hash()
  3. I changed the used php version from php-5.5 to php-5.4 … phpldapadmin again works, but I cannot login
  4. I see imapd segmentation faults in dmesg in libwrappers …so I guess there is a problem with sys-apps/tcp-wrappers
  5. I rebuild tcp-wrappers, restarting nearly all processed from /etc/init.d without success
  6. I get deeper into the logfiles of my server (needed to take a look into the live logfiles (which logs all into one file, which is heavy under a root server with many hosted domains)
  7. I see an error, that some processes (one was also slapd) cannot read /etc/hosts.deny
  8. I see, that only root has the permission to read /etc/hosts.deny
  9. I change the permission to get all a read of this file
  10. Restarting slapd and all stuff works again … what a pain

Feels like one of my living years are gone … sometimes I love, but sometimes I hate gentoo.

I do not know who has changed the permissions on this file … but if I found he/it … *g*

September 7, 2013

no CSS in mediawiki anymore

Filed under: administration,webmaster — Thomas Wabner @ 5:22 pm
Tags: , , ,

After upgrading my gentoo system, I discovered a problem with one of my new mediawiki installations:

No CSS anymore!

That’s frustrating. Looking with my browser tools, I see, that the load.php from mediawiki returns nothing. Searching around and found only one place which helped:

https://bugs.php.net/bug.php?id=64836 <– the bug entry on php.

Now I tried to downgrade my gentoo package sys-apps/file back to 5.11 and restarting my apache … viola … it works.

emerge =sys-apps/file-5.11

Now the load.php works again and it looks like, that this has nothing to do with mediawiki itself.

Februar 27, 2013

testing REST interface with Spring 3.2 and a session scoped bean

Filed under: java,spring — Thomas Wabner @ 8:00 pm
Tags: , , , , , , , , ,

There are some nice articles around the „spring 3.2 testing capabilities“ like the spring documentation itself, this blog and this blog.

I wanted to not only test one request/response action against my REST interface. I wanted to simulate and test more of a conversation as it typical happens in the UI.

Following REST interface I wanted to create and test:

@RequestMapping("/customer")
public interface RESTCustomer {

@RequestMapping(
method = RequestMethod.POST)
@ResponseBody
Customer create(@RequestParam("firstname") final String firstname,
@RequestParam("lastname") final String lastname);

@RequestMapping(
method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK)
void delete(@RequestParam("id") final String... customerIds);

@RequestMapping(
produces = MediaType.APPLICATION_JSON_VALUE,
method = RequestMethod.GET)
@ResponseBody
Collection<Customer> getAll();

@RequestMapping(
value = "/update",
method = RequestMethod.POST)
@ResponseBody
Customer update(@RequestParam("id") final String id, @RequestParam("firstname") final String firstname);

}

Following test steps I had in mind, to test the create method:

  1. Get a list of all customers and remember the count
  2. Create a new customer
  3. Check, that the ID of the returning Customer was updated
  4. Get again a list of all customers
  5. Check the size of the customer list before and after creation … they should differ between one entry/li>

The new Spring Framework version 3.2 introduced some nice feature to do REST testing with minimal effort.

To test such conversion, you need beside the WebApplicationContext a MockHttpSession which has to be used between different mockMvc calls, on one test case.

The following base test structure is required:

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(
  classes = {
    MyConfig.class,
  })
public class RESTCustomerTest {
  
@Autowired
  private WebApplicationContext wac;

  @Autowired
  MockHttpSession session;

  MockMvc mockMvc;

  ObjectMapper jsonObjectMapper;

  @Before
  public void setup() {
    mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    jsonObjectMapper = new ObjectMapper();
  }

  @Test
  public void testCreate() throws Exception {
    ....
  }
}

Let assume, there is an implementation of the RESTCustomer service interface like this:


@Component
public class CustomerResource implements RESTCustomer {

  private final PlatformService service;

  @Autowired
  public CustomerResource(final PlatformService service) {
    this.service = service;
  }

  @Override
  public Customer create(final String firstname, final String lastname) {
    ...
    return service.createCustomer(firstname, lastname);
  }

  @Override
  public Collection<Customer> getAll() {
    ...
    return service.getAllCustomers();
  }

}

Assume also, that the autowired PlatformService is a Session scoped bean (somewhere configured inside the spring configuration).

Now our testing method can be like this:


  int countCustomers() throws Exception {
    final MvcResult mvcResult = mockMvc.perform(get("/customer").session(session).accept(MediaType.APPLICATION_JSON))
        .andReturn();
    final Collection<Customer> customers = getRawObjects(mvcResult);
    return customers.size();
  }

Collection<Customer> getRawObjects(final MvcResult mvcResult) throws Exception {
    return jsonObjectMapper.readValue(mvcResult.getResponse().getContentAsString(),
        new TypeReference<Collection<Customer>() {
        });
  }

Customer getRawObject(final MvcResult mvcResult) throws Exception {
    return jsonObjectMapper.readValue(mvcResult.getResponse().getContentAsString(),
        new TypeReference<Customer>() {
        });
  }

  @Test
  public void testCreate() throws Exception {
    // get default customer list and count
    final int originalCustomerSize = countCustomers();

    // create new customer
    final MvcResult mvcResult = mockMvc
        .perform(
            post("/customer/?firstname={firstname}&lastname={lastname}","testFirstname", "testLastName").session(session).accept(
                MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andReturn();
    final Customer customerObject = getRawObject(mvcResult);
    assertNotNull("id of new customer should not empty", customerObject.get("id"));
    assertEquals("newly firstname should match", "testFirstname", customerObject.get("firstname");

    // again get list of all customers and check, if one more is available
    assertEquals("after new customer was created, the size should be one more", originalCustomerSize + 1, countCustomers());
  }

To get such conversation to work, you need to pass the session with .session(session) between the mockMvc calls. Else, every new mockMvc call creates a new session and your test fail.

REMEMBER: The trick is to pass the autowired MockHttpSession between the mock MVC requests.

Oktober 4, 2012

Januar 2, 2012

2011 in review

Filed under: Uncategorized — Thomas Wabner @ 9:08 pm

Die WordPress.com Statistikelfen fertigten einen Jahresbericht dieses Blogs für das Jahr 2011 an.

Hier ist eine Zusammenfassung:

Das Sydney Opera House bietet Platz für 2.700 Konzertbesucher. Dieses Blog wurde in 2011 etwa 30.000 mal besucht. Das entspräche etwa 11 ausverkauften Konzertveranstaltungen im Sydney Opera House.

Klicke hier um den vollständigen Bericht zu sehen.

epson perfection VT10 under gentoo

Filed under: administration — Thomas Wabner @ 3:22 pm
Tags: , , , , ,

Today I make my Epson scanner perfection VT10 running under gentoo.

What I did:

  1. Emerge the iscan packages:

    USE="X gimp jpeg png tiff -doc" emerge -av media-gfx/iscan
    emerge -av media-gfx/iscan-data
  2. Create a backup of the /etc/sane.dll/dll.conf and create a new one with only one line:

    mv /etc/sane.dll/dll.conf /etc/sane.dll/dll.conf.org
    echo "epkowa" >> /etc/sane.dll/dll.conf
  3. Changing the /etc/sane.d/epkowa.conf configuration to match the Perfection VT10.

    changing/uncomment in /etc/sane.d/epkowa.conf following lines (nothing more!):

    usb
    usb 0x04b8 0x012d

  4. Now I need some binaries for the scanner and some libs. They can be downloaded here:

    http://linux.avasys.jp/drivers/iscan-plugins/iscan-plugin-gt-s600/2.1.2/iscan-plugin-gt-s600-2.1.2-1.i386.rpm

  5. I opened the archive and extracted the libs libesint66* to /usr/lib/iscan and also the /usr/share/iscan/esfw66.bin
  6. Now I need to register the libraries and scanner binary to iscan:

    iscan-registry --add interpreter usb 0x04b8 0x012d /usr/lib/iscan/libesint66.so /usr/share/iscan/esfw66.bin
  7. The next step was to create a file called „interpreter“ in /usr/share/iscan-data/interpreter and adding the lib and binary:

    echo "interpreter usb 0x04b8 0x012d /usr/lib/iscan/libesint66 /usr/share/iscan/esfw66.bin" >> /usr/share/iscan-data/interpreter

After that, I was able to start iscan, select the first entry from the founded scanners and start to scan 🙂

Nächste Seite »

Erstelle eine kostenlose Website oder Blog – auf WordPress.com.